summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2018-08-01 15:04:35 +0200
committerMichal Klocek <michal.klocek@qt.io>2018-08-09 09:39:56 +0000
commitdb62139e1daea171e08d95592c63f663789d6391 (patch)
treeddce513a2e74bf656466a6f83b57a8efbd3cbe18
parente50fb187dc4467ac28a724e6ea9f2d51a1f131ba (diff)
Make WebChannel an optional feature
Add webengine-webchannel feature. Change-Id: I600572180f8169aafe79cf0408527cc087d9a007 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
-rw-r--r--examples/webenginewidgets/webenginewidgets.pro2
-rw-r--r--src/core/configure.json9
-rw-r--r--src/core/core_chromium.pri12
-rw-r--r--src/core/core_common.pri3
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp4
-rw-r--r--src/core/web_contents_adapter.cpp11
-rw-r--r--src/core/web_contents_adapter.h4
-rw-r--r--src/webengine/api/qquickwebengineview.cpp18
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp12
-rw-r--r--tests/auto/widgets/origins/origins.pro2
-rw-r--r--tests/auto/widgets/origins/tst_origins.cpp2
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp8
-rw-r--r--tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp18
13 files changed, 87 insertions, 18 deletions
diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro
index feabadec6..e98503e09 100644
--- a/examples/webenginewidgets/webenginewidgets.pro
+++ b/examples/webenginewidgets/webenginewidgets.pro
@@ -8,12 +8,12 @@ SUBDIRS += \
contentmanipulation \
cookiebrowser \
html2pdf \
- markdowneditor \
simplebrowser \
stylesheetbrowser \
videoplayer
qtConfig(webengine-geolocation): SUBDIRS += maps
+qtCondif(webengine-webchannel): SUBDIRS += markdowneditor
qtConfig(webengine-spellchecker):!qtConfig(webengine-native-spellchecker):!cross_compile {
SUBDIRS += spellchecker
diff --git a/src/core/configure.json b/src/core/configure.json
index 3eb30dd74..aaebcc4a8 100644
--- a/src/core/configure.json
+++ b/src/core/configure.json
@@ -23,6 +23,7 @@
"webengine-webrtc": "boolean",
"webengine-geolocation": "boolean",
"webengine-v8-snapshot": "boolean",
+ "webengine-webchannel": "boolean",
"alsa": { "type": "boolean", "name": "webengine-alsa" },
"pulseaudio": { "type": "boolean", "name": "webengine-pulseaudio" },
"ffmpeg": { "type": "enum", "name": "webengine-system-ffmpeg", "values": { "system": "yes", "qt": "no" } },
@@ -509,6 +510,13 @@
"autoDetect": "!features.webengine-embedded-build",
"output": [ "privateFeature" ]
},
+ "webengine-webchannel": {
+ "label": "WebChannel support",
+ "purpose": "Provides QtWebChannel integration.",
+ "section": "WebEngine",
+ "condition": "module.webchannel",
+ "output": [ "publicFeature" ]
+ },
"webengine-proprietary-codecs": {
"label": "Proprietary Codecs",
"purpose": "Enables the use of proprietary codecs such as h.264/h.265 and MP3.",
@@ -680,6 +688,7 @@
"webengine-webrtc",
"webengine-system-ninja",
"webengine-geolocation",
+ "webengine-webchannel",
"webengine-v8-snapshot",
{
"type": "feature",
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index ef81988dc..a3f9f5c80 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -105,9 +105,7 @@ SOURCES = \
renderer/render_frame_observer_qt.cpp \
renderer/render_view_observer_qt.cpp \
renderer/user_resource_controller.cpp \
- renderer/web_channel_ipc_transport.cpp \
renderer_host/user_resource_controller_host.cpp \
- renderer_host/web_channel_ipc_transport_host.cpp \
resource_bundle_qt.cpp \
resource_context_qt.cpp \
service/service_qt.cpp \
@@ -198,9 +196,7 @@ HEADERS = \
renderer/render_frame_observer_qt.h \
renderer/render_view_observer_qt.h \
renderer/user_resource_controller.h \
- renderer/web_channel_ipc_transport.h \
renderer_host/user_resource_controller_host.h \
- renderer_host/web_channel_ipc_transport_host.h \
request_controller.h \
resource_context_qt.h \
service/service_qt.h \
@@ -275,3 +271,11 @@ qtConfig(webengine-geolocation) {
SOURCES += location_provider_qt.cpp
HEADERS += location_provider_qt.h
}
+
+qtConfig(webengine-webchannel) {
+ HEADERS += renderer/web_channel_ipc_transport.h \
+ renderer_host/web_channel_ipc_transport_host.h
+
+ SOURCES += renderer/web_channel_ipc_transport.cpp \
+ renderer_host/web_channel_ipc_transport_host.cpp
+}
diff --git a/src/core/core_common.pri b/src/core/core_common.pri
index 3ce53bba4..0c3e69e15 100644
--- a/src/core/core_common.pri
+++ b/src/core/core_common.pri
@@ -2,7 +2,8 @@
# gyp/ninja will take care of the compilation, qmake/make will finish with linking and install.
TARGET = QtWebEngineCore
-QT += qml quick webchannel
+QT += qml quick
QT_PRIVATE += quick-private gui-private core-private webenginecoreheaders-private
qtConfig(webengine-geolocation): QT += positioning
+qtConfig(webengine-webchannel): QT += webchannel
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index 79c2294de..e9f404cb1 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -80,7 +80,9 @@
#include "renderer/render_frame_observer_qt.h"
#include "renderer/render_view_observer_qt.h"
#include "renderer/user_resource_controller.h"
+#if QT_CONFIG(webengine_webchannel)
#include "renderer/web_channel_ipc_transport.h"
+#endif
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/connector.h"
@@ -141,8 +143,10 @@ void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view
void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame)
{
new QtWebEngineCore::RenderFrameObserverQt(render_frame);
+#if QT_CONFIG(webengine_webchannel)
if (render_frame->IsMainFrame())
new WebChannelIPCTransport(render_frame);
+#endif
UserResourceController::instance()->renderFrameCreated(render_frame);
new QtWebEngineCore::ContentSettingsObserverQt(render_frame);
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index ec1416010..e65ab9d07 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -52,7 +52,6 @@
#include "printing/print_view_manager_qt.h"
#include "profile_qt.h"
#include "qwebenginecallback_p.h"
-#include "renderer_host/web_channel_ipc_transport_host.h"
#include "render_view_observer_host_qt.h"
#include "type_conversion.h"
#include "web_contents_view_qt.h"
@@ -87,6 +86,11 @@
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/gfx/font_render_params.h"
+#if QT_CONFIG(webengine_webchannel)
+#include "renderer_host/web_channel_ipc_transport_host.h"
+#include <QtWebChannel/QWebChannel>
+#endif
+
#include <QDir>
#include <QGuiApplication>
#include <QPageLayout>
@@ -100,7 +104,6 @@
#include <QtGui/qaccessible.h>
#include <QtGui/qdrag.h>
#include <QtGui/qpixmap.h>
-#include <QtWebChannel/QWebChannel>
namespace QtWebEngineCore {
@@ -386,8 +389,10 @@ QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavig
WebContentsAdapter::WebContentsAdapter(content::WebContents *webContents)
: m_profileAdapter(nullptr)
, m_webContents(webContents)
+#if QT_CONFIG(webengine_webchannel)
, m_webChannel(nullptr)
, m_webChannelWorld(0)
+#endif
, m_adapterClient(nullptr)
, m_nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
, m_lastFindRequestId(0)
@@ -1270,6 +1275,7 @@ content::WebContents *WebContentsAdapter::webContents() const
return m_webContents.get();
}
+#if QT_CONFIG(webengine_webchannel)
QWebChannel *WebContentsAdapter::webChannel() const
{
return m_webChannel;
@@ -1299,6 +1305,7 @@ void WebContentsAdapter::setWebChannel(QWebChannel *channel, uint worldId)
}
channel->connectTo(m_webChannelTransport.get());
}
+#endif
#if QT_CONFIG(draganddrop)
static QMimeData *mimeDataFromDropData(const content::DropData &dropData)
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index b367c9fcb..bd2ca4b23 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -190,8 +190,10 @@ public:
QAccessibleInterface *browserAccessible();
ProfileQt* profile();
ProfileAdapter* profileAdapter();
+#if QT_CONFIG(webengine_webchannel)
QWebChannel *webChannel() const;
void setWebChannel(QWebChannel *, uint worldId);
+#endif
FaviconManager *faviconManager();
QPointF lastScrollOffset() const;
@@ -230,9 +232,11 @@ private:
std::unique_ptr<content::WebContents> m_webContents;
std::unique_ptr<WebContentsDelegateQt> m_webContentsDelegate;
std::unique_ptr<RenderViewObserverHostQt> m_renderViewObserverHost;
+#if QT_CONFIG(webengine_webchannel)
std::unique_ptr<WebChannelIPCTransportHost> m_webChannelTransport;
QWebChannel *m_webChannel;
unsigned int m_webChannelWorld;
+#endif
WebContentsAdapterClient *m_adapterClient;
quint64 m_nextRequestId;
int m_lastFindRequestId;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index f24ba1d7d..02666d363 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -85,7 +85,9 @@
#include <QQmlContext>
#include <QQmlEngine>
#include <QQmlProperty>
+#if QT_CONFIG(webengine_webchannel)
#include <QQmlWebChannel>
+#endif
#include <QQuickWebEngineProfile>
#include <QScreen>
#include <QUrl>
@@ -777,8 +779,10 @@ void QQuickWebEngineViewPrivate::initializationFinished()
if (m_backgroundColor != Qt::white)
adapter->backgroundColorChanged();
+#if QT_CONFIG(webengine_webchannel)
if (m_webChannel)
adapter->setWebChannel(m_webChannel, m_webChannelWorld);
+#endif
if (!qFuzzyCompare(adapter->currentZoomFactor(), m_defaultZoomFactor))
q->setZoomFactor(m_defaultZoomFactor);
@@ -1273,6 +1277,7 @@ QQuickWebEngineHistory *QQuickWebEngineView::navigationHistory() const
QQmlWebChannel *QQuickWebEngineView::webChannel()
{
+#if QT_CONFIG(webengine_webchannel)
Q_D(QQuickWebEngineView);
if (!d->m_webChannel) {
d->m_webChannel = new QQmlWebChannel(this);
@@ -1280,16 +1285,24 @@ QQmlWebChannel *QQuickWebEngineView::webChannel()
}
return d->m_webChannel;
+#endif
+ qWarning("WebEngine compiled without webchannel support");
+ return nullptr;
}
void QQuickWebEngineView::setWebChannel(QQmlWebChannel *webChannel)
{
+#if QT_CONFIG(webengine_webchannel)
Q_D(QQuickWebEngineView);
if (d->m_webChannel == webChannel)
return;
d->m_webChannel = webChannel;
d->adapter->setWebChannel(webChannel, d->m_webChannelWorld);
Q_EMIT webChannelChanged();
+#else
+ Q_UNUSED(webChannel)
+ qWarning("WebEngine compiled without webchannel support");
+#endif
}
uint QQuickWebEngineView::webChannelWorld() const
@@ -1300,12 +1313,17 @@ uint QQuickWebEngineView::webChannelWorld() const
void QQuickWebEngineView::setWebChannelWorld(uint webChannelWorld)
{
+#if QT_CONFIG(webengine_webchannel)
Q_D(QQuickWebEngineView);
if (d->m_webChannelWorld == webChannelWorld)
return;
d->m_webChannelWorld = webChannelWorld;
d->adapter->setWebChannel(d->m_webChannel, d->m_webChannelWorld);
Q_EMIT webChannelWorldChanged(webChannelWorld);
+#else
+ Q_UNUSED(webChannelWorld)
+ qWarning("WebEngine compiled without webchannel support");
+#endif
}
QQuickWebEngineView *QQuickWebEngineView::inspectedView() const
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 5b42b871a..6a4554b57 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -282,8 +282,10 @@ void QWebEnginePagePrivate::initializationFinished()
{
if (m_backgroundColor != Qt::white)
adapter->backgroundColorChanged();
+#if QT_CONFIG(webengine_webchannel)
if (webChannel)
adapter->setWebChannel(webChannel, webChannelWorldId);
+#endif
if (defaultAudioMuted != adapter->isAudioMuted())
adapter->setAudioMuted(defaultAudioMuted);
if (!qFuzzyCompare(adapter->currentZoomFactor(), defaultZoomFactor))
@@ -925,8 +927,12 @@ QWebEngineSettings *QWebEnginePage::settings() const
*/
QWebChannel *QWebEnginePage::webChannel() const
{
+#if QT_CONFIG(webengine_webchannel)
Q_D(const QWebEnginePage);
return d->webChannel;
+#endif
+ qWarning("WebEngine compiled without webchannel support");
+ return nullptr;
}
/*!
@@ -963,12 +969,18 @@ void QWebEnginePage::setWebChannel(QWebChannel *channel)
*/
void QWebEnginePage::setWebChannel(QWebChannel *channel, uint worldId)
{
+#if QT_CONFIG(webengine_webchannel)
Q_D(QWebEnginePage);
if (d->webChannel != channel || d->webChannelWorldId != worldId) {
d->webChannel = channel;
d->webChannelWorldId = worldId;
d->adapter->setWebChannel(channel, worldId);
}
+#else
+ Q_UNUSED(channel)
+ Q_UNUSED(worldId)
+ qWarning("WebEngine compiled without webchannel support");
+#endif
}
/*!
diff --git a/tests/auto/widgets/origins/origins.pro b/tests/auto/widgets/origins/origins.pro
index f77b3d59b..7498354de 100644
--- a/tests/auto/widgets/origins/origins.pro
+++ b/tests/auto/widgets/origins/origins.pro
@@ -1,6 +1,6 @@
include(../tests.pri)
CONFIG += c++14
-qtHaveModule(websockets) {
+qtConfig(webengine-webchannel):qtHaveModule(websockets) {
QT += websockets
DEFINES += WEBSOCKETS
}
diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp
index 652d85ff0..364c83c3e 100644
--- a/tests/auto/widgets/origins/tst_origins.cpp
+++ b/tests/auto/widgets/origins/tst_origins.cpp
@@ -36,10 +36,10 @@
#include <QtWebEngineWidgets/qwebenginepage.h>
#include <QtWebEngineWidgets/qwebengineprofile.h>
#include <QtWebEngineWidgets/qwebenginesettings.h>
-#include <QtWebChannel/qwebchannel.h>
#if defined(WEBSOCKETS)
#include <QtWebSockets/qwebsocket.h>
#include <QtWebSockets/qwebsocketserver.h>
+#include <QtWebChannel/qwebchannel.h>
#endif
#include <QtWidgets/qaction.h>
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 4ce971c4b..95a46fbc2 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -20,6 +20,7 @@
*/
#include "../util.h"
+#include <QtWebEngineCore/qtwebenginecore-config.h>
#include <QByteArray>
#include <QClipboard>
#include <QDir>
@@ -39,7 +40,9 @@
#include <QtGui/QClipboard>
#include <QtTest/QtTest>
#include <QTextCharFormat>
+#if QT_CONFIG(webengine_webchannel)
#include <QWebChannel>
+#endif
#include <httpserver.h>
#include <qnetworkcookiejar.h>
#include <qnetworkreply.h>
@@ -200,8 +203,9 @@ private Q_SLOTS:
void loadInSignalHandlers_data();
void loadInSignalHandlers();
void loadFromQrc();
-
+#if QT_CONFIG(webengine_webchannel)
void restoreHistory();
+#endif
void toPlainTextLoadFinishedRace_data();
void toPlainTextLoadFinishedRace();
void setZoomFactor();
@@ -3950,6 +3954,7 @@ void tst_QWebEnginePage::loadFromQrc()
QCOMPARE(spy.takeFirst().value(0).toBool(), false);
}
+#if QT_CONFIG(webengine_webchannel)
void tst_QWebEnginePage::restoreHistory()
{
QWebChannel channel;
@@ -3977,6 +3982,7 @@ void tst_QWebEnginePage::restoreHistory()
QCOMPARE(page.webChannel(), &channel);
QVERIFY(page.scripts().contains(script));
}
+#endif
void tst_QWebEnginePage::toPlainTextLoadFinishedRace_data()
{
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
index 23d31a478..f4e1baa33 100644
--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
@@ -18,14 +18,16 @@
*/
#include <QtTest/QtTest>
-
+#include <QtWebEngineCore/qtwebenginecore-config.h>
#include <qwebenginepage.h>
#include <qwebengineprofile.h>
#include <qwebenginescript.h>
#include <qwebenginescriptcollection.h>
#include <qwebengineview.h>
#include "../util.h"
+#if QT_CONFIG(webengine_webchannel)
#include <QWebChannel>
+#endif
class tst_QWebEngineScript: public QObject {
Q_OBJECT
@@ -35,14 +37,16 @@ private Q_SLOTS:
void loadEvents();
void scriptWorld();
void scriptModifications();
+#if QT_CONFIG(webengine_webchannel)
void webChannel_data();
void webChannel();
- void noTransportWithoutWebChannel();
- void scriptsInNestedIframes();
void webChannelResettingAndUnsetting();
void webChannelWithExistingQtObject();
void navigation();
void webChannelWithBadString();
+#endif
+ void noTransportWithoutWebChannel();
+ void scriptsInNestedIframes();
};
void tst_QWebEngineScript::domEditing()
@@ -273,7 +277,7 @@ static QWebEngineScript webChannelScript()
script.setWorldId(QWebEngineScript::MainWorld);
return script;
}
-
+#if QT_CONFIG(webengine_webchannel)
void tst_QWebEngineScript::webChannel_data()
{
QTest::addColumn<int>("worldId");
@@ -318,7 +322,7 @@ void tst_QWebEngineScript::webChannel()
if (worldId != QWebEngineScript::MainWorld)
QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid));
}
-
+#endif
void tst_QWebEngineScript::noTransportWithoutWebChannel()
{
QWebEnginePage page;
@@ -382,7 +386,7 @@ void tst_QWebEngineScript::scriptsInNestedIframes()
QWebEngineScript::ApplicationWorld),
QVariant::fromValue(QStringLiteral("Modified Inner text")));
}
-
+#if QT_CONFIG(webengine_webchannel)
void tst_QWebEngineScript::webChannelResettingAndUnsetting()
{
QWebEnginePage page;
@@ -485,7 +489,7 @@ void tst_QWebEngineScript::webChannelWithBadString()
QVERIFY(hostSpy.wait(20000));
QCOMPARE(host.text(), QString(QChar(QChar::ReplacementCharacter)));
}
-
+#endif
QTEST_MAIN(tst_QWebEngineScript)
#include "tst_qwebenginescript.moc"