From 8af33b19f8f24f49a0ca8ef5c8097757103e5253 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 10 Sep 2015 11:36:08 +0200 Subject: Use web_cache component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the web_cache component which monitors and adjusts the web cache, so that the memory use is limited across multiple renderer processes. Change-Id: I9faa060d48f99a3c527fe0e0963bbe86db4b502c Reviewed-by: Joerg Bornemann Reviewed-by: Michael BrĂ¼ning --- src/core/renderer/content_renderer_client_qt.cpp | 5 ++++- src/core/renderer/content_renderer_client_qt.h | 5 +++++ src/core/renderer/qt_render_view_observer.cpp | 12 +++++++++++- src/core/renderer/qt_render_view_observer.h | 10 +++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src/core/renderer') diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 72ca29be9..e281cbc95 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -40,6 +40,7 @@ #include "chrome/common/localized_error.h" #include "components/error_page/common/error_page_params.h" #include "components/visitedlink/renderer/visitedlink_slave.h" +#include "components/web_cache/renderer/web_cache_render_process_observer.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view.h" @@ -77,7 +78,9 @@ void ContentRendererClientQt::RenderThreadStarted() content::RenderThread *renderThread = content::RenderThread::Get(); renderThread->RegisterExtension(WebChannelIPCTransport::getV8Extension()); m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); + m_webCacheObserver.reset(new web_cache::WebCacheRenderProcessObserver()); renderThread->AddObserver(m_visitedLinkSlave.data()); + renderThread->AddObserver(m_webCacheObserver.data()); renderThread->AddObserver(UserScriptController::instance()); // mark qrc as a secure scheme (avoids deprecation warnings) @@ -87,7 +90,7 @@ void ContentRendererClientQt::RenderThreadStarted() void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view) { // RenderViewObservers destroy themselves with their RenderView. - new QtRenderViewObserver(render_view); + new QtRenderViewObserver(render_view, m_webCacheObserver.data()); new WebChannelIPCTransport(render_view); UserScriptController::instance()->renderViewCreated(render_view); } diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index fab88441f..eb55156ad 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -45,6 +45,10 @@ namespace visitedlink { class VisitedLinkSlave; } +namespace web_cache { +class WebCacheRenderProcessObserver; +} + namespace QtWebEngineCore { class ContentRendererClientQt : public content::ContentRendererClient { @@ -64,6 +68,7 @@ public: private: QScopedPointer m_visitedLinkSlave; + QScopedPointer m_webCacheObserver; }; } // namespace diff --git a/src/core/renderer/qt_render_view_observer.cpp b/src/core/renderer/qt_render_view_observer.cpp index ba91e54ae..086b07d17 100644 --- a/src/core/renderer/qt_render_view_observer.cpp +++ b/src/core/renderer/qt_render_view_observer.cpp @@ -38,14 +38,18 @@ #include "common/qt_messages.h" +#include "components/web_cache/renderer/web_cache_render_process_observer.h" #include "content/public/renderer/render_view.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebElement.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebView.h" -QtRenderViewObserver::QtRenderViewObserver(content::RenderView* render_view) +QtRenderViewObserver::QtRenderViewObserver( + content::RenderView* render_view, + web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer) : content::RenderViewObserver(render_view) + , m_web_cache_render_process_observer(web_cache_render_process_observer) { } @@ -86,3 +90,9 @@ bool QtRenderViewObserver::OnMessageReceived(const IPC::Message& message) IPC_END_MESSAGE_MAP() return handled; } + +void QtRenderViewObserver::Navigate(const GURL &) +{ + if (m_web_cache_render_process_observer) + m_web_cache_render_process_observer->ExecutePendingClearCache(); +} diff --git a/src/core/renderer/qt_render_view_observer.h b/src/core/renderer/qt_render_view_observer.h index 3f7829a92..1ead53141 100644 --- a/src/core/renderer/qt_render_view_observer.h +++ b/src/core/renderer/qt_render_view_observer.h @@ -40,9 +40,14 @@ #include +namespace web_cache { +class WebCacheRenderProcessObserver; +} + class QtRenderViewObserver : public content::RenderViewObserver { public: - QtRenderViewObserver(content::RenderView* render_view); + QtRenderViewObserver(content::RenderView* render_view, + web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer); private: void onFetchDocumentMarkup(quint64 requestId); @@ -52,6 +57,9 @@ private: void OnFirstVisuallyNonEmptyLayout() Q_DECL_OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) Q_DECL_OVERRIDE; + virtual void Navigate(const GURL& url) Q_DECL_OVERRIDE; + + web_cache::WebCacheRenderProcessObserver* m_web_cache_render_process_observer; DISALLOW_COPY_AND_ASSIGN(QtRenderViewObserver); }; -- cgit v1.2.3 From cfee452174c58fe4048b1604503d03de2764fc8e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 28 Oct 2015 13:23:12 +0100 Subject: Use consistent naming of Qt-specific Chromium classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of our Qt specific versions of Chromium classes have Qt appended, but a few observers have it prepended. This patch renames them to keep naming consistent. Change-Id: I004b61e16bc47f39a6bbc16a5f5c10585626865c Reviewed-by: Michael BrĂ¼ning --- src/core/renderer/content_renderer_client_qt.cpp | 8 +- src/core/renderer/qt_render_frame_observer.cpp | 65 ---------------- src/core/renderer/qt_render_frame_observer.h | 66 ---------------- src/core/renderer/qt_render_view_observer.cpp | 98 ------------------------ src/core/renderer/qt_render_view_observer.h | 67 ---------------- src/core/renderer/render_frame_observer_qt.cpp | 65 ++++++++++++++++ src/core/renderer/render_frame_observer_qt.h | 66 ++++++++++++++++ src/core/renderer/render_view_observer_qt.cpp | 98 ++++++++++++++++++++++++ src/core/renderer/render_view_observer_qt.h | 67 ++++++++++++++++ 9 files changed, 300 insertions(+), 300 deletions(-) delete mode 100644 src/core/renderer/qt_render_frame_observer.cpp delete mode 100644 src/core/renderer/qt_render_frame_observer.h delete mode 100644 src/core/renderer/qt_render_view_observer.cpp delete mode 100644 src/core/renderer/qt_render_view_observer.h create mode 100644 src/core/renderer/render_frame_observer_qt.cpp create mode 100644 src/core/renderer/render_frame_observer_qt.h create mode 100644 src/core/renderer/render_view_observer_qt.cpp create mode 100644 src/core/renderer/render_view_observer_qt.h (limited to 'src/core/renderer') diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index e281cbc95..261b9c581 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -54,8 +54,8 @@ #include "content/public/common/web_preferences.h" #include "renderer/web_channel_ipc_transport.h" -#include "renderer/qt_render_frame_observer.h" -#include "renderer/qt_render_view_observer.h" +#include "renderer/render_frame_observer_qt.h" +#include "renderer/render_view_observer_qt.h" #include "renderer/user_script_controller.h" #include "grit/renderer_resources.h" @@ -90,14 +90,14 @@ void ContentRendererClientQt::RenderThreadStarted() void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view) { // RenderViewObservers destroy themselves with their RenderView. - new QtRenderViewObserver(render_view, m_webCacheObserver.data()); + new RenderViewObserverQt(render_view, m_webCacheObserver.data()); new WebChannelIPCTransport(render_view); UserScriptController::instance()->renderViewCreated(render_view); } void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame) { - new QtWebEngineCore::QtRenderFrameObserver(render_frame); + new QtWebEngineCore::RenderFrameObserverQt(render_frame); } bool ContentRendererClientQt::HasErrorPage(int httpStatusCode, std::string *errorDomain) diff --git a/src/core/renderer/qt_render_frame_observer.cpp b/src/core/renderer/qt_render_frame_observer.cpp deleted file mode 100644 index 5f06d1e4e..000000000 --- a/src/core/renderer/qt_render_frame_observer.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.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 "qt_render_frame_observer.h" - -#include "content/public/renderer/renderer_ppapi_host.h" -#include "ppapi/host/ppapi_host.h" - -#include "renderer/pepper/pepper_renderer_host_factory_qt.h" -#include "renderer/pepper/pepper_flash_renderer_host_qt.h" - -namespace QtWebEngineCore { - -QtRenderFrameObserver::QtRenderFrameObserver(content::RenderFrame* render_frame) - : RenderFrameObserver(render_frame) -{ -} - -QtRenderFrameObserver::~QtRenderFrameObserver() -{ -} - -#if defined(ENABLE_PLUGINS) -void QtRenderFrameObserver::DidCreatePepperPlugin(content::RendererPpapiHost* host) -{ - host->GetPpapiHost()->AddHostFactoryFilter( - scoped_ptr( - new PepperRendererHostFactoryQt(host))); -} -#endif - -} // namespace QtWebEngineCore diff --git a/src/core/renderer/qt_render_frame_observer.h b/src/core/renderer/qt_render_frame_observer.h deleted file mode 100644 index 42f2b7464..000000000 --- a/src/core/renderer/qt_render_frame_observer.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.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 QT_RENDER_FRAME_OBSERVER_H -#define QT_RENDER_FRAME_OBSERVER_H - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "content/public/renderer/render_frame_observer.h" - - -namespace content { -class RenderFrame; -} - -namespace QtWebEngineCore { - -class QtRenderFrameObserver : public content::RenderFrameObserver { -public: - explicit QtRenderFrameObserver(content::RenderFrame* render_frame); - ~QtRenderFrameObserver(); - -#if defined(ENABLE_PLUGINS) - void DidCreatePepperPlugin(content::RendererPpapiHost* host) override; -#endif - -private: - DISALLOW_COPY_AND_ASSIGN(QtRenderFrameObserver); -}; - -} // namespace QtWebEngineCore - -#endif // QT_RENDER_FRAME_OBSERVER_H diff --git a/src/core/renderer/qt_render_view_observer.cpp b/src/core/renderer/qt_render_view_observer.cpp deleted file mode 100644 index 086b07d17..000000000 --- a/src/core/renderer/qt_render_view_observer.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.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 "renderer/qt_render_view_observer.h" - -#include "common/qt_messages.h" - -#include "components/web_cache/renderer/web_cache_render_process_observer.h" -#include "content/public/renderer/render_view.h" -#include "third_party/WebKit/public/web/WebDocument.h" -#include "third_party/WebKit/public/web/WebElement.h" -#include "third_party/WebKit/public/web/WebFrame.h" -#include "third_party/WebKit/public/web/WebView.h" - -QtRenderViewObserver::QtRenderViewObserver( - content::RenderView* render_view, - web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer) - : content::RenderViewObserver(render_view) - , m_web_cache_render_process_observer(web_cache_render_process_observer) -{ -} - -void QtRenderViewObserver::onFetchDocumentMarkup(quint64 requestId) -{ - Send(new QtRenderViewObserverHost_DidFetchDocumentMarkup( - routing_id(), - requestId, - render_view()->GetWebView()->mainFrame()->contentAsMarkup())); -} - -void QtRenderViewObserver::onFetchDocumentInnerText(quint64 requestId) -{ - Send(new QtRenderViewObserverHost_DidFetchDocumentInnerText( - routing_id(), - requestId, - render_view()->GetWebView()->mainFrame()->contentAsText(std::numeric_limits::max()))); -} - -void QtRenderViewObserver::onSetBackgroundColor(quint32 color) -{ - render_view()->GetWebView()->setBaseBackgroundColor(color); -} - -void QtRenderViewObserver::OnFirstVisuallyNonEmptyLayout() -{ - Send(new QtRenderViewObserverHost_DidFirstVisuallyNonEmptyLayout(routing_id())); -} - -bool QtRenderViewObserver::OnMessageReceived(const IPC::Message& message) -{ - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(QtRenderViewObserver, message) - IPC_MESSAGE_HANDLER(QtRenderViewObserver_FetchDocumentMarkup, onFetchDocumentMarkup) - IPC_MESSAGE_HANDLER(QtRenderViewObserver_FetchDocumentInnerText, onFetchDocumentInnerText) - IPC_MESSAGE_HANDLER(QtRenderViewObserver_SetBackgroundColor, onSetBackgroundColor) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void QtRenderViewObserver::Navigate(const GURL &) -{ - if (m_web_cache_render_process_observer) - m_web_cache_render_process_observer->ExecutePendingClearCache(); -} diff --git a/src/core/renderer/qt_render_view_observer.h b/src/core/renderer/qt_render_view_observer.h deleted file mode 100644 index 1ead53141..000000000 --- a/src/core/renderer/qt_render_view_observer.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://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.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 QT_RENDER_VIEW_OBSERVER_H -#define QT_RENDER_VIEW_OBSERVER_H - -#include "content/public/renderer/render_view_observer.h" - -#include - -namespace web_cache { -class WebCacheRenderProcessObserver; -} - -class QtRenderViewObserver : public content::RenderViewObserver { -public: - QtRenderViewObserver(content::RenderView* render_view, - web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer); - -private: - void onFetchDocumentMarkup(quint64 requestId); - void onFetchDocumentInnerText(quint64 requestId); - void onSetBackgroundColor(quint32 color); - - void OnFirstVisuallyNonEmptyLayout() Q_DECL_OVERRIDE; - - virtual bool OnMessageReceived(const IPC::Message& message) Q_DECL_OVERRIDE; - virtual void Navigate(const GURL& url) Q_DECL_OVERRIDE; - - web_cache::WebCacheRenderProcessObserver* m_web_cache_render_process_observer; - - DISALLOW_COPY_AND_ASSIGN(QtRenderViewObserver); -}; - -#endif // QT_RENDER_VIEW_OBSERVER_H diff --git a/src/core/renderer/render_frame_observer_qt.cpp b/src/core/renderer/render_frame_observer_qt.cpp new file mode 100644 index 000000000..8130cc53a --- /dev/null +++ b/src/core/renderer/render_frame_observer_qt.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.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 "render_frame_observer_qt.h" + +#include "content/public/renderer/renderer_ppapi_host.h" +#include "ppapi/host/ppapi_host.h" + +#include "renderer/pepper/pepper_renderer_host_factory_qt.h" +#include "renderer/pepper/pepper_flash_renderer_host_qt.h" + +namespace QtWebEngineCore { + +RenderFrameObserverQt::RenderFrameObserverQt(content::RenderFrame* render_frame) + : RenderFrameObserver(render_frame) +{ +} + +RenderFrameObserverQt::~RenderFrameObserverQt() +{ +} + +#if defined(ENABLE_PLUGINS) +void RenderFrameObserverQt::DidCreatePepperPlugin(content::RendererPpapiHost* host) +{ + host->GetPpapiHost()->AddHostFactoryFilter( + scoped_ptr( + new PepperRendererHostFactoryQt(host))); +} +#endif + +} // namespace QtWebEngineCore diff --git a/src/core/renderer/render_frame_observer_qt.h b/src/core/renderer/render_frame_observer_qt.h new file mode 100644 index 000000000..4835e442e --- /dev/null +++ b/src/core/renderer/render_frame_observer_qt.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.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 RENDER_FRAME_OBSERVER_QT_H +#define RENDER_FRAME_OBSERVER_QT_H + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "content/public/renderer/render_frame_observer.h" + + +namespace content { +class RenderFrame; +} + +namespace QtWebEngineCore { + +class RenderFrameObserverQt : public content::RenderFrameObserver { +public: + explicit RenderFrameObserverQt(content::RenderFrame* render_frame); + ~RenderFrameObserverQt(); + +#if defined(ENABLE_PLUGINS) + void DidCreatePepperPlugin(content::RendererPpapiHost* host) override; +#endif + +private: + DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverQt); +}; + +} // namespace QtWebEngineCore + +#endif // RENDER_FRAME_OBSERVER_QT_H diff --git a/src/core/renderer/render_view_observer_qt.cpp b/src/core/renderer/render_view_observer_qt.cpp new file mode 100644 index 000000000..47efd07e4 --- /dev/null +++ b/src/core/renderer/render_view_observer_qt.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.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 "renderer/render_view_observer_qt.h" + +#include "common/qt_messages.h" + +#include "components/web_cache/renderer/web_cache_render_process_observer.h" +#include "content/public/renderer/render_view.h" +#include "third_party/WebKit/public/web/WebDocument.h" +#include "third_party/WebKit/public/web/WebElement.h" +#include "third_party/WebKit/public/web/WebFrame.h" +#include "third_party/WebKit/public/web/WebView.h" + +RenderViewObserverQt::RenderViewObserverQt( + content::RenderView* render_view, + web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer) + : content::RenderViewObserver(render_view) + , m_web_cache_render_process_observer(web_cache_render_process_observer) +{ +} + +void RenderViewObserverQt::onFetchDocumentMarkup(quint64 requestId) +{ + Send(new RenderViewObserverHostQt_DidFetchDocumentMarkup( + routing_id(), + requestId, + render_view()->GetWebView()->mainFrame()->contentAsMarkup())); +} + +void RenderViewObserverQt::onFetchDocumentInnerText(quint64 requestId) +{ + Send(new RenderViewObserverHostQt_DidFetchDocumentInnerText( + routing_id(), + requestId, + render_view()->GetWebView()->mainFrame()->contentAsText(std::numeric_limits::max()))); +} + +void RenderViewObserverQt::onSetBackgroundColor(quint32 color) +{ + render_view()->GetWebView()->setBaseBackgroundColor(color); +} + +void RenderViewObserverQt::OnFirstVisuallyNonEmptyLayout() +{ + Send(new RenderViewObserverHostQt_DidFirstVisuallyNonEmptyLayout(routing_id())); +} + +bool RenderViewObserverQt::OnMessageReceived(const IPC::Message& message) +{ + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(RenderViewObserverQt, message) + IPC_MESSAGE_HANDLER(RenderViewObserverQt_FetchDocumentMarkup, onFetchDocumentMarkup) + IPC_MESSAGE_HANDLER(RenderViewObserverQt_FetchDocumentInnerText, onFetchDocumentInnerText) + IPC_MESSAGE_HANDLER(RenderViewObserverQt_SetBackgroundColor, onSetBackgroundColor) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void RenderViewObserverQt::Navigate(const GURL &) +{ + if (m_web_cache_render_process_observer) + m_web_cache_render_process_observer->ExecutePendingClearCache(); +} diff --git a/src/core/renderer/render_view_observer_qt.h b/src/core/renderer/render_view_observer_qt.h new file mode 100644 index 000000000..166dcc9ea --- /dev/null +++ b/src/core/renderer/render_view_observer_qt.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.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 RENDER_VIEW_OBSERVER_QT_H +#define RENDER_VIEW_OBSERVER_QT_H + +#include "content/public/renderer/render_view_observer.h" + +#include + +namespace web_cache { +class WebCacheRenderProcessObserver; +} + +class RenderViewObserverQt : public content::RenderViewObserver { +public: + RenderViewObserverQt(content::RenderView* render_view, + web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer); + +private: + void onFetchDocumentMarkup(quint64 requestId); + void onFetchDocumentInnerText(quint64 requestId); + void onSetBackgroundColor(quint32 color); + + void OnFirstVisuallyNonEmptyLayout() Q_DECL_OVERRIDE; + + virtual bool OnMessageReceived(const IPC::Message& message) Q_DECL_OVERRIDE; + virtual void Navigate(const GURL& url) Q_DECL_OVERRIDE; + + web_cache::WebCacheRenderProcessObserver* m_web_cache_render_process_observer; + + DISALLOW_COPY_AND_ASSIGN(RenderViewObserverQt); +}; + +#endif // RENDER_VIEW_OBSERVER_QT_H -- cgit v1.2.3