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 | |
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')
-rw-r--r-- | content/browser/content_browser_client.h | 61 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.cc (renamed from content/browser/content_browser_client.cc) | 86 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.h | 105 | ||||
-rw-r--r-- | content/browser/site_instance_unittest.cc | 8 | ||||
-rw-r--r-- | content/common/content_client.cc | 28 | ||||
-rw-r--r-- | content/common/content_client.h | 18 | ||||
-rw-r--r-- | content/content_browser.gypi | 1 | ||||
-rw-r--r-- | content/content_renderer.gypi | 1 | ||||
-rw-r--r-- | content/content_utility.gypi | 1 | ||||
-rw-r--r-- | content/plugin/content_plugin_client.h | 2 | ||||
-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 | ||||
-rw-r--r-- | content/utility/content_utility_client.cc | 16 | ||||
-rw-r--r-- | content/utility/content_utility_client.h | 4 |
16 files changed, 381 insertions, 253 deletions
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index eb7fda8..0eca1d5 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -60,57 +60,58 @@ class WebUIFactory; class ContentBrowserClient { public: // Notifies that a new RenderHostView has been created. - virtual void RenderViewHostCreated(RenderViewHost* render_view_host); + virtual void RenderViewHostCreated(RenderViewHost* render_view_host) = 0; // Notifies that a BrowserRenderProcessHost has been created. This is called // before the content layer adds its own BrowserMessageFilters, so that the // embedder's IPC filters have priority. - virtual void BrowserRenderProcessHostCreated(BrowserRenderProcessHost* host); + virtual void BrowserRenderProcessHostCreated( + BrowserRenderProcessHost* host) = 0; // Notifies that a PluginProcessHost has been created. This is called // before the content layer adds its own message filters, so that the // embedder's IPC filters have priority. - virtual void PluginProcessHostCreated(PluginProcessHost* host); + virtual void PluginProcessHostCreated(PluginProcessHost* host) = 0; // Notifies that a WorkerProcessHost has been created. This is called // before the content layer adds its own message filters, so that the // embedder's IPC filters have priority. - virtual void WorkerProcessHostCreated(WorkerProcessHost* host); + virtual void WorkerProcessHostCreated(WorkerProcessHost* host) = 0; // Gets the WebUIFactory which will be responsible for generating WebUIs. - virtual WebUIFactory* GetWebUIFactory(); + virtual WebUIFactory* GetWebUIFactory() = 0; // Get the effective URL for the given actual URL, to allow an embedder to // group different url schemes in the same SiteInstance. - virtual GURL GetEffectiveURL(Profile* profile, const GURL& url); + virtual GURL GetEffectiveURL(Profile* profile, const GURL& url) = 0; // Returns whether a specified URL is to be considered the same as any // SiteInstance. - virtual bool IsURLSameAsAnySiteInstance(const GURL& url); + virtual bool IsURLSameAsAnySiteInstance(const GURL& url) = 0; // See CharacterEncoding's comment. virtual std::string GetCanonicalEncodingNameByAliasName( - const std::string& alias_name); + const std::string& alias_name) = 0; // Allows the embedder to pass extra command line flags. // switches::kProcessType will already be set at this point. virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, - int child_process_id); + int child_process_id) = 0; // Returns the locale used by the application. - virtual std::string GetApplicationLocale(); + virtual std::string GetApplicationLocale() = 0; // Returns the languages used in the Accept-Languages HTTP header. // (Not called GetAcceptLanguages so it doesn't clash with win32). - virtual std::string GetAcceptLangs(const TabContents* tab); + virtual std::string GetAcceptLangs(const TabContents* tab) = 0; // Returns the default favicon. The callee doesn't own the given bitmap. - virtual SkBitmap* GetDefaultFavicon(); + virtual SkBitmap* GetDefaultFavicon() = 0; // Allow the embedder to control if an AppCache can be used for the given url. // This is called on the IO thread. virtual bool AllowAppCache(const GURL& manifest_url, - const content::ResourceContext& context); + const content::ResourceContext& context) = 0; // Allow the embedder to control if the given cookie can be read. // This is called on the IO thread. @@ -119,7 +120,7 @@ class ContentBrowserClient { const net::CookieList& cookie_list, const content::ResourceContext& context, int render_process_id, - int render_view_id); + int render_view_id) = 0; // Allow the embedder to control if the given cookie can be set. // This is called on the IO thread. @@ -129,13 +130,13 @@ class ContentBrowserClient { const content::ResourceContext& context, int render_process_id, int render_view_id, - net::CookieOptions* options); + net::CookieOptions* options) = 0; // Create and return a new quota permission context. - virtual QuotaPermissionContext* CreateQuotaPermissionContext(); + virtual QuotaPermissionContext* CreateQuotaPermissionContext() = 0; // Shows the given path using the OS file manager. - virtual void RevealFolderInOS(const FilePath& path); + virtual void RevealFolderInOS(const FilePath& path) = 0; // Informs the embedder that a certificate error has occured. If overridable // is true, the user can ignore the error and continue. If it's false, then @@ -144,7 +145,7 @@ class ContentBrowserClient { virtual void AllowCertificateError( SSLCertErrorHandler* handler, bool overridable, - Callback2<SSLCertErrorHandler*, bool>::Type* callback); + Callback2<SSLCertErrorHandler*, bool>::Type* callback) = 0; // Shows the user a SSL client certificate selection dialog. When the user has // made a selection, the dialog will report back to |delegate|. |delegate| is @@ -153,7 +154,7 @@ class ContentBrowserClient { virtual void ShowClientCertificateRequestDialog( int render_process_id, int render_view_id, - SSLClientAuthHandler* handler); + SSLClientAuthHandler* handler) = 0; // Adds a newly-generated client cert. The embedder should ensure that there's // a private key for the cert, displays the cert to the user, and adds it upon @@ -162,21 +163,21 @@ class ContentBrowserClient { net::URLRequest* request, net::X509Certificate* cert, int render_process_id, - int render_view_id); + int render_view_id) = 0; // Asks permission to show desktop notifications. virtual void RequestDesktopNotificationPermission( const GURL& source_origin, int callback_context, int render_process_id, - int render_view_id); + int render_view_id) = 0; // Checks if the given page has permission to show desktop notifications. // This is called on the IO thread. virtual WebKit::WebNotificationPresenter::Permission CheckDesktopNotificationPermission( const GURL& source_url, - const content::ResourceContext& context); + const content::ResourceContext& context) = 0; // Show a desktop notification. If |worker| is true, the request came from an // HTML5 web worker, otherwise, it came from a renderer. @@ -184,13 +185,13 @@ class ContentBrowserClient { const DesktopNotificationHostMsg_Show_Params& params, int render_process_id, int render_view_id, - bool worker); + bool worker) = 0; // Cancels a displayed desktop notification. virtual void CancelDesktopNotification( int render_process_id, int render_view_id, - int notification_id); + int notification_id) = 0; // Returns true if the given page is allowed to open a window of the given // type. @@ -198,21 +199,21 @@ class ContentBrowserClient { virtual bool CanCreateWindow( const GURL& source_url, WindowContainerType container_type, - const content::ResourceContext& context); + const content::ResourceContext& context) = 0; // Returns a title string to use in the task manager for a process host with // the given URL, or the empty string to fall back to the default logic. // This is called on the IO thread. virtual std::string GetWorkerProcessTitle( - const GURL& url, const content::ResourceContext& context); + const GURL& url, const content::ResourceContext& context) = 0; // Getters for common objects. - virtual ResourceDispatcherHost* GetResourceDispatcherHost(); - virtual ui::Clipboard* GetClipboard(); + virtual ResourceDispatcherHost* GetResourceDispatcherHost() = 0; + virtual ui::Clipboard* GetClipboard() = 0; #if defined(OS_POSIX) && !defined(OS_MACOSX) // Can return an optional fd for crash handling, otherwise returns -1. - virtual int GetCrashSignalFD(const std::string& process_type); + virtual int GetCrashSignalFD(const std::string& process_type) = 0; #endif #if defined(USE_NSS) @@ -220,7 +221,7 @@ class ContentBrowserClient { // This is called on a worker thread. virtual crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate( - const GURL& url); + const GURL& url) = 0; #endif }; diff --git a/content/browser/content_browser_client.cc b/content/browser/mock_content_browser_client.cc index 38114eb..d89bd66 100644 --- a/content/browser/content_browser_client.cc +++ b/content/browser/mock_content_browser_client.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/content_browser_client.h" +#include "content/browser/mock_content_browser_client.h" + +#include <string> -#include "base/memory/singleton.h" -#include "content/browser/renderer_host/resource_dispatcher_host.h" -#include "content/browser/ssl/ssl_client_auth_handler.h" #include "content/browser/webui/empty_web_ui_factory.h" #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -14,61 +13,67 @@ namespace content { -void ContentBrowserClient::RenderViewHostCreated( +MockContentBrowserClient::~MockContentBrowserClient() { +} + +void MockContentBrowserClient::RenderViewHostCreated( RenderViewHost* render_view_host) { } -void ContentBrowserClient::BrowserRenderProcessHostCreated( +void MockContentBrowserClient::BrowserRenderProcessHostCreated( BrowserRenderProcessHost* host) { } -void ContentBrowserClient::PluginProcessHostCreated(PluginProcessHost* host) { +void MockContentBrowserClient::PluginProcessHostCreated( + PluginProcessHost* host) { } -void ContentBrowserClient::WorkerProcessHostCreated(WorkerProcessHost* host) { +void MockContentBrowserClient::WorkerProcessHostCreated( + WorkerProcessHost* host) { } -WebUIFactory* ContentBrowserClient::GetWebUIFactory() { +WebUIFactory* MockContentBrowserClient::GetWebUIFactory() { // Return an empty factory so callsites don't have to check for NULL. return EmptyWebUIFactory::Get(); } -GURL ContentBrowserClient::GetEffectiveURL(Profile* profile, const GURL& url) { - return url; +GURL MockContentBrowserClient::GetEffectiveURL(Profile* profile, + const GURL& url) { + return GURL(); } -bool ContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { +bool MockContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { return false; } -std::string ContentBrowserClient::GetCanonicalEncodingNameByAliasName( +std::string MockContentBrowserClient::GetCanonicalEncodingNameByAliasName( const std::string& alias_name) { - return alias_name; + return std::string(); } -void ContentBrowserClient::AppendExtraCommandLineSwitches( +void MockContentBrowserClient::AppendExtraCommandLineSwitches( CommandLine* command_line, int child_process_id) { } -std::string ContentBrowserClient::GetApplicationLocale() { +std::string MockContentBrowserClient::GetApplicationLocale() { return std::string(); } -std::string ContentBrowserClient::GetAcceptLangs(const TabContents* tab) { +std::string MockContentBrowserClient::GetAcceptLangs(const TabContents* tab) { return std::string(); } -SkBitmap* ContentBrowserClient::GetDefaultFavicon() { +SkBitmap* MockContentBrowserClient::GetDefaultFavicon() { static SkBitmap empty; return ∅ } -bool ContentBrowserClient::AllowAppCache( +bool MockContentBrowserClient::AllowAppCache( const GURL& manifest_url, const content::ResourceContext& context) { return true; } -bool ContentBrowserClient::AllowGetCookie( +bool MockContentBrowserClient::AllowGetCookie( const GURL& url, const GURL& first_party, const net::CookieList& cookie_list, @@ -78,7 +83,7 @@ bool ContentBrowserClient::AllowGetCookie( return true; } -bool ContentBrowserClient::AllowSetCookie( +bool MockContentBrowserClient::AllowSetCookie( const GURL& url, const GURL& first_party, const std::string& cookie_line, @@ -89,36 +94,34 @@ bool ContentBrowserClient::AllowSetCookie( return true; } -QuotaPermissionContext* ContentBrowserClient::CreateQuotaPermissionContext() { +QuotaPermissionContext* + MockContentBrowserClient::CreateQuotaPermissionContext() { return NULL; } -void ContentBrowserClient::RevealFolderInOS(const FilePath& path) { +void MockContentBrowserClient::RevealFolderInOS(const FilePath& path) { } -void ContentBrowserClient::AllowCertificateError( +void MockContentBrowserClient::AllowCertificateError( SSLCertErrorHandler* handler, bool overridable, Callback2<SSLCertErrorHandler*, bool>::Type* callback) { - callback->Run(handler, overridable); - delete callback; } -void ContentBrowserClient::ShowClientCertificateRequestDialog( +void MockContentBrowserClient::ShowClientCertificateRequestDialog( int render_process_id, int render_view_id, SSLClientAuthHandler* handler) { - handler->CertificateSelected(NULL); } -void ContentBrowserClient::AddNewCertificate( +void MockContentBrowserClient::AddNewCertificate( net::URLRequest* request, net::X509Certificate* cert, int render_process_id, int render_view_id) { } -void ContentBrowserClient::RequestDesktopNotificationPermission( +void MockContentBrowserClient::RequestDesktopNotificationPermission( const GURL& source_origin, int callback_context, int render_process_id, @@ -126,57 +129,56 @@ void ContentBrowserClient::RequestDesktopNotificationPermission( } WebKit::WebNotificationPresenter::Permission - ContentBrowserClient::CheckDesktopNotificationPermission( + MockContentBrowserClient::CheckDesktopNotificationPermission( const GURL& source_url, const content::ResourceContext& context) { return WebKit::WebNotificationPresenter::PermissionAllowed; } -void ContentBrowserClient::ShowDesktopNotification( +void MockContentBrowserClient::ShowDesktopNotification( const DesktopNotificationHostMsg_Show_Params& params, int render_process_id, int render_view_id, bool worker) { } -void ContentBrowserClient::CancelDesktopNotification( +void MockContentBrowserClient::CancelDesktopNotification( int render_process_id, int render_view_id, int notification_id) { } -bool ContentBrowserClient::CanCreateWindow( +bool MockContentBrowserClient::CanCreateWindow( const GURL& source_url, WindowContainerType container_type, const content::ResourceContext& context) { return false; } -std::string ContentBrowserClient::GetWorkerProcessTitle( +std::string MockContentBrowserClient::GetWorkerProcessTitle( const GURL& url, const content::ResourceContext& context) { return std::string(); } -ResourceDispatcherHost* ContentBrowserClient::GetResourceDispatcherHost() { - static ResourceQueue::DelegateSet temp; - static ResourceDispatcherHost rdh(temp); - return &rdh; +ResourceDispatcherHost* MockContentBrowserClient::GetResourceDispatcherHost() { + return NULL; } -ui::Clipboard* ContentBrowserClient::GetClipboard() { +ui::Clipboard* MockContentBrowserClient::GetClipboard() { static ui::Clipboard clipboard; return &clipboard; } #if defined(OS_POSIX) && !defined(OS_MACOSX) -int ContentBrowserClient::GetCrashSignalFD(const std::string& process_type) { +int MockContentBrowserClient::GetCrashSignalFD( + const std::string& process_type) { return -1; } #endif #if defined(USE_NSS) crypto::CryptoModuleBlockingPasswordDelegate* - ContentBrowserClient::GetCryptoPasswordDelegate(const GURL& url) { + MockContentBrowserClient::GetCryptoPasswordDelegate(const GURL& url) { return NULL; } #endif diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h new file mode 100644 index 0000000..b63e906 --- /dev/null +++ b/content/browser/mock_content_browser_client.h @@ -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. + +#ifndef CONTENT_BROWSER_MOCK_CONTENT_BROWSER_CLIENT_H_ +#define CONTENT_BROWSER_MOCK_CONTENT_BROWSER_CLIENT_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "content/browser/content_browser_client.h" + +namespace content { + +// Base for unit tests that need to mock the ContentBrowserClient. +class MockContentBrowserClient : public ContentBrowserClient { + public: + virtual ~MockContentBrowserClient(); + + virtual void RenderViewHostCreated( + RenderViewHost* render_view_host) OVERRIDE; + virtual void BrowserRenderProcessHostCreated( + BrowserRenderProcessHost* host) OVERRIDE; + virtual void PluginProcessHostCreated(PluginProcessHost* host) OVERRIDE; + virtual void WorkerProcessHostCreated(WorkerProcessHost* host) OVERRIDE; + virtual WebUIFactory* GetWebUIFactory() OVERRIDE; + virtual GURL GetEffectiveURL(Profile* profile, const GURL& url) OVERRIDE; + virtual bool IsURLSameAsAnySiteInstance(const GURL& url) OVERRIDE; + virtual std::string GetCanonicalEncodingNameByAliasName( + const std::string& alias_name) OVERRIDE; + virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, + int child_process_id) OVERRIDE; + virtual std::string GetApplicationLocale() OVERRIDE; + virtual std::string GetAcceptLangs(const TabContents* tab) OVERRIDE; + virtual SkBitmap* GetDefaultFavicon() OVERRIDE; + virtual bool AllowAppCache(const GURL& manifest_url, + const content::ResourceContext& context) OVERRIDE; + virtual bool AllowGetCookie(const GURL& url, + const GURL& first_party, + const net::CookieList& cookie_list, + const content::ResourceContext& context, + int render_process_id, + int render_view_id) OVERRIDE; + virtual bool AllowSetCookie(const GURL& url, + const GURL& first_party, + const std::string& cookie_line, + const content::ResourceContext& context, + int render_process_id, + int render_view_id, + net::CookieOptions* options) OVERRIDE; + virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE; + virtual void RevealFolderInOS(const FilePath& path) OVERRIDE; + virtual void AllowCertificateError( + SSLCertErrorHandler* handler, + bool overridable, + Callback2<SSLCertErrorHandler*, bool>::Type* callback) OVERRIDE; + virtual void ShowClientCertificateRequestDialog( + int render_process_id, + int render_view_id, + SSLClientAuthHandler* handler) OVERRIDE; + virtual void AddNewCertificate( + net::URLRequest* request, + net::X509Certificate* cert, + int render_process_id, + int render_view_id) OVERRIDE; + virtual void RequestDesktopNotificationPermission( + const GURL& source_origin, + int callback_context, + int render_process_id, + int render_view_id) OVERRIDE; + virtual WebKit::WebNotificationPresenter::Permission + CheckDesktopNotificationPermission( + const GURL& source_url, + const content::ResourceContext& context) OVERRIDE; + virtual void ShowDesktopNotification( + const DesktopNotificationHostMsg_Show_Params& params, + int render_process_id, + int render_view_id, + bool worker) OVERRIDE; + virtual void CancelDesktopNotification( + int render_process_id, + int render_view_id, + int notification_id) OVERRIDE; + virtual bool CanCreateWindow( + const GURL& source_url, + WindowContainerType container_type, + const content::ResourceContext& context) OVERRIDE; + virtual std::string GetWorkerProcessTitle( + const GURL& url, const content::ResourceContext& context) OVERRIDE; + virtual ResourceDispatcherHost* GetResourceDispatcherHost() OVERRIDE; + virtual ui::Clipboard* GetClipboard() OVERRIDE; + +#if defined(OS_POSIX) && !defined(OS_MACOSX) + virtual int GetCrashSignalFD(const std::string& process_type) OVERRIDE; +#endif + +#if defined(USE_NSS) + virtual + crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate( + const GURL& url) OVERRIDE; +#endif +}; + +} // namespace content + +#endif // CONTENT_BROWSER_MOCK_CONTENT_BROWSER_CLIENT_H_ diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_unittest.cc index 4fb3670..40b9d8c 100644 --- a/content/browser/site_instance_unittest.cc +++ b/content/browser/site_instance_unittest.cc @@ -9,7 +9,7 @@ #include "content/browser/browser_thread.h" #include "content/browser/browsing_instance.h" #include "content/browser/child_process_security_policy.h" -#include "content/browser/content_browser_client.h" +#include "content/browser/mock_content_browser_client.h" #include "content/browser/renderer_host/browser_render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/test_render_view_host.h" @@ -36,7 +36,7 @@ class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory { } }; -class SiteInstanceTestBrowserClient : public content::ContentBrowserClient { +class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient { public: virtual content::WebUIFactory* GetWebUIFactory() OVERRIDE { return &factory_; @@ -47,6 +47,10 @@ class SiteInstanceTestBrowserClient : public content::ContentBrowserClient { url == GURL(chrome::kAboutCrashURL); } + virtual GURL GetEffectiveURL(Profile* profile, const GURL& url) OVERRIDE { + return url; + } + private: SiteInstanceTestWebUIFactory factory_; }; diff --git a/content/common/content_client.cc b/content/common/content_client.cc index d903a58..cc2bad4 100644 --- a/content/common/content_client.cc +++ b/content/common/content_client.cc @@ -25,32 +25,4 @@ ContentClient::ContentClient() ContentClient::~ContentClient() { } -bool ContentClient::CanSendWhileSwappedOut(const IPC::Message* msg) { - return false; -} - -bool ContentClient::CanHandleWhileSwappedOut(const IPC::Message& msg) { - return false; -} - -std::string ContentClient::GetUserAgent(bool mimic_windows) const { - return std::string(); -} - -string16 ContentClient::GetLocalizedString(int message_id) const { - return string16(); -} - -// Return the contents of a resource in a StringPiece given the resource id. -base::StringPiece ContentClient::GetDataResource(int resource_id) const { - return base::StringPiece(); -} - -#if defined(OS_WIN) -bool ContentClient::SandboxPlugin(CommandLine* command_line, - sandbox::TargetPolicy* policy) { - return false; -} -#endif - } // namespace content diff --git a/content/common/content_client.h b/content/common/content_client.h index 7ca34b4..d3abd43 100644 --- a/content/common/content_client.h +++ b/content/common/content_client.h @@ -59,37 +59,37 @@ class ContentClient { void set_utility(ContentUtilityClient* u) { utility_ = u; } // Sets the currently active URL. Use GURL() to clear the URL. - virtual void SetActiveURL(const GURL& url) {} + virtual void SetActiveURL(const GURL& url) = 0; // Sets the data on the current gpu. - virtual void SetGpuInfo(const GPUInfo& gpu_info) {} + virtual void SetGpuInfo(const GPUInfo& gpu_info) = 0; // Gives the embedder a chance to register its own pepper plugins. - virtual void AddPepperPlugins(std::vector<PepperPluginInfo>* plugins) {} + virtual void AddPepperPlugins(std::vector<PepperPluginInfo>* plugins) = 0; // Returns whether the given message should be allowed to be sent from a // swapped out renderer. - virtual bool CanSendWhileSwappedOut(const IPC::Message* msg); + virtual bool CanSendWhileSwappedOut(const IPC::Message* msg) = 0; // Returns whether the given message should be processed in the browser on // behalf of a swapped out renderer. - virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg); + virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) = 0; // Returns the user agent. If mimic_windows is true then the embedder can // return a fake Windows user agent. This is a workaround for broken // websites. - virtual std::string GetUserAgent(bool mimic_windows) const; + virtual std::string GetUserAgent(bool mimic_windows) const = 0; // Returns a string resource given its id. - virtual string16 GetLocalizedString(int message_id) const; + virtual string16 GetLocalizedString(int message_id) const = 0; // Return the contents of a resource in a StringPiece given the resource id. - virtual base::StringPiece GetDataResource(int resource_id) const; + virtual base::StringPiece GetDataResource(int resource_id) const = 0; #if defined(OS_WIN) // Allows the embedder to sandbox a plugin, and apply a custom policy. virtual bool SandboxPlugin(CommandLine* command_line, - sandbox::TargetPolicy* policy); + sandbox::TargetPolicy* policy) = 0; #endif private: diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 88ca816..ccc0738 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -73,7 +73,6 @@ 'browser/clipboard_dispatcher_gtk.cc', 'browser/clipboard_dispatcher_mac.mm', 'browser/clipboard_dispatcher_win.cc', - 'browser/content_browser_client.cc', 'browser/content_browser_client.h', 'browser/cross_site_request_manager.cc', 'browser/cross_site_request_manager.h', diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 23b5ecd..82be1b8 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -28,7 +28,6 @@ 'sources': [ 'renderer/active_notification_tracker.cc', 'renderer/active_notification_tracker.h', - 'renderer/content_renderer_client.cc', 'renderer/content_renderer_client.h', 'renderer/device_orientation_dispatcher.cc', 'renderer/device_orientation_dispatcher.h', diff --git a/content/content_utility.gypi b/content/content_utility.gypi index 99c861a..f3f8c65 100644 --- a/content/content_utility.gypi +++ b/content/content_utility.gypi @@ -12,7 +12,6 @@ '../base/base.gyp:base', ], 'sources': [ - 'utility/content_utility_client.cc', 'utility/content_utility_client.h', 'utility/utility_main.cc', 'utility/utility_thread.cc', diff --git a/content/plugin/content_plugin_client.h b/content/plugin/content_plugin_client.h index a8f3974..e2640d9 100644 --- a/content/plugin/content_plugin_client.h +++ b/content/plugin/content_plugin_client.h @@ -15,7 +15,7 @@ namespace content { class ContentPluginClient { public: // Notifies that a plugin process has started. - virtual void PluginProcessStarted(const string16& plugin_name) {} + virtual void PluginProcessStarted(const string16& plugin_name) = 0; }; } // namespace content 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_ diff --git a/content/utility/content_utility_client.cc b/content/utility/content_utility_client.cc deleted file mode 100644 index 043ce6f..0000000 --- a/content/utility/content_utility_client.cc +++ /dev/null @@ -1,16 +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/utility/content_utility_client.h" - -namespace content { - -void ContentUtilityClient::UtilityThreadStarted() { -} - -bool ContentUtilityClient::OnMessageReceived(const IPC::Message& message) { - return false; -} - -} // namespace content diff --git a/content/utility/content_utility_client.h b/content/utility/content_utility_client.h index 4fd3d1a..6a4b3ea 100644 --- a/content/utility/content_utility_client.h +++ b/content/utility/content_utility_client.h @@ -14,10 +14,10 @@ namespace content { class ContentUtilityClient { public: // Notifies us that the UtilityThread has been created. - virtual void UtilityThreadStarted(); + virtual void UtilityThreadStarted() = 0; // Allows the embedder to filter messages. - virtual bool OnMessageReceived(const IPC::Message& message); + virtual bool OnMessageReceived(const IPC::Message& message) = 0; }; } // namespace content |