diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 02:06:28 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 02:06:28 +0000 |
commit | a77e4bc20e8a54ab4297c7961439d3c115abb71d (patch) | |
tree | 4a315810c709b75342c3a07b54dc4ac424e6d87f /content/renderer | |
parent | 3ee39623d21e7241af1359f7d8b7ef199e206db0 (diff) | |
download | chromium_src-a77e4bc20e8a54ab4297c7961439d3c115abb71d.zip chromium_src-a77e4bc20e8a54ab4297c7961439d3c115abb71d.tar.gz chromium_src-a77e4bc20e8a54ab4297c7961439d3c115abb71d.tar.bz2 |
Make all content client interfaces pure virtual.
BUG=87332
TEST=existing
Review URL: http://codereview.chromium.org/7242016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/content_renderer_client.cc | 100 | ||||
-rw-r--r-- | content/renderer/content_renderer_client.h | 40 | ||||
-rw-r--r-- | content/renderer/mock_content_renderer_client.cc | 105 | ||||
-rw-r--r-- | content/renderer/mock_content_renderer_client.h | 58 |
4 files changed, 183 insertions, 120 deletions
diff --git a/content/renderer/content_renderer_client.cc b/content/renderer/content_renderer_client.cc deleted file mode 100644 index db96ca8..0000000 --- a/content/renderer/content_renderer_client.cc +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/renderer/content_renderer_client.h" - -#include "base/file_path.h" -#include "content/renderer/render_view.h" - -using WebKit::WebFrame; - -namespace content { -void ContentRendererClient::RenderThreadStarted() { -} - -void ContentRendererClient::RenderViewCreated(RenderView* render_view) { -} - -void ContentRendererClient::SetNumberOfViews(int number_of_views) { -} - -SkBitmap* ContentRendererClient::GetSadPluginBitmap() { - return NULL; -} - -std::string ContentRendererClient::GetDefaultEncoding() { - return std::string(); -} - -WebKit::WebPlugin* ContentRendererClient::CreatePlugin(RenderView* render_view, - WebFrame* frame, - const WebKit::WebPluginParams& params) { - return render_view->CreatePluginNoCheck(frame, params); -} - -void ContentRendererClient::ShowErrorPage(RenderView* render_view, - WebKit::WebFrame* frame, - int http_status_code) { -} - -std::string ContentRendererClient::GetNavigationErrorHtml( - const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error) { - return std::string(); -} - -bool ContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { - return true; -} - -bool ContentRendererClient::AllowPopup(const GURL& creator) { - return false; -} - -bool ContentRendererClient::ShouldFork(WebFrame* frame, - const GURL& url, - bool is_content_initiated, - bool* send_referrer) { - return false; -} - -bool ContentRendererClient::WillSendRequest(WebFrame* frame, - const GURL& url, - GURL* new_url) { - return false; -} - -bool ContentRendererClient::ShouldPumpEventsDuringCookieMessage() { - return false; -} - -void ContentRendererClient::DidCreateScriptContext(WebFrame* frame) { -} - -void ContentRendererClient::DidDestroyScriptContext(WebFrame* frame) { -} - -void ContentRendererClient::DidCreateIsolatedScriptContext(WebFrame* frame) { -} - -unsigned long long ContentRendererClient::VisitedLinkHash( - const char* canonical_url, size_t length) { - return 0; -} - -bool ContentRendererClient::IsLinkVisited(unsigned long long link_hash) { - return false; -} - -void ContentRendererClient::PrefetchHostName(const char* hostname, - size_t length) { -} - -bool ContentRendererClient::ShouldOverridePageVisibilityState( - const RenderView* render_view, - WebKit::WebPageVisibilityState* override_state) const { - return false; -} - -} // namespace content diff --git a/content/renderer/content_renderer_client.h b/content/renderer/content_renderer_client.h index 3f012c1..953fdf5 100644 --- a/content/renderer/content_renderer_client.h +++ b/content/renderer/content_renderer_client.h @@ -33,73 +33,73 @@ class ContentRendererClient { virtual ~ContentRendererClient() {} // Notifies us that the RenderThread has been created. - virtual void RenderThreadStarted(); + virtual void RenderThreadStarted() = 0; // Notifies that a new RenderView has been created. - virtual void RenderViewCreated(RenderView* render_view); + virtual void RenderViewCreated(RenderView* render_view) = 0; // Sets a number of views/tabs opened in this process. - virtual void SetNumberOfViews(int number_of_views); + virtual void SetNumberOfViews(int number_of_views) = 0; // Returns the bitmap to show when a plugin crashed, or NULL for none. - virtual SkBitmap* GetSadPluginBitmap(); + virtual SkBitmap* GetSadPluginBitmap() = 0; // Returns the default text encoding. - virtual std::string GetDefaultEncoding(); + virtual std::string GetDefaultEncoding() = 0; // Create a plugin in the given frame. Can return NULL, in which case // RenderView will create a plugin itself. virtual WebKit::WebPlugin* CreatePlugin( RenderView* render_view, WebKit::WebFrame* frame, - const WebKit::WebPluginParams& params); + const WebKit::WebPluginParams& params) = 0; // Give the embedder the ability to set an error page. virtual void ShowErrorPage(RenderView* render_view, WebKit::WebFrame* frame, - int http_status_code); + int http_status_code) = 0; // Returns the html to display when a navigation error occurs. virtual std::string GetNavigationErrorHtml( const WebKit::WebURLRequest& failed_request, - const WebKit::WebURLError& error); + const WebKit::WebURLError& error) = 0; // Returns true if the renderer process should schedule the idle handler when // all widgets are hidden. - virtual bool RunIdleHandlerWhenWidgetsHidden(); + virtual bool RunIdleHandlerWhenWidgetsHidden() = 0; // Returns true if the given url can create popup windows. - virtual bool AllowPopup(const GURL& creator); + virtual bool AllowPopup(const GURL& creator) = 0; // Returns true if we should fork a new process for the given navigation. virtual bool ShouldFork(WebKit::WebFrame* frame, const GURL& url, bool is_content_initiated, - bool* send_referrer); + bool* send_referrer) = 0; // Notifies the embedder that the given frame is requesting the resource at // |url|. If the function returns true, the url is changed to |new_url|. virtual bool WillSendRequest(WebKit::WebFrame* frame, const GURL& url, - GURL* new_url); + GURL* new_url) = 0; // Whether to pump events when sending sync cookie messages. Needed if the // embedder can potentiall put up a modal dialog on the UI thread as a result. - virtual bool ShouldPumpEventsDuringCookieMessage(); + virtual bool ShouldPumpEventsDuringCookieMessage() = 0; // See the corresponding functions in WebKit::WebFrameClient. - virtual void DidCreateScriptContext(WebKit::WebFrame* frame); - virtual void DidDestroyScriptContext(WebKit::WebFrame* frame); - virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* frame); + virtual void DidCreateScriptContext(WebKit::WebFrame* frame) = 0; + virtual void DidDestroyScriptContext(WebKit::WebFrame* frame) = 0; + virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* frame) = 0; // See WebKit::WebKitClient. virtual unsigned long long VisitedLinkHash(const char* canonical_url, - size_t length); - virtual bool IsLinkVisited(unsigned long long link_hash); - virtual void PrefetchHostName(const char* hostname, size_t length); + size_t length) = 0; + virtual bool IsLinkVisited(unsigned long long link_hash) = 0; + virtual void PrefetchHostName(const char* hostname, size_t length) = 0; virtual bool ShouldOverridePageVisibilityState( const RenderView* render_view, - WebKit::WebPageVisibilityState* override_state) const; + WebKit::WebPageVisibilityState* override_state) const = 0; }; } // namespace content diff --git a/content/renderer/mock_content_renderer_client.cc b/content/renderer/mock_content_renderer_client.cc new file mode 100644 index 0000000..d70b319 --- /dev/null +++ b/content/renderer/mock_content_renderer_client.cc @@ -0,0 +1,105 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/renderer/mock_content_renderer_client.h" + +#include <string> + +namespace content { + +MockContentRendererClient::~MockContentRendererClient() { +} + +void MockContentRendererClient::RenderThreadStarted() { +} + +void MockContentRendererClient::RenderViewCreated(RenderView* render_view) { +} + +void MockContentRendererClient::SetNumberOfViews(int number_of_views) { +} + +SkBitmap* MockContentRendererClient::GetSadPluginBitmap() { + return NULL; +} + +std::string MockContentRendererClient::GetDefaultEncoding() { + return std::string(); +} + +WebKit::WebPlugin* MockContentRendererClient::CreatePlugin( + RenderView* render_view, + WebKit::WebFrame* frame, + const WebKit::WebPluginParams& params) { + return NULL; +} + +void MockContentRendererClient::ShowErrorPage(RenderView* render_view, + WebKit::WebFrame* frame, + int http_status_code) { +} + +std::string MockContentRendererClient::GetNavigationErrorHtml( + const WebKit::WebURLRequest& failed_request, + const WebKit::WebURLError& error) { + return std::string(); +} + +bool MockContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { + return true; +} + +bool MockContentRendererClient::AllowPopup(const GURL& creator) { + return false; +} + +bool MockContentRendererClient::ShouldFork(WebKit::WebFrame* frame, + const GURL& url, + bool is_content_initiated, + bool* send_referrer) { + return false; +} + +bool MockContentRendererClient::WillSendRequest(WebKit::WebFrame* frame, + const GURL& url, + GURL* new_url) { + return false; +} + +bool MockContentRendererClient::ShouldPumpEventsDuringCookieMessage() { + return false; +} + +void MockContentRendererClient::DidCreateScriptContext( + WebKit::WebFrame* frame) { +} + +void MockContentRendererClient::DidDestroyScriptContext( + WebKit::WebFrame* frame) { +} + +void MockContentRendererClient::DidCreateIsolatedScriptContext( + WebKit::WebFrame* frame) { +} + +unsigned long long MockContentRendererClient::VisitedLinkHash( + const char* canonical_url, size_t length) { + return 0LL; +} + +bool MockContentRendererClient::IsLinkVisited(unsigned long long link_hash) { + return false; +} + +void MockContentRendererClient::PrefetchHostName( + const char* hostname, size_t length) { +} + +bool MockContentRendererClient::ShouldOverridePageVisibilityState( + const RenderView* render_view, + WebKit::WebPageVisibilityState* override_state) const { + return false; +} + +} // namespace content diff --git a/content/renderer/mock_content_renderer_client.h b/content/renderer/mock_content_renderer_client.h new file mode 100644 index 0000000..32af9a2 --- /dev/null +++ b/content/renderer/mock_content_renderer_client.h @@ -0,0 +1,58 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_RENDERER_MOCK_CONTENT_RENDERER_CLIENT_H_ +#define CONTENT_RENDERER_MOCK_CONTENT_RENDERER_CLIENT_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "content/renderer/content_renderer_client.h" + +namespace content { + +// Base class for unit tests that need to mock the ContentRendererClient. +class MockContentRendererClient : public ContentRendererClient { + public: + virtual ~MockContentRendererClient(); + virtual void RenderThreadStarted() OVERRIDE; + virtual void RenderViewCreated(RenderView* render_view) OVERRIDE; + virtual void SetNumberOfViews(int number_of_views) OVERRIDE; + virtual SkBitmap* GetSadPluginBitmap() OVERRIDE; + virtual std::string GetDefaultEncoding() OVERRIDE; + virtual WebKit::WebPlugin* CreatePlugin( + RenderView* render_view, + WebKit::WebFrame* frame, + const WebKit::WebPluginParams& params) OVERRIDE; + virtual void ShowErrorPage(RenderView* render_view, + WebKit::WebFrame* frame, + int http_status_code) OVERRIDE; + virtual std::string GetNavigationErrorHtml( + const WebKit::WebURLRequest& failed_request, + const WebKit::WebURLError& error) OVERRIDE; + virtual bool RunIdleHandlerWhenWidgetsHidden() OVERRIDE; + virtual bool AllowPopup(const GURL& creator) OVERRIDE; + virtual bool ShouldFork(WebKit::WebFrame* frame, + const GURL& url, + bool is_content_initiated, + bool* send_referrer) OVERRIDE; + virtual bool WillSendRequest(WebKit::WebFrame* frame, + const GURL& url, + GURL* new_url) OVERRIDE; + virtual bool ShouldPumpEventsDuringCookieMessage() OVERRIDE; + virtual void DidCreateScriptContext(WebKit::WebFrame* frame) OVERRIDE; + virtual void DidDestroyScriptContext(WebKit::WebFrame* frame) OVERRIDE; + virtual void DidCreateIsolatedScriptContext( + WebKit::WebFrame* frame) OVERRIDE; + virtual unsigned long long VisitedLinkHash(const char* canonical_url, + size_t length) OVERRIDE; + virtual bool IsLinkVisited(unsigned long long link_hash) OVERRIDE; + virtual void PrefetchHostName(const char* hostname, size_t length) OVERRIDE; + virtual bool ShouldOverridePageVisibilityState( + const RenderView* render_view, + WebKit::WebPageVisibilityState* override_state) const OVERRIDE; +}; + +} // namespace content + +#endif // CONTENT_RENDERER_MOCK_CONTENT_RENDERER_CLIENT_H_ |