diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2018-01-15 17:57:05 +0100 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2018-02-13 08:18:06 +0000 |
commit | 2a4a5b2ec17189d4ea8fa783cf219c65560e81f8 (patch) | |
tree | 547f48440093ec3fe77e3d787696aa242e82d794 /src/core/web_contents_delegate_qt.cpp | |
parent | 58fea877aa61cf0e7bc81d0c3c91f732c2791ff3 (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/core/web_contents_delegate_qt.cpp')
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
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(); |