summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-01-15 17:57:05 +0100
committerJüri Valdmann <juri.valdmann@qt.io>2018-02-13 08:18:06 +0000
commit2a4a5b2ec17189d4ea8fa783cf219c65560e81f8 (patch)
tree547f48440093ec3fe77e3d787696aa242e82d794 /src/webengine
parent58fea877aa61cf0e7bc81d0c3c91f732c2791ff3 (diff)
Add support for registerProtocolHandler
Extend initialization of URLRequestContextGetterQt to create a content::ProtocolHandlerRegistry for each content::BrowserContext and add the registry's URL request interceptor to the front of the interceptor chain. Implement methods in WebContentsDelegateQt to add/remove protocol handlers to/from the ProtocolHandlerRegistry. Add permission request signal and classes for core, quick and widgets. Add widgets autotest. Add signal handlers to quicknanobrowser and simplebrowser. Task-number: QTBUG-62783 Change-Id: I808e7eb9a1cb4d7216686deed4895de14fe46310 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp33
-rw-r--r--src/webengine/api/qquickwebengineview_p.h21
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webengine/doc/src/external-resources.qdoc5
-rw-r--r--src/webengine/doc/src/webengineview_lgpl.qdoc49
-rw-r--r--src/webengine/plugin/plugin.cpp2
6 files changed, 111 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 617b999da..91ae20481 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -46,6 +46,7 @@
#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
#include "quota_permission_controller.h"
+#include "register_protocol_handler_permission_controller.h"
#include "qquickwebenginehistory_p.h"
#include "qquickwebenginecertificateerror_p.h"
#include "qquickwebenginecontextmenurequest_p.h"
@@ -599,6 +600,13 @@ void QQuickWebEngineViewPrivate::runQuotaPermissionRequest(QSharedPointer<QtWebE
Q_EMIT q->quotaPermissionRequested(request);
}
+void QQuickWebEngineViewPrivate::runRegisterProtocolHandlerPermissionRequest(QSharedPointer<RegisterProtocolHandlerPermissionController> controller)
+{
+ Q_Q(QQuickWebEngineView);
+ QQuickWebEngineRegisterProtocolHandlerPermissionRequest request(std::move(controller));
+ Q_EMIT q->registerProtocolHandlerPermissionRequested(request);
+}
+
QObject *QQuickWebEngineViewPrivate::accessibilityParentObject()
{
Q_Q(QQuickWebEngineView);
@@ -1828,6 +1836,31 @@ qint64 QQuickWebEngineQuotaPermissionRequest::requestedSize() const
return d_ptr->requestedSize();
}
+QQuickWebEngineRegisterProtocolHandlerPermissionRequest::QQuickWebEngineRegisterProtocolHandlerPermissionRequest(
+ QSharedPointer<QtWebEngineCore::RegisterProtocolHandlerPermissionController> d_ptr)
+ : d_ptr(std::move(d_ptr))
+{}
+
+void QQuickWebEngineRegisterProtocolHandlerPermissionRequest::accept()
+{
+ d_ptr->accept();
+}
+
+void QQuickWebEngineRegisterProtocolHandlerPermissionRequest::reject()
+{
+ d_ptr->reject();
+}
+
+QUrl QQuickWebEngineRegisterProtocolHandlerPermissionRequest::origin() const
+{
+ return d_ptr->origin();
+}
+
+QString QQuickWebEngineRegisterProtocolHandlerPermissionRequest::protocol() const
+{
+ return d_ptr->protocol();
+}
+
QQuickContextMenuBuilder::QQuickContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data,
QQuickWebEngineView *view,
QObject *menu)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 8bda609c0..5b018b8a8 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -59,6 +59,7 @@
namespace QtWebEngineCore {
class QuotaPermissionController;
+ class RegisterProtocolHandlerPermissionController;
}
@@ -123,6 +124,24 @@ private:
QSharedPointer<QtWebEngineCore::QuotaPermissionController> d_ptr;
};
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineRegisterProtocolHandlerPermissionRequest {
+ Q_GADGET
+ Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
+ Q_PROPERTY(QString protocol READ protocol CONSTANT FINAL)
+public:
+ QQuickWebEngineRegisterProtocolHandlerPermissionRequest() {}
+ QQuickWebEngineRegisterProtocolHandlerPermissionRequest(
+ QSharedPointer<QtWebEngineCore::RegisterProtocolHandlerPermissionController>);
+
+ Q_INVOKABLE void accept();
+ Q_INVOKABLE void reject();
+ QUrl origin() const;
+ QString protocol() const;
+
+private:
+ QSharedPointer<QtWebEngineCore::RegisterProtocolHandlerPermissionController> d_ptr;
+};
+
#define LATEST_WEBENGINEVIEW_REVISION 7
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
@@ -567,6 +586,7 @@ Q_SIGNALS:
Q_REVISION(7) void geometryChangeRequested(const QRect &geometry, const QRect &frameGeometry);
Q_REVISION(7) void inspectedViewChanged();
Q_REVISION(7) void devToolsViewChanged();
+ Q_REVISION(7) void registerProtocolHandlerPermissionRequested(const QQuickWebEngineRegisterProtocolHandlerPermissionRequest &request);
#ifdef ENABLE_QML_TESTSUPPORT_API
void testSupportChanged();
@@ -597,5 +617,6 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickWebEngineView)
Q_DECLARE_METATYPE(QQuickWebEngineFullScreenRequest)
Q_DECLARE_METATYPE(QQuickWebEngineQuotaPermissionRequest)
+Q_DECLARE_METATYPE(QQuickWebEngineRegisterProtocolHandlerPermissionRequest)
#endif // QQUICKWEBENGINEVIEW_P_H
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index cfe99a0d4..1b718a3da 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -132,6 +132,7 @@ public:
void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) override;
void runMouseLockPermissionRequest(const QUrl &securityOrigin) override;
void runQuotaPermissionRequest(QSharedPointer<QtWebEngineCore::QuotaPermissionController>) override;
+ void runRegisterProtocolHandlerPermissionRequest(QSharedPointer<QtWebEngineCore::RegisterProtocolHandlerPermissionController>) override;
QObject *accessibilityParentObject() override;
QtWebEngineCore::WebEngineSettings *webEngineSettings() const override;
void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) override;
diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc
index c2faaa8d4..7ff6eea6b 100644
--- a/src/webengine/doc/src/external-resources.qdoc
+++ b/src/webengine/doc/src/external-resources.qdoc
@@ -141,3 +141,8 @@
\externalpage https://wiki.greasespot.net/Metadata_Block#.40name
\title Metadata Block
*/
+
+/*!
+ \externalpage https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
+ \title registerProtocolHandler
+*/
diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc
index c6985b082..104397bf7 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview_lgpl.qdoc
@@ -1357,6 +1357,55 @@
*/
/*!
+ \qmlsignal WebEngineView::registerProtocolHandlerPermissionRequested(RegisterProtocolHandlerPermissionRequest request)
+ \since QtWebEngine 1.7
+
+ This signal is emitted when the web page tries to register a custom protocol
+ using the \l registerProtocolHandler API.
+
+ \sa RegisterProtocolHandlerPermissionRequest
+*/
+
+/*!
+ \qmltype RegisterProtocolHandlerPermissionRequest
+ \instantiates QQuickWebEngineRegisterProtocolHandlerPermissionRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.7
+ \brief The RegisterProtocolHandlerPermissionRequest type enables accepting
+ or rejecting requests from the \l registerProtocolHandler API.
+
+ \sa WebEngineView::registerProtocolHandlerPermissionRequested()
+*/
+
+/*!
+ \qmlproperty url RegisterProtocolHandlerPermissionRequest::origin
+ \brief The URL template for the protocol handler.
+
+ This is the second parameter from the \l registerProtocolHandler call.
+*/
+
+/*!
+ \qmlproperty string RegisterProtocolHandlerPermissionRequest::protocol
+ \brief The URL scheme for the protocol handler.
+
+ This is the first parameter from the \l registerProtocolHandler call.
+*/
+
+/*!
+ \qmlmethod void RegisterProtocolHandlerPermissionRequest::accept()
+ \brief Accepts the request.
+
+ Subsequent calls to accept() and reject() are ignored.
+*/
+
+/*!
+ \qmlmethod void RegisterProtocolHandlerPermissionRequest::reject()
+ \brief Accepts the request.
+
+ Subsequent calls to accept() and reject() are ignored.
+*/
+
+/*!
\qmlsignal WebEngineView::geometryChangeRequested(rect geometry, rect frameGeometry)
\since QtWebEngine 1.7
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index 5f9d16158..a9f406d49 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -139,6 +139,8 @@ public:
msgUncreatableType("FormValidationMessageRequest"));
qmlRegisterUncreatableType<QQuickWebEngineQuotaPermissionRequest>(uri, 1, 7, "QuotaPermissionRequest",
tr("Cannot create a separate instance of QuotaPermissionRequest"));
+ qmlRegisterUncreatableType<QQuickWebEngineRegisterProtocolHandlerPermissionRequest>(uri, 1, 7, "RegisterProtocolHandlerPermissionRequest",
+ tr("Cannot create a separate instance of RegisterProtocolHandlerPermissionRequest"));
}
private: