diff options
20 files changed, 389 insertions, 721 deletions
diff --git a/.qmake.conf b/.qmake.conf index d4700d4ce..c9888ee8b 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -5,4 +5,4 @@ QTWEBENGINE_OUT_ROOT = $$shadowed($$PWD) load(qt_build_config) CONFIG += warning_clean -MODULE_VERSION = 5.11.0 +MODULE_VERSION = 5.12.0 diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index fc9cd0253..f60d6ad1f 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -294,7 +294,7 @@ ApplicationWindow { id: offTheRecordEnabled text: "Off The Record" checkable: true - checked: currentWebView.profile.offTheRecord + checked: currentWebView.profile === otrProfile onToggled: function(checked) { currentWebView.profile = checked ? otrProfile : defaultProfile; } diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp index 9a07c7c7b..5fcd46064 100644 --- a/src/core/api/qwebenginecookiestore.cpp +++ b/src/core/api/qwebenginecookiestore.cpp @@ -184,11 +184,10 @@ void QWebEngineCookieStorePrivate::onDeleteCallbackResult(qint64 callbackId, int void QWebEngineCookieStorePrivate::onCookieChanged(const QNetworkCookie &cookie, bool removed) { - Q_Q(QWebEngineCookieStore); if (removed) - Q_EMIT q->cookieRemoved(cookie); + Q_EMIT q_ptr->cookieRemoved(cookie); else - Q_EMIT q->cookieAdded(cookie); + Q_EMIT q_ptr->cookieAdded(cookie); } bool QWebEngineCookieStorePrivate::canAccessCookies(const QUrl &firstPartyUrl, const QUrl &url) @@ -268,8 +267,7 @@ QWebEngineCookieStore::~QWebEngineCookieStore() void QWebEngineCookieStore::setCookie(const QNetworkCookie &cookie, const QUrl &origin) { //TODO: use callbacks or delete dummy ones - Q_D(QWebEngineCookieStore); - d->setCookie(QWebEngineCallback<bool>(), cookie, origin); + d_ptr->setCookie(QWebEngineCallback<bool>(), cookie, origin); } /*! @@ -282,8 +280,7 @@ void QWebEngineCookieStore::setCookie(const QNetworkCookie &cookie, const QUrl & void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin) { - Q_D(QWebEngineCookieStore); - d->deleteCookie(cookie, origin); + d_ptr->deleteCookie(cookie, origin); } /*! @@ -298,12 +295,11 @@ void QWebEngineCookieStore::deleteCookie(const QNetworkCookie &cookie, const QUr void QWebEngineCookieStore::loadAllCookies() { //TODO: use callbacks or delete dummy ones - Q_D(QWebEngineCookieStore); - if (d->m_getAllCookiesPending) + if (d_ptr->m_getAllCookiesPending) return; - d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, QWebEngineCallback<const QByteArray&>()); + d_ptr->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, QWebEngineCallback<const QByteArray&>()); //this will trigger cookieAdded signal - d->getAllCookies(); + d_ptr->getAllCookies(); } /*! @@ -317,11 +313,10 @@ void QWebEngineCookieStore::loadAllCookies() void QWebEngineCookieStore::deleteSessionCookies() { //TODO: use callbacks or delete dummy ones - Q_D(QWebEngineCookieStore); - if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending) + if (d_ptr->m_deleteAllCookiesPending || d_ptr->m_deleteSessionCookiesPending) return; - d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, QWebEngineCallback<int>()); - d->deleteSessionCookies(); + d_ptr->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, QWebEngineCallback<int>()); + d_ptr->deleteSessionCookies(); } /*! @@ -333,11 +328,10 @@ void QWebEngineCookieStore::deleteSessionCookies() void QWebEngineCookieStore::deleteAllCookies() { //TODO: use callbacks or delete dummy ones - Q_D(QWebEngineCookieStore); - if (d->m_deleteAllCookiesPending) + if (d_ptr->m_deleteAllCookiesPending) return; - d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, QWebEngineCallback<int>()); - d->deleteAllCookies(); + d_ptr->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, QWebEngineCallback<int>()); + d_ptr->deleteAllCookies(); } /*! @@ -370,8 +364,7 @@ void QWebEngineCookieStore::deleteAllCookies() */ void QWebEngineCookieStore::setCookieFilter(const std::function<bool(const FilterRequest &)> &filterCallback) { - Q_D(QWebEngineCookieStore); - d->filterCallback = filterCallback; + d_ptr->filterCallback = filterCallback; } /*! @@ -380,8 +373,7 @@ void QWebEngineCookieStore::setCookieFilter(const std::function<bool(const Filte */ void QWebEngineCookieStore::setCookieFilter(std::function<bool(const FilterRequest &)> &&filterCallback) { - Q_D(QWebEngineCookieStore); - d->filterCallback = std::move(filterCallback); + d_ptr->filterCallback = std::move(filterCallback); } /*! diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp index e6972932e..2bb870071 100644 --- a/src/core/api/qwebengineurlrequestinfo.cpp +++ b/src/core/api/qwebengineurlrequestinfo.cpp @@ -192,8 +192,7 @@ QWebEngineUrlRequestInfo::QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPriva QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType() const { - Q_D(const QWebEngineUrlRequestInfo); - return d->resourceType; + return d_ptr->resourceType; } /*! @@ -217,8 +216,7 @@ QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType() QWebEngineUrlRequestInfo::NavigationType QWebEngineUrlRequestInfo::navigationType() const { - Q_D(const QWebEngineUrlRequestInfo); - return d->navigationType; + return d_ptr->navigationType; } /*! @@ -227,8 +225,7 @@ QWebEngineUrlRequestInfo::NavigationType QWebEngineUrlRequestInfo::navigationTyp QUrl QWebEngineUrlRequestInfo::requestUrl() const { - Q_D(const QWebEngineUrlRequestInfo); - return d->url; + return d_ptr->url; } /*! @@ -238,8 +235,7 @@ QUrl QWebEngineUrlRequestInfo::requestUrl() const QUrl QWebEngineUrlRequestInfo::firstPartyUrl() const { - Q_D(const QWebEngineUrlRequestInfo); - return d->firstPartyUrl; + return d_ptr->firstPartyUrl; } @@ -249,8 +245,7 @@ QUrl QWebEngineUrlRequestInfo::firstPartyUrl() const QByteArray QWebEngineUrlRequestInfo::requestMethod() const { - Q_D(const QWebEngineUrlRequestInfo); - return d->method; + return d_ptr->method; } /*! @@ -258,8 +253,7 @@ QByteArray QWebEngineUrlRequestInfo::requestMethod() const */ bool QWebEngineUrlRequestInfo::changed() const { - Q_D(const QWebEngineUrlRequestInfo); - return d->changed; + return d_ptr->changed; } /*! @@ -269,9 +263,8 @@ bool QWebEngineUrlRequestInfo::changed() const void QWebEngineUrlRequestInfo::redirect(const QUrl &url) { - Q_D(QWebEngineUrlRequestInfo); - d->changed = true; - d->url = url; + d_ptr->changed = true; + d_ptr->url = url; } /*! @@ -282,9 +275,8 @@ void QWebEngineUrlRequestInfo::redirect(const QUrl &url) void QWebEngineUrlRequestInfo::block(bool shouldBlock) { - Q_D(QWebEngineUrlRequestInfo); - d->changed = true; - d->shouldBlockRequest = shouldBlock; + d_ptr->changed = true; + d_ptr->shouldBlockRequest = shouldBlock; } /*! @@ -293,9 +285,8 @@ void QWebEngineUrlRequestInfo::block(bool shouldBlock) void QWebEngineUrlRequestInfo::setHttpHeader(const QByteArray &name, const QByteArray &value) { - Q_D(QWebEngineUrlRequestInfo); - d->changed = true; - d->extraHeaders.insert(name, value); + d_ptr->changed = true; + d_ptr->extraHeaders.insert(name, value); } QT_END_NAMESPACE diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 3878bd1bf..aa13cce3a 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -142,8 +142,6 @@ namespace QtWebEngineCore { namespace { -ContentBrowserClientQt* gBrowserClient = 0; // Owned by ContentMainDelegateQt. - // Return a timeout suitable for the glib loop, -1 to block forever, // 0 to return right away, or a timeout in milliseconds from now. int GetTimeIntervalMilliseconds(const base::TimeTicks& from) { @@ -374,18 +372,10 @@ void ShareGroupQtQuick::AboutToAddFirstContext() ContentBrowserClientQt::ContentBrowserClientQt() : m_browserMainParts(0) { - Q_ASSERT(!gBrowserClient); - gBrowserClient = this; } ContentBrowserClientQt::~ContentBrowserClientQt() { - gBrowserClient = 0; -} - -ContentBrowserClientQt *ContentBrowserClientQt::Get() -{ - return gBrowserClient; } content::BrowserMainParts *ContentBrowserClientQt::CreateBrowserMainParts(const content::MainFunctionParams&) diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index d803c856e..515574147 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -84,7 +84,6 @@ class ContentBrowserClientQt : public content::ContentBrowserClient { public: ContentBrowserClientQt(); ~ContentBrowserClientQt(); - static ContentBrowserClientQt* Get(); content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) override; void RenderProcessWillLaunch(content::RenderProcessHost* host) override; void ResourceDispatcherHostCreated() override; diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 73e07c156..d036f82fd 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -146,7 +146,6 @@ HEADERS = \ devtools_manager_delegate_qt.h \ download_manager_delegate_qt.h \ chromium_gpu_helper.h \ - favicon_manager_p.h \ favicon_manager.h \ file_picker_controller.h \ gl_context_qt.h \ @@ -202,7 +201,6 @@ HEADERS = \ visited_links_manager_qt.h \ web_contents_adapter.h \ web_contents_adapter_client.h \ - web_contents_adapter_p.h \ web_contents_delegate_qt.h \ web_contents_view_qt.h \ web_engine_context.h \ diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp index 03da67335..2a7d78320 100644 --- a/src/core/favicon_manager.cpp +++ b/src/core/favicon_manager.cpp @@ -38,8 +38,6 @@ ****************************************************************************/ #include "favicon_manager.h" -#include "favicon_manager_p.h" - #include "type_conversion.h" #include "web_contents_adapter_client.h" #include "web_engine_settings.h" @@ -72,18 +70,19 @@ static inline unsigned area(const QSize &size) } -FaviconManagerPrivate::FaviconManagerPrivate(content::WebContents *webContents, WebContentsAdapterClient *viewClient) +FaviconManager::FaviconManager(content::WebContents *webContents, WebContentsAdapterClient *viewClient) : m_webContents(webContents) , m_viewClient(viewClient) - , m_weakFactory(this) + , m_candidateCount(0) + , m_weakFactory(new base::WeakPtrFactory<FaviconManager>(this)) { } -FaviconManagerPrivate::~FaviconManagerPrivate() +FaviconManager::~FaviconManager() { } -int FaviconManagerPrivate::downloadIcon(const QUrl &url) +int FaviconManager::downloadIcon(const QUrl &url) { static int fakeId = 0; int id; @@ -98,7 +97,7 @@ int FaviconManagerPrivate::downloadIcon(const QUrl &url) true, // is_favicon 0, // no max size false, // normal cache policy - base::Bind(&FaviconManagerPrivate::iconDownloadFinished, m_weakFactory.GetWeakPtr())); + base::Bind(&FaviconManager::iconDownloadFinished, m_weakFactory->GetWeakPtr())); } Q_ASSERT(!m_inProgressRequests.contains(id)); @@ -107,7 +106,7 @@ int FaviconManagerPrivate::downloadIcon(const QUrl &url) return id; } -void FaviconManagerPrivate::iconDownloadFinished(int id, +void FaviconManager::iconDownloadFinished(int id, int status, const GURL &url, const std::vector<SkBitmap> &bitmaps, @@ -125,7 +124,7 @@ void FaviconManagerPrivate::iconDownloadFinished(int id, * icons are stored in m_icons explicitly by this function. It is necessary to avoid * m_inProgressRequests being emptied right before the next icon is added by a downloadIcon() call. */ -void FaviconManagerPrivate::downloadPendingRequests() +void FaviconManager::downloadPendingRequests() { for (auto it = m_pendingRequests.cbegin(), end = m_pendingRequests.cend(); it != end; ++it) { QIcon icon; @@ -150,16 +149,15 @@ void FaviconManagerPrivate::downloadPendingRequests() m_pendingRequests.clear(); } -void FaviconManagerPrivate::storeIcon(int id, const QIcon &icon) +void FaviconManager::storeIcon(int id, const QIcon &icon) { - Q_Q(FaviconManager); // Icon download has been interrupted if (!m_inProgressRequests.contains(id)) return; QUrl requestUrl = m_inProgressRequests[id]; - FaviconInfo &faviconInfo = q->m_faviconInfoMap[requestUrl]; + FaviconInfo &faviconInfo = m_faviconInfoMap[requestUrl]; unsigned iconCount = 0; if (!icon.isNull()) @@ -190,13 +188,13 @@ void FaviconManagerPrivate::storeIcon(int id, const QIcon &icon) WebEngineSettings *settings = m_viewClient->webEngineSettings(); bool touchIconsEnabled = settings->testAttribute(WebEngineSettings::TouchIconsEnabled); - q->generateCandidateIcon(touchIconsEnabled); - const QUrl &iconUrl = q->candidateIconUrl(touchIconsEnabled); + generateCandidateIcon(touchIconsEnabled); + const QUrl &iconUrl = candidateIconUrl(touchIconsEnabled); propagateIcon(iconUrl); } } -void FaviconManagerPrivate::propagateIcon(const QUrl &iconUrl) const +void FaviconManager::propagateIcon(const QUrl &iconUrl) const { content::NavigationEntry *entry = m_webContents->GetController().GetVisibleEntry(); if (entry) { @@ -208,30 +206,15 @@ void FaviconManagerPrivate::propagateIcon(const QUrl &iconUrl) const m_viewClient->iconChanged(iconUrl); } -FaviconManager::FaviconManager(FaviconManagerPrivate *d) - : m_candidateCount(0) -{ - Q_ASSERT(d); - d_ptr.reset(d); - - d->q_ptr = this; -} - -FaviconManager::~FaviconManager() -{ -} - QIcon FaviconManager::getIcon(const QUrl &url) const { - Q_D(const FaviconManager); - if (url.isEmpty()) return m_candidateIcon; - if (!d->m_icons.contains(url)) + if (!m_icons.contains(url)) return QIcon(); - return d->m_icons[url]; + return m_icons[url]; } FaviconInfo FaviconManager::getFaviconInfo(const QUrl &url) const @@ -257,12 +240,11 @@ QList<FaviconInfo> FaviconManager::getFaviconInfoList(bool candidatesOnly) const void FaviconManager::update(const QList<FaviconInfo> &candidates) { - Q_D(FaviconManager); updateCandidates(candidates); - WebEngineSettings *settings = d->m_viewClient->webEngineSettings(); + WebEngineSettings *settings = m_viewClient->webEngineSettings(); if (!settings->testAttribute(WebEngineSettings::AutoLoadIconsForPage)) { - d->m_viewClient->iconChanged(QUrl()); + m_viewClient->iconChanged(QUrl()); return; } @@ -274,16 +256,16 @@ void FaviconManager::update(const QList<FaviconInfo> &candidates) continue; if (it->isValid()) - d->downloadIcon(it->url); + downloadIcon(it->url); } - d->downloadPendingRequests(); + downloadPendingRequests(); // Reset icon if nothing was downloaded - if (d->m_inProgressRequests.isEmpty()) { - content::NavigationEntry *entry = d->m_webContents->GetController().GetVisibleEntry(); + if (m_inProgressRequests.isEmpty()) { + content::NavigationEntry *entry = m_webContents->GetController().GetVisibleEntry(); if (entry && !entry->GetFavicon().valid) - d->m_viewClient->iconChanged(QUrl()); + m_viewClient->iconChanged(QUrl()); } } @@ -306,11 +288,9 @@ void FaviconManager::updateCandidates(const QList<FaviconInfo> &candidates) void FaviconManager::resetCandidates() { - Q_D(FaviconManager); - // Interrupt in progress icon downloads - d->m_pendingRequests.clear(); - d->m_inProgressRequests.clear(); + m_pendingRequests.clear(); + m_inProgressRequests.clear(); m_candidateCount = 0; m_candidateIcon = QIcon(); diff --git a/src/core/favicon_manager.h b/src/core/favicon_manager.h index e351831c2..28244f90b 100644 --- a/src/core/favicon_manager.h +++ b/src/core/favicon_manager.h @@ -41,7 +41,7 @@ #define FAVICON_MANAGER_H #include "qtwebenginecoreglobal.h" - +#include <memory> #include <QtCore/QMap> #include <QtCore/QObject> #include <QtCore/QSize> @@ -50,9 +50,25 @@ #include "web_engine_settings.h" +class GURL; +class SkBitmap; + +namespace gfx { +class Size; +} + +namespace content { +class WebContents; +} + +namespace base { +template<class T> +class WeakPtrFactory; +} + namespace QtWebEngineCore { -class FaviconManagerPrivate; +class WebContentsAdapterClient; // Based on src/3rdparty/chromium/content/public/common/favicon_url.h class QWEBENGINE_EXPORT FaviconInfo { @@ -81,9 +97,10 @@ public: }; -class QWEBENGINE_EXPORT FaviconManager : public QObject { - Q_OBJECT +class QWEBENGINE_EXPORT FaviconManager { + public: + FaviconManager(content::WebContents *, WebContentsAdapterClient *); ~FaviconManager(); QIcon getIcon(const QUrl &url = QUrl()) const; @@ -91,24 +108,28 @@ public: QList<FaviconInfo> getFaviconInfoList(bool) const; private: - FaviconManager(FaviconManagerPrivate *); - void update(const QList<FaviconInfo> &); void updateCandidates(const QList<FaviconInfo> &); void resetCandidates(); bool hasCandidate() const; - QUrl candidateIconUrl(bool touchIconsEnabled) const; void generateCandidateIcon(bool touchIconsEnabled); + int downloadIcon(const QUrl &); + void iconDownloadFinished(int, int, const GURL &, const std::vector<SkBitmap> &, const std::vector<gfx::Size> &); + void storeIcon(int, const QIcon &); + void downloadPendingRequests(); + void propagateIcon(const QUrl &) const; +private: + content::WebContents *m_webContents; + WebContentsAdapterClient *m_viewClient; QMap<QUrl, FaviconInfo> m_faviconInfoMap; int m_candidateCount; QIcon m_candidateIcon; - - Q_DISABLE_COPY(FaviconManager) - Q_DECLARE_PRIVATE(FaviconManager) - QScopedPointer<FaviconManagerPrivate> d_ptr; - + QMap<QUrl, QIcon> m_icons; + QMap<int, QUrl> m_inProgressRequests; + QMap<int, QUrl> m_pendingRequests; + std::unique_ptr<base::WeakPtrFactory<FaviconManager>> m_weakFactory; friend class WebContentsDelegateQt; }; diff --git a/src/core/favicon_manager_p.h b/src/core/favicon_manager_p.h deleted file mode 100644 index e2a49dbc7..000000000 --- a/src/core/favicon_manager_p.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FAVICON_MANAGER_P_H -#define FAVICON_MANAGER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qtwebenginecoreglobal_p.h" - -#include <QtCore/QMap> -#include <QtCore/QObject> -#include <vector> - -#include "base/memory/weak_ptr.h" - -QT_FORWARD_DECLARE_CLASS(QUrl) - -class GURL; -class SkBitmap; - -namespace gfx { - class Size; -} - -namespace content { - class WebContents; -} - -namespace QtWebEngineCore { - -class FaviconManager; -class WebContentsAdapterClient; - -class FaviconManagerPrivate { -public: - FaviconManagerPrivate(content::WebContents *, WebContentsAdapterClient *); - ~FaviconManagerPrivate(); - - int downloadIcon(const QUrl &); - - void iconDownloadFinished(int, int, const GURL &, const std::vector<SkBitmap> &, const std::vector<gfx::Size> &); - void storeIcon(int, const QIcon &); - void downloadPendingRequests(); - void propagateIcon(const QUrl &) const; - - content::WebContents *m_webContents; - WebContentsAdapterClient *m_viewClient; - base::WeakPtrFactory<FaviconManagerPrivate> m_weakFactory; - - QMap<QUrl, QIcon> m_icons; - QMap<int, QUrl> m_inProgressRequests; - QMap<int, QUrl> m_pendingRequests; - - Q_DECLARE_PUBLIC(FaviconManager) - FaviconManager *q_ptr; -}; - -} // namespace QtWebEngineCore - -#endif // FAVICON_MANAGER_P_H diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index db3ab5745..82467c2cb 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -146,17 +146,6 @@ void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_fr #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) } -void ContentRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame* render_frame) -{ - // Check whether the render_frame has been created and has not been detached yet. - // Otherwise the WebFrame is not available. - RenderFrameObserverQt *render_frame_observer = RenderFrameObserverQt::Get(render_frame); - if (!render_frame_observer || render_frame_observer->isFrameDetached()) - return; // The frame is invisible to scripts. - - UserResourceController::instance()->RunScriptsAtDocumentStart(render_frame); -} - void ContentRendererClientQt::RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) { // Check whether the render_frame has been created and has not been detached yet. diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index b91f57fc2..a1bf29966 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -84,7 +84,6 @@ public: bool IsLinkVisited(unsigned long long linkHash) override; void AddSupportedKeySystems(std::vector<std::unique_ptr<media::KeySystemProperties>>* key_systems) override; - void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override; void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override; private: diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp index 860f94a52..50a3924c6 100644 --- a/src/core/renderer/user_resource_controller.cpp +++ b/src/core/renderer/user_resource_controller.cpp @@ -60,6 +60,8 @@ #include <QRegularExpression> +#include <bitset> + Q_GLOBAL_STATIC(UserResourceController, qt_webengine_userResourceController) static content::RenderView * const globalScriptsIndex = 0; @@ -134,12 +136,11 @@ public: RenderFrameObserverHelper(content::RenderFrame* render_frame); private: - ~RenderFrameObserverHelper() override; - // RenderFrameObserver implementation. + void DidCommitProvisionalLoad(bool is_new_navigation, bool is_same_document_navigation) override; + void DidClearWindowObject() override; void DidFinishDocumentLoad() override; void DidFinishLoad() override; - void DidStartProvisionalLoad(blink::WebDocumentLoader *document_loader) override; void FrameDetached() override; void OnDestruct() override; bool OnMessageReceived(const IPC::Message& message) override; @@ -148,12 +149,31 @@ private: void onUserScriptRemoved(const UserScriptData &); void onScriptsCleared(); - void runScripts(UserScriptData::InjectionPoint, blink::WebLocalFrame *); + class Runner; + QScopedPointer<Runner> m_runner; +}; + +// Helper class to create WeakPtrs so the AfterLoad tasks can be canceled and to +// avoid running scripts more than once per injection point. +class UserResourceController::RenderFrameObserverHelper::Runner : public base::SupportsWeakPtr<Runner> { +public: + explicit Runner(blink::WebLocalFrame *frame) + : m_frame(frame) + { + } - // Set of frames which are pending to get an AfterLoad invocation of runScripts, if they - // haven't gotten it already. - QSet<blink::WebLocalFrame *> m_pendingFrames; - base::WeakPtrFactory<RenderFrameObserverHelper> m_weakPtrFactory; + void run(UserScriptData::InjectionPoint p) + { + DCHECK_LT(p, m_ran.size()); + if (!m_ran[p]) { + UserResourceController::instance()->runScripts(p, m_frame); + m_ran[p] = true; + } + } + +private: + blink::WebLocalFrame *m_frame; + std::bitset<3> m_ran; }; // Used only for script cleanup on RenderView destruction. @@ -166,14 +186,6 @@ private: void OnDestruct() override; }; -void UserResourceController::RenderFrameObserverHelper::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame) -{ - if (p == UserScriptData::AfterLoad && !m_pendingFrames.remove(frame)) - return; - - UserResourceController::instance()->runScripts(p, frame); -} - void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink::WebLocalFrame *frame) { content::RenderFrame *renderFrame = content::RenderFrame::FromWebFrame(frame); @@ -203,60 +215,63 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink: } } -void UserResourceController::RunScriptsAtDocumentStart(content::RenderFrame *render_frame) -{ - runScripts(UserScriptData::DocumentElementCreation, render_frame->GetWebFrame()); -} - void UserResourceController::RunScriptsAtDocumentEnd(content::RenderFrame *render_frame) { runScripts(UserScriptData::DocumentLoadFinished, render_frame->GetWebFrame()); } UserResourceController::RenderFrameObserverHelper::RenderFrameObserverHelper(content::RenderFrame *render_frame) - : content::RenderFrameObserver(render_frame), m_weakPtrFactory(this) + : content::RenderFrameObserver(render_frame) { } -UserResourceController::RenderFrameObserverHelper::~RenderFrameObserverHelper() +UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *render_view) + : content::RenderViewObserver(render_view) { - m_weakPtrFactory.InvalidateWeakPtrs(); } -UserResourceController::RenderViewObserverHelper::RenderViewObserverHelper(content::RenderView *render_view) - : content::RenderViewObserver(render_view) +void UserResourceController::RenderFrameObserverHelper::DidCommitProvisionalLoad(bool /* is_new_navigation */, + bool is_same_document_navigation) { + if (is_same_document_navigation) + return; + + // We are almost ready to run scripts. We still have to wait until the host + // process has been notified of the DidCommitProvisionalLoad event to ensure + // that the WebChannelTransportHost is ready to receive messages. + + m_runner.reset(new Runner(render_frame()->GetWebFrame())); } -void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad() +void UserResourceController::RenderFrameObserverHelper::DidClearWindowObject() { - blink::WebLocalFrame *frame = render_frame()->GetWebFrame(); - m_pendingFrames.insert(frame); - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, base::Bind(&UserResourceController::RenderFrameObserverHelper::runScripts, - m_weakPtrFactory.GetWeakPtr(), UserScriptData::AfterLoad, frame), - base::TimeDelta::FromMilliseconds(afterLoadTimeout)); + // This is called both before and after DidCommitProvisionalLoad, non-null + // m_runner means it's after. + if (m_runner) + m_runner->run(UserScriptData::DocumentElementCreation); } -void UserResourceController::RenderFrameObserverHelper::DidFinishLoad() +void UserResourceController::RenderFrameObserverHelper::DidFinishDocumentLoad() { - blink::WebLocalFrame *frame = render_frame()->GetWebFrame(); + DCHECK(m_runner); + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, + base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad), + base::TimeDelta::FromMilliseconds(afterLoadTimeout)); - // DidFinishDocumentLoad always comes before this, so frame has already been marked as pending. - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(&UserResourceController::RenderFrameObserverHelper::runScripts, - m_weakPtrFactory.GetWeakPtr(), UserScriptData::AfterLoad, frame)); } -void UserResourceController::RenderFrameObserverHelper::DidStartProvisionalLoad(blink::WebDocumentLoader *document_loader) +void UserResourceController::RenderFrameObserverHelper::DidFinishLoad() { - Q_UNUSED(document_loader); - blink::WebLocalFrame *frame = render_frame()->GetWebFrame(); - m_pendingFrames.remove(frame); + DCHECK(m_runner); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce(&Runner::run, m_runner->AsWeakPtr(), UserScriptData::AfterLoad)); } void UserResourceController::RenderFrameObserverHelper::FrameDetached() { - blink::WebLocalFrame *frame = render_frame()->GetWebFrame(); - m_pendingFrames.remove(frame); + m_runner.reset(); } void UserResourceController::RenderFrameObserverHelper::OnDestruct() @@ -326,7 +341,7 @@ UserResourceController::UserResourceController() { #if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS) static bool onlyCalledOnce = true; - Q_ASSERT(onlyCalledOnce); + DCHECK(onlyCalledOnce); onlyCalledOnce = false; #endif // !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS) } diff --git a/src/core/renderer/user_resource_controller.h b/src/core/renderer/user_resource_controller.h index 50af24243..0b5e0a0c6 100644 --- a/src/core/renderer/user_resource_controller.h +++ b/src/core/renderer/user_resource_controller.h @@ -68,7 +68,6 @@ public: void removeScriptForView(const UserScriptData &, content::RenderView *); void clearScriptsForView(content::RenderView *); - void RunScriptsAtDocumentStart(content::RenderFrame *render_frame); void RunScriptsAtDocumentEnd(content::RenderFrame *render_frame); private: diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp index a9071df8f..d889915a6 100644 --- a/src/core/renderer_host/user_resource_controller_host.cpp +++ b/src/core/renderer_host/user_resource_controller_host.cpp @@ -42,8 +42,6 @@ #include "common/qt_messages.h" #include "type_conversion.h" #include "web_contents_adapter.h" -#include "web_contents_adapter_p.h" - #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host_observer.h" #include "content/public/browser/render_view_host.h" diff --git a/src/core/renderer_host/user_resource_controller_host.h b/src/core/renderer_host/user_resource_controller_host.h index 8e6e1e3bf..cd02b4757 100644 --- a/src/core/renderer_host/user_resource_controller_host.h +++ b/src/core/renderer_host/user_resource_controller_host.h @@ -54,7 +54,6 @@ class WebContents; namespace QtWebEngineCore { class WebContentsAdapter; -class WebContentsAdapterPrivate; class QWEBENGINE_EXPORT UserResourceControllerHost { diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 4ebed8fc9..3145583c3 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -42,7 +42,6 @@ // found in the LICENSE.Chromium file. #include "web_contents_adapter.h" -#include "web_contents_adapter_p.h" #include "browser_accessibility_qt.h" #include "browser_context_adapter.h" @@ -354,23 +353,6 @@ class LoadRecursionGuard { }; } // Anonymous namespace -WebContentsAdapterPrivate::WebContentsAdapterPrivate() - // This has to be the first thing we create, and the last we destroy. - : engineContext(WebEngineContext::current()) - , webChannel(0) - , webChannelWorld(0) - , adapterClient(0) - , nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd) - , lastFindRequestId(0) - , currentDropAction(blink::kWebDragOperationNone) - , devToolsFrontend(nullptr) -{ -} - -WebContentsAdapterPrivate::~WebContentsAdapterPrivate() -{ -} - QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient) { int currentIndex; @@ -400,29 +382,34 @@ QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavig } WebContentsAdapter::WebContentsAdapter(content::WebContents *webContents) - : d_ptr(new WebContentsAdapterPrivate) + : m_webContents(webContents) + , m_webChannel(nullptr) + , m_webChannelWorld(0) + , m_adapterClient(nullptr) + , m_nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd) + , m_lastFindRequestId(0) + , m_currentDropAction(blink::kWebDragOperationNone) + , m_devToolsFrontend(nullptr) { - Q_D(WebContentsAdapter); - d->webContents.reset(webContents); + // This has to be the first thing we create, and the last we destroy. + WebEngineContext::current(); } WebContentsAdapter::~WebContentsAdapter() { - Q_D(WebContentsAdapter); - if (d->devToolsFrontend) + if (m_devToolsFrontend) closeDevToolsFrontend(); - Q_ASSERT(!d->devToolsFrontend); + Q_ASSERT(!m_devToolsFrontend); } void WebContentsAdapter::setClient(WebContentsAdapterClient *adapterClient) { - Q_D(WebContentsAdapter); Q_ASSERT(!isInitialized()); - d->adapterClient = adapterClient; + m_adapterClient = adapterClient; // We keep a reference to browserContextAdapter to keep it alive as long as we use it. // This is needed in case the QML WebEngineProfile is garbage collected before the WebEnginePage. - d->browserContextAdapter = adapterClient->browserContextAdapter(); - Q_ASSERT(d->browserContextAdapter); + m_browserContextAdapter = adapterClient->browserContextAdapter(); + Q_ASSERT(m_browserContextAdapter); // This might replace any adapter that has been initialized with this WebEngineSettings. adapterClient->webEngineSettings()->setWebContentsAdapter(this); @@ -430,37 +417,35 @@ void WebContentsAdapter::setClient(WebContentsAdapterClient *adapterClient) bool WebContentsAdapter::isInitialized() const { - Q_D(const WebContentsAdapter); - return bool(d->webContentsDelegate); + return (bool)m_webContentsDelegate; } void WebContentsAdapter::initialize(content::SiteInstance *site) { - Q_D(WebContentsAdapter); - Q_ASSERT(d->adapterClient); + Q_ASSERT(m_adapterClient); Q_ASSERT(!isInitialized()); // Create our own if a WebContents wasn't provided at construction. - if (!d->webContents) { - content::WebContents::CreateParams create_params(d->browserContextAdapter->browserContext(), site); + if (!m_webContents) { + content::WebContents::CreateParams create_params(m_browserContextAdapter->browserContext(), site); create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight); - create_params.context = reinterpret_cast<gfx::NativeView>(d->adapterClient); - d->webContents.reset(content::WebContents::Create(create_params)); + create_params.context = reinterpret_cast<gfx::NativeView>(m_adapterClient); + m_webContents.reset(content::WebContents::Create(create_params)); } - content::RendererPreferences* rendererPrefs = d->webContents->GetMutableRendererPrefs(); + content::RendererPreferences* rendererPrefs = m_webContents->GetMutableRendererPrefs(); rendererPrefs->use_custom_colors = true; // 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 = d->browserContextAdapter->httpUserAgent().toStdString(); - rendererPrefs->accept_languages = d->browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString(); + rendererPrefs->user_agent_override = m_browserContextAdapter->httpUserAgent().toStdString(); + rendererPrefs->accept_languages = m_browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString(); #if BUILDFLAG(ENABLE_WEBRTC) base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess(); if (commandLine->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) rendererPrefs->webrtc_ip_handling_policy = commandLine->GetSwitchValueASCII(switches::kForceWebRtcIPHandlingPolicy); else - rendererPrefs->webrtc_ip_handling_policy = d->adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly) + rendererPrefs->webrtc_ip_handling_policy = m_adapterClient->webEngineSettings()->testAttribute(WebEngineSettings::WebRTCPublicInterfacesOnly) ? content::kWebRTCIPHandlingDefaultPublicInterfaceOnly : content::kWebRTCIPHandlingDefault; #endif @@ -473,18 +458,18 @@ void WebContentsAdapter::initialize(content::SiteInstance *site) rendererPrefs->use_autohinter = params.autohinter; rendererPrefs->use_bitmaps = params.use_bitmaps; rendererPrefs->subpixel_rendering = params.subpixel_rendering; - d->webContents->GetRenderViewHost()->SyncRendererPrefs(); + m_webContents->GetRenderViewHost()->SyncRendererPrefs(); // Create and attach observers to the WebContents. - d->webContentsDelegate.reset(new WebContentsDelegateQt(d->webContents.get(), d->adapterClient)); - d->renderViewObserverHost.reset(new RenderViewObserverHostQt(d->webContents.get(), d->adapterClient)); + m_webContentsDelegate.reset(new WebContentsDelegateQt(m_webContents.get(), m_adapterClient)); + m_renderViewObserverHost.reset(new RenderViewObserverHostQt(m_webContents.get(), m_adapterClient)); // Let the WebContent's view know about the WebContentsAdapterClient. - WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(static_cast<content::WebContentsImpl*>(d->webContents.get())->GetView()); - contentsView->initialize(d->adapterClient); + WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(static_cast<content::WebContentsImpl*>(m_webContents.get())->GetView()); + contentsView->initialize(m_adapterClient); // This should only be necessary after having restored the history to a new WebContentsAdapter. - d->webContents->GetController().LoadIfNecessary(); + m_webContents->GetController().LoadIfNecessary(); #if BUILDFLAG(ENABLE_BASIC_PRINTING) PrintViewManagerQt::CreateForWebContents(webContents()); @@ -494,68 +479,62 @@ 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. - d->browserContextAdapter->visitedLinksManager(); + m_browserContextAdapter->visitedLinksManager(); // Create a RenderView with the initial empty document - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); Q_ASSERT(rvh); if (!rvh->IsRenderViewLive()) - static_cast<content::WebContentsImpl*>(d->webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, base::UnguessableToken::Create(), content::FrameReplicationState()); + static_cast<content::WebContentsImpl*>(m_webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, base::UnguessableToken::Create(), content::FrameReplicationState()); - d->adapterClient->initializationFinished(); + m_adapterClient->initializationFinished(); } void WebContentsAdapter::reattachRWHV() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView()) + if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView()) rwhv->InitAsChild(0); } bool WebContentsAdapter::canGoBack() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(false); - return d->webContents->GetController().CanGoBack(); + return m_webContents->GetController().CanGoBack(); } bool WebContentsAdapter::canGoForward() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(false); - return d->webContents->GetController().CanGoForward(); + return m_webContents->GetController().CanGoForward(); } void WebContentsAdapter::stop() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - content::NavigationController& controller = d->webContents->GetController(); + content::NavigationController& controller = m_webContents->GetController(); int index = controller.GetPendingEntryIndex(); if (index != -1) controller.RemoveEntryAtIndex(index); - d->webContents->Stop(); + m_webContents->Stop(); focusIfNecessary(); } void WebContentsAdapter::reload() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost()); - d->webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false); + CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + m_webContents->GetController().Reload(content::ReloadType::NORMAL, /*checkRepost = */false); focusIfNecessary(); } void WebContentsAdapter::reloadAndBypassCache() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost()); - d->webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false); + CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + m_webContents->GetController().Reload(content::ReloadType::BYPASSING_CACHE, /*checkRepost = */false); focusIfNecessary(); } @@ -573,16 +552,14 @@ void WebContentsAdapter::load(const QUrl &url) void WebContentsAdapter::load(const QWebEngineHttpRequest &request) { - Q_D(WebContentsAdapter); - GURL gurl = toGurl(request.url()); if (!isInitialized()) { scoped_refptr<content::SiteInstance> site = - content::SiteInstance::CreateForURL(d->browserContextAdapter->browserContext(), gurl); + content::SiteInstance::CreateForURL(m_browserContextAdapter->browserContext(), gurl); initialize(site.get()); } - CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost()); + CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); // The situation can occur when relying on the editingFinished signal in QML to set the url // of the WebView. @@ -623,7 +600,7 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request) params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST; // chromium accepts LOAD_TYPE_HTTP_POST only for the HTTP and HTTPS protocols if (!params.url.SchemeIsHTTPOrHTTPS()) { - d->adapterClient->loadFinished(false, request.url(), false, + m_adapterClient->loadFinished(false, request.url(), false, net::ERR_DISALLOWED_URL_SCHEME, QCoreApplication::translate("WebContentsAdapter", "HTTP-POST data can only be sent over HTTP(S) protocol")); @@ -653,10 +630,9 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request) } auto navigate = [this, params]() { - Q_D(WebContentsAdapter); webContents()->GetController().LoadURLWithParams(params); // Follow chrome::Navigate and invalidate the URL immediately. - d->webContentsDelegate->NavigationStateChanged(webContents(), content::INVALIDATE_TYPE_URL); + m_webContentsDelegate->NavigationStateChanged(webContents(), content::INVALIDATE_TYPE_URL); focusIfNecessary(); }; @@ -670,12 +646,10 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request) void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) { - Q_D(WebContentsAdapter); - if (!isInitialized()) loadDefault(); - CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost()); + CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); QByteArray encodedData = data.toPercentEncoding(); std::string urlString; @@ -687,7 +661,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT GURL dataUrlToLoad(urlString); if (dataUrlToLoad.spec().size() > url::kMaxURLChars) { - d->adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED); + m_adapterClient->loadFinished(false, baseUrl, false, net::ERR_ABORTED); return; } content::NavigationController::LoadURLParams params((dataUrlToLoad)); @@ -697,32 +671,29 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT params.can_load_local_resources = true; params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API); params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE; - d->webContents->GetController().LoadURLWithParams(params); + m_webContents->GetController().LoadURLWithParams(params); focusIfNecessary(); - d->webContents->CollapseSelection(); + m_webContents->CollapseSelection(); } void WebContentsAdapter::save(const QString &filePath, int savePageFormat) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContentsDelegate->setSavePageInfo(SavePageInfo(filePath, savePageFormat)); - d->webContents->OnSavePage(); + m_webContentsDelegate->setSavePageInfo(SavePageInfo(filePath, savePageFormat)); + m_webContents->OnSavePage(); } QUrl WebContentsAdapter::activeUrl() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(QUrl()); - return d->webContentsDelegate->url(); + return m_webContentsDelegate->url(); } QUrl WebContentsAdapter::requestedUrl() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(QUrl()); - content::NavigationEntry* entry = d->webContents->GetController().GetVisibleEntry(); - content::NavigationEntry* pendingEntry = d->webContents->GetController().GetPendingEntry(); + content::NavigationEntry* entry = m_webContents->GetController().GetVisibleEntry(); + content::NavigationEntry* pendingEntry = m_webContents->GetController().GetPendingEntry(); if (entry) { if (!entry->GetOriginalRequestURL().is_empty()) @@ -736,9 +707,8 @@ QUrl WebContentsAdapter::requestedUrl() const QUrl WebContentsAdapter::iconUrl() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(QUrl()); - if (content::NavigationEntry* entry = d->webContents->GetController().GetVisibleEntry()) { + if (content::NavigationEntry* entry = m_webContents->GetController().GetVisibleEntry()) { content::FaviconStatus favicon = entry->GetFavicon(); if (favicon.valid) return toQt(favicon.url); @@ -748,152 +718,132 @@ QUrl WebContentsAdapter::iconUrl() const QString WebContentsAdapter::pageTitle() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(QString()); - return d->webContentsDelegate->title(); + return m_webContentsDelegate->title(); } QString WebContentsAdapter::selectedText() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(QString()); - if (auto *rwhv = d->webContents->GetRenderWidgetHostView()) + if (auto *rwhv = m_webContents->GetRenderWidgetHostView()) return toQt(rwhv->GetSelectedText()); return QString(); } void WebContentsAdapter::undo() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->Undo(); + m_webContents->Undo(); } void WebContentsAdapter::redo() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->Redo(); + m_webContents->Redo(); } void WebContentsAdapter::cut() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->Cut(); + m_webContents->Cut(); } void WebContentsAdapter::copy() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->Copy(); + m_webContents->Copy(); } void WebContentsAdapter::paste() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->Paste(); + m_webContents->Paste(); } void WebContentsAdapter::pasteAndMatchStyle() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->PasteAndMatchStyle(); + m_webContents->PasteAndMatchStyle(); } void WebContentsAdapter::selectAll() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->SelectAll(); + m_webContents->SelectAll(); } void WebContentsAdapter::requestClose() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->DispatchBeforeUnload(); + m_webContents->DispatchBeforeUnload(); } void WebContentsAdapter::unselect() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->CollapseSelection(); + m_webContents->CollapseSelection(); } void WebContentsAdapter::navigateToIndex(int offset) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost()); - d->webContents->GetController().GoToIndex(offset); + CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + m_webContents->GetController().GoToIndex(offset); focusIfNecessary(); } void WebContentsAdapter::navigateToOffset(int offset) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - CHECK_VALID_RENDER_WIDGET_HOST_VIEW(d->webContents->GetRenderViewHost()); - d->webContents->GetController().GoToOffset(offset); + CHECK_VALID_RENDER_WIDGET_HOST_VIEW(m_webContents->GetRenderViewHost()); + m_webContents->GetController().GoToOffset(offset); focusIfNecessary(); } int WebContentsAdapter::navigationEntryCount() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(0); - return d->webContents->GetController().GetEntryCount(); + return m_webContents->GetController().GetEntryCount(); } int WebContentsAdapter::currentNavigationEntryIndex() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(0); - return d->webContents->GetController().GetCurrentEntryIndex(); + return m_webContents->GetController().GetCurrentEntryIndex(); } QUrl WebContentsAdapter::getNavigationEntryOriginalUrl(int index) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(QUrl()); - content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index); + content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index); return entry ? toQt(entry->GetOriginalRequestURL()) : QUrl(); } QUrl WebContentsAdapter::getNavigationEntryUrl(int index) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(QUrl()); - content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index); + content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index); return entry ? toQt(entry->GetURL()) : QUrl(); } QString WebContentsAdapter::getNavigationEntryTitle(int index) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(QString()); - content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index); + content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index); return entry ? toQt(entry->GetTitle()) : QString(); } QDateTime WebContentsAdapter::getNavigationEntryTimestamp(int index) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(QDateTime()); - content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index); + content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index); return entry ? toQt(entry->GetTimestamp()) : QDateTime(); } QUrl WebContentsAdapter::getNavigationEntryIconUrl(int index) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(QUrl()); - content::NavigationEntry *entry = d->webContents->GetController().GetEntryAtIndex(index); + content::NavigationEntry *entry = m_webContents->GetController().GetEntryAtIndex(index); if (!entry) return QUrl(); content::FaviconStatus favicon = entry->GetFavicon(); @@ -902,61 +852,54 @@ QUrl WebContentsAdapter::getNavigationEntryIconUrl(int index) void WebContentsAdapter::clearNavigationHistory() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - if (d->webContents->GetController().CanPruneAllButLastCommitted()) - d->webContents->GetController().PruneAllButLastCommitted(); + if (m_webContents->GetController().CanPruneAllButLastCommitted()) + m_webContents->GetController().PruneAllButLastCommitted(); } void WebContentsAdapter::serializeNavigationHistory(QDataStream &output) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - QtWebEngineCore::serializeNavigationHistory(d->webContents->GetController(), output); + QtWebEngineCore::serializeNavigationHistory(m_webContents->GetController(), output); } void WebContentsAdapter::setZoomFactor(qreal factor) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); if (factor < content::kMinimumZoomFactor || factor > content::kMaximumZoomFactor) return; double zoomLevel = content::ZoomFactorToZoomLevel(static_cast<double>(factor)); - content::HostZoomMap *zoomMap = content::HostZoomMap::GetForWebContents(d->webContents.get()); + content::HostZoomMap *zoomMap = content::HostZoomMap::GetForWebContents(m_webContents.get()); if (zoomMap) { - int render_process_id = d->webContents->GetMainFrame()->GetProcess()->GetID(); - int render_view_id = d->webContents->GetRenderViewHost()->GetRoutingID(); + int render_process_id = m_webContents->GetMainFrame()->GetProcess()->GetID(); + int render_view_id = m_webContents->GetRenderViewHost()->GetRoutingID(); zoomMap->SetTemporaryZoomLevel(render_process_id, render_view_id, zoomLevel); } } qreal WebContentsAdapter::currentZoomFactor() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(1); - return content::ZoomLevelToZoomFactor(content::HostZoomMap::GetZoomLevel(d->webContents.get())); + return content::ZoomLevelToZoomFactor(content::HostZoomMap::GetZoomLevel(m_webContents.get())); } BrowserContextQt* WebContentsAdapter::browserContext() { - Q_D(WebContentsAdapter); - return d->browserContextAdapter ? d->browserContextAdapter->browserContext() : d->webContents ? static_cast<BrowserContextQt*>(d->webContents->GetBrowserContext()) : 0; + return m_browserContextAdapter ? m_browserContextAdapter->browserContext() : m_webContents ? static_cast<BrowserContextQt*>(m_webContents->GetBrowserContext()) : 0; } BrowserContextAdapter* WebContentsAdapter::browserContextAdapter() { - Q_D(WebContentsAdapter); - return d->browserContextAdapter ? d->browserContextAdapter.data() : d->webContents ? static_cast<BrowserContextQt*>(d->webContents->GetBrowserContext())->adapter() : 0; + return m_browserContextAdapter ? m_browserContextAdapter.data() : m_webContents ? static_cast<BrowserContextQt*>(m_webContents->GetBrowserContext())->adapter() : 0; } #ifndef QT_NO_ACCESSIBILITY QAccessibleInterface *WebContentsAdapter::browserAccessible() { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(nullptr); - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); Q_ASSERT(rvh); content::BrowserAccessibilityManager *manager = static_cast<content::RenderFrameHostImpl*>(rvh->GetMainFrame())->GetOrCreateBrowserAccessibilityManager(); if (!manager) // FIXME! @@ -969,100 +912,92 @@ QAccessibleInterface *WebContentsAdapter::browserAccessible() void WebContentsAdapter::runJavaScript(const QString &javaScript, quint32 worldId) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); Q_ASSERT(rvh); if (worldId == 0) { rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript)); return; } - content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, d->adapterClient, CallbackDirectory::NoCallbackId); + content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, m_adapterClient, CallbackDirectory::NoCallbackId); rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), callback, worldId); } quint64 WebContentsAdapter::runJavaScriptCallbackResult(const QString &javaScript, quint32 worldId) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(0); - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); Q_ASSERT(rvh); - content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, d->adapterClient, d->nextRequestId); + content::RenderFrameHost::JavaScriptResultCallback callback = base::Bind(&callbackOnEvaluateJS, m_adapterClient, m_nextRequestId); if (worldId == 0) rvh->GetMainFrame()->ExecuteJavaScript(toString16(javaScript), callback); else rvh->GetMainFrame()->ExecuteJavaScriptInIsolatedWorld(toString16(javaScript), callback, worldId); - return d->nextRequestId++; + return m_nextRequestId++; } quint64 WebContentsAdapter::fetchDocumentMarkup() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(0); - d->renderViewObserverHost->fetchDocumentMarkup(d->nextRequestId); - return d->nextRequestId++; + m_renderViewObserverHost->fetchDocumentMarkup(m_nextRequestId); + return m_nextRequestId++; } quint64 WebContentsAdapter::fetchDocumentInnerText() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(0); - d->renderViewObserverHost->fetchDocumentInnerText(d->nextRequestId); - return d->nextRequestId++; + m_renderViewObserverHost->fetchDocumentInnerText(m_nextRequestId); + return m_nextRequestId++; } quint64 WebContentsAdapter::findText(const QString &subString, bool caseSensitively, bool findBackward) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(0); - if (d->lastFindRequestId > d->webContentsDelegate->lastReceivedFindReply()) { + if (m_lastFindRequestId > m_webContentsDelegate->lastReceivedFindReply()) { // There are cases where the render process will overwrite a previous request // with the new search and we'll have a dangling callback, leaving the application // waiting for it forever. // Assume that any unfinished find has been unsuccessful when a new one is started // to cover that case. - d->adapterClient->didFindText(d->lastFindRequestId, 0); + m_adapterClient->didFindText(m_lastFindRequestId, 0); } blink::WebFindOptions options; options.forward = !findBackward; options.match_case = caseSensitively; - options.find_next = subString == d->webContentsDelegate->lastSearchedString(); - d->webContentsDelegate->setLastSearchedString(subString); + options.find_next = subString == m_webContentsDelegate->lastSearchedString(); + m_webContentsDelegate->setLastSearchedString(subString); // Find already allows a request ID as input, but only as an int. // Use the same counter but mod it to MAX_INT, this keeps the same likeliness of request ID clashing. - int shrunkRequestId = d->nextRequestId++ & 0x7fffffff; - d->webContents->Find(shrunkRequestId, toString16(subString), options); - d->lastFindRequestId = shrunkRequestId; + int shrunkRequestId = m_nextRequestId++ & 0x7fffffff; + m_webContents->Find(shrunkRequestId, toString16(subString), options); + m_lastFindRequestId = shrunkRequestId; return shrunkRequestId; } void WebContentsAdapter::stopFinding() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContentsDelegate->setLastSearchedString(QString()); - d->webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION); + m_webContentsDelegate->setLastSearchedString(QString()); + m_webContents->StopFinding(content::STOP_FIND_ACTION_KEEP_SELECTION); } void WebContentsAdapter::updateWebPreferences(const content::WebPreferences & webPreferences) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences); + m_webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences); } void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileName, const QUrl &referrerUrl, ReferrerPolicy referrerPolicy) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - content::BrowserContext *bctx = webContents()->GetBrowserContext(); + content::BrowserContext *bctx = m_webContents->GetBrowserContext(); content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx); - DownloadManagerDelegateQt *dlmd = d->browserContextAdapter->downloadManagerDelegate(); + DownloadManagerDelegateQt *dlmd = m_browserContextAdapter->downloadManagerDelegate(); if (!dlm) return; @@ -1105,30 +1040,26 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN bool WebContentsAdapter::isAudioMuted() const { - const Q_D(WebContentsAdapter); CHECK_INITIALIZED(false); - return d->webContents->IsAudioMuted(); + return m_webContents->IsAudioMuted(); } void WebContentsAdapter::setAudioMuted(bool muted) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->SetAudioMuted(muted); + m_webContents->SetAudioMuted(muted); } bool WebContentsAdapter::recentlyAudible() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(false); - return d->webContents->WasRecentlyAudible(); + return m_webContents->WasRecentlyAudible(); } void WebContentsAdapter::copyImageAt(const QPoint &location) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y()); + m_webContents->GetRenderViewHost()->GetMainFrame()->CopyImageAt(location.x(), location.y()); } ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerNoAction, blink::WebMediaPlayerAction::kUnknown) @@ -1139,105 +1070,94 @@ ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerControls, blink::WebMediaPlay void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); blink::WebMediaPlayerAction blinkAction((blink::WebMediaPlayerAction::Type)action, enable); - d->webContents->GetRenderViewHost()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction); + m_webContents->GetRenderViewHost()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction); } void WebContentsAdapter::inspectElementAt(const QPoint &location) { - Q_D(WebContentsAdapter); Q_ASSERT(isInitialized()); - if (d->devToolsFrontend) { - d->devToolsFrontend->InspectElementAt(location.x(), location.y()); + if (m_devToolsFrontend) { + m_devToolsFrontend->InspectElementAt(location.x(), location.y()); return; } - if (content::DevToolsAgentHost::HasFor(d->webContents.get())) - content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->InspectElement(nullptr, location.x(), location.y()); + if (content::DevToolsAgentHost::HasFor(m_webContents.get())) + content::DevToolsAgentHost::GetOrCreateFor(m_webContents.get())->InspectElement(nullptr, location.x(), location.y()); } bool WebContentsAdapter::hasInspector() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(false); - if (d->devToolsFrontend) + if (m_devToolsFrontend) return true; - if (content::DevToolsAgentHost::HasFor(d->webContents.get())) - return content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->IsAttached(); + if (content::DevToolsAgentHost::HasFor(m_webContents.get())) + return content::DevToolsAgentHost::GetOrCreateFor(m_webContents.get())->IsAttached(); return false; } void WebContentsAdapter::openDevToolsFrontend(QSharedPointer<WebContentsAdapter> frontendAdapter) { - Q_D(WebContentsAdapter); Q_ASSERT(isInitialized()); - if (d->devToolsFrontend && frontendAdapter->webContents() && - d->devToolsFrontend->frontendDelegate() == frontendAdapter->webContents()->GetDelegate()) + if (m_devToolsFrontend && frontendAdapter->webContents() && + m_devToolsFrontend->frontendDelegate() == frontendAdapter->webContents()->GetDelegate()) return; - if (d->devToolsFrontend) { - d->devToolsFrontend->DisconnectFromTarget(); - d->devToolsFrontend->Close(); + if (m_devToolsFrontend) { + m_devToolsFrontend->DisconnectFromTarget(); + m_devToolsFrontend->Close(); } - d->devToolsFrontend = DevToolsFrontendQt::Show(frontendAdapter, d->webContents.get()); + m_devToolsFrontend = DevToolsFrontendQt::Show(frontendAdapter, m_webContents.get()); } void WebContentsAdapter::closeDevToolsFrontend() { - Q_D(WebContentsAdapter); - if (d->devToolsFrontend) { - d->devToolsFrontend->DisconnectFromTarget(); - d->devToolsFrontend->Close(); + if (m_devToolsFrontend) { + m_devToolsFrontend->DisconnectFromTarget(); + m_devToolsFrontend->Close(); } } void WebContentsAdapter::devToolsFrontendDestroyed(DevToolsFrontendQt *frontend) { - Q_D(WebContentsAdapter); - Q_ASSERT(frontend == d->devToolsFrontend); + Q_ASSERT(frontend == m_devToolsFrontend); Q_UNUSED(frontend); - d->devToolsFrontend = nullptr; + m_devToolsFrontend = nullptr; } void WebContentsAdapter::exitFullScreen() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->ExitFullscreen(false); + m_webContents->ExitFullscreen(false); } void WebContentsAdapter::changedFullScreen() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->NotifyFullscreenChanged(false); + m_webContents->NotifyFullscreenChanged(false); } void WebContentsAdapter::wasShown() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->WasShown(); + m_webContents->WasShown(); } void WebContentsAdapter::wasHidden() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->WasHidden(); + m_webContents->WasHidden(); } void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString &filePath) { #if BUILDFLAG(ENABLE_BASIC_PRINTING) - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); PrintViewManagerQt::PrintToPDFFileCallback callback = base::Bind(&callbackOnPdfSavingFinished, - d->adapterClient, + m_adapterClient, filePath); - PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFFileWithCallback(pageLayout, + PrintViewManagerQt::FromWebContents(m_webContents.get())->PrintToPDFFileWithCallback(pageLayout, true, filePath, callback); @@ -1249,16 +1169,15 @@ quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayo bool useCustomMargins) { #if BUILDFLAG(ENABLE_BASIC_PRINTING) - Q_D(WebContentsAdapter); CHECK_INITIALIZED(0); PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished, - d->adapterClient, - d->nextRequestId); - PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(pageLayout, + m_adapterClient, + m_nextRequestId); + PrintViewManagerQt::FromWebContents(m_webContents.get())->PrintToPDFWithCallback(pageLayout, colorMode, useCustomMargins, callback); - return d->nextRequestId++; + return m_nextRequestId++; #else Q_UNUSED(pageLayout); Q_UNUSED(colorMode); @@ -1268,111 +1187,101 @@ quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayo QPointF WebContentsAdapter::lastScrollOffset() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(QPointF()); - if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView()) + if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView()) return toQt(rwhv->GetLastScrollOffset()); return QPointF(); } QSizeF WebContentsAdapter::lastContentsSize() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(QSizeF()); - if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(d->webContents->GetRenderWidgetHostView())) + if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) return toQt(rwhv->lastContentsSize()); return QSizeF(); } void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); // Let the permission manager remember the reply. if (flags & WebContentsAdapterClient::MediaAudioCapture) - d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::AudioCapturePermission, true); + m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::AudioCapturePermission, true); if (flags & WebContentsAdapterClient::MediaVideoCapture) - d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::VideoCapturePermission, true); - MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(d->webContents.get(), securityOrigin, flags); + m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::VideoCapturePermission, true); + MediaCaptureDevicesDispatcher::GetInstance()->handleMediaAccessPermissionResponse(m_webContents.get(), securityOrigin, flags); } void WebContentsAdapter::runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::GeolocationPermission, allowed); + m_browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::GeolocationPermission, allowed); } void WebContentsAdapter::grantMouseLockPermission(bool granted) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); if (granted) { - if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(d->webContents->GetRenderWidgetHostView())) + if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) rwhv->Focus(); else granted = false; } - d->webContents->GotResponseToLockMouseRequest(granted); + m_webContents->GotResponseToLockMouseRequest(granted); } void WebContentsAdapter::dpiScaleChanged() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); content::RenderWidgetHostImpl* impl = NULL; - if (d->webContents->GetRenderViewHost()) - impl = content::RenderWidgetHostImpl::From(d->webContents->GetRenderViewHost()->GetWidget()); + if (m_webContents->GetRenderViewHost()) + impl = content::RenderWidgetHostImpl::From(m_webContents->GetRenderViewHost()->GetWidget()); if (impl) impl->NotifyScreenInfoChanged(); } void WebContentsAdapter::backgroundColorChanged() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView()) - rwhv->SetBackgroundColor(toSk(d->adapterClient->backgroundColor())); + if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView()) + rwhv->SetBackgroundColor(toSk(m_adapterClient->backgroundColor())); } content::WebContents *WebContentsAdapter::webContents() const { - Q_D(const WebContentsAdapter); - return d->webContents.get(); + return m_webContents.get(); } QWebChannel *WebContentsAdapter::webChannel() const { - Q_D(const WebContentsAdapter); - return d->webChannel; + return m_webChannel; } void WebContentsAdapter::setWebChannel(QWebChannel *channel, uint worldId) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - if (d->webChannel == channel && d->webChannelWorld == worldId) + if (m_webChannel == channel && m_webChannelWorld == worldId) return; - if (!d->webChannelTransport.get()) - d->webChannelTransport.reset(new WebChannelIPCTransportHost(d->webContents.get(), worldId)); + if (!m_webChannelTransport.get()) + m_webChannelTransport.reset(new WebChannelIPCTransportHost(m_webContents.get(), worldId)); else { - if (d->webChannel != channel) - d->webChannel->disconnectFrom(d->webChannelTransport.get()); - if (d->webChannelWorld != worldId) - d->webChannelTransport->setWorldId(worldId); + if (m_webChannel != channel) + m_webChannel->disconnectFrom(m_webChannelTransport.get()); + if (m_webChannelWorld != worldId) + m_webChannelTransport->setWorldId(worldId); } - d->webChannel = channel; - d->webChannelWorld = worldId; + m_webChannel = channel; + m_webChannelWorld = worldId; if (!channel) { - d->webChannelTransport.reset(); + m_webChannelTransport.reset(); return; } - channel->connectTo(d->webChannelTransport.get()); + channel->connectTo(m_webChannelTransport.get()); } #if QT_CONFIG(draganddrop) @@ -1409,20 +1318,19 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD Qt::DropActions allowedActions, const QPixmap &pixmap, const QPoint &offset) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - if (d->currentDropData) + if (m_currentDropData) return; // Clear certain fields of the drop data to not run into DCHECKs // of DropDataToWebDragData in render_view_impl.cc. - d->currentDropData.reset(new content::DropData(dropData)); - d->currentDropData->download_metadata.clear(); - d->currentDropData->file_contents.clear(); - d->currentDropData->file_contents_content_disposition.clear(); + m_currentDropData.reset(new content::DropData(dropData)); + m_currentDropData->download_metadata.clear(); + m_currentDropData->file_contents.clear(); + m_currentDropData->file_contents_content_disposition.clear(); - d->currentDropAction = blink::kWebDragOperationNone; + m_currentDropAction = blink::kWebDragOperationNone; QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation bool dValid = true; QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){ @@ -1430,7 +1338,7 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD QDrag::cancel(); }); - QMimeData *mimeData = mimeDataFromDropData(*d->currentDropData); + QMimeData *mimeData = mimeDataFromDropData(*m_currentDropData); if (handleDropDataFileContents(dropData, mimeData)) allowedActions = Qt::MoveAction; @@ -1447,16 +1355,16 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD QObject::disconnect(onDestroyed); if (dValid) { - if (d->webContents) { - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); + if (m_webContents) { + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); if (rvh) { - rvh->GetWidget()->DragSourceEndedAt(gfx::PointF(d->lastDragClientPos.x(), d->lastDragClientPos.y()), - gfx::PointF(d->lastDragScreenPos.x(), d->lastDragScreenPos.y()), - d->currentDropAction); + rvh->GetWidget()->DragSourceEndedAt(gfx::PointF(m_lastDragClientPos.x(), m_lastDragClientPos.y()), + gfx::PointF(m_lastDragScreenPos.x(), m_lastDragScreenPos.y()), + blink::WebDragOperation(m_currentDropAction)); rvh->GetWidget()->DragSourceSystemDragEnded(); } } - d->currentDropData.reset(); + m_currentDropData.reset(); } } @@ -1467,11 +1375,10 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro if (dropData.file_contents.empty()) return false; - Q_D(WebContentsAdapter); - if (!d->dndTmpDir) { - d->dndTmpDir.reset(new QTemporaryDir); - if (!d->dndTmpDir->isValid()) { - d->dndTmpDir.reset(); + if (!m_dndTmpDir) { + m_dndTmpDir.reset(new QTemporaryDir); + if (!m_dndTmpDir->isValid()) { + m_dndTmpDir.reset(); return false; } } @@ -1479,9 +1386,9 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro const auto maybeFilename = dropData.GetSafeFilenameForImageFileContents(); const QString fileName = maybeFilename ? toQt(maybeFilename->AsUTF16Unsafe()) : QString(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) - const QString &filePath = d->dndTmpDir->filePath(fileName); + const QString &filePath = m_dndTmpDir->filePath(fileName); #else - const QString &filePath = d->dndTmpDir->path() + QLatin1Char('/') + fileName; + const QString &filePath = m_dndTmpDir->path() + QLatin1Char('/') + fileName; #endif QFile file(filePath); if (!file.open(QIODevice::WriteOnly)) { @@ -1519,18 +1426,17 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPointF &screenPos) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - if (!d->currentDropData) { + if (!m_currentDropData) { // The drag originated outside the WebEngineView. - d->currentDropData.reset(new content::DropData); - fillDropDataFromMimeData(d->currentDropData.get(), e->mimeData()); + m_currentDropData.reset(new content::DropData); + fillDropDataFromMimeData(m_currentDropData.get(), e->mimeData()); } - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - rvh->GetWidget()->FilterDropData(d->currentDropData.get()); - rvh->GetWidget()->DragTargetDragEnter(*d->currentDropData, toGfx(e->posF()), toGfx(screenPos), + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); + rvh->GetWidget()->FilterDropData(m_currentDropData.get()); + rvh->GetWidget()->DragTargetDragEnter(*m_currentDropData, toGfx(e->posF()), toGfx(screenPos), toWeb(e->possibleActions()), flagsFromModifiers(e->keyboardModifiers())); } @@ -1574,30 +1480,28 @@ static int toWeb(Qt::KeyboardModifiers modifiers) Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const QPointF &screenPos) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(Qt::DropAction()); - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - d->lastDragClientPos = toGfx(e->posF()); - d->lastDragScreenPos = toGfx(screenPos); - rvh->GetWidget()->DragTargetDragOver(d->lastDragClientPos, d->lastDragScreenPos, toWeb(e->possibleActions()), + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); + m_lastDragClientPos = e->posF(); + m_lastDragScreenPos = screenPos; + rvh->GetWidget()->DragTargetDragOver(toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), toWeb(e->possibleActions()), toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers())); waitForUpdateDragActionCalled(); - return toQt(d->currentDropAction); + return toQt(blink::WebDragOperation(m_currentDropAction)); } void WebContentsAdapter::waitForUpdateDragActionCalled() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); const qint64 timeout = 3000; QElapsedTimer t; t.start(); base::MessagePump::Delegate *delegate = base::MessageLoop::current(); DCHECK(delegate); - d->updateDragActionCalled = false; + m_updateDragActionCalled = false; for (;;) { - while (delegate->DoWork() && !d->updateDragActionCalled) {} - if (d->updateDragActionCalled) + while (delegate->DoWork() && !m_updateDragActionCalled) {} + if (m_updateDragActionCalled) break; if (t.hasExpired(timeout)) { qWarning("WebContentsAdapter::updateDragAction was not called within %d ms.", @@ -1610,58 +1514,52 @@ void WebContentsAdapter::waitForUpdateDragActionCalled() void WebContentsAdapter::updateDragAction(int action) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->updateDragActionCalled = true; - d->currentDropAction = static_cast<blink::WebDragOperation>(action); + m_updateDragActionCalled = true; + m_currentDropAction = static_cast<blink::WebDragOperation>(action); } void WebContentsAdapter::endDragging(const QPointF &clientPos, const QPointF &screenPos) { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - rvh->GetWidget()->FilterDropData(d->currentDropData.get()); - d->lastDragClientPos = toGfx(clientPos); - d->lastDragScreenPos = toGfx(screenPos); - rvh->GetWidget()->DragTargetDrop(*d->currentDropData, d->lastDragClientPos, d->lastDragScreenPos, 0); - d->currentDropData.reset(); + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); + rvh->GetWidget()->FilterDropData(m_currentDropData.get()); + m_lastDragClientPos = clientPos; + m_lastDragScreenPos = screenPos; + rvh->GetWidget()->DragTargetDrop(*m_currentDropData, toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), 0); + m_currentDropData.reset(); } void WebContentsAdapter::leaveDrag() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - rvh->GetWidget()->DragTargetDragLeave(d->lastDragClientPos, d->lastDragScreenPos); - d->currentDropData.reset(); + content::RenderViewHost *rvh = m_webContents->GetRenderViewHost(); + rvh->GetWidget()->DragTargetDragLeave(toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos)); + m_currentDropData.reset(); } #endif // QT_CONFIG(draganddrop) void WebContentsAdapter::replaceMisspelling(const QString &word) { #if BUILDFLAG(ENABLE_SPELLCHECK) - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->ReplaceMisspelling(toString16(word)); + m_webContents->ReplaceMisspelling(toString16(word)); #endif } void WebContentsAdapter::focusIfNecessary() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - const WebEngineSettings *settings = d->adapterClient->webEngineSettings(); + const WebEngineSettings *settings = m_adapterClient->webEngineSettings(); bool focusOnNavigation = settings->testAttribute(WebEngineSettings::FocusOnNavigationEnabled); if (focusOnNavigation) - d->webContents->Focus(); + m_webContents->Focus(); } bool WebContentsAdapter::isFindTextInProgress() const { - Q_D(const WebContentsAdapter); CHECK_INITIALIZED(false); - return d->lastFindRequestId != d->webContentsDelegate->lastReceivedFindReply(); + return m_lastFindRequestId != m_webContentsDelegate->lastReceivedFindReply(); } WebContentsAdapterClient::RenderProcessTerminationStatus @@ -1698,23 +1596,20 @@ WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) { FaviconManager *WebContentsAdapter::faviconManager() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(nullptr); - return d->webContentsDelegate->faviconManager(); + return m_webContentsDelegate->faviconManager(); } void WebContentsAdapter::viewSource() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(); - d->webContents->GetMainFrame()->ViewSource(); + m_webContents->GetMainFrame()->ViewSource(); } bool WebContentsAdapter::canViewSource() { - Q_D(WebContentsAdapter); CHECK_INITIALIZED(false); - return d->webContents->GetController().CanViewSource(); + return m_webContents->GetController().CanViewSource(); } ASSERT_ENUMS_MATCH(WebContentsAdapterClient::UnknownDisposition, WindowOpenDisposition::UNKNOWN) diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 111100bba..794ed867b 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -42,6 +42,7 @@ #include "qtwebenginecoreglobal.h" #include "web_contents_adapter_client.h" +#include <memory> #include <QtGui/qtgui-config.h> #include <QtWebEngineCore/qwebenginehttprequest.h> @@ -64,6 +65,7 @@ class QDragMoveEvent; class QMimeData; class QPageLayout; class QString; +class QTemporaryDir; class QWebChannel; QT_END_NAMESPACE @@ -72,8 +74,10 @@ namespace QtWebEngineCore { class BrowserContextQt; class DevToolsFrontendQt; class MessagePassingInterface; -class WebContentsAdapterPrivate; class FaviconManager; +class WebEngineContext; +class RenderViewObserverHostQt; +class WebChannelIPCTransportHost; class QWEBENGINE_EXPORT WebContentsAdapter : public QEnableSharedFromThis<WebContentsAdapter> { public: @@ -208,11 +212,26 @@ public: private: Q_DISABLE_COPY(WebContentsAdapter) - Q_DECLARE_PRIVATE(WebContentsAdapter) void waitForUpdateDragActionCalled(); bool handleDropDataFileContents(const content::DropData &dropData, QMimeData *mimeData); - QScopedPointer<WebContentsAdapterPrivate> d_ptr; + QSharedPointer<BrowserContextAdapter> m_browserContextAdapter; + std::unique_ptr<content::WebContents> m_webContents; + std::unique_ptr<WebContentsDelegateQt> m_webContentsDelegate; + std::unique_ptr<RenderViewObserverHostQt> m_renderViewObserverHost; + std::unique_ptr<WebChannelIPCTransportHost> m_webChannelTransport; + QWebChannel *m_webChannel; + unsigned int m_webChannelWorld; + WebContentsAdapterClient *m_adapterClient; + quint64 m_nextRequestId; + int m_lastFindRequestId; + std::unique_ptr<content::DropData> m_currentDropData; + uint m_currentDropAction; + bool m_updateDragActionCalled; + QPointF m_lastDragClientPos; + QPointF m_lastDragScreenPos; + std::unique_ptr<QTemporaryDir> m_dndTmpDir; + DevToolsFrontendQt *m_devToolsFrontend; }; } // namespace QtWebEngineCore diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h deleted file mode 100644 index 5b902fc94..000000000 --- a/src/core/web_contents_adapter_p.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WEB_CONTENTS_ADAPTER_P_H -#define WEB_CONTENTS_ADAPTER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "web_contents_adapter.h" - -#include "base/callback.h" -#include "base/memory/ref_counted.h" -#include "ui/gfx/geometry/point_f.h" -#include "third_party/WebKit/public/platform/WebDragOperation.h" - -#include <QScopedPointer> -#include <QSharedPointer> - -QT_FORWARD_DECLARE_CLASS(QTemporaryDir) -QT_FORWARD_DECLARE_CLASS(QWebChannel) - -class WebEngineContext; - -namespace content { -struct DropData; -} - -namespace QtWebEngineCore { - -class BrowserContextAdapter; -class DevToolsFrontendQt; -class RenderViewObserverHostQt; -class WebChannelIPCTransportHost; -class WebContentsAdapterClient; -class WebContentsDelegateQt; -class WebEngineContext; - -class WebContentsAdapterPrivate { -public: - WebContentsAdapterPrivate(); - ~WebContentsAdapterPrivate(); - scoped_refptr<WebEngineContext> engineContext; - QSharedPointer<BrowserContextAdapter> browserContextAdapter; - std::unique_ptr<content::WebContents> webContents; - std::unique_ptr<WebContentsDelegateQt> webContentsDelegate; - std::unique_ptr<RenderViewObserverHostQt> renderViewObserverHost; - std::unique_ptr<WebChannelIPCTransportHost> webChannelTransport; - QWebChannel *webChannel; - unsigned int webChannelWorld; - WebContentsAdapterClient *adapterClient; - quint64 nextRequestId; - int lastFindRequestId; - std::unique_ptr<content::DropData> currentDropData; - blink::WebDragOperation currentDropAction; - bool updateDragActionCalled; - gfx::PointF lastDragClientPos; - gfx::PointF lastDragScreenPos; - std::unique_ptr<QTemporaryDir> dndTmpDir; - DevToolsFrontendQt *devToolsFrontend; -}; - -} // namespace QtWebEngineCore - -#endif // WEB_CONTENTS_ADAPTER_P_H diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 7f3ced8aa..fe1f6fee0 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -48,7 +48,6 @@ #include "color_chooser_qt.h" #include "color_chooser_controller.h" #include "favicon_manager.h" -#include "favicon_manager_p.h" #include "file_picker_controller.h" #include "media_capture_devices_dispatcher.h" #include "net/network_delegate_qt.h" @@ -57,8 +56,8 @@ #include "render_widget_host_view_qt.h" #include "type_conversion.h" #include "visited_links_manager_qt.h" +#include "web_contents_adapter.h" #include "web_contents_adapter_client.h" -#include "web_contents_adapter_p.h" #include "web_engine_context.h" #include "web_engine_settings.h" @@ -100,7 +99,7 @@ static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptCo WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents *webContents, WebContentsAdapterClient *adapterClient) : m_viewClient(adapterClient) , m_lastReceivedFindReply(0) - , m_faviconManager(new FaviconManager(new FaviconManagerPrivate(webContents, adapterClient))) + , m_faviconManager(new FaviconManager(webContents, adapterClient)) , m_lastLoadProgress(-1) { webContents->SetDelegate(this); |