summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@theqtcompany.com>2015-02-12 15:13:46 +0100
committerPierre Rossi <pierre.rossi@theqtcompany.com>2015-02-13 14:11:20 +0000
commit53876e63be3a5aa1de038e3ecd593fdac721b78d (patch)
tree8471ed1b4ff1f1a703bfe83df3d8a2874ebe29c7
parenteee482929a81ae9d685a0ee140733227ceac6543 (diff)
Add QWebChannel setter and getter to QWebEnginePage
This allows using the WebChannel integration from the widgets API. Contains documentation, the underlying API for transport is tested by the qml tests already. Change-Id: If5520eddf5d1a9c917df890960e042f53baa42ce Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp31
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h4
2 files changed, 35 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index a59165e8b..91f10486f 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -482,6 +482,37 @@ QWebEngineSettings *QWebEnginePage::settings() const
return d->settings;
}
+/*!
+ * Returns a pointer to the web channel instance used by this page, or a null pointer if none was set.
+ * This channel is automatically using the internal QtWebEngine transport mechanism over Chromium IPC,
+ * and exposed in the javascript context of this page as \c navigator.qtWebChannelTransport
+ *
+ * \since 5.5
+ * \sa {QtWebChannel::QWebChannel}{QWebChannel}
+ */
+QWebChannel *QWebEnginePage::webChannel() const
+{
+ Q_D(const QWebEnginePage);
+ return d->adapter->webChannel();
+}
+
+/*!
+ * Sets the web channel instance to be used by this page and connects it to QtWebEngine's transport
+ * using Chromium IPC messages. That transport is exposed in the javascript context of this page as
+ * \c navigator.qtWebChannelTransport, which should be used when using the \l{Qt WebChannel JavaScript API}.
+ *
+ * \note The page does not take ownership of the \a channel object.
+ *
+ * \since 5.5
+ * \param channel
+ */
+
+void QWebEnginePage::setWebChannel(QWebChannel *channel)
+{
+ Q_D(QWebEnginePage);
+ d->adapter->setWebChannel(channel);
+}
+
void QWebEnginePage::setView(QWidget *view)
{
QWebEngineViewPrivate::bind(qobject_cast<QWebEngineView*>(view), this);
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index a194df831..8d8f3666a 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QMenu;
+class QWebChannel;
class QWebEngineHistory;
class QWebEnginePage;
class QWebEnginePagePrivate;
@@ -232,6 +233,9 @@ public:
QWebEngineSettings *settings() const;
+ QWebChannel *webChannel() const;
+ void setWebChannel(QWebChannel *);
+
Q_SIGNALS:
void loadStarted();
void loadProgress(int progress);