| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/content_browser_client.h" | 5 #include "content/browser/mock_content_browser_client.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include <string> |
| 8 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 8 |
| 9 #include "content/browser/ssl/ssl_client_auth_handler.h" | |
| 10 #include "content/browser/webui/empty_web_ui_factory.h" | 9 #include "content/browser/webui/empty_web_ui_factory.h" |
| 11 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "ui/base/clipboard/clipboard.h" | 12 #include "ui/base/clipboard/clipboard.h" |
| 14 | 13 |
| 15 namespace content { | 14 namespace content { |
| 16 | 15 |
| 17 void ContentBrowserClient::RenderViewHostCreated( | 16 MockContentBrowserClient::~MockContentBrowserClient() { |
| 17 } |
| 18 |
| 19 void MockContentBrowserClient::RenderViewHostCreated( |
| 18 RenderViewHost* render_view_host) { | 20 RenderViewHost* render_view_host) { |
| 19 } | 21 } |
| 20 | 22 |
| 21 void ContentBrowserClient::BrowserRenderProcessHostCreated( | 23 void MockContentBrowserClient::BrowserRenderProcessHostCreated( |
| 22 BrowserRenderProcessHost* host) { | 24 BrowserRenderProcessHost* host) { |
| 23 } | 25 } |
| 24 | 26 |
| 25 void ContentBrowserClient::PluginProcessHostCreated(PluginProcessHost* host) { | 27 void MockContentBrowserClient::PluginProcessHostCreated( |
| 28 PluginProcessHost* host) { |
| 26 } | 29 } |
| 27 | 30 |
| 28 void ContentBrowserClient::WorkerProcessHostCreated(WorkerProcessHost* host) { | 31 void MockContentBrowserClient::WorkerProcessHostCreated( |
| 32 WorkerProcessHost* host) { |
| 29 } | 33 } |
| 30 | 34 |
| 31 WebUIFactory* ContentBrowserClient::GetWebUIFactory() { | 35 WebUIFactory* MockContentBrowserClient::GetWebUIFactory() { |
| 32 // Return an empty factory so callsites don't have to check for NULL. | 36 // Return an empty factory so callsites don't have to check for NULL. |
| 33 return EmptyWebUIFactory::Get(); | 37 return EmptyWebUIFactory::Get(); |
| 34 } | 38 } |
| 35 | 39 |
| 36 GURL ContentBrowserClient::GetEffectiveURL(Profile* profile, const GURL& url) { | 40 GURL MockContentBrowserClient::GetEffectiveURL(Profile* profile, |
| 37 return url; | 41 const GURL& url) { |
| 42 return GURL(); |
| 38 } | 43 } |
| 39 | 44 |
| 40 bool ContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { | 45 bool MockContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { |
| 41 return false; | 46 return false; |
| 42 } | 47 } |
| 43 | 48 |
| 44 std::string ContentBrowserClient::GetCanonicalEncodingNameByAliasName( | 49 std::string MockContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
| 45 const std::string& alias_name) { | 50 const std::string& alias_name) { |
| 46 return alias_name; | 51 return std::string(); |
| 47 } | 52 } |
| 48 | 53 |
| 49 void ContentBrowserClient::AppendExtraCommandLineSwitches( | 54 void MockContentBrowserClient::AppendExtraCommandLineSwitches( |
| 50 CommandLine* command_line, int child_process_id) { | 55 CommandLine* command_line, int child_process_id) { |
| 51 } | 56 } |
| 52 | 57 |
| 53 std::string ContentBrowserClient::GetApplicationLocale() { | 58 std::string MockContentBrowserClient::GetApplicationLocale() { |
| 54 return std::string(); | 59 return std::string(); |
| 55 } | 60 } |
| 56 | 61 |
| 57 std::string ContentBrowserClient::GetAcceptLangs(const TabContents* tab) { | 62 std::string MockContentBrowserClient::GetAcceptLangs(const TabContents* tab) { |
| 58 return std::string(); | 63 return std::string(); |
| 59 } | 64 } |
| 60 | 65 |
| 61 SkBitmap* ContentBrowserClient::GetDefaultFavicon() { | 66 SkBitmap* MockContentBrowserClient::GetDefaultFavicon() { |
| 62 static SkBitmap empty; | 67 static SkBitmap empty; |
| 63 return ∅ | 68 return ∅ |
| 64 } | 69 } |
| 65 | 70 |
| 66 bool ContentBrowserClient::AllowAppCache( | 71 bool MockContentBrowserClient::AllowAppCache( |
| 67 const GURL& manifest_url, const content::ResourceContext& context) { | 72 const GURL& manifest_url, const content::ResourceContext& context) { |
| 68 return true; | 73 return true; |
| 69 } | 74 } |
| 70 | 75 |
| 71 bool ContentBrowserClient::AllowGetCookie( | 76 bool MockContentBrowserClient::AllowGetCookie( |
| 72 const GURL& url, | 77 const GURL& url, |
| 73 const GURL& first_party, | 78 const GURL& first_party, |
| 74 const net::CookieList& cookie_list, | 79 const net::CookieList& cookie_list, |
| 75 const content::ResourceContext& context, | 80 const content::ResourceContext& context, |
| 76 int render_process_id, | 81 int render_process_id, |
| 77 int render_view_id) { | 82 int render_view_id) { |
| 78 return true; | 83 return true; |
| 79 } | 84 } |
| 80 | 85 |
| 81 bool ContentBrowserClient::AllowSetCookie( | 86 bool MockContentBrowserClient::AllowSetCookie( |
| 82 const GURL& url, | 87 const GURL& url, |
| 83 const GURL& first_party, | 88 const GURL& first_party, |
| 84 const std::string& cookie_line, | 89 const std::string& cookie_line, |
| 85 const content::ResourceContext& context, | 90 const content::ResourceContext& context, |
| 86 int render_process_id, | 91 int render_process_id, |
| 87 int render_view_id, | 92 int render_view_id, |
| 88 net::CookieOptions* options) { | 93 net::CookieOptions* options) { |
| 89 return true; | 94 return true; |
| 90 } | 95 } |
| 91 | 96 |
| 92 QuotaPermissionContext* ContentBrowserClient::CreateQuotaPermissionContext() { | 97 QuotaPermissionContext* |
| 98 MockContentBrowserClient::CreateQuotaPermissionContext() { |
| 93 return NULL; | 99 return NULL; |
| 94 } | 100 } |
| 95 | 101 |
| 96 void ContentBrowserClient::RevealFolderInOS(const FilePath& path) { | 102 void MockContentBrowserClient::RevealFolderInOS(const FilePath& path) { |
| 97 } | 103 } |
| 98 | 104 |
| 99 void ContentBrowserClient::AllowCertificateError( | 105 void MockContentBrowserClient::AllowCertificateError( |
| 100 SSLCertErrorHandler* handler, | 106 SSLCertErrorHandler* handler, |
| 101 bool overridable, | 107 bool overridable, |
| 102 Callback2<SSLCertErrorHandler*, bool>::Type* callback) { | 108 Callback2<SSLCertErrorHandler*, bool>::Type* callback) { |
| 103 callback->Run(handler, overridable); | |
| 104 delete callback; | |
| 105 } | 109 } |
| 106 | 110 |
| 107 void ContentBrowserClient::ShowClientCertificateRequestDialog( | 111 void MockContentBrowserClient::ShowClientCertificateRequestDialog( |
| 108 int render_process_id, | 112 int render_process_id, |
| 109 int render_view_id, | 113 int render_view_id, |
| 110 SSLClientAuthHandler* handler) { | 114 SSLClientAuthHandler* handler) { |
| 111 handler->CertificateSelected(NULL); | |
| 112 } | 115 } |
| 113 | 116 |
| 114 void ContentBrowserClient::AddNewCertificate( | 117 void MockContentBrowserClient::AddNewCertificate( |
| 115 net::URLRequest* request, | 118 net::URLRequest* request, |
| 116 net::X509Certificate* cert, | 119 net::X509Certificate* cert, |
| 117 int render_process_id, | 120 int render_process_id, |
| 118 int render_view_id) { | 121 int render_view_id) { |
| 119 } | 122 } |
| 120 | 123 |
| 121 void ContentBrowserClient::RequestDesktopNotificationPermission( | 124 void MockContentBrowserClient::RequestDesktopNotificationPermission( |
| 122 const GURL& source_origin, | 125 const GURL& source_origin, |
| 123 int callback_context, | 126 int callback_context, |
| 124 int render_process_id, | 127 int render_process_id, |
| 125 int render_view_id) { | 128 int render_view_id) { |
| 126 } | 129 } |
| 127 | 130 |
| 128 WebKit::WebNotificationPresenter::Permission | 131 WebKit::WebNotificationPresenter::Permission |
| 129 ContentBrowserClient::CheckDesktopNotificationPermission( | 132 MockContentBrowserClient::CheckDesktopNotificationPermission( |
| 130 const GURL& source_url, | 133 const GURL& source_url, |
| 131 const content::ResourceContext& context) { | 134 const content::ResourceContext& context) { |
| 132 return WebKit::WebNotificationPresenter::PermissionAllowed; | 135 return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 133 } | 136 } |
| 134 | 137 |
| 135 void ContentBrowserClient::ShowDesktopNotification( | 138 void MockContentBrowserClient::ShowDesktopNotification( |
| 136 const DesktopNotificationHostMsg_Show_Params& params, | 139 const DesktopNotificationHostMsg_Show_Params& params, |
| 137 int render_process_id, | 140 int render_process_id, |
| 138 int render_view_id, | 141 int render_view_id, |
| 139 bool worker) { | 142 bool worker) { |
| 140 } | 143 } |
| 141 | 144 |
| 142 void ContentBrowserClient::CancelDesktopNotification( | 145 void MockContentBrowserClient::CancelDesktopNotification( |
| 143 int render_process_id, | 146 int render_process_id, |
| 144 int render_view_id, | 147 int render_view_id, |
| 145 int notification_id) { | 148 int notification_id) { |
| 146 } | 149 } |
| 147 | 150 |
| 148 bool ContentBrowserClient::CanCreateWindow( | 151 bool MockContentBrowserClient::CanCreateWindow( |
| 149 const GURL& source_url, | 152 const GURL& source_url, |
| 150 WindowContainerType container_type, | 153 WindowContainerType container_type, |
| 151 const content::ResourceContext& context) { | 154 const content::ResourceContext& context) { |
| 152 return false; | 155 return false; |
| 153 } | 156 } |
| 154 | 157 |
| 155 std::string ContentBrowserClient::GetWorkerProcessTitle( | 158 std::string MockContentBrowserClient::GetWorkerProcessTitle( |
| 156 const GURL& url, const content::ResourceContext& context) { | 159 const GURL& url, const content::ResourceContext& context) { |
| 157 return std::string(); | 160 return std::string(); |
| 158 } | 161 } |
| 159 | 162 |
| 160 ResourceDispatcherHost* ContentBrowserClient::GetResourceDispatcherHost() { | 163 ResourceDispatcherHost* MockContentBrowserClient::GetResourceDispatcherHost() { |
| 161 static ResourceQueue::DelegateSet temp; | 164 return NULL; |
| 162 static ResourceDispatcherHost rdh(temp); | |
| 163 return &rdh; | |
| 164 } | 165 } |
| 165 | 166 |
| 166 ui::Clipboard* ContentBrowserClient::GetClipboard() { | 167 ui::Clipboard* MockContentBrowserClient::GetClipboard() { |
| 167 static ui::Clipboard clipboard; | 168 static ui::Clipboard clipboard; |
| 168 return &clipboard; | 169 return &clipboard; |
| 169 } | 170 } |
| 170 | 171 |
| 171 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 172 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 172 int ContentBrowserClient::GetCrashSignalFD(const std::string& process_type) { | 173 int MockContentBrowserClient::GetCrashSignalFD( |
| 174 const std::string& process_type) { |
| 173 return -1; | 175 return -1; |
| 174 } | 176 } |
| 175 #endif | 177 #endif |
| 176 | 178 |
| 177 #if defined(USE_NSS) | 179 #if defined(USE_NSS) |
| 178 crypto::CryptoModuleBlockingPasswordDelegate* | 180 crypto::CryptoModuleBlockingPasswordDelegate* |
| 179 ContentBrowserClient::GetCryptoPasswordDelegate(const GURL& url) { | 181 MockContentBrowserClient::GetCryptoPasswordDelegate(const GURL& url) { |
| 180 return NULL; | 182 return NULL; |
| 181 } | 183 } |
| 182 #endif | 184 #endif |
| 183 | 185 |
| 184 } // namespace content | 186 } // namespace content |
| OLD | NEW |