summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2020-01-24 14:40:01 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-02-26 14:10:18 +0100
commit6adf1bf7162185d1f57f0a25226dec8e27520673 (patch)
treea493ab3241ecade943f1aaf5f814f5f22f3b6c16
parentd9349a299f66fb154ad24f410451872a7ca253fb (diff)
Fix changing profile settings with network service
Fixes: QTBUG-81558 Change-Id: I6f6d1b927d0f20d99477dce21697d4a03f61c059 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/net/cookie_monster_delegate_qt.cpp4
-rw-r--r--src/core/profile_adapter.cpp39
-rw-r--r--src/core/profile_io_data_qt.cpp13
-rw-r--r--src/core/profile_io_data_qt.h1
4 files changed, 37 insertions, 20 deletions
diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp
index dba79b4db..2ddaec526 100644
--- a/src/core/net/cookie_monster_delegate_qt.cpp
+++ b/src/core/net/cookie_monster_delegate_qt.cpp
@@ -168,6 +168,10 @@ void CookieMonsterDelegateQt::deleteAllCookies(quint64 callbackId)
void CookieMonsterDelegateQt::setMojoCookieManager(network::mojom::CookieManagerPtrInfo cookie_manager_info)
{
// DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (m_binding)
+ unsetMojoCookieManager();
+
m_mojoCookieManager.Bind(std::move(cookie_manager_info));
network::mojom::CookieChangeListenerPtr listener_ptr;
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index 80edf40bf..85577ef52 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -49,6 +49,7 @@
#include "download_manager_delegate_qt.h"
#include "permission_manager_qt.h"
#include "profile_adapter_client.h"
+#include "profile_io_data_qt.h"
#include "profile_qt.h"
#include "renderer_host/user_resource_controller_host.h"
#include "type_conversion.h"
@@ -128,8 +129,7 @@ void ProfileAdapter::setStorageName(const QString &storageName)
m_name = storageName;
if (!m_offTheRecord) {
m_profile->setupPrefService();
- if (m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateStorageSettings();
+ m_profile->m_profileIOData->resetNetworkContext();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -141,8 +141,7 @@ void ProfileAdapter::setOffTheRecord(bool offTheRecord)
return;
m_offTheRecord = offTheRecord;
m_profile->setupPrefService();
- if (m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateStorageSettings();
+ m_profile->m_profileIOData->resetNetworkContext();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -273,8 +272,7 @@ void ProfileAdapter::setDataPath(const QString &path)
m_dataPath = path;
if (!m_offTheRecord) {
m_profile->setupPrefService();
- if (m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateStorageSettings();
+ m_profile->m_profileIOData->resetNetworkContext();
if (m_visitedLinksManager)
resetVisitedLinksManager();
}
@@ -301,8 +299,8 @@ void ProfileAdapter::setCachePath(const QString &path)
if (m_cachePath == path)
return;
m_cachePath = path;
- if (!m_offTheRecord && m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateHttpCache();
+ if (!m_offTheRecord)
+ m_profile->m_profileIOData->resetNetworkContext();
}
QString ProfileAdapter::cookiesPath() const
@@ -348,8 +346,7 @@ void ProfileAdapter::setHttpUserAgent(const QString &userAgent)
if (web_contents->GetBrowserContext() == m_profile.data())
web_contents->SetUserAgentOverride(m_httpUserAgent.toStdString(), true);
- if (m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateUserAgent();
+ m_profile->m_profileIOData->resetNetworkContext();
}
ProfileAdapter::HttpCacheType ProfileAdapter::httpCacheType() const
@@ -367,8 +364,11 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache
m_httpCacheType = newhttpCacheType;
if (oldCacheType == httpCacheType())
return;
- if (!m_offTheRecord && m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateHttpCache();
+ if (!m_offTheRecord) {
+ m_profile->m_profileIOData->resetNetworkContext();
+ if (m_httpCacheType == NoCache)
+ clearHttpCache();
+ }
}
ProfileAdapter::PersistentCookiesPolicy ProfileAdapter::persistentCookiesPolicy() const
@@ -384,8 +384,8 @@ void ProfileAdapter::setPersistentCookiesPolicy(ProfileAdapter::PersistentCookie
m_persistentCookiesPolicy = newPersistentCookiesPolicy;
if (oldPolicy == persistentCookiesPolicy())
return;
- if (!m_offTheRecord && m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateCookieStore();
+ if (!m_offTheRecord)
+ m_profile->m_profileIOData->resetNetworkContext();
}
ProfileAdapter::VisitedLinksPolicy ProfileAdapter::visitedLinksPolicy() const
@@ -439,8 +439,8 @@ void ProfileAdapter::setHttpCacheMaxSize(int maxSize)
if (m_httpCacheMaxSize == maxSize)
return;
m_httpCacheMaxSize = maxSize;
- if (!m_offTheRecord && m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateHttpCache();
+ if (!m_offTheRecord)
+ m_profile->m_profileIOData->resetNetworkContext();
}
enum class SchemeType { Protected, Overridable, Custom, Unknown };
@@ -601,8 +601,7 @@ void ProfileAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
}
}
- if (m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateUserAgent();
+ m_profile->m_profileIOData->resetNetworkContext();
}
void ProfileAdapter::clearHttpCache()
@@ -671,6 +670,7 @@ void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable)
if (enable) {
if (profileForglobalCertificateVerification) {
profileForglobalCertificateVerification->m_usedForGlobalCertificateVerification = false;
+ profileForglobalCertificateVerification->m_profile->m_profileIOData->resetNetworkContext();
for (auto *client : qAsConst(profileForglobalCertificateVerification->m_clients))
client->useForGlobalCertificateVerificationChanged();
}
@@ -681,8 +681,7 @@ void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable)
profileForglobalCertificateVerification = nullptr;
}
- if (m_profile->m_urlRequestContextGetter.get())
- m_profile->m_profileIOData->updateUsedForGlobalCertificateVerification();
+ m_profile->m_profileIOData->resetNetworkContext();
}
bool ProfileAdapter::isUsedForGlobalCertificateVerification() const
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index ef8f30e10..00d3e768a 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -41,6 +41,7 @@
#include "base/task/post_task.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
+#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_remover.h"
@@ -224,6 +225,18 @@ void ProfileIODataQt::setFullConfiguration()
m_dataPath = m_profileAdapter->dataPath();
}
+void ProfileIODataQt::resetNetworkContext()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ setFullConfiguration();
+ content::BrowserContext::ForEachStoragePartition(
+ m_profile, base::BindRepeating([](content::StoragePartition *storage) {
+ auto storage_impl = static_cast<content::StoragePartitionImpl *>(storage);
+ storage_impl->ResetURLLoaderFactories();
+ storage_impl->ResetNetworkContext();
+ }));
+}
+
void ProfileIODataQt::requestStorageGeneration() {
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
const std::lock_guard<QRecursiveMutex> lock(m_mutex);
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index 25e03a4fd..a1334f412 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -123,6 +123,7 @@ public:
void setRequestContextData(content::ProtocolHandlerMap *protocolHandlers,
content::URLRequestInterceptorScopedVector request_interceptors);
void setFullConfiguration(); // runs on ui thread
+ void resetNetworkContext(); // runs on ui thread
void updateStorageSettings(); // runs on ui thread
void updateUserAgent(); // runs on ui thread
void updateCookieStore(); // runs on ui thread