diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-07-15 17:17:40 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-07-19 09:19:26 +0000 |
commit | f84869e9d8ea3ea9ced15adcc092558555874606 (patch) | |
tree | f186b4aaf1583ac51a21ba8504a01555528245ba | |
parent | 7b0477f14adcb2ccb7e364900df546680cacbfbc (diff) | |
download | qtwebengine-f84869e9d8ea3ea9ced15adcc092558555874606.tar.gz |
Add persistent backend to channel id service
Channel-ids are only supposed to be memory only when running in off
the record profiles. We have just never initialized the sql-based
backend.
We follow the cookie-settings, because channel-ids are used together
with cookies, have similar implications, and newer Chromium versions
will assert that cookie-store and channel-id store have matching
storage models.
Change-Id: I0a64146f0ed36a8913706bfc3fcadd7404894745
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
-rw-r--r-- | src/core/browser_context_adapter.cpp | 10 | ||||
-rw-r--r-- | src/core/browser_context_adapter.h | 1 | ||||
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 21 | ||||
-rw-r--r-- | src/core/url_request_context_getter_qt.h | 1 |
4 files changed, 28 insertions, 5 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 702851ba5..66cbdb040 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -236,6 +236,16 @@ QString BrowserContextAdapter::cookiesPath() const return QString(); } +QString BrowserContextAdapter::channelIdPath() const +{ + if (m_offTheRecord) + return QString(); + QString basePath = dataPath(); + if (!basePath.isEmpty()) + return basePath % QLatin1String("/Origin Bound Certs"); + return QString(); +} + QString BrowserContextAdapter::httpCachePath() const { if (m_offTheRecord) diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index 1eeb88770..162f89a2d 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -100,6 +100,7 @@ public: QString httpCachePath() const; QString cookiesPath() const; + QString channelIdPath() const; QString httpUserAgent() const; void setHttpUserAgent(const QString &userAgent); diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index da651517d..db2240eb4 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -47,6 +47,7 @@ #include "net/cert/cert_verifier.h" #include "net/dns/host_resolver.h" #include "net/dns/mapped_host_resolver.h" +#include "net/extras/sqlite/sqlite_channel_id_store.h" #include "net/http/http_auth_handler_factory.h" #include "net/http/http_cache.h" #include "net/http/http_network_session.h" @@ -122,6 +123,7 @@ void URLRequestContextGetterQt::setFullConfiguration(QSharedPointer<BrowserConte m_requestInterceptor = browserContext->requestInterceptor(); m_persistentCookiesPolicy = browserContext->persistentCookiesPolicy(); m_cookiesPath = browserContext->cookiesPath(); + m_channelIdPath = browserContext->channelIdPath(); m_httpAcceptLanguage = browserContext->httpAcceptLanguage(); m_httpUserAgent = browserContext->httpUserAgent(); m_httpCacheType = browserContext->httpCacheType(); @@ -217,11 +219,6 @@ void URLRequestContextGetterQt::generateStorage() net::ProxyConfigService *proxyConfigService = m_proxyConfigService.fetchAndStoreAcquire(0); Q_ASSERT(proxyConfigService); - - m_storage->set_channel_id_service(scoped_ptr<net::ChannelIDService>(new net::ChannelIDService( - new net::DefaultChannelIDStore(NULL), - base::WorkerPool::GetTaskRunner(true)))); - m_storage->set_cert_verifier(net::CertVerifier::CreateDefault()); scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL)); @@ -255,6 +252,7 @@ void URLRequestContextGetterQt::updateCookieStore() QMutexLocker lock(&m_mutex); m_persistentCookiesPolicy = m_browserContext.data()->persistentCookiesPolicy(); m_cookiesPath = m_browserContext.data()->cookiesPath(); + m_channelIdPath = m_browserContext.data()->channelIdPath(); if (m_contextInitialized && !m_updateAllStorage && !m_updateCookieStore) { m_updateCookieStore = true; @@ -272,6 +270,19 @@ void URLRequestContextGetterQt::generateCookieStore() QMutexLocker lock(&m_mutex); m_updateCookieStore = false; + scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; + if (!m_channelIdPath.isEmpty() && m_persistentCookiesPolicy != BrowserContextAdapter::NoPersistentCookies) { + channel_id_db = new net::SQLiteChannelIDStore( + toFilePath(m_channelIdPath), + BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( + BrowserThread::GetBlockingPool()->GetSequenceToken())); + } + + m_storage->set_channel_id_service( + scoped_ptr<net::ChannelIDService>(new net::ChannelIDService( + new net::DefaultChannelIDStore(channel_id_db.get()), + base::WorkerPool::GetTaskRunner(true)))); + // Unset it first to get a chance to destroy and flush the old cookie store before opening a new on possibly the same file. m_storage->set_cookie_store(0); m_cookieDelegate->setCookieMonster(0); diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h index 11c3f4e79..9a4c74303 100644 --- a/src/core/url_request_context_getter_qt.h +++ b/src/core/url_request_context_getter_qt.h @@ -127,6 +127,7 @@ private: // FIXME: Should later be moved to a separate ProfileIOData class. BrowserContextAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy; QString m_cookiesPath; + QString m_channelIdPath; QString m_httpAcceptLanguage; QString m_httpUserAgent; BrowserContextAdapter::HttpCacheType m_httpCacheType; |