summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Yermakov <jp.kuraisu@gmail.com>2015-12-15 17:13:05 +0300
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-12-16 08:50:14 +0000
commit318cd591e2af2a8f825a0742762a5d93345e0753 (patch)
treecf02cb68b228670857307b46173c252afd75f2f0
parente094d0e630f8c0df8c89746f4690d979a05cd9ff (diff)
Use default URLRequestInterceptors passed from Chromium
Default URLRequestInterceptors are required for App Cache and Service Workers support. They were previously ignored and dropped in BrowserContextQt::CreateRequestContext. Implementation in content shell was taken as a reference. Change-Id: I5a12e90febdb4c639f9ead9faf044df09431bdd0 Reviewed-by: Aleksey Yermakov <jp.kuraisu@gmail.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
-rw-r--r--src/core/browser_context_qt.cpp4
-rw-r--r--src/core/browser_context_qt.h2
-rw-r--r--src/core/content_browser_client_qt.cpp2
-rw-r--r--src/core/url_request_context_getter_qt.cpp29
-rw-r--r--src/core/url_request_context_getter_qt.h6
5 files changed, 29 insertions, 14 deletions
diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp
index 28486cced..d21f963a9 100644
--- a/src/core/browser_context_qt.cpp
+++ b/src/core/browser_context_qt.cpp
@@ -147,9 +147,9 @@ content::PermissionManager *BrowserContextQt::GetPermissionManager()
return permissionManager.get();
}
-net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers)
+net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
{
- url_request_getter_ = new URLRequestContextGetterQt(m_adapter, protocol_handlers);
+ url_request_getter_ = new URLRequestContextGetterQt(m_adapter, protocol_handlers, request_interceptors.Pass());
return url_request_getter_.get();
}
diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h
index eccd684a3..9deb42b56 100644
--- a/src/core/browser_context_qt.h
+++ b/src/core/browser_context_qt.h
@@ -72,7 +72,7 @@ public:
virtual storage::SpecialStoragePolicy *GetSpecialStoragePolicy() Q_DECL_OVERRIDE;
virtual content::PushMessagingService* GetPushMessagingService() Q_DECL_OVERRIDE;
virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() Q_DECL_OVERRIDE;
- net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers);
+ net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors);
virtual scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(const base::FilePath& partition_path) Q_DECL_OVERRIDE;
virtual content::PermissionManager *GetPermissionManager() Q_DECL_OVERRIDE;
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 91cd0b0c4..078874da1 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -384,7 +384,7 @@ content::AccessTokenStore *ContentBrowserClientQt::CreateAccessTokenStore()
net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors)
{
- return static_cast<BrowserContextQt*>(browser_context)->CreateRequestContext(protocol_handlers);
+ return static_cast<BrowserContextQt*>(browser_context)->CreateRequestContext(protocol_handlers, request_interceptors.Pass());
}
content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext()
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 609be75d3..f5c310e90 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -64,6 +64,7 @@
#include "net/url_request/data_protocol_handler.h"
#include "net/url_request/file_protocol_handler.h"
#include "net/url_request/ftp_protocol_handler.h"
+#include "net/url_request/url_request_intercepting_job_factory.h"
#include "net/ftp/ftp_network_layer.h"
#include "api/qwebengineurlschemehandler.h"
@@ -84,10 +85,11 @@ static const char kQrcSchemeQt[] = "qrc";
using content::BrowserThread;
-URLRequestContextGetterQt::URLRequestContextGetterQt(BrowserContextAdapter *browserContext, content::ProtocolHandlerMap *protocolHandlers)
+URLRequestContextGetterQt::URLRequestContextGetterQt(BrowserContextAdapter *browserContext, content::ProtocolHandlerMap *protocolHandlers, content::URLRequestInterceptorScopedVector request_interceptors)
: m_ignoreCertificateErrors(false)
, m_browserContext(browserContext)
, m_cookieDelegate(new CookieMonsterDelegateQt())
+ , m_requestInterceptors(request_interceptors.Pass())
{
std::swap(m_protocolHandlers, *protocolHandlers);
@@ -388,28 +390,39 @@ void URLRequestContextGetterQt::generateJobFactory()
{
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(!m_jobFactory);
- m_jobFactory.reset(new net::URLRequestJobFactoryImpl());
+
+ scoped_ptr<net::URLRequestJobFactoryImpl> jobFactory(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());
+ 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(
+ jobFactory->SetProtocolHandler(url::kDataScheme, new net::DataProtocolHandler());
+ jobFactory->SetProtocolHandler(url::kFileScheme, new net::FileProtocolHandler(
content::BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
- m_jobFactory->SetProtocolHandler(kQrcSchemeQt, new QrcProtocolHandlerQt());
- m_jobFactory->SetProtocolHandler(url::kFtpScheme,
+ jobFactory->SetProtocolHandler(kQrcSchemeQt, new QrcProtocolHandlerQt());
+ jobFactory->SetProtocolHandler(url::kFtpScheme,
new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver())));
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()));
+ jobFactory->SetProtocolHandler(it.key().toStdString(), new CustomProtocolHandler(it.value()));
+
+ // Set up interceptors in the reverse order.
+ scoped_ptr<net::URLRequestJobFactory> topJobFactory = jobFactory.Pass();
+
+ for (content::URLRequestInterceptorScopedVector::reverse_iterator i = m_requestInterceptors.rbegin(); i != m_requestInterceptors.rend(); ++i)
+ topJobFactory.reset(new net::URLRequestInterceptingJobFactory(topJobFactory.Pass(), make_scoped_ptr(*i)));
+
+ m_requestInterceptors.weak_clear();
+
+ m_jobFactory = topJobFactory.Pass();
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 247247f7c..f61e4f09b 100644
--- a/src/core/url_request_context_getter_qt.h
+++ b/src/core/url_request_context_getter_qt.h
@@ -67,7 +67,7 @@ class BrowserContextAdapter;
class URLRequestContextGetterQt : public net::URLRequestContextGetter {
public:
- explicit URLRequestContextGetterQt(BrowserContextAdapter *browserContext, content::ProtocolHandlerMap *protocolHandlers);
+ explicit URLRequestContextGetterQt(BrowserContextAdapter *browserContext, content::ProtocolHandlerMap *protocolHandlers, content::URLRequestInterceptorScopedVector request_interceptors);
virtual net::URLRequestContext *GetURLRequestContext() Q_DECL_OVERRIDE;
virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const Q_DECL_OVERRIDE;
@@ -100,9 +100,11 @@ private:
scoped_ptr<net::URLRequestContext> m_urlRequestContext;
scoped_ptr<NetworkDelegateQt> m_networkDelegate;
scoped_ptr<net::URLRequestContextStorage> m_storage;
- scoped_ptr<net::URLRequestJobFactoryImpl> m_jobFactory;
+ scoped_ptr<net::URLRequestJobFactory> m_jobFactory;
scoped_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
+ content::URLRequestInterceptorScopedVector m_requestInterceptors;
+
friend class NetworkDelegateQt;
};