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/url_request_context_getter_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/url_request_context_getter_qt.cpp')
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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()); |