From fca9015175950b04bafb9b3af7d4e693eb0243d9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Sep 2014 15:03:16 +0200 Subject: Unglobalize browserContext This patch makes it possible to have more than one BrowserContext, for instance for off-the-record browsering but also to enable any other configuration on browser context level. This will make it possible to add page-groups settings and API for settingsthat can only be done on BrowserContext level. This patch does not expose any new API. Change-Id: I0a0e194449cfb5a096a4ac6e2f2b3882b6b4cfa2 Reviewed-by: Jocelyn Turcotte --- src/core/browser_context_adapter.cpp | 89 +++++++++++++++++++++++++++ src/core/browser_context_adapter.h | 75 ++++++++++++++++++++++ src/core/browser_context_qt.cpp | 20 ++---- src/core/browser_context_qt.h | 5 +- src/core/content_browser_client_qt.cpp | 23 ++----- src/core/content_browser_client_qt.h | 4 +- src/core/core_gyp_generator.pro | 2 + src/core/web_contents_adapter.cpp | 22 ++++--- src/core/web_contents_adapter.h | 3 + src/core/web_contents_adapter_client.h | 3 + src/core/web_contents_delegate_qt.cpp | 3 +- src/core/web_engine_context.cpp | 18 ++++-- src/core/web_engine_context.h | 8 ++- src/core/web_engine_visited_links_manager.cpp | 9 +-- src/core/web_engine_visited_links_manager.h | 3 +- src/webengine/api/qquickwebengineview.cpp | 6 ++ src/webengine/api/qquickwebengineview_p_p.h | 2 + src/webenginewidgets/api/qwebenginepage.cpp | 6 ++ src/webenginewidgets/api/qwebenginepage_p.h | 2 + 19 files changed, 242 insertions(+), 61 deletions(-) create mode 100644 src/core/browser_context_adapter.cpp create mode 100644 src/core/browser_context_adapter.h diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp new file mode 100644 index 000000000..2d56dcff7 --- /dev/null +++ b/src/core/browser_context_adapter.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "browser_context_adapter.h" + +#include "browser_context_qt.h" +#include "web_engine_context.h" +#include "web_engine_visited_links_manager.h" + +#include +#include +#include +#include +#include + + +BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord) + : m_offTheRecord(offTheRecord) + , m_browserContext(new BrowserContextQt(this)) + , m_visitedLinksManager(new WebEngineVisitedLinksManager(this)) +{ +} + +BrowserContextAdapter::~BrowserContextAdapter() +{ +} + +BrowserContextQt *BrowserContextAdapter::browserContext() +{ + return m_browserContext.data(); +} + +WebEngineVisitedLinksManager *BrowserContextAdapter::visitedLinksManager() +{ + return m_visitedLinksManager.data(); +} + +BrowserContextAdapter* BrowserContextAdapter::defaultContext() +{ + return WebEngineContext::current()->defaultBrowserContext(); +} + +BrowserContextAdapter* BrowserContextAdapter::offTheRecordContext() +{ + return WebEngineContext::current()->offTheRecordBrowserContext(); +} + +QString BrowserContextAdapter::path() const +{ + QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation); + if (dataLocation.isEmpty()) + dataLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName(); + + dataLocation.append(QDir::separator() % QLatin1String("QtWebEngine")); + return dataLocation; +} diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h new file mode 100644 index 000000000..99022f98d --- /dev/null +++ b/src/core/browser_context_adapter.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BROWSER_CONTEXT_ADAPTER_H +#define BROWSER_CONTEXT_ADAPTER_H + +#include "qtwebenginecoreglobal.h" + +#include +#include + +class BrowserContextQt; +class WebEngineVisitedLinksManager; + +// Make a QSharedData if we need to open arbitrary BrowserContextAdapter beyond the defaults. +class QWEBENGINE_EXPORT BrowserContextAdapter // : public QSharedData +{ +public: + virtual ~BrowserContextAdapter(); + + static BrowserContextAdapter* defaultContext(); + static BrowserContextAdapter* offTheRecordContext(); + + WebEngineVisitedLinksManager *visitedLinksManager(); + + BrowserContextQt *browserContext(); + bool isOffTheRecord() const { return m_offTheRecord; } + QString path() const; + +protected: + explicit BrowserContextAdapter(bool offTheRecord = false); + +private: + bool m_offTheRecord; + QScopedPointer m_browserContext; + QScopedPointer m_visitedLinksManager; + friend class WebEngineContext; + + Q_DISABLE_COPY(BrowserContextAdapter) +}; + +#endif // BROWSER_CONTEXT_ADAPTER_H diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 3913b7548..4c17171d4 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -36,6 +36,7 @@ #include "browser_context_qt.h" +#include "browser_context_adapter.h" #include "type_conversion.h" #include "qtwebenginecoreglobal.h" #include "resource_context_qt.h" @@ -47,14 +48,8 @@ #include "content/public/browser/storage_partition.h" #include "net/proxy/proxy_config_service.h" -#include -#include -#include -#include -#include -#include - -BrowserContextQt::BrowserContextQt() +BrowserContextQt::BrowserContextQt(BrowserContextAdapter *adapter) + : m_adapter(adapter) { resourceContext.reset(new ResourceContextQt(this)); } @@ -67,17 +62,12 @@ BrowserContextQt::~BrowserContextQt() base::FilePath BrowserContextQt::GetPath() const { - QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - if (dataLocation.isEmpty()) - dataLocation = QDir::homePath() % QDir::separator() % QChar::fromLatin1('.') % QCoreApplication::applicationName(); - - dataLocation.append(QDir::separator() % QLatin1String("QtWebEngine")); - return base::FilePath(toFilePathString(dataLocation)); + return base::FilePath(toFilePathString(m_adapter->path())); } bool BrowserContextQt::IsOffTheRecord() const { - return false; + return m_adapter->isOffTheRecord(); } net::URLRequestContextGetter *BrowserContextQt::GetRequestContext() diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h index 8c7e707a8..4e18c1a4a 100644 --- a/src/core/browser_context_qt.h +++ b/src/core/browser_context_qt.h @@ -43,10 +43,12 @@ #include "net/url_request/url_request_context.h" #include "download_manager_delegate_qt.h" +class BrowserContextAdapter; + class BrowserContextQt : public content::BrowserContext { public: - explicit BrowserContextQt(); + explicit BrowserContextQt(BrowserContextAdapter *); virtual ~BrowserContextQt(); @@ -69,6 +71,7 @@ private: scoped_ptr resourceContext; scoped_refptr url_request_getter_; scoped_ptr downloadManagerDelegate; + BrowserContextAdapter *m_adapter; DISALLOW_COPY_AND_ASSIGN(BrowserContextQt); }; diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 28294dce7..f10dd7500 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -201,12 +201,10 @@ public: void PreMainMessageLoopRun() Q_DECL_OVERRIDE { - m_browserContext.reset(new BrowserContextQt()); } void PostMainMessageLoopRun() { - m_browserContext.reset(); } int PreCreateThreads() Q_DECL_OVERRIDE @@ -217,13 +215,7 @@ public: return 0; } - BrowserContextQt* browser_context() const { - return m_browserContext.get(); - } - private: - scoped_ptr m_browserContext; - DISALLOW_COPY_AND_ASSIGN(BrowserMainPartsQt); }; @@ -347,22 +339,15 @@ void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, c static_cast(webContents->GetDelegate())->overrideWebPreferences(webContents, web_prefs); } -BrowserContextQt* ContentBrowserClientQt::browser_context() { - Q_ASSERT(m_browserMainParts); - return static_cast(m_browserMainParts)->browser_context(); -} - -net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* content_browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) +net::URLRequestContextGetter* ContentBrowserClientQt::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) { - if (content_browser_context != browser_context()) - fprintf(stderr, "Warning: off the record browser context not implemented !\n"); - return static_cast(browser_context())->CreateRequestContext(protocol_handlers); + return static_cast(browser_context)->CreateRequestContext(protocol_handlers); } -void ContentBrowserClientQt::enableInspector(bool enable) +void ContentBrowserClientQt::enableInspector(bool enable, content::BrowserContext* browser_context) { if (enable && !m_devtools) { - m_devtools.reset(new DevToolsHttpHandlerDelegateQt(browser_context())); + m_devtools.reset(new DevToolsHttpHandlerDelegateQt(browser_context)); } else if (!enable && m_devtools) { m_devtools.reset(); } diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index 9cf1695fe..3a70e2427 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -91,11 +91,9 @@ public: const base::Callback& callback, content::CertificateRequestResultType* result) Q_DECL_OVERRIDE; - BrowserContextQt* browser_context(); - virtual net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *content_browser_context, content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptorss) Q_DECL_OVERRIDE; - void enableInspector(bool); + void enableInspector(bool enable, content::BrowserContext *browser_context); private: BrowserMainPartsQt* m_browserMainParts; diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro index c50d56df4..c6144b344 100644 --- a/src/core/core_gyp_generator.pro +++ b/src/core/core_gyp_generator.pro @@ -35,6 +35,7 @@ INCLUDEPATH += $$[QT_INSTALL_HEADERS] $$PWD SOURCES = \ browser_accessibility_manager_qt.cpp \ browser_accessibility_qt.cpp \ + browser_context_adapter.cpp \ browser_context_qt.cpp \ certificate_error_controller.cpp \ chromium_gpu_helper.cpp \ @@ -82,6 +83,7 @@ SOURCES = \ HEADERS = \ browser_accessibility_manager_qt.h \ browser_accessibility_qt.h \ + browser_context_adapter.h \ browser_context_qt.h \ certificate_error_controller_p.h \ certificate_error_controller.h \ diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 3533c0743..0f71bbbee 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -41,6 +41,7 @@ #include "web_contents_adapter.h" #include "web_contents_adapter_p.h" +#include "browser_context_adapter.h" #include "browser_context_qt.h" #include "content_browser_client_qt.h" #include "javascript_dialog_manager_qt.h" @@ -175,9 +176,8 @@ static QStringList listRecursively(const QDir& dir) { return ret; } -static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient) +static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext) { - content::BrowserContext* browserContext = ContentBrowserClientQt::Get()->browser_context(); content::WebContents::CreateParams create_params(browserContext, NULL); create_params.routing_id = MSG_ROUTING_NONE; create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight); @@ -222,7 +222,7 @@ static void serializeNavigationHistory(const content::NavigationController &cont } } -void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector *entries) +void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector *entries, content::BrowserContext *browserContext) { int version; input >> version; @@ -278,7 +278,7 @@ void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::ve false, // The extra headers are not sync'ed across sessions. std::string(), - ContentBrowserClientQt::Get()->browser_context()); + browserContext); entry->SetTitle(toString16(title)); entry->SetPageState(content::PageState::CreateFromEncodedData(std::string(pageState.data(), pageState.size()))); @@ -308,13 +308,13 @@ QExplicitlySharedDataPointer WebContentsAdapter::createFromS { int currentIndex; std::vector entries; - deserializeNavigationHistory(input, ¤tIndex, &entries); + deserializeNavigationHistory(input, ¤tIndex, &entries, adapterClient->browserContextAdapter()->browserContext()); if (currentIndex == -1) return QExplicitlySharedDataPointer(); // Unlike WebCore, Chromium only supports Restoring to a new WebContents instance. - content::WebContents* newWebContents = createBlankWebContents(adapterClient); + content::WebContents* newWebContents = createBlankWebContents(adapterClient, adapterClient->browserContextAdapter()->browserContext()); content::NavigationController &controller = newWebContents->GetController(); controller.Restore(currentIndex, content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); @@ -350,7 +350,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) // Create our own if a WebContents wasn't provided at construction. if (!d->webContents) - d->webContents.reset(createBlankWebContents(adapterClient)); + d->webContents.reset(createBlankWebContents(adapterClient, adapterClient->browserContextAdapter()->browserContext())); // This might replace any adapter that has been initialized with this WebEngineSettings. adapterClient->webEngineSettings()->setWebContentsAdapter(this); @@ -623,7 +623,13 @@ qreal WebContentsAdapter::currentZoomFactor() const void WebContentsAdapter::enableInspector(bool enable) { - ContentBrowserClientQt::Get()->enableInspector(enable); + ContentBrowserClientQt::Get()->enableInspector(enable, browserContext()); +} + +BrowserContextQt* WebContentsAdapter::browserContext() +{ + Q_D(WebContentsAdapter); + return static_cast(d->webContents->GetBrowserContext()); } QAccessibleInterface *WebContentsAdapter::browserAccessible() diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 6bec50316..6e17fc2f5 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -48,6 +48,7 @@ namespace content { class WebContents; } +class BrowserContextQt; class WebContentsAdapterPrivate; struct WebPreferences; @@ -111,11 +112,13 @@ public: void dpiScaleChanged(); QAccessibleInterface *browserAccessible(); + BrowserContextQt* browserContext(); private: Q_DISABLE_COPY(WebContentsAdapter); Q_DECLARE_PRIVATE(WebContentsAdapter); QScopedPointer d_ptr; + friend class WebContentsDelegateQt; }; #endif // WEB_CONTENTS_ADAPTER_H diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 8fd401fe4..8fd988c7e 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -48,6 +48,7 @@ QT_FORWARD_DECLARE_CLASS(QVariant) +class BrowserContextAdapter; class CertificateErrorController; class JavaScriptDialogController; class RenderWidgetHostViewQt; @@ -176,6 +177,8 @@ public: virtual void allowCertificateError(const QExplicitlySharedDataPointer &errorController) = 0; + virtual BrowserContextAdapter* browserContextAdapter() = 0; + }; #endif // WEB_CONTENTS_ADAPTER_CLIENT_H diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index c2cccfedb..f9dba67fe 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -40,6 +40,7 @@ #include "web_contents_delegate_qt.h" +#include "browser_context_adapter.h" #include "media_capture_devices_dispatcher.h" #include "type_conversion.h" #include "web_contents_adapter_client.h" @@ -270,7 +271,7 @@ void WebContentsDelegateQt::DidNavigateAnyFrame(const content::LoadCommittedDeta { if (!params.should_update_history) return; - WebEngineContext::current()->visitedLinksManager()->addUrl(params.url); + m_viewClient->browserContextAdapter()->visitedLinksManager()->addUrl(params.url); } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 13daef5f6..c2e2da740 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -65,6 +65,7 @@ #include "content/public/app/startup_helper_win.h" #endif // OS_WIN +#include "browser_context_adapter.h" #include "content_browser_client_qt.h" #include "content_client_qt.h" #include "content_main_delegate_qt.h" @@ -73,7 +74,6 @@ #include "type_conversion.h" #include "surface_factory_qt.h" #include "web_engine_library_info.h" -#include "web_engine_visited_links_manager.h" #include #include #include @@ -107,9 +107,18 @@ scoped_refptr WebEngineContext::current() return sContext; } -WebEngineVisitedLinksManager *WebEngineContext::visitedLinksManager() +BrowserContextAdapter* WebEngineContext::defaultBrowserContext() { - return m_visitedLinksManager.get(); + if (!m_defaultBrowserContext) + m_defaultBrowserContext.reset(new BrowserContextAdapter()); + return m_defaultBrowserContext.get(); +} + +BrowserContextAdapter* WebEngineContext::offTheRecordBrowserContext() +{ + if (!m_offTheRecordBrowserContext) + m_offTheRecordBrowserContext.reset(new BrowserContextAdapter(true)); + return m_offTheRecordBrowserContext.get(); } #ifndef CHROMIUM_VERSION @@ -203,7 +212,4 @@ WebEngineContext::WebEngineContext() // thread to avoid a thread check assertion in its constructor when it // first gets referenced on the IO thread. MediaCaptureDevicesDispatcher::GetInstance(); - - // Ensure we have a VisitedLinksMaster instance up and running - m_visitedLinksManager.reset(new WebEngineVisitedLinksManager); } diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index d1cd9a7a5..0b3ad8678 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -49,15 +49,16 @@ class BrowserMainRunner; class ContentMainRunner; } +class BrowserContextAdapter; class ContentMainDelegateQt; class SurfaceFactoryQt; -class WebEngineVisitedLinksManager; class WebEngineContext : public base::RefCounted { public: static scoped_refptr current(); - WebEngineVisitedLinksManager *visitedLinksManager(); + BrowserContextAdapter *defaultBrowserContext(); + BrowserContextAdapter *offTheRecordBrowserContext(); private: friend class base::RefCounted; @@ -71,7 +72,8 @@ private: #if defined(OS_ANDROID) scoped_ptr m_surfaceFactory; #endif - scoped_ptr m_visitedLinksManager; + scoped_ptr m_defaultBrowserContext; + scoped_ptr m_offTheRecordBrowserContext; }; #endif // WEB_ENGINE_CONTEXT_H diff --git a/src/core/web_engine_visited_links_manager.cpp b/src/core/web_engine_visited_links_manager.cpp index 36467ca21..a2f6dbf9f 100644 --- a/src/core/web_engine_visited_links_manager.cpp +++ b/src/core/web_engine_visited_links_manager.cpp @@ -36,8 +36,9 @@ #include "web_engine_visited_links_manager.h" -#include "content_browser_client_qt.h" +#include "browser_context_adapter.h" #include "browser_context_qt.h" +#include "content_browser_client_qt.h" #include "type_conversion.h" #include "base/memory/scoped_ptr.h" @@ -80,11 +81,11 @@ void WebEngineVisitedLinksManager::deleteVisitedLinkDataForUrls(const QListDeleteURLs(&iterator); } -WebEngineVisitedLinksManager::WebEngineVisitedLinksManager() +WebEngineVisitedLinksManager::WebEngineVisitedLinksManager(BrowserContextAdapter *adapter) : m_delegate(new VisitedLinkDelegateQt) { - Q_ASSERT(ContentBrowserClientQt::Get() && ContentBrowserClientQt::Get()->browser_context()); - BrowserContextQt *browserContext = ContentBrowserClientQt::Get()->browser_context(); + Q_ASSERT(adapter && adapter->browserContext()); + BrowserContextQt *browserContext = adapter->browserContext(); m_visitedLinkMaster.reset(new visitedlink::VisitedLinkMaster(browserContext, m_delegate.data(), /* persist to disk = */true)); m_visitedLinkMaster->Init(); } diff --git a/src/core/web_engine_visited_links_manager.h b/src/core/web_engine_visited_links_manager.h index aa44dd9cf..5b0286c51 100644 --- a/src/core/web_engine_visited_links_manager.h +++ b/src/core/web_engine_visited_links_manager.h @@ -49,6 +49,7 @@ namespace visitedlink { class VisitedLinkMaster; } +class BrowserContextAdapter; class VisitedLinkDelegateQt; class GURL; @@ -57,7 +58,7 @@ class QWEBENGINE_EXPORT WebEngineVisitedLinksManager { public: virtual~WebEngineVisitedLinksManager(); - WebEngineVisitedLinksManager(); + WebEngineVisitedLinksManager(BrowserContextAdapter*); void deleteAllVisitedLinkData(); void deleteVisitedLinkDataForUrls(const QList &); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index e3ec66352..ce53d4f8a 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -37,6 +37,7 @@ #include "qquickwebengineview_p.h" #include "qquickwebengineview_p_p.h" +#include "browser_context_adapter.h" #include "certificate_error_controller.h" #include "javascript_dialog_controller.h" #include "qquickwebenginehistory_p.h" @@ -401,6 +402,11 @@ QObject *QQuickWebEngineViewPrivate::accessibilityParentObject() return q; } +BrowserContextAdapter *QQuickWebEngineViewPrivate::browserContextAdapter() +{ + return BrowserContextAdapter::defaultContext(); +} + WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const { return m_settings->d_func()->coreSettings.data(); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index ac8b8564f..a89de5556 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -179,6 +179,8 @@ public: virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; virtual void allowCertificateError(const QExplicitlySharedDataPointer &errorController); + virtual BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; + void setDevicePixelRatio(qreal); void adoptWebContents(WebContentsAdapter *webContents); diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 51cb84514..9b0636696 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -23,6 +23,7 @@ #include "qwebenginepage.h" #include "qwebenginepage_p.h" +#include "browser_context_adapter.h" #include "certificate_error_controller.h" #include "javascript_dialog_controller.h" #include "qwebenginehistory.h" @@ -410,6 +411,11 @@ void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input) } } +BrowserContextAdapter *QWebEnginePagePrivate::browserContextAdapter() +{ + return BrowserContextAdapter::defaultContext(); +} + QWebEnginePage::QWebEnginePage(QObject* parent) : QObject(parent) , d_ptr(new QWebEnginePagePrivate) diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index eeae6de65..57c44cacb 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -139,6 +139,8 @@ public: virtual WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE; virtual void allowCertificateError(const QExplicitlySharedDataPointer &controller) Q_DECL_OVERRIDE; + virtual BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; + void updateAction(QWebEnginePage::WebAction) const; void updateNavigationActions(); void _q_webActionTriggered(bool checked); -- cgit v1.2.3