diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-12 17:38:32 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-16 14:22:34 +0000 |
commit | d9d1cc3ec8931cecc0b0dcb5d5d184cdb53ff434 (patch) | |
tree | 5733a96d78502f4f2f3b3326403e717636b04f34 /src/core/url_request_context_getter_qt.cpp | |
parent | fbfd6b7617a88bf9668f88be5db220d3a3f92071 (diff) |
Decouple scheme and url scheme handler
Remove the scheme from the url scheme handler constructor, this way
the same handler can handle multiple schemes, the API look more natural
and we can get rid of the private class.
Change-Id: I33906b8a5ea51641e28a53f93f4feb1472c24baf
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/core/url_request_context_getter_qt.cpp')
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 771a662b9..26e1dbea8 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -336,11 +336,13 @@ void URLRequestContextGetterQt::generateJobFactory() Q_ASSERT(!m_jobFactory); m_jobFactory.reset(new net::URLRequestJobFactoryImpl()); - // Chromium has a few protocol handlers ready for us, only pick blob: and throw away the rest. - content::ProtocolHandlerMap::iterator it = m_protocolHandlers.find(url::kBlobScheme); - Q_ASSERT(it != m_protocolHandlers.end()); - m_jobFactory->SetProtocolHandler(it->first, it->second.release()); - m_protocolHandlers.clear(); + { + // Chromium has a few protocol handlers ready for us, only pick blob: and throw away the rest. + content::ProtocolHandlerMap::iterator it = m_protocolHandlers.find(url::kBlobScheme); + Q_ASSERT(it != m_protocolHandlers.end()); + m_jobFactory->SetProtocolHandler(it->first, it->second.release()); + m_protocolHandlers.clear(); + } m_jobFactory->SetProtocolHandler(url::kDataScheme, new net::DataProtocolHandler()); m_jobFactory->SetProtocolHandler(url::kFileScheme, new net::FileProtocolHandler( @@ -350,9 +352,10 @@ void URLRequestContextGetterQt::generateJobFactory() m_jobFactory->SetProtocolHandler(url::kFtpScheme, new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver()))); - Q_FOREACH (QWebEngineUrlSchemeHandler *handler, m_browserContext->customUrlSchemeHandlers()) { - m_jobFactory->SetProtocolHandler(handler->scheme().toStdString(), new CustomProtocolHandler(handler)); - } + QHash<QByteArray, QWebEngineUrlSchemeHandler*>::const_iterator it = m_browserContext->customUrlSchemeHandlers().constBegin(); + const QHash<QByteArray, QWebEngineUrlSchemeHandler*>::const_iterator end = m_browserContext->customUrlSchemeHandlers().constEnd(); + for (; it != end; ++it) + m_jobFactory->SetProtocolHandler(it.key().toStdString(), new CustomProtocolHandler(it.value())); m_urlRequestContext->set_job_factory(m_jobFactory.get()); } |