diff options
42 files changed, 408 insertions, 403 deletions
diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h index 764c7b9a7..89e72dfb0 100644 --- a/src/core/api/qwebenginecookiestore.h +++ b/src/core/api/qwebenginecookiestore.h @@ -50,7 +50,7 @@ #include <functional> namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; class CookieMonsterDelegateQt; } @@ -84,7 +84,7 @@ Q_SIGNALS: private: explicit QWebEngineCookieStore(QObject *parent = Q_NULLPTR); - friend class QtWebEngineCore::BrowserContextAdapter; + friend class QtWebEngineCore::ProfileAdapter; friend class QtWebEngineCore::CookieMonsterDelegateQt; Q_DISABLE_COPY(QWebEngineCookieStore) Q_DECLARE_PRIVATE(QWebEngineCookieStore) diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 7bbe85b4e..a7a2605eb 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -89,7 +89,7 @@ #include "service/service_qt.h" #include "qtwebengine/grit/qt_webengine_resources.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "browser_message_filter_qt.h" #include "certificate_error_controller.h" #include "certificate_error_controller_p.h" @@ -412,7 +412,7 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost* Profile *profile = Profile::FromBrowserContext(host->GetBrowserContext()); // FIXME: Add a settings variable to enable/disable the file scheme. content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(id, url::kFileScheme); - static_cast<ProfileQt*>(host->GetBrowserContext())->m_adapter->userResourceController()->renderProcessStartedWithHost(host); + static_cast<ProfileQt*>(host->GetBrowserContext())->m_profileAdapter->userResourceController()->renderProcessStartedWithHost(host); host->AddFilter(new BrowserMessageFilterQt(id, profile)); #if defined(Q_OS_MACOS) && QT_CONFIG(webengine_spellchecker) && QT_CONFIG(webengine_native_spellchecker) host->AddFilter(new SpellCheckMessageFilterPlatform(id)); @@ -562,7 +562,7 @@ std::string ContentBrowserClientQt::GetApplicationLocale() std::string ContentBrowserClientQt::GetAcceptLangs(content::BrowserContext *context) { - return static_cast<ProfileQt*>(context)->adapter()->httpAcceptLanguage().toStdString(); + return static_cast<ProfileQt*>(context)->profileAdapter()->httpAcceptLanguage().toStdString(); } void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) @@ -765,7 +765,7 @@ scoped_refptr<net::URLRequestContextGetter> GetSystemRequestContextOnUIThread() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); return scoped_refptr<net::URLRequestContextGetter>( - BrowserContextAdapter::defaultContext()->profile()->GetRequestContext()); + ProfileAdapter::defaultProfileAdapter()->profile()->GetRequestContext()); } void ContentBrowserClientQt::GetGeolocationRequestContext( diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 6c4bfc0e1..b349b0f4f 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -41,7 +41,6 @@ SOURCES = \ authentication_dialog_controller.cpp \ browser_accessibility_manager_qt.cpp \ browser_accessibility_qt.cpp \ - browser_context_adapter.cpp \ browser_context_adapter_client.cpp \ browsing_data_remover_delegate_qt.cpp \ browser_message_filter_qt.cpp \ @@ -93,6 +92,7 @@ SOURCES = \ ozone/surface_factory_qt.cpp \ permission_manager_qt.cpp \ process_main.cpp \ + profile_adapter.cpp \ profile_qt.cpp \ profile_io_data_qt.cpp \ quota_permission_context_qt.cpp \ @@ -130,7 +130,6 @@ HEADERS = \ build_config_qt.h \ browser_accessibility_manager_qt.h \ browser_accessibility_qt.h \ - browser_context_adapter.h \ browser_context_adapter_client.h \ browsing_data_remover_delegate_qt.h \ browser_message_filter_qt.h \ @@ -183,6 +182,7 @@ HEADERS = \ ozone/surface_factory_qt.h \ permission_manager_qt.h \ process_main.h \ + profile_adapter.h \ profile_qt.h \ profile_io_data_qt.h \ proxy_config_service_qt.h \ diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp index 02473079f..154b275b5 100644 --- a/src/core/devtools_frontend_qt.cpp +++ b/src/core/devtools_frontend_qt.cpp @@ -44,7 +44,7 @@ #include "devtools_frontend_qt.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "profile_qt.h" #include "web_contents_adapter.h" @@ -209,7 +209,7 @@ DevToolsFrontendQt::DevToolsFrontendQt(QSharedPointer<WebContentsAdapter> webCon { // We use a separate prefstore than one in ProfileQt, because that one is in-memory only, and this // needs to be stored or it will show introduction text on every load. - if (webContentsAdapter->browserContextAdapter()->isOffTheRecord()) + if (webContentsAdapter->profileAdapter()->isOffTheRecord()) m_prefStore = std::move(scoped_refptr<PersistentPrefStore>(new InMemoryPrefStore())); else CreateJsonPreferences(false); diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 0a40d4284..720f88d1f 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -53,7 +53,7 @@ #include <QStandardPaths> #include "browser_context_adapter_client.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "profile_qt.h" #include "qtwebenginecoreglobal.h" #include "type_conversion.h" @@ -61,13 +61,13 @@ namespace QtWebEngineCore { -DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *contextAdapter) - : m_contextAdapter(contextAdapter) +DownloadManagerDelegateQt::DownloadManagerDelegateQt(ProfileAdapter *profileAdapter) + : m_profileAdapter(profileAdapter) , m_currentId(0) , m_weakPtrFactory(this) , m_nextDownloadIsUserRequested(false) { - Q_ASSERT(m_contextAdapter); + Q_ASSERT(m_profileAdapter); } DownloadManagerDelegateQt::~DownloadManagerDelegateQt() @@ -86,7 +86,7 @@ void DownloadManagerDelegateQt::cancelDownload(const content::DownloadTargetCall void DownloadManagerDelegateQt::cancelDownload(quint32 downloadId) { - content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->profile()); + content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_profileAdapter->profile()); download::DownloadItem *download = dlm->GetDownload(downloadId); if (download) download->Cancel(/* user_cancel */ true); @@ -94,7 +94,7 @@ void DownloadManagerDelegateQt::cancelDownload(quint32 downloadId) void DownloadManagerDelegateQt::pauseDownload(quint32 downloadId) { - content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->profile()); + content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_profileAdapter->profile()); download::DownloadItem *download = dlm->GetDownload(downloadId); if (download) download->Pause(); @@ -102,7 +102,7 @@ void DownloadManagerDelegateQt::pauseDownload(quint32 downloadId) void DownloadManagerDelegateQt::resumeDownload(quint32 downloadId) { - content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_contextAdapter->profile()); + content::DownloadManager* dlm = content::BrowserContext::GetDownloadManager(m_profileAdapter->profile()); download::DownloadItem *download = dlm->GetDownload(downloadId); if (download) download->Resume(); @@ -166,7 +166,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem* } item->AddObserver(this); - QList<BrowserContextAdapterClient*> clients = m_contextAdapter->clients(); + QList<BrowserContextAdapterClient*> clients = m_profileAdapter->clients(); if (!clients.isEmpty()) { BrowserContextAdapterClient::DownloadItemInfo info = { item->GetId(), @@ -234,7 +234,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content Q_UNUSED(default_extension); Q_UNUSED(can_save_as_complete); - QList<BrowserContextAdapterClient*> clients = m_contextAdapter->clients(); + QList<BrowserContextAdapterClient*> clients = m_profileAdapter->clients(); if (clients.isEmpty()) return; @@ -321,7 +321,7 @@ void DownloadManagerDelegateQt::savePackageDownloadCreated(download::DownloadIte void DownloadManagerDelegateQt::OnDownloadUpdated(download::DownloadItem *download) { - QList<BrowserContextAdapterClient*> clients = m_contextAdapter->clients(); + QList<BrowserContextAdapterClient*> clients = m_profileAdapter->clients(); if (!clients.isEmpty()) { BrowserContextAdapterClient::DownloadItemInfo info = { download->GetId(), diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h index 57fd5389b..fa5bd12ec 100644 --- a/src/core/download_manager_delegate_qt.h +++ b/src/core/download_manager_delegate_qt.h @@ -59,7 +59,7 @@ class DownloadItem; } namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; class DownloadManagerDelegateInstance; class DownloadTargetHelper; @@ -68,7 +68,7 @@ class DownloadManagerDelegateQt , public download::DownloadItem::Observer { public: - DownloadManagerDelegateQt(BrowserContextAdapter *contextAdapter); + DownloadManagerDelegateQt(ProfileAdapter *profileAdapter); ~DownloadManagerDelegateQt(); void GetNextId(const content::DownloadIdCallback& callback) override; @@ -100,7 +100,7 @@ public: private: void cancelDownload(const content::DownloadTargetCallback& callback); void savePackageDownloadCreated(download::DownloadItem *download); - BrowserContextAdapter *m_contextAdapter; + ProfileAdapter *m_profileAdapter; uint64_t m_currentId; base::WeakPtrFactory<DownloadManagerDelegateQt> m_weakPtrFactory; diff --git a/src/core/net/custom_protocol_handler.cpp b/src/core/net/custom_protocol_handler.cpp index 3620bc10c..5132782c2 100644 --- a/src/core/net/custom_protocol_handler.cpp +++ b/src/core/net/custom_protocol_handler.cpp @@ -46,8 +46,8 @@ namespace QtWebEngineCore { -CustomProtocolHandler::CustomProtocolHandler(QPointer<BrowserContextAdapter> adapter) - : m_adapter(adapter) +CustomProtocolHandler::CustomProtocolHandler(QPointer<ProfileAdapter> profileAdapter) + : m_profileAdapter(profileAdapter) { } @@ -56,7 +56,7 @@ net::URLRequestJob *CustomProtocolHandler::MaybeCreateJob(net::URLRequest *reque if (!networkDelegate) return new net::URLRequestErrorJob(request, Q_NULLPTR, net::ERR_ACCESS_DENIED); - return new URLRequestCustomJob(request, networkDelegate, request->url().scheme(), m_adapter); + return new URLRequestCustomJob(request, networkDelegate, request->url().scheme(), m_profileAdapter); } } // namespace diff --git a/src/core/net/custom_protocol_handler.h b/src/core/net/custom_protocol_handler.h index 3869af143..d5b512b03 100644 --- a/src/core/net/custom_protocol_handler.h +++ b/src/core/net/custom_protocol_handler.h @@ -67,20 +67,20 @@ class URLRequestJob; namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; // Implements a ProtocolHandler for custom URL schemes. // If |network_delegate_| is NULL then all file requests will fail with ERR_ACCESS_DENIED. class QWEBENGINECORE_PRIVATE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: - CustomProtocolHandler(QPointer<BrowserContextAdapter> adapter); + CustomProtocolHandler(QPointer<ProfileAdapter> profileAdapter); net::URLRequestJob *MaybeCreateJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate) const override; private: DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler); - QPointer<BrowserContextAdapter> m_adapter; + QPointer<ProfileAdapter> m_profileAdapter; }; } // namespace diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp index a67baf96f..580f202e5 100644 --- a/src/core/net/network_delegate_qt.cpp +++ b/src/core/net/network_delegate_qt.cpp @@ -39,7 +39,7 @@ #include "network_delegate_qt.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_request_info.h" diff --git a/src/core/net/ssl_host_state_delegate_qt.h b/src/core/net/ssl_host_state_delegate_qt.h index 3ebabb601..aeccb42fd 100644 --- a/src/core/net/ssl_host_state_delegate_qt.h +++ b/src/core/net/ssl_host_state_delegate_qt.h @@ -41,7 +41,7 @@ #define SSL_HOST_STATE_DELEGATE_QT_H #include "content/public/browser/ssl_host_state_delegate.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" namespace QtWebEngineCore { diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index d9337687b..c69fb1808 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -51,9 +51,9 @@ namespace QtWebEngineCore { URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate, const std::string &scheme, - QPointer<BrowserContextAdapter> adapter) + QPointer<ProfileAdapter> profileAdapter) : URLRequestJob(request, networkDelegate) - , m_proxy(new URLRequestCustomJobProxy(this, scheme, adapter)) + , m_proxy(new URLRequestCustomJobProxy(this, scheme, profileAdapter)) , m_device(nullptr) , m_error(0) , m_pendingReadSize(0) diff --git a/src/core/net/url_request_custom_job.h b/src/core/net/url_request_custom_job.h index 71c8d2613..cc997fc66 100644 --- a/src/core/net/url_request_custom_job.h +++ b/src/core/net/url_request_custom_job.h @@ -48,7 +48,7 @@ QT_FORWARD_DECLARE_CLASS(QIODevice) namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; class URLRequestCustomJobDelegate; class URLRequestCustomJobProxy; @@ -58,7 +58,7 @@ public: URLRequestCustomJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate, const std::string &scheme, - QPointer<BrowserContextAdapter> adapter); + QPointer<ProfileAdapter> profileAdapter); void Start() override; void Kill() override; int ReadRawData(net::IOBuffer *buf, int buf_size) override; diff --git a/src/core/net/url_request_custom_job_proxy.cpp b/src/core/net/url_request_custom_job_proxy.cpp index 38fbd7670..5280318ad 100644 --- a/src/core/net/url_request_custom_job_proxy.cpp +++ b/src/core/net/url_request_custom_job_proxy.cpp @@ -41,7 +41,7 @@ #include "url_request_custom_job.h" #include "url_request_custom_job_delegate.h" #include "api/qwebengineurlrequestjob.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "type_conversion.h" #include "content/public/browser/browser_thread.h" #include "web_engine_context.h" @@ -52,12 +52,12 @@ namespace QtWebEngineCore { URLRequestCustomJobProxy::URLRequestCustomJobProxy(URLRequestCustomJob *job, const std::string &scheme, - QPointer<BrowserContextAdapter> adapter) + QPointer<ProfileAdapter> profileAdapter) : m_job(job) , m_started(false) , m_scheme(scheme) , m_delegate(nullptr) - , m_adapter(adapter) + , m_profileAdapter(profileAdapter) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); } @@ -163,8 +163,8 @@ void URLRequestCustomJobProxy::initialize(GURL url, std::string method, base::Op QWebEngineUrlSchemeHandler *schemeHandler = nullptr; - if (m_adapter) - schemeHandler = m_adapter->customUrlSchemeHandlers()[toQByteArray(m_scheme)]; + if (m_profileAdapter) + schemeHandler = m_profileAdapter->customUrlSchemeHandlers()[toQByteArray(m_scheme)]; if (schemeHandler) { m_delegate = new URLRequestCustomJobDelegate(this, toQt(url), diff --git a/src/core/net/url_request_custom_job_proxy.h b/src/core/net/url_request_custom_job_proxy.h index 34d526348..3986fe119 100644 --- a/src/core/net/url_request_custom_job_proxy.h +++ b/src/core/net/url_request_custom_job_proxy.h @@ -52,7 +52,7 @@ namespace QtWebEngineCore { class URLRequestCustomJob; class URLRequestCustomJobDelegate; -class BrowserContextAdapter; +class ProfileAdapter; // Used to comunicate between URLRequestCustomJob living on the IO thread // and URLRequestCustomJobDelegate living on the UI thread. @@ -62,7 +62,7 @@ class URLRequestCustomJobProxy public: URLRequestCustomJobProxy(URLRequestCustomJob *job, const std::string &scheme, - QPointer<BrowserContextAdapter> adapter); + QPointer<ProfileAdapter> profileAdapter); ~URLRequestCustomJobProxy(); // Called from URLRequestCustomJobDelegate via post: @@ -82,7 +82,7 @@ public: // UI thread owned: std::string m_scheme; URLRequestCustomJobDelegate *m_delegate; - QPointer<BrowserContextAdapter> m_adapter; + QPointer<ProfileAdapter> m_profileAdapter; }; } // namespace QtWebEngineCore diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index b0614ada4..65a806452 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -50,15 +50,15 @@ namespace QtWebEngineCore { -BrowserContextAdapter::PermissionType toQt(content::PermissionType type) +ProfileAdapter::PermissionType toQt(content::PermissionType type) { switch (type) { case content::PermissionType::GEOLOCATION: - return BrowserContextAdapter::GeolocationPermission; + return ProfileAdapter::GeolocationPermission; case content::PermissionType::AUDIO_CAPTURE: - return BrowserContextAdapter::AudioCapturePermission; + return ProfileAdapter::AudioCapturePermission; case content::PermissionType::VIDEO_CAPTURE: - return BrowserContextAdapter::VideoCapturePermission; + return ProfileAdapter::VideoCapturePermission; case content::PermissionType::FLASH: case content::PermissionType::NOTIFICATIONS: case content::PermissionType::MIDI_SYSEX: @@ -74,7 +74,7 @@ BrowserContextAdapter::PermissionType toQt(content::PermissionType type) case content::PermissionType::NUM: break; } - return BrowserContextAdapter::UnsupportedPermission; + return ProfileAdapter::UnsupportedPermission; } PermissionManagerQt::PermissionManagerQt() @@ -87,9 +87,9 @@ PermissionManagerQt::~PermissionManagerQt() { } -void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserContextAdapter::PermissionType type, bool reply) +void PermissionManagerQt::permissionRequestReply(const QUrl &origin, ProfileAdapter::PermissionType type, bool reply) { - QPair<QUrl, BrowserContextAdapter::PermissionType> key(origin, type); + QPair<QUrl, ProfileAdapter::PermissionType> key(origin, type); m_permissions[key] = reply; blink::mojom::PermissionStatus status = reply ? blink::mojom::PermissionStatus::GRANTED : blink::mojom::PermissionStatus::DENIED; { @@ -114,13 +114,13 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont std::vector<blink::mojom::PermissionStatus> result; result.reserve(it->types.size()); for (content::PermissionType permission : it->types) { - const BrowserContextAdapter::PermissionType permissionType = toQt(permission); - if (permissionType == BrowserContextAdapter::UnsupportedPermission) { + const ProfileAdapter::PermissionType permissionType = toQt(permission); + if (permissionType == ProfileAdapter::UnsupportedPermission) { result.push_back(blink::mojom::PermissionStatus::DENIED); continue; } - QPair<QUrl, BrowserContextAdapter::PermissionType> key(origin, permissionType); + QPair<QUrl, ProfileAdapter::PermissionType> key(origin, permissionType); if (!m_permissions.contains(key)) { answerable = false; break; @@ -140,9 +140,9 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont } } -bool PermissionManagerQt::checkPermission(const QUrl &origin, BrowserContextAdapter::PermissionType type) +bool PermissionManagerQt::checkPermission(const QUrl &origin, ProfileAdapter::PermissionType type) { - QPair<QUrl, BrowserContextAdapter::PermissionType> key(origin, type); + QPair<QUrl, ProfileAdapter::PermissionType> key(origin, type); return m_permissions.contains(key) && m_permissions[key]; } @@ -153,14 +153,14 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission, const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { int request_id = ++m_requestIdCount; - BrowserContextAdapter::PermissionType permissionType = toQt(permission); - if (permissionType == BrowserContextAdapter::UnsupportedPermission) { + ProfileAdapter::PermissionType permissionType = toQt(permission); + if (permissionType == ProfileAdapter::UnsupportedPermission) { callback.Run(blink::mojom::PermissionStatus::DENIED); return kNoPendingOperation; } // Audio and video-capture should not come this way currently - Q_ASSERT(permissionType != BrowserContextAdapter::AudioCapturePermission - && permissionType != BrowserContextAdapter::VideoCapturePermission); + Q_ASSERT(permissionType != ProfileAdapter::AudioCapturePermission + && permissionType != ProfileAdapter::VideoCapturePermission); content::WebContents *webContents = frameHost->GetRenderViewHost()->GetDelegate()->GetAsWebContents(); WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); @@ -171,7 +171,7 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission, callback }; m_requests.insert(request_id, request); - if (permissionType == BrowserContextAdapter::GeolocationPermission) + if (permissionType == ProfileAdapter::GeolocationPermission) contentsDelegate->requestGeolocationPermission(request.origin); return request_id; } @@ -186,8 +186,8 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio std::vector<blink::mojom::PermissionStatus> result; result.reserve(permissions.size()); for (content::PermissionType permission : permissions) { - const BrowserContextAdapter::PermissionType permissionType = toQt(permission); - if (permissionType == BrowserContextAdapter::UnsupportedPermission) + const ProfileAdapter::PermissionType permissionType = toQt(permission); + if (permissionType == ProfileAdapter::UnsupportedPermission) result.push_back(blink::mojom::PermissionStatus::DENIED); else { answerable = false; @@ -210,8 +210,8 @@ int PermissionManagerQt::RequestPermissions(const std::vector<content::Permissio }; m_multiRequests.insert(request_id, request); for (content::PermissionType permission : permissions) { - const BrowserContextAdapter::PermissionType permissionType = toQt(permission); - if (permissionType == BrowserContextAdapter::GeolocationPermission) + const ProfileAdapter::PermissionType permissionType = toQt(permission); + if (permissionType == ProfileAdapter::GeolocationPermission) contentsDelegate->requestGeolocationPermission(request.origin); } return request_id; @@ -222,11 +222,11 @@ blink::mojom::PermissionStatus PermissionManagerQt::GetPermissionStatus( const GURL& requesting_origin, const GURL& /*embedding_origin*/) { - const BrowserContextAdapter::PermissionType permissionType = toQt(permission); - if (permissionType == BrowserContextAdapter::UnsupportedPermission) + const ProfileAdapter::PermissionType permissionType = toQt(permission); + if (permissionType == ProfileAdapter::UnsupportedPermission) return blink::mojom::PermissionStatus::DENIED; - QPair<QUrl, BrowserContextAdapter::PermissionType> key(toQt(requesting_origin), permissionType); + QPair<QUrl, ProfileAdapter::PermissionType> key(toQt(requesting_origin), permissionType); if (!m_permissions.contains(key)) return blink::mojom::PermissionStatus::ASK; if (m_permissions[key]) @@ -250,11 +250,11 @@ void PermissionManagerQt::ResetPermission( const GURL& requesting_origin, const GURL& /*embedding_origin*/) { - const BrowserContextAdapter::PermissionType permissionType = toQt(permission); - if (permissionType == BrowserContextAdapter::UnsupportedPermission) + const ProfileAdapter::PermissionType permissionType = toQt(permission); + if (permissionType == ProfileAdapter::UnsupportedPermission) return; - QPair<QUrl, BrowserContextAdapter::PermissionType> key(toQt(requesting_origin), permissionType); + QPair<QUrl, ProfileAdapter::PermissionType> key(toQt(requesting_origin), permissionType); m_permissions.remove(key); } diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h index 6a4b78d7c..31fb257b6 100644 --- a/src/core/permission_manager_qt.h +++ b/src/core/permission_manager_qt.h @@ -42,7 +42,7 @@ #include "base/callback.h" #include "content/public/browser/permission_manager.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include <QHash> @@ -53,7 +53,7 @@ class PermissionManagerQt : public content::PermissionManager { public: PermissionManagerQt(); ~PermissionManagerQt(); - typedef BrowserContextAdapter::PermissionType PermissionType; + typedef ProfileAdapter::PermissionType PermissionType; void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply); bool checkPermission(const QUrl &origin, PermissionType type); diff --git a/src/core/browser_context_adapter.cpp b/src/core/profile_adapter.cpp index 7d74d06c0..aa539f857 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_thread.h" @@ -74,7 +74,7 @@ inline QString buildLocationFromStandardPath(const QString &standardPath, const namespace QtWebEngineCore { -BrowserContextAdapter::BrowserContextAdapter(const QString &storageName): +ProfileAdapter::ProfileAdapter(const QString &storageName): m_name(storageName) , m_offTheRecord(storageName.isEmpty()) , m_httpCacheType(DiskHttpCache) @@ -90,7 +90,7 @@ BrowserContextAdapter::BrowserContextAdapter(const QString &storageName): m_profile->m_profileIOData->initializeOnUIThread(); } -BrowserContextAdapter::~BrowserContextAdapter() +ProfileAdapter::~ProfileAdapter() { WebEngineContext::current()->removeBrowserContext(this); if (m_downloadManagerDelegate) { @@ -99,7 +99,7 @@ BrowserContextAdapter::~BrowserContextAdapter() } } -void BrowserContextAdapter::setStorageName(const QString &storageName) +void ProfileAdapter::setStorageName(const QString &storageName) { if (storageName == m_name) return; @@ -112,7 +112,7 @@ void BrowserContextAdapter::setStorageName(const QString &storageName) } } -void BrowserContextAdapter::setOffTheRecord(bool offTheRecord) +void ProfileAdapter::setOffTheRecord(bool offTheRecord) { if (offTheRecord == m_offTheRecord) return; @@ -123,38 +123,38 @@ void BrowserContextAdapter::setOffTheRecord(bool offTheRecord) resetVisitedLinksManager(); } -ProfileQt *BrowserContextAdapter::profile() +ProfileQt *ProfileAdapter::profile() { return m_profile.data(); } -VisitedLinksManagerQt *BrowserContextAdapter::visitedLinksManager() +VisitedLinksManagerQt *ProfileAdapter::visitedLinksManager() { if (!m_visitedLinksManager) resetVisitedLinksManager(); return m_visitedLinksManager.data(); } -DownloadManagerDelegateQt *BrowserContextAdapter::downloadManagerDelegate() +DownloadManagerDelegateQt *ProfileAdapter::downloadManagerDelegate() { if (!m_downloadManagerDelegate) m_downloadManagerDelegate.reset(new DownloadManagerDelegateQt(this)); return m_downloadManagerDelegate.data(); } -QWebEngineCookieStore *BrowserContextAdapter::cookieStore() +QWebEngineCookieStore *ProfileAdapter::cookieStore() { if (!m_cookieStore) m_cookieStore.reset(new QWebEngineCookieStore); return m_cookieStore.data(); } -QWebEngineUrlRequestInterceptor *BrowserContextAdapter::requestInterceptor() +QWebEngineUrlRequestInterceptor *ProfileAdapter::requestInterceptor() { return m_requestInterceptor.data(); } -void BrowserContextAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) +void ProfileAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { if (m_requestInterceptor == interceptor) return; @@ -163,42 +163,42 @@ void BrowserContextAdapter::setRequestInterceptor(QWebEngineUrlRequestIntercepto m_profile->m_profileIOData->updateRequestInterceptor(); } -void BrowserContextAdapter::addClient(BrowserContextAdapterClient *adapterClient) +void ProfileAdapter::addClient(BrowserContextAdapterClient *adapterClient) { m_clients.append(adapterClient); } -void BrowserContextAdapter::removeClient(BrowserContextAdapterClient *adapterClient) +void ProfileAdapter::removeClient(BrowserContextAdapterClient *adapterClient) { m_clients.removeOne(adapterClient); } -void BrowserContextAdapter::cancelDownload(quint32 downloadId) +void ProfileAdapter::cancelDownload(quint32 downloadId) { downloadManagerDelegate()->cancelDownload(downloadId); } -void BrowserContextAdapter::pauseDownload(quint32 downloadId) +void ProfileAdapter::pauseDownload(quint32 downloadId) { downloadManagerDelegate()->pauseDownload(downloadId); } -void BrowserContextAdapter::resumeDownload(quint32 downloadId) +void ProfileAdapter::resumeDownload(quint32 downloadId) { downloadManagerDelegate()->resumeDownload(downloadId); } -BrowserContextAdapter *BrowserContextAdapter::defaultContext() +ProfileAdapter *ProfileAdapter::defaultProfileAdapter() { - return WebEngineContext::current()->defaultBrowserContext(); + return WebEngineContext::current()->defaultProfileAdapter(); } -QObject* BrowserContextAdapter::globalQObjectRoot() +QObject* ProfileAdapter::globalQObjectRoot() { return WebEngineContext::current()->globalQObject(); } -QString BrowserContextAdapter::dataPath() const +QString ProfileAdapter::dataPath() const { if (m_offTheRecord) return QString(); @@ -209,7 +209,7 @@ QString BrowserContextAdapter::dataPath() const return QString(); } -void BrowserContextAdapter::setDataPath(const QString &path) +void ProfileAdapter::setDataPath(const QString &path) { if (m_dataPath == path) return; @@ -222,7 +222,7 @@ void BrowserContextAdapter::setDataPath(const QString &path) } } -QString BrowserContextAdapter::cachePath() const +QString ProfileAdapter::cachePath() const { if (m_offTheRecord) return QString(); @@ -233,7 +233,7 @@ QString BrowserContextAdapter::cachePath() const return QString(); } -void BrowserContextAdapter::setCachePath(const QString &path) +void ProfileAdapter::setCachePath(const QString &path) { if (m_cachePath == path) return; @@ -242,7 +242,7 @@ void BrowserContextAdapter::setCachePath(const QString &path) m_profile->m_profileIOData->updateHttpCache(); } -QString BrowserContextAdapter::cookiesPath() const +QString ProfileAdapter::cookiesPath() const { if (m_offTheRecord) return QString(); @@ -257,7 +257,7 @@ QString BrowserContextAdapter::cookiesPath() const return QString(); } -QString BrowserContextAdapter::channelIdPath() const +QString ProfileAdapter::channelIdPath() const { if (m_offTheRecord) return QString(); @@ -267,7 +267,7 @@ QString BrowserContextAdapter::channelIdPath() const return QString(); } -QString BrowserContextAdapter::httpCachePath() const +QString ProfileAdapter::httpCachePath() const { if (m_offTheRecord) return QString(); @@ -277,14 +277,14 @@ QString BrowserContextAdapter::httpCachePath() const return QString(); } -QString BrowserContextAdapter::httpUserAgent() const +QString ProfileAdapter::httpUserAgent() const { if (m_httpUserAgent.isNull()) return QString::fromStdString(ContentClientQt::getUserAgent()); return m_httpUserAgent; } -void BrowserContextAdapter::setHttpUserAgent(const QString &userAgent) +void ProfileAdapter::setHttpUserAgent(const QString &userAgent) { if (m_httpUserAgent == userAgent) return; @@ -299,7 +299,7 @@ void BrowserContextAdapter::setHttpUserAgent(const QString &userAgent) m_profile->m_profileIOData->updateUserAgent(); } -BrowserContextAdapter::HttpCacheType BrowserContextAdapter::httpCacheType() const +ProfileAdapter::HttpCacheType ProfileAdapter::httpCacheType() const { if (m_httpCacheType == NoCache) return NoCache; @@ -308,9 +308,9 @@ BrowserContextAdapter::HttpCacheType BrowserContextAdapter::httpCacheType() cons return m_httpCacheType; } -void BrowserContextAdapter::setHttpCacheType(BrowserContextAdapter::HttpCacheType newhttpCacheType) +void ProfileAdapter::setHttpCacheType(ProfileAdapter::HttpCacheType newhttpCacheType) { - BrowserContextAdapter::HttpCacheType oldCacheType = httpCacheType(); + ProfileAdapter::HttpCacheType oldCacheType = httpCacheType(); m_httpCacheType = newhttpCacheType; if (oldCacheType == httpCacheType()) return; @@ -318,16 +318,16 @@ void BrowserContextAdapter::setHttpCacheType(BrowserContextAdapter::HttpCacheTyp m_profile->m_profileIOData->updateHttpCache(); } -BrowserContextAdapter::PersistentCookiesPolicy BrowserContextAdapter::persistentCookiesPolicy() const +ProfileAdapter::PersistentCookiesPolicy ProfileAdapter::persistentCookiesPolicy() const { if (isOffTheRecord() || cookiesPath().isEmpty()) return NoPersistentCookies; return m_persistentCookiesPolicy; } -void BrowserContextAdapter::setPersistentCookiesPolicy(BrowserContextAdapter::PersistentCookiesPolicy newPersistentCookiesPolicy) +void ProfileAdapter::setPersistentCookiesPolicy(ProfileAdapter::PersistentCookiesPolicy newPersistentCookiesPolicy) { - BrowserContextAdapter::PersistentCookiesPolicy oldPolicy = persistentCookiesPolicy(); + ProfileAdapter::PersistentCookiesPolicy oldPolicy = persistentCookiesPolicy(); m_persistentCookiesPolicy = newPersistentCookiesPolicy; if (oldPolicy == persistentCookiesPolicy()) return; @@ -335,7 +335,7 @@ void BrowserContextAdapter::setPersistentCookiesPolicy(BrowserContextAdapter::Pe m_profile->m_profileIOData->updateCookieStore(); } -BrowserContextAdapter::VisitedLinksPolicy BrowserContextAdapter::visitedLinksPolicy() const +ProfileAdapter::VisitedLinksPolicy ProfileAdapter::visitedLinksPolicy() const { if (isOffTheRecord() || m_visitedLinksPolicy == DoNotTrackVisitedLinks) return DoNotTrackVisitedLinks; @@ -344,7 +344,7 @@ BrowserContextAdapter::VisitedLinksPolicy BrowserContextAdapter::visitedLinksPol return m_visitedLinksPolicy; } -bool BrowserContextAdapter::trackVisitedLinks() const +bool ProfileAdapter::trackVisitedLinks() const { switch (visitedLinksPolicy()) { case DoNotTrackVisitedLinks: @@ -355,7 +355,7 @@ bool BrowserContextAdapter::trackVisitedLinks() const return true; } -bool BrowserContextAdapter::persistVisitedLinks() const +bool ProfileAdapter::persistVisitedLinks() const { switch (visitedLinksPolicy()) { case DoNotTrackVisitedLinks: @@ -367,7 +367,7 @@ bool BrowserContextAdapter::persistVisitedLinks() const return true; } -void BrowserContextAdapter::setVisitedLinksPolicy(BrowserContextAdapter::VisitedLinksPolicy visitedLinksPolicy) +void ProfileAdapter::setVisitedLinksPolicy(ProfileAdapter::VisitedLinksPolicy visitedLinksPolicy) { if (m_visitedLinksPolicy == visitedLinksPolicy) return; @@ -376,12 +376,12 @@ void BrowserContextAdapter::setVisitedLinksPolicy(BrowserContextAdapter::Visited resetVisitedLinksManager(); } -int BrowserContextAdapter::httpCacheMaxSize() const +int ProfileAdapter::httpCacheMaxSize() const { return m_httpCacheMaxSize; } -void BrowserContextAdapter::setHttpCacheMaxSize(int maxSize) +void ProfileAdapter::setHttpCacheMaxSize(int maxSize) { if (m_httpCacheMaxSize == maxSize) return; @@ -390,23 +390,23 @@ void BrowserContextAdapter::setHttpCacheMaxSize(int maxSize) m_profile->m_profileIOData->updateHttpCache(); } -const QHash<QByteArray, QWebEngineUrlSchemeHandler *> &BrowserContextAdapter::customUrlSchemeHandlers() const +const QHash<QByteArray, QWebEngineUrlSchemeHandler *> &ProfileAdapter::customUrlSchemeHandlers() const { return m_customUrlSchemeHandlers; } -const QList<QByteArray> BrowserContextAdapter::customUrlSchemes() const +const QList<QByteArray> ProfileAdapter::customUrlSchemes() const { return m_customUrlSchemeHandlers.keys(); } -void BrowserContextAdapter::updateCustomUrlSchemeHandlers() +void ProfileAdapter::updateCustomUrlSchemeHandlers() { if (m_profile->m_urlRequestContextGetter.get()) m_profile->m_profileIOData->updateJobFactory(); } -bool BrowserContextAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) +bool ProfileAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) { bool removedOneOrMore = false; auto it = m_customUrlSchemeHandlers.begin(); @@ -423,7 +423,7 @@ bool BrowserContextAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHand return removedOneOrMore; } -QWebEngineUrlSchemeHandler *BrowserContextAdapter::takeCustomUrlSchemeHandler(const QByteArray &scheme) +QWebEngineUrlSchemeHandler *ProfileAdapter::takeCustomUrlSchemeHandler(const QByteArray &scheme) { QWebEngineUrlSchemeHandler *handler = m_customUrlSchemeHandlers.take(scheme); if (handler) @@ -431,36 +431,36 @@ QWebEngineUrlSchemeHandler *BrowserContextAdapter::takeCustomUrlSchemeHandler(co return handler; } -void BrowserContextAdapter::addCustomUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler) +void ProfileAdapter::addCustomUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler) { m_customUrlSchemeHandlers.insert(scheme, handler); updateCustomUrlSchemeHandlers(); } -void BrowserContextAdapter::clearCustomUrlSchemeHandlers() +void ProfileAdapter::clearCustomUrlSchemeHandlers() { m_customUrlSchemeHandlers.clear(); updateCustomUrlSchemeHandlers(); } -UserResourceControllerHost *BrowserContextAdapter::userResourceController() +UserResourceControllerHost *ProfileAdapter::userResourceController() { if (!m_userResourceController) m_userResourceController.reset(new UserResourceControllerHost); return m_userResourceController.data(); } -void BrowserContextAdapter::permissionRequestReply(const QUrl &origin, PermissionType type, bool reply) +void ProfileAdapter::permissionRequestReply(const QUrl &origin, PermissionType type, bool reply) { static_cast<PermissionManagerQt*>(profile()->GetPermissionManager())->permissionRequestReply(origin, type, reply); } -bool BrowserContextAdapter::checkPermission(const QUrl &origin, PermissionType type) +bool ProfileAdapter::checkPermission(const QUrl &origin, PermissionType type) { return static_cast<PermissionManagerQt*>(profile()->GetPermissionManager())->checkPermission(origin, type); } -QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const +QString ProfileAdapter::httpAcceptLanguageWithoutQualities() const { const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(',')); QString out; @@ -472,12 +472,12 @@ QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const return out; } -QString BrowserContextAdapter::httpAcceptLanguage() const +QString ProfileAdapter::httpAcceptLanguage() const { return m_httpAcceptLanguage; } -void BrowserContextAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage) +void ProfileAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage) { if (m_httpAcceptLanguage == httpAcceptLanguage) return; @@ -496,7 +496,7 @@ void BrowserContextAdapter::setHttpAcceptLanguage(const QString &httpAcceptLangu m_profile->m_profileIOData->updateUserAgent(); } -void BrowserContextAdapter::clearHttpCache() +void ProfileAdapter::clearHttpCache() { content::BrowsingDataRemover *remover = content::BrowserContext::GetBrowsingDataRemover(m_profile.data()); remover->Remove(base::Time(), base::Time::Max(), @@ -504,14 +504,14 @@ void BrowserContextAdapter::clearHttpCache() content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB); } -void BrowserContextAdapter::setSpellCheckLanguages(const QStringList &languages) +void ProfileAdapter::setSpellCheckLanguages(const QStringList &languages) { #if QT_CONFIG(webengine_spellchecker) m_profile->setSpellCheckLanguages(languages); #endif } -QStringList BrowserContextAdapter::spellCheckLanguages() const +QStringList ProfileAdapter::spellCheckLanguages() const { #if QT_CONFIG(webengine_spellchecker) return m_profile->spellCheckLanguages(); @@ -520,14 +520,14 @@ QStringList BrowserContextAdapter::spellCheckLanguages() const #endif } -void BrowserContextAdapter::setSpellCheckEnabled(bool enabled) +void ProfileAdapter::setSpellCheckEnabled(bool enabled) { #if QT_CONFIG(webengine_spellchecker) m_profile->setSpellCheckEnabled(enabled); #endif } -bool BrowserContextAdapter::isSpellCheckEnabled() const +bool ProfileAdapter::isSpellCheckEnabled() const { #if QT_CONFIG(webengine_spellchecker) return m_profile->isSpellCheckEnabled(); @@ -536,7 +536,7 @@ bool BrowserContextAdapter::isSpellCheckEnabled() const #endif } -void BrowserContextAdapter::resetVisitedLinksManager() +void ProfileAdapter::resetVisitedLinksManager() { m_visitedLinksManager.reset(new VisitedLinksManagerQt(this)); } diff --git a/src/core/browser_context_adapter.h b/src/core/profile_adapter.h index da9f37645..64d73bd34 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/profile_adapter.h @@ -48,8 +48,8 @@ // We mean it. // -#ifndef BROWSER_CONTEXT_ADAPTER_H -#define BROWSER_CONTEXT_ADAPTER_H +#ifndef PROFILE_ADAPTER_H +#define PROFILE_ADAPTER_H #include "qtwebenginecoreglobal_p.h" @@ -74,13 +74,13 @@ class ProfileQt; class UserResourceControllerHost; class VisitedLinksManagerQt; -class QWEBENGINECORE_PRIVATE_EXPORT BrowserContextAdapter : public QObject +class QWEBENGINECORE_PRIVATE_EXPORT ProfileAdapter : public QObject { public: - explicit BrowserContextAdapter(const QString &storagePrefix = QString()); - virtual ~BrowserContextAdapter(); + explicit ProfileAdapter(const QString &storagePrefix = QString()); + virtual ~ProfileAdapter(); - static BrowserContextAdapter* defaultContext(); + static ProfileAdapter* defaultProfileAdapter(); static QObject* globalQObjectRoot(); VisitedLinksManagerQt *visitedLinksManager(); @@ -154,13 +154,13 @@ public: }; HttpCacheType httpCacheType() const; - void setHttpCacheType(BrowserContextAdapter::HttpCacheType); + void setHttpCacheType(ProfileAdapter::HttpCacheType); PersistentCookiesPolicy persistentCookiesPolicy() const; - void setPersistentCookiesPolicy(BrowserContextAdapter::PersistentCookiesPolicy); + void setPersistentCookiesPolicy(ProfileAdapter::PersistentCookiesPolicy); VisitedLinksPolicy visitedLinksPolicy() const; - void setVisitedLinksPolicy(BrowserContextAdapter::VisitedLinksPolicy); + void setVisitedLinksPolicy(ProfileAdapter::VisitedLinksPolicy); int httpCacheMaxSize() const; void setHttpCacheMaxSize(int maxSize); @@ -209,9 +209,9 @@ private: QList<BrowserContextAdapterClient*> m_clients; int m_httpCacheMaxSize; - Q_DISABLE_COPY(BrowserContextAdapter) + Q_DISABLE_COPY(ProfileAdapter) }; } // namespace QtWebEngineCore -#endif // BROWSER_CONTEXT_ADAPTER_H +#endif // PROFILE_ADAPTER_H diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index 3ed4f2650..a011c2b81 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -207,7 +207,7 @@ void ProfileIODataQt::initializeOnIOThread() void ProfileIODataQt::initializeOnUIThread() { - m_browserContextAdapter = m_profile->adapter(); + m_profileAdapter = m_profile->profileAdapter(); DCHECK_CURRENTLY_ON(content::BrowserThread::UI); m_resourceContext.reset(new ResourceContextQt(this)); ProtocolHandlerRegistry* protocolHandlerRegistry = @@ -216,7 +216,7 @@ void ProfileIODataQt::initializeOnUIThread() m_protocolHandlerInterceptor = protocolHandlerRegistry->CreateJobInterceptorFactory(); m_cookieDelegate = new CookieMonsterDelegateQt(); - m_cookieDelegate->setClient(m_profile->adapter()->cookieStore()); + m_cookieDelegate->setClient(m_profile->profileAdapter()->cookieStore()); } void ProfileIODataQt::cancelAllUrlRequests() @@ -320,7 +320,7 @@ void ProfileIODataQt::generateCookieStore() m_updateCookieStore = false; scoped_refptr<net::SQLiteChannelIDStore> channel_id_db; - if (!m_channelIdPath.isEmpty() && m_persistentCookiesPolicy != BrowserContextAdapter::NoPersistentCookies) { + if (!m_channelIdPath.isEmpty() && m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies) { channel_id_db = new net::SQLiteChannelIDStore( toFilePath(m_channelIdPath), base::CreateSequencedTaskRunnerWithTraits( @@ -338,7 +338,7 @@ void ProfileIODataQt::generateCookieStore() std::unique_ptr<net::CookieStore> cookieStore; switch (m_persistentCookiesPolicy) { - case BrowserContextAdapter::NoPersistentCookies: + case ProfileAdapter::NoPersistentCookies: cookieStore = content::CreateCookieStore( content::CookieStoreConfig( base::FilePath(), @@ -347,7 +347,7 @@ void ProfileIODataQt::generateCookieStore() nullptr) ); break; - case BrowserContextAdapter::AllowPersistentCookies: + case ProfileAdapter::AllowPersistentCookies: cookieStore = content::CreateCookieStore( content::CookieStoreConfig( toFilePath(m_cookiesPath), @@ -356,7 +356,7 @@ void ProfileIODataQt::generateCookieStore() nullptr) ); break; - case BrowserContextAdapter::ForcePersistentCookies: + case ProfileAdapter::ForcePersistentCookies: cookieStore = content::CreateCookieStore( content::CookieStoreConfig( toFilePath(m_cookiesPath), @@ -410,7 +410,7 @@ void ProfileIODataQt::generateHttpCache() net::HttpCache::DefaultBackend* main_backend = 0; switch (m_httpCacheType) { - case BrowserContextAdapter::MemoryHttpCache: + case ProfileAdapter::MemoryHttpCache: main_backend = new net::HttpCache::DefaultBackend( net::MEMORY_CACHE, @@ -419,7 +419,7 @@ void ProfileIODataQt::generateHttpCache() m_httpCacheMaxSize ); break; - case BrowserContextAdapter::DiskHttpCache: + case ProfileAdapter::DiskHttpCache: main_backend = new net::HttpCache::DefaultBackend( net::DISK_CACHE, @@ -428,7 +428,7 @@ void ProfileIODataQt::generateHttpCache() m_httpCacheMaxSize ); break; - case BrowserContextAdapter::NoCache: + case ProfileAdapter::NoCache: // It's safe to not create BackendFactory. break; } @@ -485,7 +485,7 @@ void ProfileIODataQt::generateJobFactory() for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) { jobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>( - new CustomProtocolHandler(m_browserContextAdapter))); + new CustomProtocolHandler(m_profileAdapter))); } m_baseJobFactory = jobFactory.get(); @@ -531,7 +531,7 @@ void ProfileIODataQt::regenerateJobFactory() for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) { m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>( - new CustomProtocolHandler(m_browserContextAdapter))); + new CustomProtocolHandler(m_profileAdapter))); } } @@ -547,16 +547,16 @@ void ProfileIODataQt::setRequestContextData(content::ProtocolHandlerMap *protoco void ProfileIODataQt::setFullConfiguration() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - m_requestInterceptor = m_browserContextAdapter->requestInterceptor(); - m_persistentCookiesPolicy = m_browserContextAdapter->persistentCookiesPolicy(); - m_cookiesPath = m_browserContextAdapter->cookiesPath(); - m_channelIdPath = m_browserContextAdapter->channelIdPath(); - m_httpAcceptLanguage = m_browserContextAdapter->httpAcceptLanguage(); - m_httpUserAgent = m_browserContextAdapter->httpUserAgent(); - m_httpCacheType = m_browserContextAdapter->httpCacheType(); - m_httpCachePath = m_browserContextAdapter->httpCachePath(); - m_httpCacheMaxSize = m_browserContextAdapter->httpCacheMaxSize(); - m_customUrlSchemes = m_browserContextAdapter->customUrlSchemes(); + m_requestInterceptor = m_profileAdapter->requestInterceptor(); + m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy(); + m_cookiesPath = m_profileAdapter->cookiesPath(); + m_channelIdPath = m_profileAdapter->channelIdPath(); + 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(); } void ProfileIODataQt::updateStorageSettings() @@ -588,9 +588,9 @@ void ProfileIODataQt::updateCookieStore() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_persistentCookiesPolicy = m_browserContextAdapter->persistentCookiesPolicy(); - m_cookiesPath = m_browserContextAdapter->cookiesPath(); - m_channelIdPath = m_browserContextAdapter->channelIdPath(); + m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy(); + m_cookiesPath = m_profileAdapter->cookiesPath(); + m_channelIdPath = m_profileAdapter->channelIdPath(); if (m_initialized && !m_updateAllStorage && !m_updateCookieStore) { m_updateCookieStore = true; @@ -604,8 +604,8 @@ void ProfileIODataQt::updateUserAgent() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_httpAcceptLanguage = m_browserContextAdapter->httpAcceptLanguage(); - m_httpUserAgent = m_browserContextAdapter->httpUserAgent(); + m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage(); + m_httpUserAgent = m_profileAdapter->httpUserAgent(); if (m_initialized && !m_updateAllStorage && !m_updateUserAgent) { m_updateUserAgent = true; @@ -618,13 +618,13 @@ void ProfileIODataQt::updateHttpCache() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_httpCacheType = m_browserContextAdapter->httpCacheType(); - m_httpCachePath = m_browserContextAdapter->httpCachePath(); - m_httpCacheMaxSize = m_browserContextAdapter->httpCacheMaxSize(); + m_httpCacheType = m_profileAdapter->httpCacheType(); + m_httpCachePath = m_profileAdapter->httpCachePath(); + m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize(); - if (m_httpCacheType == BrowserContextAdapter::NoCache) { + if (m_httpCacheType == ProfileAdapter::NoCache) { content::BrowsingDataRemover *remover = - content::BrowserContext::GetBrowsingDataRemover(m_browserContextAdapter->profile()); + content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile()); remover->Remove(base::Time(), base::Time::Max(), content::BrowsingDataRemover::DATA_TYPE_CACHE, content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | @@ -643,7 +643,7 @@ void ProfileIODataQt::updateJobFactory() Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_customUrlSchemes = m_browserContextAdapter->customUrlSchemes(); + m_customUrlSchemes = m_profileAdapter->customUrlSchemes(); if (m_initialized && !m_updateJobFactory) { m_updateJobFactory = true; @@ -656,7 +656,7 @@ void ProfileIODataQt::updateRequestInterceptor() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_requestInterceptor = m_browserContextAdapter->requestInterceptor(); + m_requestInterceptor = m_profileAdapter->requestInterceptor(); // We in this case do not need to regenerate any Chromium classes. } } // namespace QtWebEngineCore diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index c11227423..db0ec0146 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -40,8 +40,7 @@ #ifndef PROFILE_IO_DATA_QT_H #define PROFILE_IO_DATA_QT_H -#include "browser_context_adapter.h" - +#include "profile_adapter.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h" @@ -118,13 +117,13 @@ private: proxy_resolver::mojom::ProxyResolverFactoryPtr m_proxyResolverFactory; net::URLRequestJobFactoryImpl *m_baseJobFactory = nullptr; QAtomicPointer<net::ProxyConfigService> m_proxyConfigService; - QPointer<BrowserContextAdapter> m_browserContextAdapter; // never dereferenced in IO thread and it is passed by qpointer - BrowserContextAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy; + QPointer<ProfileAdapter> m_profileAdapter; // never dereferenced in IO thread and it is passed by qpointer + ProfileAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy; QString m_cookiesPath; QString m_channelIdPath; QString m_httpAcceptLanguage; QString m_httpUserAgent; - BrowserContextAdapter::HttpCacheType m_httpCacheType; + ProfileAdapter::HttpCacheType m_httpCacheType; QString m_httpCachePath; QList<QByteArray> m_customUrlSchemes; QList<QByteArray> m_installedCustomSchemes; diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp index a499e0849..f14782cfe 100644 --- a/src/core/profile_qt.cpp +++ b/src/core/profile_qt.cpp @@ -39,7 +39,7 @@ #include "profile_qt.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "browsing_data_remover_delegate_qt.h" #include "download_manager_delegate_qt.h" #include "net/ssl_host_state_delegate_qt.h" @@ -70,9 +70,9 @@ namespace QtWebEngineCore { -ProfileQt::ProfileQt(BrowserContextAdapter *adapter) +ProfileQt::ProfileQt(ProfileAdapter *profileAdapter) : m_profileIOData(new ProfileIODataQt(this)), - m_adapter(adapter) + m_profileAdapter(profileAdapter) { PrefServiceFactory factory; factory.set_user_prefs(new InMemoryPrefStore); @@ -120,12 +120,12 @@ const PrefService* ProfileQt::GetPrefs() const base::FilePath ProfileQt::GetPath() const { - return toFilePath(m_adapter->dataPath()); + return toFilePath(m_profileAdapter->dataPath()); } bool ProfileQt::IsOffTheRecord() const { - return m_adapter->isOffTheRecord(); + return m_profileAdapter->isOffTheRecord(); } net::URLRequestContextGetter *ProfileQt::GetRequestContext() @@ -151,7 +151,7 @@ content::ResourceContext *ProfileQt::GetResourceContext() content::DownloadManagerDelegate *ProfileQt::GetDownloadManagerDelegate() { - return m_adapter->downloadManagerDelegate(); + return m_profileAdapter->downloadManagerDelegate(); } content::BrowserPluginGuestManager *ProfileQt::GetGuestManager() diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h index b8de5531c..56b52198c 100644 --- a/src/core/profile_qt.h +++ b/src/core/profile_qt.h @@ -55,14 +55,14 @@ class PrefService; namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; class PermissionManagerQt; class SSLHostStateDelegateQt; class ProfileQt : public Profile { public: - explicit ProfileQt(BrowserContextAdapter *); + explicit ProfileQt(ProfileAdapter *profileAdapter); virtual ~ProfileQt(); @@ -99,7 +99,7 @@ public: const PrefService *GetPrefs() const override; net::URLRequestContextGetter *GetRequestContext() override; - BrowserContextAdapter *adapter() { return m_adapter; } + ProfileAdapter *profileAdapter() { return m_profileAdapter; } #if QT_CONFIG(webengine_spellchecker) void FailedToLoadDictionary(const std::string &language) override; @@ -117,8 +117,8 @@ private: std::unique_ptr<SSLHostStateDelegateQt> m_sslHostStateDelegate; std::unique_ptr<PrefService> m_prefService; std::unique_ptr<ProfileIODataQt> m_profileIOData; - BrowserContextAdapter *m_adapter; - friend class BrowserContextAdapter; + ProfileAdapter *m_profileAdapter; + friend class ProfileAdapter; DISALLOW_COPY_AND_ASSIGN(ProfileQt); }; diff --git a/src/core/visited_links_manager_qt.cpp b/src/core/visited_links_manager_qt.cpp index abde6c2c3..ac27446b8 100644 --- a/src/core/visited_links_manager_qt.cpp +++ b/src/core/visited_links_manager_qt.cpp @@ -39,7 +39,7 @@ #include "visited_links_manager_qt.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "content_browser_client_qt.h" #include "profile_qt.h" #include "type_conversion.h" @@ -106,7 +106,7 @@ static void ensureDirectoryExists(const base::FilePath &path) errorstr.c_str()); } -VisitedLinksManagerQt::VisitedLinksManagerQt(BrowserContextAdapter *adapter) +VisitedLinksManagerQt::VisitedLinksManagerQt(ProfileAdapter *adapter) : m_delegate(new VisitedLinkDelegateQt) { Q_ASSERT(adapter && adapter->profile()); diff --git a/src/core/visited_links_manager_qt.h b/src/core/visited_links_manager_qt.h index ee836d118..8d9a7495b 100644 --- a/src/core/visited_links_manager_qt.h +++ b/src/core/visited_links_manager_qt.h @@ -67,14 +67,14 @@ class GURL; namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; class VisitedLinkDelegateQt; class QWEBENGINECORE_PRIVATE_EXPORT VisitedLinksManagerQt { public: virtual~VisitedLinksManagerQt(); - VisitedLinksManagerQt(BrowserContextAdapter*); + VisitedLinksManagerQt(ProfileAdapter *profileAdapter); void deleteAllVisitedLinkData(); void deleteVisitedLinkDataForUrls(const QList<QUrl> &); diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index e239e853a..047d3e0c2 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -45,7 +45,7 @@ #include "browser_accessibility_qt.h" #include "browser_context_adapter_client.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "devtools_frontend_qt.h" #include "download_manager_delegate_qt.h" #include "media_capture_devices_dispatcher.h" @@ -358,13 +358,13 @@ QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavig { int currentIndex; std::vector<std::unique_ptr<content::NavigationEntry>> entries; - deserializeNavigationHistory(input, ¤tIndex, &entries, adapterClient->browserContextAdapter()->profile()); + deserializeNavigationHistory(input, ¤tIndex, &entries, adapterClient->profileAdapter()->profile()); if (currentIndex == -1) return QSharedPointer<WebContentsAdapter>(); // Unlike WebCore, Chromium only supports Restoring to a new WebContents instance. - content::WebContents* newWebContents = createBlankWebContents(adapterClient, adapterClient->browserContextAdapter()->profile()); + content::WebContents* newWebContents = createBlankWebContents(adapterClient, adapterClient->profileAdapter()->profile()); content::NavigationController &controller = newWebContents->GetController(); controller.Restore(currentIndex, content::RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); @@ -383,7 +383,7 @@ QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavig } WebContentsAdapter::WebContentsAdapter(content::WebContents *webContents) - : m_browserContextAdapter(nullptr) + : m_profileAdapter(nullptr) , m_webContents(webContents) , m_webChannel(nullptr) , m_webChannelWorld(0) @@ -408,8 +408,8 @@ void WebContentsAdapter::setClient(WebContentsAdapterClient *adapterClient) { Q_ASSERT(!isInitialized()); m_adapterClient = adapterClient; - m_browserContextAdapter = adapterClient->browserContextAdapter(); - Q_ASSERT(m_browserContextAdapter); + m_profileAdapter = adapterClient->profileAdapter(); + Q_ASSERT(m_profileAdapter); // This might replace any adapter that has been initialized with this WebEngineSettings. adapterClient->webEngineSettings()->setWebContentsAdapter(this); @@ -427,7 +427,7 @@ void WebContentsAdapter::initialize(content::SiteInstance *site) // Create our own if a WebContents wasn't provided at construction. if (!m_webContents) { - content::WebContents::CreateParams create_params(m_browserContextAdapter->profile(), site); + content::WebContents::CreateParams create_params(m_profileAdapter->profile(), site); create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight); create_params.context = reinterpret_cast<gfx::NativeView>(m_adapterClient); m_webContents.reset(content::WebContents::Create(create_params)); @@ -438,8 +438,8 @@ void WebContentsAdapter::initialize(content::SiteInstance *site) // Qt returns a flash time (the whole cycle) in ms, chromium expects just the interval in seconds const int qtCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime(); rendererPrefs->caret_blink_interval = base::TimeDelta::FromMillisecondsD(0.5 * static_cast<double>(qtCursorFlashTime)); - rendererPrefs->user_agent_override = m_browserContextAdapter->httpUserAgent().toStdString(); - rendererPrefs->accept_languages = m_browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString(); + rendererPrefs->user_agent_override = m_profileAdapter->httpUserAgent().toStdString(); + rendererPrefs->accept_languages = m_profileAdapter->httpAcceptLanguageWithoutQualities().toStdString(); #if QT_CONFIG(webengine_webrtc) base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess(); if (commandLine->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) @@ -479,7 +479,7 @@ void WebContentsAdapter::initialize(content::SiteInstance *site) // content::NOTIFICATION_RENDERER_PROCESS_CREATED event. This event will // force to initialize visited links in VisitedLinkSlave. // It must be done before creating a RenderView. - m_browserContextAdapter->visitedLinksManager(); + m_profileAdapter->visitedLinksManager(); // Create a RenderView with the initial empty document content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); @@ -555,7 +555,7 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request) GURL gurl = toGurl(request.url()); if (!isInitialized()) { scoped_refptr<content::SiteInstance> site = - content::SiteInstance::CreateForURL(m_browserContextAdapter->profile(), gurl); + content::SiteInstance::CreateForURL(m_profileAdapter->profile(), gurl); initialize(site.get()); } @@ -887,14 +887,14 @@ qreal WebContentsAdapter::currentZoomFactor() const ProfileQt* WebContentsAdapter::profile() { - return m_browserContextAdapter ? m_browserContextAdapter->profile() : m_webContents ? + return m_profileAdapter ? m_profileAdapter->profile() : m_webContents ? static_cast<ProfileQt*>(m_webContents->GetBrowserContext()) : nullptr; } -BrowserContextAdapter* WebContentsAdapter::browserContextAdapter() +ProfileAdapter* WebContentsAdapter::profileAdapter() { - return m_browserContextAdapter ? m_browserContextAdapter : m_webContents ? - static_cast<ProfileQt*>(m_webContents->GetBrowserContext())->adapter() : nullptr; + return m_profileAdapter ? m_profileAdapter : m_webContents ? + static_cast<ProfileQt*>(m_webContents->GetBrowserContext())->profileAdapter() : nullptr; } #ifndef QT_NO_ACCESSIBILITY @@ -1008,7 +1008,7 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN CHECK_INITIALIZED(); content::BrowserContext *bctx = m_webContents->GetBrowserContext(); content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx); - DownloadManagerDelegateQt *dlmd = m_browserContextAdapter->downloadManagerDelegate(); + DownloadManagerDelegateQt *dlmd = m_profileAdapter->downloadManagerDelegate(); if (!dlm) return; @@ -1220,16 +1220,16 @@ void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin, CHECK_INITIALIZED(); // Let the permission manager remember the reply. if (flags & WebContentsAdapterClient::MediaAudioCapture) - m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::AudioCapturePermission, true); + m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::AudioCapturePermission, true); if (flags & WebContentsAdapterClient::MediaVideoCapture) - m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::VideoCapturePermission, true); + m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::VideoCapturePermission, true); MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(m_webContents.get(), securityOrigin, flags); } void WebContentsAdapter::runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed) { CHECK_INITIALIZED(); - m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::GeolocationPermission, allowed); + m_profileAdapter->permissionRequestReply(securityOrigin, ProfileAdapter::GeolocationPermission, allowed); } void WebContentsAdapter::grantMouseLockPermission(bool granted) diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index a5ed1f471..b367c9fcb 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -189,7 +189,7 @@ public: void backgroundColorChanged(); QAccessibleInterface *browserAccessible(); ProfileQt* profile(); - BrowserContextAdapter* browserContextAdapter(); + ProfileAdapter* profileAdapter(); QWebChannel *webChannel() const; void setWebChannel(QWebChannel *, uint worldId); FaviconManager *faviconManager(); @@ -226,7 +226,7 @@ private: void waitForUpdateDragActionCalled(); bool handleDropDataFileContents(const content::DropData &dropData, QMimeData *mimeData); - BrowserContextAdapter *m_browserContextAdapter; + ProfileAdapter *m_profileAdapter; std::unique_ptr<content::WebContents> m_webContents; std::unique_ptr<WebContentsDelegateQt> m_webContentsDelegate; std::unique_ptr<RenderViewObserverHostQt> m_renderViewObserverHost; diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index c539bfa66..2419a1259 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -74,7 +74,7 @@ struct DropData; namespace QtWebEngineCore { class AuthenticationDialogController; -class BrowserContextAdapter; +class ProfileAdapter; class ColorChooserController; class FilePickerController; class JavaScriptDialogController; @@ -467,7 +467,7 @@ public: virtual const QObject *holdingQObject() const = 0; virtual void setToolTip(const QString& toolTipText) = 0; - virtual BrowserContextAdapter *browserContextAdapter() = 0; + virtual ProfileAdapter *profileAdapter() = 0; virtual WebContentsAdapter* webContentsAdapter() = 0; }; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 8abe2263d..7f1604162 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -43,7 +43,7 @@ #include "web_contents_delegate_qt.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "color_chooser_controller.h" #include "color_chooser_qt.h" #include "favicon_manager.h" @@ -295,11 +295,11 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig return; if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) { - BrowserContextAdapter *browserContextAdapter = m_viewClient->browserContextAdapter(); + ProfileAdapter *profileAdapter = m_viewClient->profileAdapter(); // VisistedLinksMaster asserts !IsOffTheRecord(). - if (navigation_handle->ShouldUpdateHistory() && browserContextAdapter->trackVisitedLinks()) { + if (navigation_handle->ShouldUpdateHistory() && profileAdapter->trackVisitedLinks()) { for (const GURL &url : navigation_handle->GetRedirectChain()) - browserContextAdapter->visitedLinksManager()->addUrl(url); + profileAdapter->visitedLinksManager()->addUrl(url); } // Make sure that we don't set the findNext WebFindOptions on a new frame. @@ -628,9 +628,9 @@ bool WebContentsDelegateQt::CheckMediaAccessPermission(content::RenderFrameHost { switch (type) { case content::MEDIA_DEVICE_AUDIO_CAPTURE: - return m_viewClient->browserContextAdapter()->checkPermission(toQt(security_origin), BrowserContextAdapter::AudioCapturePermission); + return m_viewClient->profileAdapter()->checkPermission(toQt(security_origin), ProfileAdapter::AudioCapturePermission); case content::MEDIA_DEVICE_VIDEO_CAPTURE: - return m_viewClient->browserContextAdapter()->checkPermission(toQt(security_origin), BrowserContextAdapter::VideoCapturePermission); + return m_viewClient->profileAdapter()->checkPermission(toQt(security_origin), ProfileAdapter::VideoCapturePermission); default: LOG(INFO) << "WebContentsDelegateQt::CheckMediaAccessPermission: " << "Unsupported media stream type checked" << type; diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index a60454fa8..c71dde724 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -39,7 +39,7 @@ #include "web_contents_view_qt.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "content_browser_client_qt.h" #include "render_widget_host_view_qt_delegate.h" #include "type_conversion.h" @@ -205,7 +205,7 @@ void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *, const conten // must be initialized to true due to the way how the initialization sequence // in SpellCheck works ie. typing the first word triggers the creation // of the SpellcheckService. Use user preference store instead. - contextMenuData.setIsSpellCheckerEnabled(m_client->browserContextAdapter()->isSpellCheckEnabled()); + contextMenuData.setIsSpellCheckerEnabled(m_client->profileAdapter()->isSpellCheckEnabled()); #endif m_client->contextMenuRequested(contextMenuData); } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index fce5e9859..4eb689d93 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -83,7 +83,7 @@ #include "content/public/app/sandbox_helper_win.h" #endif // OS_WIN -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "content_browser_client_qt.h" #include "content_client_qt.h" #include "content_main_delegate_qt.h" @@ -185,29 +185,29 @@ bool WebEngineContext::m_destroyed = false; void WebEngineContext::destroyBrowserContext() { - if (m_defaultBrowserContext) + if (m_defaultProfileAdapter) qWarning("PostMainMessageLoopRun is done, but global profile still exists !"); } -void WebEngineContext::addBrowserContext(BrowserContextAdapter *contextAdapter) +void WebEngineContext::addBrowserContext(ProfileAdapter *profileAdapter) { - Q_ASSERT(!m_browserContextAdapters.contains(contextAdapter)); - const QString path = contextAdapter->dataPath(); + Q_ASSERT(!m_profileAdapters.contains(profileAdapter)); + const QString path = profileAdapter->dataPath(); if (!path.isEmpty()) { - for (auto browserContextAdapter : m_browserContextAdapters) { - if (browserContextAdapter->dataPath() == path) { + for (auto profileAdapter : m_profileAdapters) { + if (profileAdapter->dataPath() == path) { // QTBUG-66068 qWarning("Using the same data path for profile, may corrupt the data."); break; } } } - m_browserContextAdapters.append(contextAdapter); + m_profileAdapters.append(profileAdapter); } -void WebEngineContext::removeBrowserContext(BrowserContextAdapter *contextAdapter) +void WebEngineContext::removeBrowserContext(ProfileAdapter *profileAdapter) { - m_browserContextAdapters.removeAll(contextAdapter); + m_profileAdapters.removeAll(profileAdapter); } void WebEngineContext::destroy() @@ -220,10 +220,10 @@ void WebEngineContext::destroy() while (delegate->DoWork()) { } // Delete the global object and thus custom profiles - m_defaultBrowserContext.reset(); + m_defaultProfileAdapter.reset(); m_globalQObject.reset(); - while (m_browserContextAdapters.count()) - delete m_browserContextAdapters.first(); + while (m_profileAdapters.count()) + delete m_profileAdapters.first(); // Handle any events posted by browser-context shutdown. while (delegate->DoWork()) { } @@ -247,7 +247,7 @@ WebEngineContext::~WebEngineContext() Q_ASSERT(!m_globalQObject); Q_ASSERT(!m_devtoolsServer); Q_ASSERT(!m_browserRunner); - Q_ASSERT(m_browserContextAdapters.isEmpty()); + Q_ASSERT(m_profileAdapters.isEmpty()); } WebEngineContext *WebEngineContext::current() @@ -264,12 +264,12 @@ WebEngineContext *WebEngineContext::current() return m_handle.get(); } -BrowserContextAdapter *WebEngineContext::defaultBrowserContext() +ProfileAdapter *WebEngineContext::defaultProfileAdapter() { Q_ASSERT(!m_destroyed); - if (!m_defaultBrowserContext) - m_defaultBrowserContext.reset(new BrowserContextAdapter(QStringLiteral("Default"))); - return m_defaultBrowserContext.get(); + if (!m_defaultProfileAdapter) + m_defaultProfileAdapter.reset(new ProfileAdapter(QStringLiteral("Default"))); + return m_defaultProfileAdapter.get(); } QObject *WebEngineContext::globalQObject() diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index 0729144a0..678ad713d 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -64,7 +64,7 @@ QT_FORWARD_DECLARE_CLASS(QObject) namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; class ContentMainDelegateQt; class DevToolsServerQt; class SurfaceFactoryQt; @@ -76,20 +76,20 @@ public: static WebEngineContext *current(); static void destroyContextPostRoutine(); - BrowserContextAdapter *defaultBrowserContext(); + ProfileAdapter *defaultProfileAdapter(); QObject *globalQObject(); #if QT_CONFIG(webengine_printing_and_pdf) printing::PrintJobManager* getPrintJobManager(); #endif void destroyBrowserContext(); - void addBrowserContext(BrowserContextAdapter*); - void removeBrowserContext(BrowserContextAdapter*); + void addBrowserContext(ProfileAdapter *profileAdapter); + void removeBrowserContext(ProfileAdapter *profileAdapter); void destroy(); private: friend class base::RefCounted<WebEngineContext>; - friend class BrowserContextAdapter; + friend class ProfileAdapter; WebEngineContext(); ~WebEngineContext(); @@ -98,9 +98,9 @@ private: std::unique_ptr<content::ContentMainRunner> m_contentRunner; std::unique_ptr<content::BrowserMainRunner> m_browserRunner; std::unique_ptr<QObject> m_globalQObject; - std::unique_ptr<BrowserContextAdapter> m_defaultBrowserContext; + std::unique_ptr<ProfileAdapter> m_defaultProfileAdapter; std::unique_ptr<DevToolsServerQt> m_devtoolsServer; - QVector<BrowserContextAdapter*> m_browserContextAdapters; + QVector<ProfileAdapter*> m_profileAdapters; #if QT_CONFIG(webengine_printing_and_pdf) std::unique_ptr<printing::PrintJobManager> m_printJobManager; diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index 4f60083c8..8f903564b 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -40,7 +40,7 @@ #include "qquickwebenginedownloaditem_p.h" #include "qquickwebenginedownloaditem_p_p.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "qquickwebengineprofile_p.h" using QtWebEngineCore::BrowserContextAdapterClient; @@ -286,7 +286,7 @@ void QQuickWebEngineDownloadItem::pause() return; if (d->profile) - d->profile->d_ptr->browserContext()->pauseDownload(d->downloadId); + d->profile->d_ptr->profileAdapter()->pauseDownload(d->downloadId); } /*! @@ -310,7 +310,7 @@ void QQuickWebEngineDownloadItem::resume() return; if (d->profile) - d->profile->d_ptr->browserContext()->resumeDownload(d->downloadId); + d->profile->d_ptr->profileAdapter()->resumeDownload(d->downloadId); } /*! diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index d8db796de..858b2bd95 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -49,11 +49,11 @@ #include <QQmlEngine> -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "renderer_host/user_resource_controller_host.h" #include "web_engine_settings.h" -using QtWebEngineCore::BrowserContextAdapter; +using QtWebEngineCore::ProfileAdapter; QT_BEGIN_NAMESPACE @@ -141,11 +141,11 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC The \a download argument holds the state of the finished download instance. */ -QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter *browserContext) +QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(ProfileAdapter *profileAdapter) : m_settings(new QQuickWebEngineSettings()) - , m_browserContextAdapter(browserContext) + , m_profileAdapter(profileAdapter) { - m_browserContextAdapter->addClient(this); + profileAdapter->addClient(this); m_settings->d_ptr->initDefaults(); // Fullscreen API was implemented before the supported setting, so we must // make it default true to avoid change in default API behavior. @@ -159,11 +159,11 @@ QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() m_webContentsAdapterClients.first()->destroy(); } - if (m_browserContextAdapter) { + if (m_profileAdapter) { // In the case the user sets this profile as the parent of the interceptor // it can be deleted before the browser-context still referencing it is. - m_browserContextAdapter->setRequestInterceptor(nullptr); - m_browserContextAdapter->removeClient(this); + m_profileAdapter->setRequestInterceptor(nullptr); + m_profileAdapter->removeClient(this); } for (QQuickWebEngineDownloadItem *download : qAsConst(m_ongoingDownloads)) { @@ -174,7 +174,7 @@ QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() m_ongoingDownloads.clear(); if (q_ptr != QQuickWebEngineProfile::defaultProfile()) - delete m_browserContextAdapter; + delete m_profileAdapter; } void QQuickWebEngineProfilePrivate::addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter) @@ -187,10 +187,20 @@ void QQuickWebEngineProfilePrivate::removeWebContentsAdapterClient(QQuickWebEngi m_webContentsAdapterClients.removeAll(adapter); } +QtWebEngineCore::ProfileAdapter *QQuickWebEngineProfilePrivate::profileAdapter() const +{ + return m_profileAdapter; +} + +QQuickWebEngineSettings *QQuickWebEngineProfilePrivate::settings() const +{ + return m_settings.data(); +} + void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId) { - if (m_browserContextAdapter) - m_browserContextAdapter->cancelDownload(downloadId); + if (m_profileAdapter) + m_profileAdapter->cancelDownload(downloadId); } void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) @@ -260,7 +270,7 @@ void QQuickWebEngineProfilePrivate::userScripts_append(QQmlListProperty<QQuickWe { Q_ASSERT(p && p->data); QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data); - QtWebEngineCore::UserResourceControllerHost *resourceController = d->browserContext()->userResourceController(); + QtWebEngineCore::UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); d->m_userScripts.append(script); script->d_func()->bind(resourceController); } @@ -283,7 +293,7 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWeb { Q_ASSERT(p && p->data); QQuickWebEngineProfilePrivate *d = static_cast<QQuickWebEngineProfilePrivate *>(p->data); - QtWebEngineCore::UserResourceControllerHost *resourceController = d->browserContext()->userResourceController(); + QtWebEngineCore::UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); resourceController->clearAllScripts(NULL); d->m_userScripts.clear(); } @@ -325,7 +335,7 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWeb */ QQuickWebEngineProfile::QQuickWebEngineProfile(QObject *parent) : QObject(parent), - d_ptr(new QQuickWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter())) + d_ptr(new QQuickWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter())) { // Sets up the global WebEngineContext QQuickWebEngineProfile::defaultProfile(); @@ -367,23 +377,23 @@ QQuickWebEngineProfile::~QQuickWebEngineProfile() QString QQuickWebEngineProfile::storageName() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->storageName(); + return d->profileAdapter()->storageName(); } void QQuickWebEngineProfile::setStorageName(const QString &name) { Q_D(QQuickWebEngineProfile); - if (d->browserContext()->storageName() == name) + if (d->profileAdapter()->storageName() == name) return; - BrowserContextAdapter::HttpCacheType oldCacheType = d->browserContext()->httpCacheType(); - BrowserContextAdapter::PersistentCookiesPolicy oldPolicy = d->browserContext()->persistentCookiesPolicy(); - d->browserContext()->setStorageName(name); + ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType(); + ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy(); + d->profileAdapter()->setStorageName(name); emit storageNameChanged(); emit persistentStoragePathChanged(); emit cachePathChanged(); - if (d->browserContext()->httpCacheType() != oldCacheType) + if (d->profileAdapter()->httpCacheType() != oldCacheType) emit httpCacheTypeChanged(); - if (d->browserContext()->persistentCookiesPolicy() != oldPolicy) + if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy) emit persistentCookiesPolicyChanged(); } @@ -407,21 +417,21 @@ void QQuickWebEngineProfile::setStorageName(const QString &name) bool QQuickWebEngineProfile::isOffTheRecord() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->isOffTheRecord(); + return d->profileAdapter()->isOffTheRecord(); } void QQuickWebEngineProfile::setOffTheRecord(bool offTheRecord) { Q_D(QQuickWebEngineProfile); - if (d->browserContext()->isOffTheRecord() == offTheRecord) + if (d->profileAdapter()->isOffTheRecord() == offTheRecord) return; - BrowserContextAdapter::HttpCacheType oldCacheType = d->browserContext()->httpCacheType(); - BrowserContextAdapter::PersistentCookiesPolicy oldPolicy = d->browserContext()->persistentCookiesPolicy(); - d->browserContext()->setOffTheRecord(offTheRecord); + ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType(); + ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy(); + d->profileAdapter()->setOffTheRecord(offTheRecord); emit offTheRecordChanged(); - if (d->browserContext()->httpCacheType() != oldCacheType) + if (d->profileAdapter()->httpCacheType() != oldCacheType) emit httpCacheTypeChanged(); - if (d->browserContext()->persistentCookiesPolicy() != oldPolicy) + if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy) emit persistentCookiesPolicyChanged(); } @@ -450,7 +460,7 @@ void QQuickWebEngineProfile::setOffTheRecord(bool offTheRecord) QString QQuickWebEngineProfile::persistentStoragePath() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->dataPath(); + return d->profileAdapter()->dataPath(); } void QQuickWebEngineProfile::setPersistentStoragePath(const QString &path) @@ -458,7 +468,7 @@ void QQuickWebEngineProfile::setPersistentStoragePath(const QString &path) Q_D(QQuickWebEngineProfile); if (persistentStoragePath() == path) return; - d->browserContext()->setDataPath(path); + d->profileAdapter()->setDataPath(path); emit persistentStoragePathChanged(); } @@ -485,7 +495,7 @@ void QQuickWebEngineProfile::setPersistentStoragePath(const QString &path) QString QQuickWebEngineProfile::cachePath() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->cachePath(); + return d->profileAdapter()->cachePath(); } void QQuickWebEngineProfile::setCachePath(const QString &path) @@ -493,7 +503,7 @@ void QQuickWebEngineProfile::setCachePath(const QString &path) Q_D(QQuickWebEngineProfile); if (cachePath() == path) return; - d->browserContext()->setCachePath(path); + d->profileAdapter()->setCachePath(path); emit cachePathChanged(); } @@ -516,15 +526,15 @@ void QQuickWebEngineProfile::setCachePath(const QString &path) QString QQuickWebEngineProfile::httpUserAgent() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->httpUserAgent(); + return d->profileAdapter()->httpUserAgent(); } void QQuickWebEngineProfile::setHttpUserAgent(const QString &userAgent) { Q_D(QQuickWebEngineProfile); - if (d->browserContext()->httpUserAgent() == userAgent) + if (d->profileAdapter()->httpUserAgent() == userAgent) return; - d->browserContext()->setHttpUserAgent(userAgent); + d->profileAdapter()->setHttpUserAgent(userAgent); emit httpUserAgentChanged(); } @@ -554,15 +564,15 @@ void QQuickWebEngineProfile::setHttpUserAgent(const QString &userAgent) QQuickWebEngineProfile::HttpCacheType QQuickWebEngineProfile::httpCacheType() const { const Q_D(QQuickWebEngineProfile); - return QQuickWebEngineProfile::HttpCacheType(d->browserContext()->httpCacheType()); + return QQuickWebEngineProfile::HttpCacheType(d->profileAdapter()->httpCacheType()); } void QQuickWebEngineProfile::setHttpCacheType(QQuickWebEngineProfile::HttpCacheType httpCacheType) { Q_D(QQuickWebEngineProfile); - BrowserContextAdapter::HttpCacheType oldCacheType = d->browserContext()->httpCacheType(); - d->browserContext()->setHttpCacheType(BrowserContextAdapter::HttpCacheType(httpCacheType)); - if (d->browserContext()->httpCacheType() != oldCacheType) + ProfileAdapter::HttpCacheType oldCacheType = d->profileAdapter()->httpCacheType(); + d->profileAdapter()->setHttpCacheType(ProfileAdapter::HttpCacheType(httpCacheType)); + if (d->profileAdapter()->httpCacheType() != oldCacheType) emit httpCacheTypeChanged(); } @@ -591,15 +601,15 @@ void QQuickWebEngineProfile::setHttpCacheType(QQuickWebEngineProfile::HttpCacheT QQuickWebEngineProfile::PersistentCookiesPolicy QQuickWebEngineProfile::persistentCookiesPolicy() const { const Q_D(QQuickWebEngineProfile); - return QQuickWebEngineProfile::PersistentCookiesPolicy(d->browserContext()->persistentCookiesPolicy()); + return QQuickWebEngineProfile::PersistentCookiesPolicy(d->profileAdapter()->persistentCookiesPolicy()); } void QQuickWebEngineProfile::setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy) { Q_D(QQuickWebEngineProfile); - BrowserContextAdapter::PersistentCookiesPolicy oldPolicy = d->browserContext()->persistentCookiesPolicy(); - d->browserContext()->setPersistentCookiesPolicy(BrowserContextAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy)); - if (d->browserContext()->persistentCookiesPolicy() != oldPolicy) + ProfileAdapter::PersistentCookiesPolicy oldPolicy = d->profileAdapter()->persistentCookiesPolicy(); + d->profileAdapter()->setPersistentCookiesPolicy(ProfileAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy)); + if (d->profileAdapter()->persistentCookiesPolicy() != oldPolicy) emit persistentCookiesPolicyChanged(); } @@ -624,15 +634,15 @@ void QQuickWebEngineProfile::setPersistentCookiesPolicy(QQuickWebEngineProfile:: int QQuickWebEngineProfile::httpCacheMaximumSize() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->httpCacheMaxSize(); + return d->profileAdapter()->httpCacheMaxSize(); } void QQuickWebEngineProfile::setHttpCacheMaximumSize(int maximumSize) { Q_D(QQuickWebEngineProfile); - if (d->browserContext()->httpCacheMaxSize() == maximumSize) + if (d->profileAdapter()->httpCacheMaxSize() == maximumSize) return; - d->browserContext()->setHttpCacheMaxSize(maximumSize); + d->profileAdapter()->setHttpCacheMaxSize(maximumSize); emit httpCacheMaximumSizeChanged(); } @@ -653,15 +663,15 @@ void QQuickWebEngineProfile::setHttpCacheMaximumSize(int maximumSize) QString QQuickWebEngineProfile::httpAcceptLanguage() const { Q_D(const QQuickWebEngineProfile); - return d->browserContext()->httpAcceptLanguage(); + return d->profileAdapter()->httpAcceptLanguage(); } void QQuickWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage) { Q_D(QQuickWebEngineProfile); - if (d->browserContext()->httpAcceptLanguage() == httpAcceptLanguage) + if (d->profileAdapter()->httpAcceptLanguage() == httpAcceptLanguage) return; - d->browserContext()->setHttpAcceptLanguage(httpAcceptLanguage); + d->profileAdapter()->setHttpAcceptLanguage(httpAcceptLanguage); emit httpAcceptLanguageChanged(); } @@ -675,8 +685,8 @@ void QQuickWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLang QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() { static QQuickWebEngineProfile *profile = new QQuickWebEngineProfile( - new QQuickWebEngineProfilePrivate(BrowserContextAdapter::defaultContext()), - BrowserContextAdapter::globalQObjectRoot()); + new QQuickWebEngineProfilePrivate(ProfileAdapter::defaultProfileAdapter()), + ProfileAdapter::globalQObjectRoot()); return profile; } @@ -706,8 +716,8 @@ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() void QQuickWebEngineProfile::setSpellCheckLanguages(const QStringList &languages) { Q_D(QQuickWebEngineProfile); - if (languages != d->browserContext()->spellCheckLanguages()) { - d->browserContext()->setSpellCheckLanguages(languages); + if (languages != d->profileAdapter()->spellCheckLanguages()) { + d->profileAdapter()->setSpellCheckLanguages(languages); emit spellCheckLanguagesChanged(); } } @@ -720,7 +730,7 @@ void QQuickWebEngineProfile::setSpellCheckLanguages(const QStringList &languages QStringList QQuickWebEngineProfile::spellCheckLanguages() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->spellCheckLanguages(); + return d->profileAdapter()->spellCheckLanguages(); } /*! @@ -741,7 +751,7 @@ void QQuickWebEngineProfile::setSpellCheckEnabled(bool enable) { Q_D(QQuickWebEngineProfile); if (enable != isSpellCheckEnabled()) { - d->browserContext()->setSpellCheckEnabled(enable); + d->profileAdapter()->setSpellCheckEnabled(enable); emit spellCheckEnabledChanged(); } } @@ -749,7 +759,7 @@ void QQuickWebEngineProfile::setSpellCheckEnabled(bool enable) bool QQuickWebEngineProfile::isSpellCheckEnabled() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->isSpellCheckEnabled(); + return d->profileAdapter()->isSpellCheckEnabled(); } /*! @@ -759,7 +769,7 @@ bool QQuickWebEngineProfile::isSpellCheckEnabled() const QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const { const Q_D(QQuickWebEngineProfile); - return d->browserContext()->cookieStore(); + return d->profileAdapter()->cookieStore(); } /*! @@ -781,7 +791,7 @@ QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const void QQuickWebEngineProfile::clearHttpCache() { Q_D(QQuickWebEngineProfile); - d->browserContext()->clearHttpCache(); + d->profileAdapter()->clearHttpCache(); } @@ -795,7 +805,7 @@ void QQuickWebEngineProfile::clearHttpCache() void QQuickWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { Q_D(QQuickWebEngineProfile); - d->browserContext()->setRequestInterceptor(interceptor); + d->profileAdapter()->setRequestInterceptor(interceptor); } /*! @@ -804,8 +814,8 @@ void QQuickWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestIntercept const QWebEngineUrlSchemeHandler *QQuickWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const { const Q_D(QQuickWebEngineProfile); - if (d->browserContext()->customUrlSchemeHandlers().contains(scheme)) - return d->browserContext()->customUrlSchemeHandlers().value(scheme); + if (d->profileAdapter()->customUrlSchemeHandlers().contains(scheme)) + return d->profileAdapter()->customUrlSchemeHandlers().value(scheme); return 0; } @@ -832,12 +842,12 @@ void QQuickWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, Q return; } - if (d->browserContext()->customUrlSchemeHandlers().contains(scheme)) { - if (d->browserContext()->customUrlSchemeHandlers().value(scheme) != handler) + if (d->profileAdapter()->customUrlSchemeHandlers().contains(scheme)) { + if (d->profileAdapter()->customUrlSchemeHandlers().value(scheme) != handler) qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData()); return; } - d->browserContext()->addCustomUrlSchemeHandler(scheme, handler); + d->profileAdapter()->addCustomUrlSchemeHandler(scheme, handler); connect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); } @@ -850,7 +860,7 @@ void QQuickWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler * { Q_D(QQuickWebEngineProfile); Q_ASSERT(handler); - if (!d->browserContext()->removeCustomUrlSchemeHandler(handler)) + if (!d->profileAdapter()->removeCustomUrlSchemeHandler(handler)) return; disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); } @@ -863,7 +873,7 @@ void QQuickWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler * void QQuickWebEngineProfile::removeUrlScheme(const QByteArray &scheme) { Q_D(QQuickWebEngineProfile); - QWebEngineUrlSchemeHandler *handler = d->browserContext()->takeCustomUrlSchemeHandler(scheme); + QWebEngineUrlSchemeHandler *handler = d->profileAdapter()->takeCustomUrlSchemeHandler(scheme); if (!handler) return; disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); @@ -875,7 +885,7 @@ void QQuickWebEngineProfile::removeUrlScheme(const QByteArray &scheme) void QQuickWebEngineProfile::removeAllUrlSchemeHandlers() { Q_D(QQuickWebEngineProfile); - d->browserContext()->clearCustomUrlSchemeHandlers(); + d->profileAdapter()->clearCustomUrlSchemeHandlers(); } void QQuickWebEngineProfile::destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *obj) diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h index 0155c954a..4f1053924 100644 --- a/src/webengine/api/qquickwebengineprofile.h +++ b/src/webengine/api/qquickwebengineprofile.h @@ -48,10 +48,6 @@ #include <QtCore/QString> #include <QtQml/QQmlListProperty> -namespace QtWebEngineCore { -class BrowserContextAdapter; -} - QT_BEGIN_NAMESPACE class QQuickWebEngineDownloadItem; diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 4bb5e6b39..dcd634b42 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -52,7 +52,7 @@ // #include "browser_context_adapter_client.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "qquickwebengineprofile_p.h" #include <QExplicitlySharedDataPointer> @@ -69,13 +69,13 @@ class QQuickWebEngineViewPrivate; class QQuickWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QQuickWebEngineProfile) - QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter *browserContext); + QQuickWebEngineProfilePrivate(QtWebEngineCore::ProfileAdapter *profileAdapter); ~QQuickWebEngineProfilePrivate(); void addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter); void removeWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter); - QtWebEngineCore::BrowserContextAdapter* browserContext() const { return m_browserContextAdapter; } - QQuickWebEngineSettings *settings() const { return m_settings.data(); } + QtWebEngineCore::ProfileAdapter* profileAdapter() const; + QQuickWebEngineSettings *settings() const; void cancelDownload(quint32 downloadId); void downloadDestroyed(quint32 downloadId); @@ -93,7 +93,7 @@ private: friend class QQuickWebEngineViewPrivate; QQuickWebEngineProfile *q_ptr; QScopedPointer<QQuickWebEngineSettings> m_settings; - QPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextAdapter; + QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter; QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; QList<QQuickWebEngineScript *> m_userScripts; QVector<QQuickWebEngineViewPrivate *> m_webContentsAdapterClients; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index c19c731a8..83ee19f03 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -41,7 +41,7 @@ #include "qquickwebengineview_p_p.h" #include "qtwebenginecoreglobal_p.h" #include "authentication_dialog_controller.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "certificate_error_controller.h" #include "file_picker_controller.h" #include "javascript_dialog_controller.h" @@ -626,9 +626,9 @@ QObject *QQuickWebEngineViewPrivate::accessibilityParentObject() return q; } -BrowserContextAdapter *QQuickWebEngineViewPrivate::browserContextAdapter() +ProfileAdapter *QQuickWebEngineViewPrivate::profileAdapter() { - return m_profile->d_ptr->browserContext(); + return m_profile->d_ptr->profileAdapter(); } WebContentsAdapter *QQuickWebEngineViewPrivate::webContentsAdapter() @@ -717,7 +717,7 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent return; } - if (webContents->browserContextAdapter() && browserContextAdapter() != webContents->browserContextAdapter()) { + if (webContents->profileAdapter() && profileAdapter() != webContents->profileAdapter()) { qWarning("Can not adopt content from a different WebEngineProfile."); return; } @@ -774,7 +774,7 @@ void QQuickWebEngineViewPrivate::initializationFinished() adapter->openDevToolsFrontend(devToolsView->d_ptr->adapter); for (QQuickWebEngineScript *script : qAsConst(m_userScripts)) - script->d_func()->bind(browserContextAdapter()->userResourceController(), adapter.data()); + script->d_func()->bind(profileAdapter()->userResourceController(), adapter.data()); if (!m_isBeingAdopted) return; @@ -918,7 +918,7 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile) Q_EMIT q->profileChanged(); m_settings->setParentSettings(profile->settings()); - if (adapter->profile() != browserContextAdapter()->profile()) { + if (adapter->profile() != profileAdapter()->profile()) { // When the profile changes we need to create a new WebContentAdapter and reload the active URL. bool wasInitialized = adapter->isInitialized(); QUrl activeUrl = adapter->activeUrl(); @@ -1667,7 +1667,7 @@ void QQuickWebEngineViewPrivate::userScripts_append(QQmlListProperty<QQuickWebEn // If the adapter hasn't been initialized, we'll bind the scripts in initializationFinished() if (!d->adapter->isInitialized()) return; - UserResourceControllerHost *resourceController = d->browserContextAdapter()->userResourceController(); + UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); script->d_func()->bind(resourceController, d->adapter.data()); } @@ -1692,7 +1692,7 @@ void QQuickWebEngineViewPrivate::userScripts_clear(QQmlListProperty<QQuickWebEng d->m_userScripts.clear(); if (!d->adapter->isInitialized()) return; - UserResourceControllerHost *resourceController = d->browserContextAdapter()->userResourceController(); + UserResourceControllerHost *resourceController = d->profileAdapter()->userResourceController(); resourceController->clearAllScripts(d->adapter.data()); } diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 0e48ffc94..062125e70 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -152,7 +152,7 @@ public: void setToolTip(const QString &toolTipText) override; const QObject *holdingQObject() const override; - QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() override; + QtWebEngineCore::ProfileAdapter *profileAdapter() override; QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents); diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index ada7e058c..25813cfef 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -40,7 +40,7 @@ #include "qwebenginedownloaditem.h" #include "qwebenginedownloaditem_p.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "qwebengineprofile_p.h" @@ -256,8 +256,8 @@ void QWebEngineDownloadItem::cancel() // We directly cancel the download request if the user cancels // before it even started, so no need to notify the profile here. if (state == QWebEngineDownloadItem::DownloadInProgress) { - if (auto browserContext = d->profile->browserContext()) - browserContext->cancelDownload(d->downloadId); + if (auto profileAdapter = d->profile->profileAdapter()) + profileAdapter->cancelDownload(d->downloadId); } else { d->downloadState = QWebEngineDownloadItem::DownloadCancelled; Q_EMIT stateChanged(d->downloadState); @@ -283,7 +283,7 @@ void QWebEngineDownloadItem::pause() if (state != QWebEngineDownloadItem::DownloadInProgress) return; - d->profile->browserContext()->pauseDownload(d->downloadId); + d->profile->profileAdapter()->pauseDownload(d->downloadId); } /*! @@ -303,7 +303,7 @@ void QWebEngineDownloadItem::resume() if (d->downloadFinished || (state != QWebEngineDownloadItem::DownloadInProgress && state != QWebEngineDownloadItem::DownloadInterrupted)) return; - d->profile->browserContext()->resumeDownload(d->downloadId); + d->profile->profileAdapter()->resumeDownload(d->downloadId); } /*! diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 885ad7a69..57af5b20d 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -41,7 +41,7 @@ #include "qwebenginepage_p.h" #include "authentication_dialog_controller.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "certificate_error_controller.h" #include "color_chooser_controller.h" #include "favicon_manager.h" @@ -223,7 +223,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , settings(new QWebEngineSettings(profile->settings())) , view(0) , isLoading(false) - , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userResourceController(), adapter)) + , scriptCollection(new QWebEngineScriptCollectionPrivate(profileAdapter()->userResourceController(), adapter)) , m_isBeingAdopted(false) , m_backgroundColor(Qt::white) , fullscreenMode(false) @@ -692,9 +692,9 @@ void QWebEnginePagePrivate::setFullScreenMode(bool fullscreen) } } -BrowserContextAdapter* QWebEnginePagePrivate::browserContextAdapter() +ProfileAdapter* QWebEnginePagePrivate::profileAdapter() { - return profile->d_ptr->browserContext(); + return profile->d_ptr->profileAdapter(); } WebContentsAdapter *QWebEnginePagePrivate::webContentsAdapter() diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index e5657c1b6..fbaf0b579 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -148,7 +148,7 @@ public: void setToolTip(const QString &toolTipText) override; const QObject *holdingQObject() const override; - QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() override; + QtWebEngineCore::ProfileAdapter *profileAdapter() override; QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void updateAction(QWebEnginePage::WebAction) const; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index bec5455cb..68f9365b9 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -47,7 +47,7 @@ #include "qwebenginesettings.h" #include "qwebenginescriptcollection_p.h" #include "qtwebenginecoreglobal.h" -#include "browser_context_adapter.h" +#include "profile_adapter.h" #include "visited_links_manager_qt.h" #include "web_engine_settings.h" @@ -59,7 +59,7 @@ ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::CompleteHtmlSaveFormat) ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::MimeHtmlSaveFormat) -using QtWebEngineCore::BrowserContextAdapter; +using QtWebEngineCore::ProfileAdapter; /*! \class QWebEngineProfile @@ -147,23 +147,23 @@ using QtWebEngineCore::BrowserContextAdapter; \sa QWebEngineDownloadItem, QWebEnginePage::download() */ -QWebEngineProfilePrivate::QWebEngineProfilePrivate(BrowserContextAdapter* browserContextAdapter) +QWebEngineProfilePrivate::QWebEngineProfilePrivate(ProfileAdapter* profileAdapter) : m_settings(new QWebEngineSettings()) - , m_browserContextAdapter(browserContextAdapter) + , m_profileAdapter(profileAdapter) , m_scriptCollection(new QWebEngineScriptCollection( - new QWebEngineScriptCollectionPrivate(browserContextAdapter->userResourceController()))) + new QWebEngineScriptCollectionPrivate(profileAdapter->userResourceController()))) { - m_browserContextAdapter->addClient(this); + m_profileAdapter->addClient(this); m_settings->d_ptr->initDefaults(); } QWebEngineProfilePrivate::~QWebEngineProfilePrivate() { - if (m_browserContextAdapter) { + if (m_profileAdapter) { // In the case the user sets this profile as the parent of the interceptor // it can be deleted before the browser-context still referencing it is. - m_browserContextAdapter->setRequestInterceptor(nullptr); - m_browserContextAdapter->removeClient(this); + m_profileAdapter->setRequestInterceptor(nullptr); + m_profileAdapter->removeClient(this); } for (QWebEngineDownloadItem *download : qAsConst(m_ongoingDownloads)) { @@ -174,14 +174,14 @@ QWebEngineProfilePrivate::~QWebEngineProfilePrivate() m_ongoingDownloads.clear(); if (q_ptr != QWebEngineProfile::defaultProfile()) - delete m_browserContextAdapter; + delete m_profileAdapter; delete m_settings; } -BrowserContextAdapter* QWebEngineProfilePrivate::browserContext() const +ProfileAdapter* QWebEngineProfilePrivate::profileAdapter() const { - return m_browserContextAdapter; + return m_profileAdapter; } void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) @@ -253,7 +253,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info) */ QWebEngineProfile::QWebEngineProfile(QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter())) + , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter())) { d_ptr->q_ptr = this; } @@ -270,7 +270,7 @@ QWebEngineProfile::QWebEngineProfile(QObject *parent) */ QWebEngineProfile::QWebEngineProfile(const QString &storageName, QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter(storageName))) + , d_ptr(new QWebEngineProfilePrivate(new QtWebEngineCore::ProfileAdapter(storageName))) { d_ptr->q_ptr = this; } @@ -298,7 +298,7 @@ QWebEngineProfile::~QWebEngineProfile() QString QWebEngineProfile::storageName() const { const Q_D(QWebEngineProfile); - return d->browserContext()->storageName(); + return d->profileAdapter()->storageName(); } /*! @@ -310,7 +310,7 @@ QString QWebEngineProfile::storageName() const bool QWebEngineProfile::isOffTheRecord() const { const Q_D(QWebEngineProfile); - return d->browserContext()->isOffTheRecord(); + return d->profileAdapter()->isOffTheRecord(); } /*! @@ -329,7 +329,7 @@ bool QWebEngineProfile::isOffTheRecord() const QString QWebEngineProfile::persistentStoragePath() const { const Q_D(QWebEngineProfile); - return d->browserContext()->dataPath(); + return d->profileAdapter()->dataPath(); } /*! @@ -342,7 +342,7 @@ QString QWebEngineProfile::persistentStoragePath() const void QWebEngineProfile::setPersistentStoragePath(const QString &path) { const Q_D(QWebEngineProfile); - d->browserContext()->setDataPath(path); + d->profileAdapter()->setDataPath(path); } /*! @@ -359,7 +359,7 @@ void QWebEngineProfile::setPersistentStoragePath(const QString &path) QString QWebEngineProfile::cachePath() const { const Q_D(QWebEngineProfile); - return d->browserContext()->cachePath(); + return d->profileAdapter()->cachePath(); } /*! @@ -372,7 +372,7 @@ QString QWebEngineProfile::cachePath() const void QWebEngineProfile::setCachePath(const QString &path) { Q_D(QWebEngineProfile); - d->browserContext()->setCachePath(path); + d->profileAdapter()->setCachePath(path); } /*! @@ -387,7 +387,7 @@ void QWebEngineProfile::setCachePath(const QString &path) QString QWebEngineProfile::httpUserAgent() const { const Q_D(QWebEngineProfile); - return d->browserContext()->httpUserAgent(); + return d->profileAdapter()->httpUserAgent(); } /*! @@ -398,7 +398,7 @@ QString QWebEngineProfile::httpUserAgent() const void QWebEngineProfile::setHttpUserAgent(const QString &userAgent) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpUserAgent(userAgent); + d->profileAdapter()->setHttpUserAgent(userAgent); } /*! @@ -411,7 +411,7 @@ void QWebEngineProfile::setHttpUserAgent(const QString &userAgent) QWebEngineProfile::HttpCacheType QWebEngineProfile::httpCacheType() const { const Q_D(QWebEngineProfile); - return QWebEngineProfile::HttpCacheType(d->browserContext()->httpCacheType()); + return QWebEngineProfile::HttpCacheType(d->profileAdapter()->httpCacheType()); } /*! @@ -422,7 +422,7 @@ QWebEngineProfile::HttpCacheType QWebEngineProfile::httpCacheType() const void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCacheType) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpCacheType(BrowserContextAdapter::HttpCacheType(httpCacheType)); + d->profileAdapter()->setHttpCacheType(ProfileAdapter::HttpCacheType(httpCacheType)); } /*! @@ -433,7 +433,7 @@ void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCa void QWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpAcceptLanguage(httpAcceptLanguage); + d->profileAdapter()->setHttpAcceptLanguage(httpAcceptLanguage); } /*! @@ -444,7 +444,7 @@ void QWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage) QString QWebEngineProfile::httpAcceptLanguage() const { Q_D(const QWebEngineProfile); - return d->browserContext()->httpAcceptLanguage(); + return d->profileAdapter()->httpAcceptLanguage(); } /*! @@ -457,7 +457,7 @@ QString QWebEngineProfile::httpAcceptLanguage() const QWebEngineProfile::PersistentCookiesPolicy QWebEngineProfile::persistentCookiesPolicy() const { const Q_D(QWebEngineProfile); - return QWebEngineProfile::PersistentCookiesPolicy(d->browserContext()->persistentCookiesPolicy()); + return QWebEngineProfile::PersistentCookiesPolicy(d->profileAdapter()->persistentCookiesPolicy()); } /*! @@ -468,7 +468,7 @@ QWebEngineProfile::PersistentCookiesPolicy QWebEngineProfile::persistentCookiesP void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy) { Q_D(QWebEngineProfile); - d->browserContext()->setPersistentCookiesPolicy(BrowserContextAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy)); + d->profileAdapter()->setPersistentCookiesPolicy(ProfileAdapter::PersistentCookiesPolicy(newPersistentCookiesPolicy)); } /*! @@ -481,7 +481,7 @@ void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::Persistent int QWebEngineProfile::httpCacheMaximumSize() const { const Q_D(QWebEngineProfile); - return d->browserContext()->httpCacheMaxSize(); + return d->profileAdapter()->httpCacheMaxSize(); } /*! @@ -494,7 +494,7 @@ int QWebEngineProfile::httpCacheMaximumSize() const void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize) { Q_D(QWebEngineProfile); - d->browserContext()->setHttpCacheMaxSize(maxSize); + d->profileAdapter()->setHttpCacheMaxSize(maxSize); } /*! @@ -506,7 +506,7 @@ void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize) QWebEngineCookieStore* QWebEngineProfile::cookieStore() { Q_D(QWebEngineProfile); - return d->browserContext()->cookieStore(); + return d->profileAdapter()->cookieStore(); } @@ -522,7 +522,7 @@ QWebEngineCookieStore* QWebEngineProfile::cookieStore() void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { Q_D(QWebEngineProfile); - d->browserContext()->setRequestInterceptor(interceptor); + d->profileAdapter()->setRequestInterceptor(interceptor); } /*! @@ -533,7 +533,7 @@ void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *i void QWebEngineProfile::clearAllVisitedLinks() { Q_D(QWebEngineProfile); - d->browserContext()->visitedLinksManager()->deleteAllVisitedLinkData(); + d->profileAdapter()->visitedLinksManager()->deleteAllVisitedLinkData(); } /*! @@ -544,7 +544,7 @@ void QWebEngineProfile::clearAllVisitedLinks() void QWebEngineProfile::clearVisitedLinks(const QList<QUrl> &urls) { Q_D(QWebEngineProfile); - d->browserContext()->visitedLinksManager()->deleteVisitedLinkDataForUrls(urls); + d->profileAdapter()->visitedLinksManager()->deleteVisitedLinkDataForUrls(urls); } /*! @@ -553,7 +553,7 @@ void QWebEngineProfile::clearVisitedLinks(const QList<QUrl> &urls) bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const { Q_D(const QWebEngineProfile); - return d->browserContext()->visitedLinksManager()->containsUrl(url); + return d->profileAdapter()->visitedLinksManager()->containsUrl(url); } /*! @@ -578,8 +578,8 @@ QWebEngineScriptCollection *QWebEngineProfile::scripts() const QWebEngineProfile *QWebEngineProfile::defaultProfile() { static QWebEngineProfile* profile = new QWebEngineProfile( - new QWebEngineProfilePrivate(BrowserContextAdapter::defaultContext()), - BrowserContextAdapter::globalQObjectRoot()); + new QWebEngineProfilePrivate(ProfileAdapter::defaultProfileAdapter()), + ProfileAdapter::globalQObjectRoot()); return profile; } @@ -601,7 +601,7 @@ QWebEngineProfile *QWebEngineProfile::defaultProfile() void QWebEngineProfile::setSpellCheckLanguages(const QStringList &languages) { Q_D(QWebEngineProfile); - d->browserContext()->setSpellCheckLanguages(languages); + d->profileAdapter()->setSpellCheckLanguages(languages); } /*! @@ -612,7 +612,7 @@ void QWebEngineProfile::setSpellCheckLanguages(const QStringList &languages) QStringList QWebEngineProfile::spellCheckLanguages() const { const Q_D(QWebEngineProfile); - return d->browserContext()->spellCheckLanguages(); + return d->profileAdapter()->spellCheckLanguages(); } /*! @@ -624,7 +624,7 @@ QStringList QWebEngineProfile::spellCheckLanguages() const void QWebEngineProfile::setSpellCheckEnabled(bool enable) { Q_D(QWebEngineProfile); - d->browserContext()->setSpellCheckEnabled(enable); + d->profileAdapter()->setSpellCheckEnabled(enable); } /*! \since 5.8 @@ -635,7 +635,7 @@ void QWebEngineProfile::setSpellCheckEnabled(bool enable) bool QWebEngineProfile::isSpellCheckEnabled() const { const Q_D(QWebEngineProfile); - return d->browserContext()->isSpellCheckEnabled(); + return d->profileAdapter()->isSpellCheckEnabled(); } /*! @@ -655,8 +655,8 @@ QWebEngineSettings *QWebEngineProfile::settings() const const QWebEngineUrlSchemeHandler *QWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const { const Q_D(QWebEngineProfile); - if (d->browserContext()->customUrlSchemeHandlers().contains(scheme)) - return d->browserContext()->customUrlSchemeHandlers().value(scheme); + if (d->profileAdapter()->customUrlSchemeHandlers().contains(scheme)) + return d->profileAdapter()->customUrlSchemeHandlers().value(scheme); return 0; } @@ -685,12 +685,12 @@ void QWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEn return; } - if (d->browserContext()->customUrlSchemeHandlers().contains(scheme)) { - if (d->browserContext()->customUrlSchemeHandlers().value(scheme) != handler) + if (d->profileAdapter()->customUrlSchemeHandlers().contains(scheme)) { + if (d->profileAdapter()->customUrlSchemeHandlers().value(scheme) != handler) qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData()); return; } - d->browserContext()->addCustomUrlSchemeHandler(scheme, handler); + d->profileAdapter()->addCustomUrlSchemeHandler(scheme, handler); connect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); } @@ -705,7 +705,7 @@ void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handl { Q_D(QWebEngineProfile); Q_ASSERT(handler); - if (!d->browserContext()->removeCustomUrlSchemeHandler(handler)) + if (!d->profileAdapter()->removeCustomUrlSchemeHandler(handler)) return; disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); } @@ -720,7 +720,7 @@ void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handl void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme) { Q_D(QWebEngineProfile); - QWebEngineUrlSchemeHandler *handler = d->browserContext()->takeCustomUrlSchemeHandler(scheme); + QWebEngineUrlSchemeHandler *handler = d->profileAdapter()->takeCustomUrlSchemeHandler(scheme); if (!handler) return; disconnect(handler, SIGNAL(_q_destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*)), this, SLOT(destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler*))); @@ -734,7 +734,7 @@ void QWebEngineProfile::removeUrlScheme(const QByteArray &scheme) void QWebEngineProfile::removeAllUrlSchemeHandlers() { Q_D(QWebEngineProfile); - d->browserContext()->clearCustomUrlSchemeHandlers(); + d->profileAdapter()->clearCustomUrlSchemeHandlers(); } void QWebEngineProfile::destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *obj) @@ -750,7 +750,7 @@ void QWebEngineProfile::destroyedUrlSchemeHandler(QWebEngineUrlSchemeHandler *ob void QWebEngineProfile::clearHttpCache() { Q_D(QWebEngineProfile); - d->browserContext()->clearHttpCache(); + d->profileAdapter()->clearHttpCache(); } QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index f363482e9..c86b897b5 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -61,7 +61,7 @@ #include <QSharedPointer> namespace QtWebEngineCore { -class BrowserContextAdapter; +class ProfileAdapter; } QT_BEGIN_NAMESPACE @@ -73,10 +73,10 @@ class QWebEngineSettings; class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QWebEngineProfile) - QWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter *browserContextAdapter); + QWebEngineProfilePrivate(QtWebEngineCore::ProfileAdapter *profileAdapter); ~QWebEngineProfilePrivate(); - QtWebEngineCore::BrowserContextAdapter* browserContext() const; + QtWebEngineCore::ProfileAdapter* profileAdapter() const; QWebEngineSettings *settings() const { return m_settings; } void downloadDestroyed(quint32 downloadId); @@ -87,7 +87,7 @@ public: private: QWebEngineProfile *q_ptr; QWebEngineSettings *m_settings; - QPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextAdapter; + QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter; QScopedPointer<QWebEngineScriptCollection> m_scriptCollection; QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads; }; |