summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/core/core_chromium.pri3
-rw-r--r--src/core/qtwebengine_sources.gni6
-rw-r--r--src/core/register_protocol_handler_permission_controller.h62
-rw-r--r--src/core/register_protocol_handler_permission_controller_impl.cpp65
-rw-r--r--src/core/register_protocol_handler_permission_controller_impl.h69
-rw-r--r--src/core/url_request_context_getter_qt.cpp15
-rw-r--r--src/core/url_request_context_getter_qt.h2
-rw-r--r--src/core/web_contents_adapter_client.h2
-rw-r--r--src/core/web_contents_delegate_qt.cpp36
-rw-r--r--src/core/web_contents_delegate_qt.h2
-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
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp20
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h2
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.cpp115
-rw-r--r--src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.h73
-rw-r--r--src/webenginewidgets/webenginewidgets.pro2
22 files changed, 586 insertions, 0 deletions
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index 1b2f2edb1..e62ffdbfb 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -79,6 +79,7 @@ SOURCES = \
qrc_protocol_handler_qt.cpp \
quota_permission_context_qt.cpp \
quota_permission_controller_impl.cpp \
+ register_protocol_handler_permission_controller_impl.cpp \
render_view_context_menu_qt.cpp \
render_view_observer_host_qt.cpp \
render_widget_host_view_qt.cpp \
@@ -163,6 +164,8 @@ HEADERS = \
quota_permission_context_qt.h \
quota_permission_controller.h \
quota_permission_controller_impl.h \
+ register_protocol_handler_permission_controller.h \
+ register_protocol_handler_permission_controller_impl.h \
render_view_context_menu_qt.h \
render_view_observer_host_qt.h \
render_widget_host_view_qt.h \
diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni
index 6d17838a6..bdedf11d3 100644
--- a/src/core/qtwebengine_sources.gni
+++ b/src/core/qtwebengine_sources.gni
@@ -43,6 +43,12 @@ source_set("qtwebengine_sources") {
"//extensions/features:features",
]
sources = [
+ "//chrome/common/custom_handlers/protocol_handler.cc",
+ "//chrome/common/custom_handlers/protocol_handler.h",
+ "//chrome/browser/custom_handlers/protocol_handler_registry.cc",
+ "//chrome/browser/custom_handlers/protocol_handler_registry.h",
+ "//chrome/browser/custom_handlers/protocol_handler_registry_factory.cc",
+ "//chrome/browser/custom_handlers/protocol_handler_registry_factory.h",
"//chrome/browser/media/webrtc/desktop_media_list.h",
"//chrome/browser/media/webrtc/desktop_streams_registry.cc",
"//chrome/browser/media/webrtc/desktop_streams_registry.h",
diff --git a/src/core/register_protocol_handler_permission_controller.h b/src/core/register_protocol_handler_permission_controller.h
new file mode 100644
index 000000000..54e16f569
--- /dev/null
+++ b/src/core/register_protocol_handler_permission_controller.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REGISTER_PROTOCOL_HANDLER_PERMISSION_CONTROLLER_H
+#define REGISTER_PROTOCOL_HANDLER_PERMISSION_CONTROLLER_H
+
+#include "permission_controller.h"
+
+namespace QtWebEngineCore {
+
+class QWEBENGINE_EXPORT RegisterProtocolHandlerPermissionController : public PermissionController {
+public:
+ RegisterProtocolHandlerPermissionController(QUrl origin, QString protocol)
+ : PermissionController(std::move(origin))
+ , m_protocol(std::move(protocol))
+ {}
+
+ QString protocol() const { return m_protocol; }
+
+private:
+ QString m_protocol;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // REGISTER_PROTOCOL_HANDLER_PERMISSION_CONTROLLER_H
diff --git a/src/core/register_protocol_handler_permission_controller_impl.cpp b/src/core/register_protocol_handler_permission_controller_impl.cpp
new file mode 100644
index 000000000..96f2edb87
--- /dev/null
+++ b/src/core/register_protocol_handler_permission_controller_impl.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "register_protocol_handler_permission_controller_impl.h"
+
+#include "type_conversion.h"
+
+namespace QtWebEngineCore {
+
+RegisterProtocolHandlerPermissionControllerImpl::RegisterProtocolHandlerPermissionControllerImpl(
+ ProtocolHandlerRegistry *registry,
+ ProtocolHandler handler)
+ : RegisterProtocolHandlerPermissionController(
+ toQt(handler.url()),
+ toQt(handler.protocol()))
+ , m_registry(registry)
+ , m_handler(handler)
+{}
+
+void RegisterProtocolHandlerPermissionControllerImpl::accepted()
+{
+ m_registry->OnAcceptRegisterProtocolHandler(m_handler);
+}
+
+void RegisterProtocolHandlerPermissionControllerImpl::rejected()
+{
+ m_registry->OnIgnoreRegisterProtocolHandler(m_handler);
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/register_protocol_handler_permission_controller_impl.h b/src/core/register_protocol_handler_permission_controller_impl.h
new file mode 100644
index 000000000..57a094fd9
--- /dev/null
+++ b/src/core/register_protocol_handler_permission_controller_impl.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REGISTER_PROTOCOL_HANDLER_PERMISSION_CONTROLLER_IMPL_H
+#define REGISTER_PROTOCOL_HANDLER_PERMISSION_CONTROLLER_IMPL_H
+
+#include "register_protocol_handler_permission_controller.h"
+
+#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
+#include "chrome/common/custom_handlers/protocol_handler.h"
+
+class ProtocolHandlerRegistry;
+
+namespace QtWebEngineCore {
+
+class RegisterProtocolHandlerPermissionControllerImpl final : public RegisterProtocolHandlerPermissionController {
+public:
+ RegisterProtocolHandlerPermissionControllerImpl(
+ ProtocolHandlerRegistry *registry,
+ ProtocolHandler handler);
+
+protected:
+ void accepted() override;
+ void rejected() override;
+
+private:
+ ProtocolHandlerRegistry *m_registry;
+ ProtocolHandler m_handler;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // REGISTER_PROTOCOL_HANDLER_PERMISSION_CONTROLLER_IMPL_H
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index fd0f24735..2622cb09e 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -44,6 +44,7 @@
#include "base/strings/string_util.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/sequenced_worker_pool.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h"
#include "content/network/proxy_service_mojo.h"
#include "content/public/browser/browser_thread.h"
@@ -81,6 +82,7 @@
#include "api/qwebengineurlschemehandler.h"
#include "browser_context_adapter.h"
+#include "browser_context_qt.h"
#include "custom_protocol_handler.h"
#include "cookie_monster_delegate_qt.h"
#include "content_client_qt.h"
@@ -111,6 +113,14 @@ URLRequestContextGetterQt::URLRequestContextGetterQt(QSharedPointer<BrowserConte
{
std::swap(m_protocolHandlers, *protocolHandlers);
+ // The ProtocolHandlerRegistry and it's JobInterceptorFactory need to be
+ // created on the UI thread:
+ ProtocolHandlerRegistry* protocolHandlerRegistry =
+ ProtocolHandlerRegistryFactory::GetForBrowserContext(browserContext->browserContext());
+ DCHECK(protocolHandlerRegistry);
+ m_protocolHandlerInterceptor =
+ protocolHandlerRegistry->CreateJobInterceptorFactory();
+
QMutexLocker lock(&m_mutex);
m_cookieDelegate->setClient(browserContext->cookieStore());
setFullConfiguration(browserContext);
@@ -583,6 +593,11 @@ void URLRequestContextGetterQt::generateJobFactory()
m_requestInterceptors.clear();
+ if (m_protocolHandlerInterceptor) {
+ m_protocolHandlerInterceptor->Chain(std::move(topJobFactory));
+ topJobFactory = std::move(m_protocolHandlerInterceptor);
+ }
+
m_jobFactory = std::move(topJobFactory);
m_urlRequestContext->set_job_factory(m_jobFactory.get());
diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h
index 4a97a1398..fd80d62c2 100644
--- a/src/core/url_request_context_getter_qt.h
+++ b/src/core/url_request_context_getter_qt.h
@@ -45,6 +45,7 @@
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/url_constants.h"
@@ -120,6 +121,7 @@ private:
std::unique_ptr<NetworkDelegateQt> m_networkDelegate;
std::unique_ptr<net::URLRequestContextStorage> m_storage;
std::unique_ptr<net::URLRequestJobFactory> m_jobFactory;
+ std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> m_protocolHandlerInterceptor;
net::URLRequestJobFactoryImpl *m_baseJobFactory;
std::unique_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index dfb2dddcc..495be3d84 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -65,6 +65,7 @@ class ColorChooserController;
class FilePickerController;
class JavaScriptDialogController;
class QuotaPermissionController;
+class RegisterProtocolHandlerPermissionController;
class RenderWidgetHostViewQt;
class RenderWidgetHostViewQtDelegate;
class RenderWidgetHostViewQtDelegateClient;
@@ -437,6 +438,7 @@ public:
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0;
virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0;
virtual void runQuotaPermissionRequest(QSharedPointer<QuotaPermissionController>) = 0;
+ virtual void runRegisterProtocolHandlerPermissionRequest(QSharedPointer<RegisterProtocolHandlerPermissionController>) = 0;
virtual WebEngineSettings *webEngineSettings() const = 0;
virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) = 0;
virtual void hideValidationMessage() = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 09cca943e..3d2337884 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -58,9 +58,12 @@
#include "web_contents_adapter_p.h"
#include "web_engine_context.h"
#include "web_engine_settings.h"
+#include "register_protocol_handler_permission_controller_impl.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "components/web_cache/browser/web_cache_manager.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
@@ -608,6 +611,39 @@ bool WebContentsDelegateQt::CheckMediaAccessPermission(content::WebContents *web
}
}
+void WebContentsDelegateQt::RegisterProtocolHandler(content::WebContents *webContents, const std::string &protocol, const GURL &url, bool)
+{
+ content::BrowserContext *context = webContents->GetBrowserContext();
+ if (context->IsOffTheRecord())
+ return;
+
+ ProtocolHandler handler =
+ ProtocolHandler::CreateProtocolHandler(protocol, url);
+
+ ProtocolHandlerRegistry *registry =
+ ProtocolHandlerRegistryFactory::GetForBrowserContext(context);
+ if (registry->SilentlyHandleRegisterHandlerRequest(handler))
+ return;
+
+ QSharedPointer<RegisterProtocolHandlerPermissionController> controller(
+ new RegisterProtocolHandlerPermissionControllerImpl(registry, handler));
+ m_viewClient->runRegisterProtocolHandlerPermissionRequest(std::move(controller));
+}
+
+void WebContentsDelegateQt::UnregisterProtocolHandler(content::WebContents *webContents, const std::string &protocol, const GURL &url, bool)
+{
+ content::BrowserContext* context = webContents->GetBrowserContext();
+ if (context->IsOffTheRecord())
+ return;
+
+ ProtocolHandler handler =
+ ProtocolHandler::CreateProtocolHandler(protocol, url);
+
+ ProtocolHandlerRegistry* registry =
+ ProtocolHandlerRegistryFactory::GetForBrowserContext(context);
+ registry->RemoveHandler(handler);
+}
+
FaviconManager *WebContentsDelegateQt::faviconManager()
{
return m_faviconManager.data();
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 8a3331163..e649ca727 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -128,6 +128,8 @@ public:
void MoveValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view) override;
void BeforeUnloadFired(content::WebContents* tab, bool proceed, bool* proceed_to_fire_unload) override;
bool CheckMediaAccessPermission(content::WebContents *web_contents, const GURL& security_origin, content::MediaStreamType type) override;
+ void RegisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, bool user_gesture) override;
+ void UnregisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, bool user_gesture) override;
// WebContentsObserver overrides
void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) override;
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:
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 67d55b20f..ec35ea6ce 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -54,6 +54,7 @@
#include "qwebengineprofile.h"
#include "qwebengineprofile_p.h"
#include "qwebenginequotapermissionrequest.h"
+#include "qwebengineregisterprotocolhandlerpermissionrequest.h"
#include "qwebenginescriptcollection_p.h"
#include "qwebenginesettings.h"
#include "qwebengineview.h"
@@ -578,6 +579,13 @@ void QWebEnginePagePrivate::runQuotaPermissionRequest(QSharedPointer<QtWebEngine
Q_EMIT q->quotaPermissionRequested(request);
}
+void QWebEnginePagePrivate::runRegisterProtocolHandlerPermissionRequest(QSharedPointer<RegisterProtocolHandlerPermissionController> controller)
+{
+ Q_Q(QWebEnginePage);
+ QWebEngineRegisterProtocolHandlerPermissionRequest request(std::move(controller));
+ Q_EMIT q->registerProtocolHandlerPermissionRequested(request);
+}
+
QObject *QWebEnginePagePrivate::accessibilityParentObject()
{
return view;
@@ -750,6 +758,18 @@ QWebEnginePage::QWebEnginePage(QObject* parent)
*/
/*!
+ \fn QWebEnginePage::registerProtocolHandlerPermissionRequested(QWebEngineRegisterProtocolHandlerPermissionRequest request)
+ \since 5.11
+
+ This signal is emitted when the web page tries to register a custom protocol
+ using the \l registerProtocolHandler API.
+
+ The request object \a request can be used to accept or reject the request:
+
+ \snippet webenginewidgets/simplebrowser/webpage.cpp registerProtocolHandlerPermissionRequested
+*/
+
+/*!
\fn void QWebEnginePage::pdfPrintingFinished(const QString &filePath, bool success)
\since 5.9
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 7ce72258b..d716765fe 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -66,6 +66,7 @@ class QWebEnginePage;
class QWebEnginePagePrivate;
class QWebEngineProfile;
class QWebEngineQuotaPermissionRequest;
+class QWebEngineRegisterProtocolHandlerPermissionRequest;
class QWebEngineScriptCollection;
class QWebEngineSettings;
@@ -338,6 +339,7 @@ Q_SIGNALS:
void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature);
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
void quotaPermissionRequested(QWebEngineQuotaPermissionRequest quotaPermissionRequest);
+ void registerProtocolHandlerPermissionRequested(QWebEngineRegisterProtocolHandlerPermissionRequest request);
void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 301028e39..61092fa6a 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -130,6 +130,7 @@ public:
void runGeolocationPermissionRequest(const QUrl &securityOrigin) 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> &controller) override;
diff --git a/src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.cpp b/src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.cpp
new file mode 100644
index 000000000..ad1398daf
--- /dev/null
+++ b/src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebengineregisterprotocolhandlerpermissionrequest.h"
+
+#include "register_protocol_handler_permission_controller.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWebEngineRegisterProtocolHandlerPermissionRequest
+ \inmodule QtWebEngineWidgets
+ \since 5.11
+ \brief The QWebEngineRegisterProtocolHandlerPermissionRequest type enables
+ accepting or rejecting requests from the \l registerProtocolHandler API.
+
+ \sa QWebEnginePage::registerProtocolHandlerPermissionRequested
+*/
+
+static void registerMetaTypes()
+{
+ qRegisterMetaType<QWebEngineRegisterProtocolHandlerPermissionRequest>();
+}
+
+Q_CONSTRUCTOR_FUNCTION(registerMetaTypes)
+
+/*! \fn QWebEngineRegisterProtocolHandlerPermissionRequest::QWebEngineRegisterProtocolHandlerPermissionRequest()
+ \internal
+*/
+
+/*! \internal */
+QWebEngineRegisterProtocolHandlerPermissionRequest::QWebEngineRegisterProtocolHandlerPermissionRequest(
+ QSharedPointer<QtWebEngineCore::RegisterProtocolHandlerPermissionController> d_ptr)
+ : d_ptr(std::move(d_ptr))
+{}
+
+/*!
+ Rejects the request.
+
+ Subsequent calls to accept() and reject() are ignored.
+*/
+void QWebEngineRegisterProtocolHandlerPermissionRequest::reject()
+{
+ d_ptr->reject();
+}
+
+/*!
+ Accepts the request
+
+ Subsequent calls to accept() and reject() are ignored.
+*/
+void QWebEngineRegisterProtocolHandlerPermissionRequest::accept()
+{
+ d_ptr->accept();
+}
+
+/*!
+ \property QWebEngineRegisterProtocolHandlerPermissionRequest::origin
+ \brief The URL template for the protocol handler.
+
+ This is the second parameter from the \l registerProtocolHandler call.
+*/
+QUrl QWebEngineRegisterProtocolHandlerPermissionRequest::origin() const
+{
+ return d_ptr->origin();
+}
+
+/*!
+ \property QWebEngineRegisterProtocolHandlerPermissionRequest::protocol
+ \brief The URL scheme for the protocol handler.
+
+ This is the first parameter from the \l registerProtocolHandler call.
+*/
+QString QWebEngineRegisterProtocolHandlerPermissionRequest::protocol() const
+{
+ return d_ptr->protocol();
+}
+
+QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.h b/src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.h
new file mode 100644
index 000000000..592eabb34
--- /dev/null
+++ b/src/webenginewidgets/api/qwebengineregisterprotocolhandlerpermissionrequest.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINEREGISTERPROTOCOLHANDLERPERMISSIONREQUEST_H
+#define QWEBENGINEREGISTERPROTOCOLHANDLERPERMISSIONREQUEST_H
+
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qurl.h>
+#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+
+namespace QtWebEngineCore {
+ class RegisterProtocolHandlerPermissionController;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QWEBENGINEWIDGETS_EXPORT QWebEngineRegisterProtocolHandlerPermissionRequest {
+ Q_GADGET
+ Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
+ Q_PROPERTY(QString protocol READ protocol CONSTANT FINAL)
+public:
+ QWebEngineRegisterProtocolHandlerPermissionRequest() {}
+ QWebEngineRegisterProtocolHandlerPermissionRequest(
+ QSharedPointer<QtWebEngineCore::RegisterProtocolHandlerPermissionController>);
+ Q_INVOKABLE void accept();
+ Q_INVOKABLE void reject();
+ QUrl origin() const;
+ QString protocol() const;
+
+private:
+ QSharedPointer<QtWebEngineCore::RegisterProtocolHandlerPermissionController> d_ptr;
+};
+
+QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QWebEngineRegisterProtocolHandlerPermissionRequest)
+
+#endif // QWEBENGINEREGISTERPROTOCOLHANDLERPERMISSIONREQUEST_H
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 37cb7a1f0..c3132b640 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -20,6 +20,7 @@ SOURCES = \
api/qwebenginepage.cpp \
api/qwebengineprofile.cpp \
api/qwebenginequotapermissionrequest.cpp \
+ api/qwebengineregisterprotocolhandlerpermissionrequest.cpp \
api/qwebenginescript.cpp \
api/qwebenginescriptcollection.cpp \
api/qwebenginesettings.cpp \
@@ -39,6 +40,7 @@ HEADERS = \
api/qwebengineprofile.h \
api/qwebengineprofile_p.h \
api/qwebenginequotapermissionrequest.h \
+ api/qwebengineregisterprotocolhandlerpermissionrequest.h \
api/qwebenginescriptcollection.h \
api/qwebenginescriptcollection_p.h \
api/qwebenginesettings.h \