diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2014-07-03 19:12:37 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-16 09:49:41 +0200 |
commit | 05ea746d3042d1409305bc1ebcaf15095870b6d9 (patch) | |
tree | 5155938d7e853d96a6a4de44c314d715b88d547c /Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp | |
parent | 6d998167b9f14d441172022636091251fa34a15a (diff) | |
download | qtwebkit-05ea746d3042d1409305bc1ebcaf15095870b6d9.tar.gz |
Integrate QWebChannel with QtWebKit.
WebView.experimental gets a new webChannel property. By default, this
is initialized to a QQmlWebChannel internal to the WebView. By setting
it from the outside, it is possible to share the same WebChannel
between different WebViews. The webChannel property can be set to null
to disable this new feature.
For IPC, a navigator.qtWebChannelTransport property is added, which is
essentially a copy of navigator.qt. This is required to be able to use
both independently. The transport is implicitly connected to the
WebView's webChannel.
On the JavaScript client side, some manual boiler plate code is still
required. Potentially, this can be adapted in the future to preload
the qwebchannel.js. Furthermore, we might be able to instantiate and
initialize the QWebChannel before we emit window.onload.
A basic test is added which verifies that this basic integration works.
Change-Id: I5eb0389e6edd6d0c978917e441365e11a02b5c3f
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp b/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp index c75a446dd..3bb795cad 100644 --- a/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp +++ b/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp @@ -93,6 +93,10 @@ void QtBuiltinBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef handleMessageToNavigatorQtObject(page, messageBody); else if (WKStringIsEqualToUTF8CString(messageName, "SetNavigatorQtObjectEnabled")) handleSetNavigatorQtObjectEnabled(page, messageBody); +#ifdef HAVE_WEBCHANNEL + else if (WKStringIsEqualToUTF8CString(messageName, "MessageToNavigatorQtWebChannelTransportObject")) + handleMessageToNavigatorQtWebChannelTransport(page, messageBody); +#endif } void QtBuiltinBundle::handleMessageToNavigatorQtObject(WKBundlePageRef page, WKTypeRef messageBody) @@ -119,4 +123,18 @@ void QtBuiltinBundle::handleSetNavigatorQtObjectEnabled(WKBundlePageRef page, WK bundlePage->setNavigatorQtObjectEnabled(enabled); } +#ifdef HAVE_WEBCHANNEL +void QtBuiltinBundle::handleMessageToNavigatorQtWebChannelTransport(WKBundlePageRef page, WKTypeRef messageBody) +{ + ASSERT(messageBody); + ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); + WKStringRef contents = static_cast<WKStringRef>(messageBody); + + QtBuiltinBundlePage* bundlePage = m_pages.get(page); + if (!bundlePage) + return; + bundlePage->didReceiveMessageToNavigatorQtWebChannelTransport(contents); +} +#endif + } // namespace WebKit |