summaryrefslogtreecommitdiffstats
path: root/src/core/url_request_context_getter_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-04-21 14:35:28 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-04-21 15:26:12 +0000
commitad82daf8f597855aefbaa190ab89abb148362c7f (patch)
treeb75476ab40f6132f4df39628d4e73cd7d51ee72b /src/core/url_request_context_getter_qt.cpp
parenta1eda6b9aa885619a357f5532e584092b8e5bf91 (diff)
Do not access browser-context to read user-agent or accept language
Switches HttpUserAgentSettingsQt to reading local string that lives on the IO thread, instead of accessing a pointer that may be deleted. Also adds a test and fixes updating accept-language of already initialized WebContents. Change-Id: Iff4e3bd1ac40482a92bed50c3f703ed8b974b0ad Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com>
Diffstat (limited to 'src/core/url_request_context_getter_qt.cpp')
-rw-r--r--src/core/url_request_context_getter_qt.cpp23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index bbabb8707..0a6a85e41 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -268,33 +268,14 @@ void URLRequestContextGetterQt::updateUserAgent()
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestContextGetterQt::generateUserAgent, this));
}
-class HttpUserAgentSettingsQt : public net::HttpUserAgentSettings
-{
- const BrowserContextAdapter *m_browserContext;
-public:
- HttpUserAgentSettingsQt(const BrowserContextAdapter *ctx)
- : m_browserContext(ctx)
- {
- }
-
- std::string GetAcceptLanguage() const Q_DECL_OVERRIDE
- {
- return m_browserContext->httpAcceptLanguage().toStdString();
- }
-
- std::string GetUserAgent() const Q_DECL_OVERRIDE
- {
- return m_browserContext->httpUserAgent().toStdString();
- }
-};
-
void URLRequestContextGetterQt::generateUserAgent()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(m_storage);
- m_storage->set_http_user_agent_settings(new HttpUserAgentSettingsQt(m_browserContext.data()));
+ m_storage->set_http_user_agent_settings(
+ new net::StaticHttpUserAgentSettings(m_browserContext->httpAcceptLanguage().toStdString(), m_browserContext->httpUserAgent().toStdString()));
}
void URLRequestContextGetterQt::updateHttpCache()