summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-02-12 12:59:00 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-03-02 11:48:10 +0100
commit218d7ddae16c777714819eab5c487a355413279b (patch)
tree9107eac0a35301e8487bbfa54e5000dac9054260
parentc3ab932f8b2f3a52383ce0db3ff67c925b138bde (diff)
Improvements to dynamic update of profiles
Avoid reseting network-context on accept-language change, and trigger update of url-loaders when customer schemes change, but not when a set of none are cleared. Change-Id: Iad268b7066cfd3854348f9a103120c4a104be7af Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
-rw-r--r--src/core/profile_adapter.cpp24
-rw-r--r--src/core/profile_io_data_qt.cpp5
2 files changed, 20 insertions, 9 deletions
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index 143e6ccee..7387cc421 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -44,6 +44,7 @@
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
+#include "content/public/browser/storage_partition.h"
#include "services/network/public/cpp/cors/origin_access_list.h"
#include "url/url_util.h"
@@ -499,8 +500,10 @@ const QList<QByteArray> ProfileAdapter::customUrlSchemes() const
void ProfileAdapter::updateCustomUrlSchemeHandlers()
{
-// if (m_profile->m_urlRequestContextGetter.get())
-// m_profile->m_profileIOData->updateJobFactory();
+ content::BrowserContext::ForEachStoragePartition(
+ m_profile.get(), base::BindRepeating([](content::StoragePartition *storage_partition) {
+ storage_partition->ResetURLLoaderFactories();
+ }));
}
void ProfileAdapter::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
@@ -561,9 +564,11 @@ void ProfileAdapter::installUrlSchemeHandler(const QByteArray &scheme, QWebEngin
void ProfileAdapter::removeAllUrlSchemeHandlers()
{
- m_customUrlSchemeHandlers.clear();
- m_customUrlSchemeHandlers.insert(QByteArrayLiteral("qrc"), &m_qrcHandler);
- updateCustomUrlSchemeHandlers();
+ if (m_customUrlSchemeHandlers.size() > 1) {
+ m_customUrlSchemeHandlers.clear();
+ m_customUrlSchemeHandlers.insert(QByteArrayLiteral("qrc"), &m_qrcHandler);
+ updateCustomUrlSchemeHandlers();
+ }
}
UserResourceControllerHost *ProfileAdapter::userResourceController()
@@ -606,16 +611,21 @@ void ProfileAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
return;
m_httpAcceptLanguage = httpAcceptLanguage;
+ std::string http_accept_language = httpAcceptLanguageWithoutQualities().toStdString();
+
std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents();
for (content::WebContentsImpl *web_contents : list) {
if (web_contents->GetBrowserContext() == m_profile.data()) {
blink::mojom::RendererPreferences *rendererPrefs = web_contents->GetMutableRendererPrefs();
- rendererPrefs->accept_languages = httpAcceptLanguageWithoutQualities().toStdString();
+ rendererPrefs->accept_languages = http_accept_language;
web_contents->SyncRendererPrefs();
}
}
- m_profile->m_profileIOData->resetNetworkContext();
+ content::BrowserContext::ForEachStoragePartition(
+ m_profile.get(), base::BindRepeating([](std::string accept_language, content::StoragePartition *storage_partition) {
+ storage_partition->GetNetworkContext()->SetAcceptLanguage(accept_language);
+ }, http_accept_language));
}
void ProfileAdapter::clearHttpCache()
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 6eb758f46..7e1313a16 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -420,6 +420,7 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar
SystemNetworkContextManager::GetInstance()->CreateDefaultNetworkContextParams();
network_context_params->context_name = m_profile->profileAdapter()->storageName().toStdString();
+ network_context_params->user_agent = m_httpUserAgent.toStdString();
network_context_params->accept_language = m_httpAcceptLanguage.toStdString();
network_context_params->enable_referrers = true;
@@ -429,10 +430,10 @@ network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextPar
network_context_params->http_cache_enabled = m_httpCacheType != ProfileAdapter::NoCache;
network_context_params->http_cache_max_size = m_httpCacheMaxSize;
- if (m_httpCacheType == ProfileAdapter::DiskHttpCache)
+ if (m_httpCacheType == ProfileAdapter::DiskHttpCache && !m_httpCachePath.isEmpty())
network_context_params->http_cache_path = toFilePath(m_httpCachePath);
- if (m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies) {
+ if (m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies && !m_dataPath.isEmpty()) {
base::FilePath cookie_path = toFilePath(m_dataPath);
cookie_path = cookie_path.AppendASCII("Cookies");
network_context_params->cookie_path = cookie_path;