summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2020-04-08 13:59:48 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2020-04-10 05:04:32 +0200
commit8cd89e807b58c4ac750b5719ddde319741a7edb9 (patch)
tree714ab8be333feb00a8bc03c6a692a11b8c6c378e
parenta3bc7f797d740da416b858806ce9fcfb46e77ac6 (diff)
ProfileIODataQt: remove more remains of non network service code
Task-number: QTBUG-83394 Change-Id: Ib1b4431ac75ae7e988bf62580e2bfb690840f54a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/profile_adapter.cpp17
-rw-r--r--src/core/profile_adapter.h1
-rw-r--r--src/core/profile_io_data_qt.cpp185
-rw-r--r--src/core/profile_io_data_qt.h48
4 files changed, 2 insertions, 249 deletions
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index e9e2a2c5d..c27883b65 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -318,21 +318,6 @@ void ProfileAdapter::setCachePath(const QString &path)
m_profile->m_profileIOData->resetNetworkContext();
}
-QString ProfileAdapter::cookiesPath() const
-{
- if (m_offTheRecord)
- return QString();
- QString basePath = dataPath();
- if (!basePath.isEmpty()) {
- // This is a typo fix. We still need the old path in order to avoid breaking migration.
- QDir coookiesFolder(basePath % QLatin1String("/Coookies"));
- if (coookiesFolder.exists())
- return coookiesFolder.path();
- return basePath % QLatin1String("/Cookies");
- }
- return QString();
-}
-
QString ProfileAdapter::httpCachePath() const
{
if (m_offTheRecord)
@@ -393,7 +378,7 @@ void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCache
ProfileAdapter::PersistentCookiesPolicy ProfileAdapter::persistentCookiesPolicy() const
{
- if (isOffTheRecord() || cookiesPath().isEmpty())
+ if (isOffTheRecord() || dataPath().isEmpty())
return NoPersistentCookies;
return m_persistentCookiesPolicy;
}
diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h
index 1b89a8004..60d04273b 100644
--- a/src/core/profile_adapter.h
+++ b/src/core/profile_adapter.h
@@ -123,7 +123,6 @@ public:
void setCachePath(const QString &path);
QString httpCachePath() const;
- QString cookiesPath() const;
QString httpUserAgent() const;
void setHttpUserAgent(const QString &userAgent);
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 91af8d544..fd073f208 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -43,7 +43,6 @@
#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"
#include "content/public/browser/shared_cors_origin_access_list.h"
#include "content/public/common/content_features.h"
#include "net/ssl/ssl_config_service_defaults.h"
@@ -58,8 +57,6 @@
#include "type_conversion.h"
#include <QDebug>
-#include <QVariant>
-
#include <mutex>
namespace QtWebEngineCore {
@@ -69,7 +66,6 @@ ProfileIODataQt::ProfileIODataQt(ProfileQt *profile)
#if QT_CONFIG(ssl)
m_clientCertificateStoreData(new ClientCertificateStoreData),
#endif
- m_removerObserver(this),
m_weakPtrFactory(this)
{
if (content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI))
@@ -106,14 +102,6 @@ void ProfileIODataQt::shutdownOnUIThread()
}
}
-net::URLRequestContext *ProfileIODataQt::urlRequestContext()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- if (!m_initialized)
- initializeOnIOThread();
- return nullptr;
-}
-
content::ResourceContext *ProfileIODataQt::resourceContext()
{
return m_resourceContext.get();
@@ -126,29 +114,12 @@ extensions::ExtensionSystemQt* ProfileIODataQt::GetExtensionSystem()
}
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-base::WeakPtr<ProfileIODataQt> ProfileIODataQt::getWeakPtrOnUIThread()
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- DCHECK(m_initialized);
- return m_weakPtr;
-}
-
base::WeakPtr<ProfileIODataQt> ProfileIODataQt::getWeakPtrOnIOThread()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
return m_weakPtrFactory.GetWeakPtr();
}
-void ProfileIODataQt::initializeOnIOThread()
-{
- // this binds factory to io thread
- m_weakPtr = m_weakPtrFactory.GetWeakPtr();
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- generateAllStorage();
- setGlobalCertificateVerification();
- m_initialized = true;
-}
-
void ProfileIODataQt::initializeOnUIThread()
{
m_profileAdapter = m_profile->profileAdapter();
@@ -159,52 +130,15 @@ void ProfileIODataQt::initializeOnUIThread()
m_proxyConfigMonitor.reset(new ProxyConfigMonitor(m_profile->GetPrefs()));
}
-void ProfileIODataQt::generateAllStorage()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_updateAllStorage = false;
-}
-
-void ProfileIODataQt::regenerateJobFactory()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
-
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_updateJobFactory = false;
-
- if (m_customUrlSchemes == m_installedCustomSchemes)
- return;
-
- m_installedCustomSchemes = m_customUrlSchemes;
-}
-
-void ProfileIODataQt::setGlobalCertificateVerification()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
-}
-
-void ProfileIODataQt::setRequestContextData(content::ProtocolHandlerMap *protocolHandlers,
- content::URLRequestInterceptorScopedVector request_interceptors)
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- Q_ASSERT(!m_initialized);
- m_requestInterceptors = std::move(request_interceptors);
- std::swap(m_protocolHandlers, *protocolHandlers);
-}
-
void ProfileIODataQt::setFullConfiguration()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
- m_cookiesPath = m_profileAdapter->cookiesPath();
m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
m_httpUserAgent = m_profileAdapter->httpUserAgent();
m_httpCacheType = m_profileAdapter->httpCacheType();
m_httpCachePath = m_profileAdapter->httpCachePath();
m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
- m_customUrlSchemes = m_profileAdapter->customUrlSchemes();
m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification();
m_dataPath = m_profileAdapter->dataPath();
}
@@ -221,85 +155,6 @@ void ProfileIODataQt::resetNetworkContext()
}));
}
-void ProfileIODataQt::requestStorageGeneration() {
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- if (m_initialized && !m_updateAllStorage) {
- m_updateAllStorage = true;
- base::PostTask(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr));
- }
-}
-
-void ProfileIODataQt::updateStorageSettings()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- setFullConfiguration();
-
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateCookieStore()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
- m_cookiesPath = m_profileAdapter->cookiesPath();
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateUserAgent()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
- m_httpUserAgent = m_profileAdapter->httpUserAgent();
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateHttpCache()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- m_httpCacheType = m_profileAdapter->httpCacheType();
- m_httpCachePath = m_profileAdapter->httpCachePath();
- m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
-
- if (m_httpCacheType == ProfileAdapter::NoCache) {
- m_pendingStorageRequestGeneration = true;
- content::BrowsingDataRemover *remover =
- content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
- remover->AddObserver(&m_removerObserver);
- remover->RemoveAndReply(base::Time(), base::Time::Max(),
- content::BrowsingDataRemover::DATA_TYPE_CACHE,
- content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
- content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB,
- &m_removerObserver);
- return;
- }
- if (!m_pendingStorageRequestGeneration)
- requestStorageGeneration();
-}
-
-void ProfileIODataQt::updateJobFactory()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
-
- m_customUrlSchemes = m_profileAdapter->customUrlSchemes();
-
- if (m_initialized && !m_updateJobFactory) {
- m_updateJobFactory = true;
- base::PostTask(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::regenerateJobFactory, m_weakPtr));
- }
-}
-
void ProfileIODataQt::updateRequestInterceptor()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -343,29 +198,11 @@ void ProfileIODataQt::releaseInterceptor()
m_mutex.unlock();
}
-bool ProfileIODataQt::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const
-{
- return m_cookieDelegate->canSetCookie(firstPartyUrl,cookieLine, url);
-}
-
bool ProfileIODataQt::canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const
{
return m_cookieDelegate->canGetCookies(firstPartyUrl, url);
}
-void ProfileIODataQt::updateUsedForGlobalCertificateVerification()
-{
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- const std::lock_guard<QRecursiveMutex> lock(m_mutex);
- if (m_useForGlobalCertificateVerification == m_profileAdapter->isUsedForGlobalCertificateVerification())
- return;
- m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification();
-
- if (m_useForGlobalCertificateVerification)
- base::PostTask(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::setGlobalCertificateVerification, m_weakPtr));
-}
-
#if QT_CONFIG(ssl)
ClientCertificateStoreData *ProfileIODataQt::clientCertificateStoreData()
{
@@ -384,7 +221,7 @@ std::unique_ptr<net::ClientCertStore> ProfileIODataQt::CreateClientCertStore()
network::mojom::NetworkContextParamsPtr ProfileIODataQt::CreateNetworkContextParams()
{
- updateStorageSettings();
+ setFullConfiguration();
network::mojom::NetworkContextParamsPtr network_context_params =
SystemNetworkContextManager::GetInstance()->CreateDefaultNetworkContextParams();
@@ -447,24 +284,4 @@ ProfileIODataQt *ProfileIODataQt::FromResourceContext(content::ResourceContext *
return static_cast<ResourceContextQt *>(resource_context)->m_io_data;
}
-void ProfileIODataQt::removeBrowsingDataRemoverObserver()
-{
- content::BrowsingDataRemover *remover =
- content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
- remover->RemoveObserver(&m_removerObserver);
-}
-
-BrowsingDataRemoverObserverQt::BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData)
- : m_profileIOData(profileIOData)
-{
-}
-
-void BrowsingDataRemoverObserverQt::OnBrowsingDataRemoverDone()
-{
- Q_ASSERT(m_profileIOData->m_pendingStorageRequestGeneration);
- m_profileIOData->requestStorageGeneration();
- m_profileIOData->removeBrowsingDataRemoverObserver();
- m_profileIOData->m_pendingStorageRequestGeneration = false;
-}
-
} // namespace QtWebEngineCore
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index fcd209bf8..6d9dd1a45 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -40,10 +40,8 @@
#ifndef PROFILE_IO_DATA_QT_H
#define PROFILE_IO_DATA_QT_H
-#include "content/public/browser/browsing_data_remover.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/buildflags/buildflags.h"
-#include "services/network/cookie_settings.h"
#include "net/proxy_config_monitor.h"
#include "profile_adapter.h"
@@ -67,18 +65,6 @@ struct ClientCertificateStoreData;
class ProfileIODataQt;
class ProfileQt;
-
-class BrowsingDataRemoverObserverQt : public content::BrowsingDataRemover::Observer {
-public:
- BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData);
-
- void OnBrowsingDataRemoverDone() override;
-
-private:
- ProfileIODataQt *m_profileIOData;
-};
-
-
// ProfileIOData contains data that lives on the IOthread
// we still use shared memebers and use mutex which breaks
// idea for this object, but this is wip.
@@ -91,21 +77,14 @@ public:
QPointer<ProfileAdapter> profileAdapter();
content::ResourceContext *resourceContext();
- net::URLRequestContext *urlRequestContext();
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ExtensionSystemQt* GetExtensionSystem();
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
- void initializeOnIOThread();
void initializeOnUIThread(); // runs on ui thread
void shutdownOnUIThread(); // runs on ui thread
- void cancelAllUrlRequests();
- void generateAllStorage();
- void regenerateJobFactory();
- bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const;
bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const;
- void setGlobalCertificateVerification();
// Used in NetworkDelegateQt::OnBeforeURLRequest.
bool isInterceptorDeprecated() const; // Remove for Qt6
@@ -113,18 +92,9 @@ public:
void releaseInterceptor();
QWebEngineUrlRequestInterceptor *requestInterceptor();
- 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
- void updateHttpCache(); // runs on ui thread
- void updateJobFactory(); // runs on ui thread
void updateRequestInterceptor(); // runs on ui thread
- void requestStorageGeneration(); //runs on ui thread
- void updateUsedForGlobalCertificateVerification(); // runs on ui thread
bool hasPageInterceptors();
network::mojom::NetworkContextParamsPtr CreateNetworkContextParams();
@@ -137,19 +107,13 @@ public:
static ProfileIODataQt *FromResourceContext(content::ResourceContext *resource_context);
base::WeakPtr<ProfileIODataQt> getWeakPtrOnIOThread();
- base::WeakPtr<ProfileIODataQt> getWeakPtrOnUIThread();
CookieMonsterDelegateQt *cookieDelegate() const { return m_cookieDelegate.get(); }
private:
- void removeBrowsingDataRemoverObserver();
-
ProfileQt *m_profile;
std::unique_ptr<content::ResourceContext> m_resourceContext;
- base::WeakPtr<ProfileIODataQt> m_weakPtr;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
- content::URLRequestInterceptorScopedVector m_requestInterceptors;
- content::ProtocolHandlerMap m_protocolHandlers;
QPointer<ProfileAdapter> m_profileAdapter; // never dereferenced in IO thread and it is passed by qpointer
ProfileAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy;
std::unique_ptr<ProxyConfigMonitor> m_proxyConfigMonitor;
@@ -157,15 +121,11 @@ private:
#if QT_CONFIG(ssl)
ClientCertificateStoreData *m_clientCertificateStoreData;
#endif
- QString m_cookiesPath;
QString m_httpAcceptLanguage;
QString m_httpUserAgent;
ProfileAdapter::HttpCacheType m_httpCacheType;
QString m_httpCachePath;
- QList<QByteArray> m_customUrlSchemes;
- QList<QByteArray> m_installedCustomSchemes;
QWebEngineUrlRequestInterceptor* m_requestInterceptor = nullptr;
- network::CookieSettings m_cookieSettings;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QMutex m_mutex{QMutex::Recursive};
using QRecursiveMutex = QMutex;
@@ -173,20 +133,12 @@ private:
QRecursiveMutex m_mutex;
#endif
int m_httpCacheMaxSize = 0;
- bool m_initialized = false;
- bool m_updateAllStorage = false;
- bool m_updateJobFactory = false;
- bool m_ignoreCertificateErrors = false;
bool m_useForGlobalCertificateVerification = false;
bool m_hasPageInterceptors = false;
- BrowsingDataRemoverObserverQt m_removerObserver;
base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member
QString m_dataPath;
- bool m_pendingStorageRequestGeneration = false;
volatile bool m_isInterceptorDeprecated = false; // Remove for Qt6
DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt);
-
- friend class BrowsingDataRemoverObserverQt;
};
} // namespace QtWebEngineCore