blob: eafe4e43e3bcb5e60a526f24b3d4d83166cbe85b [file] [log] [blame]
[email protected]d977f9c2011-03-14 16:10:261// 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
3// found in the LICENSE file.
4
5#include "chrome/browser/chrome_content_browser_client.h"
6
[email protected]b80f68432011-05-02 17:22:307#include "base/command_line.h"
8#include "chrome/app/breakpad_mac.h"
[email protected]b8148ac2011-07-13 22:03:259#include "chrome/browser/browser_about_handler.h"
[email protected]b80f68432011-05-02 17:22:3010#include "chrome/browser/browser_process.h"
[email protected]3b8f7e32011-07-13 11:52:2311#include "chrome/browser/browsing_data_remover.h"
[email protected]763ec4ca2011-04-29 15:48:1212#include "chrome/browser/character_encoding.h"
[email protected]6f08af82011-09-15 01:19:0313#include "chrome/browser/chrome_benchmarking_message_filter.h"
[email protected]97e6c4c2011-05-18 16:08:5114#include "chrome/browser/chrome_plugin_message_filter.h"
[email protected]317f96c92011-05-31 06:53:4115#include "chrome/browser/chrome_quota_permission_context.h"
[email protected]5327dfb2011-05-03 17:50:3616#include "chrome/browser/chrome_worker_message_filter.h"
[email protected]a2176792011-05-08 19:30:4917#include "chrome/browser/content_settings/host_content_settings_map.h"
[email protected]8093a542011-05-13 07:29:3218#include "chrome/browser/content_settings/tab_specific_content_settings.h"
[email protected]e1d16eb92011-08-18 23:19:3219#include "chrome/browser/download/download_util.h"
[email protected]941623e2011-06-07 23:06:0420#include "chrome/browser/extensions/extension_info_map.h"
[email protected]f364d1392011-04-08 21:03:1021#include "chrome/browser/extensions/extension_message_handler.h"
[email protected]d977f9c2011-03-14 16:10:2622#include "chrome/browser/extensions/extension_service.h"
[email protected]b8148ac2011-07-13 22:03:2523#include "chrome/browser/extensions/extension_web_ui.h"
[email protected]32538d92011-08-25 00:09:2324#include "chrome/browser/geolocation/chrome_access_token_store.h"
[email protected]763ec4ca2011-04-29 15:48:1225#include "chrome/browser/google/google_util.h"
[email protected]ae6e9912011-07-27 01:18:2826#include "chrome/browser/net/chrome_net_log.h"
[email protected]941623e2011-06-07 23:06:0427#include "chrome/browser/notifications/desktop_notification_service.h"
28#include "chrome/browser/notifications/desktop_notification_service_factory.h"
[email protected]0609b17f2011-05-31 20:13:4229#include "chrome/browser/platform_util.h"
[email protected]763ec4ca2011-04-29 15:48:1230#include "chrome/browser/prefs/pref_service.h"
[email protected]f9034cf2011-07-21 12:43:4131#include "chrome/browser/prerender/prerender_manager.h"
[email protected]3085c502011-10-05 17:50:5032#include "chrome/browser/prerender/prerender_manager_factory.h"
[email protected]f9034cf2011-07-21 12:43:4133#include "chrome/browser/prerender/prerender_tracker.h"
[email protected]05fcf982011-04-19 00:44:1434#include "chrome/browser/printing/printing_message_filter.h"
35#include "chrome/browser/profiles/profile.h"
[email protected]8093a542011-05-13 07:29:3236#include "chrome/browser/profiles/profile_io_data.h"
[email protected]05fcf982011-04-19 00:44:1437#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
[email protected]53a0afa2011-04-28 02:09:3338#include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
[email protected]05fcf982011-04-19 00:44:1439#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
[email protected]3bc0b562011-08-24 23:51:0440#include "chrome/browser/speech/chrome_speech_input_manager.h"
[email protected]8ec71262011-07-28 08:12:4641#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
[email protected]8ec26472011-06-06 16:52:4542#include "chrome/browser/ssl/ssl_add_cert_handler.h"
[email protected]848dd042011-06-04 18:24:0343#include "chrome/browser/ssl/ssl_blocking_page.h"
[email protected]181a95ee2011-07-12 19:26:3644#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
[email protected]8ec26472011-06-06 16:52:4545#include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
46#include "chrome/browser/tab_contents/tab_util.h"
47#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
[email protected]1fd1a502011-03-30 16:55:5648#include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
[email protected]b80f68432011-05-02 17:22:3049#include "chrome/common/child_process_logging.h"
[email protected]4a65826d2011-08-25 16:04:0150#include "chrome/common/chrome_constants.h"
[email protected]b80f68432011-05-02 17:22:3051#include "chrome/common/chrome_switches.h"
[email protected]941623e2011-06-07 23:06:0452#include "chrome/common/extensions/extension.h"
[email protected]f1933792011-06-14 00:49:3453#include "chrome/common/logging_chrome.h"
[email protected]763ec4ca2011-04-29 15:48:1254#include "chrome/common/pref_names.h"
[email protected]3e69bc82011-05-26 23:22:3855#include "chrome/common/render_messages.h"
[email protected]c5dbef02011-05-13 05:06:0956#include "chrome/common/url_constants.h"
[email protected]b8148ac2011-07-13 22:03:2557#include "content/browser/browser_url_handler.h"
[email protected]c5dbef02011-05-13 05:06:0958#include "content/browser/browsing_instance.h"
[email protected]97e6c4c2011-05-18 16:08:5159#include "content/browser/plugin_process_host.h"
[email protected]05fcf982011-04-19 00:44:1460#include "content/browser/renderer_host/browser_render_process_host.h"
[email protected]d977f9c2011-03-14 16:10:2661#include "content/browser/renderer_host/render_view_host.h"
[email protected]a2176792011-05-08 19:30:4962#include "content/browser/resource_context.h"
[email protected]c5dbef02011-05-13 05:06:0963#include "content/browser/site_instance.h"
[email protected]f9034cf2011-07-21 12:43:4164#include "content/browser/ssl/ssl_cert_error_handler.h"
[email protected]8ec26472011-06-06 16:52:4565#include "content/browser/ssl/ssl_client_auth_handler.h"
[email protected]763ec4ca2011-04-29 15:48:1266#include "content/browser/tab_contents/tab_contents.h"
[email protected]74313b42011-08-24 16:51:3267#include "content/browser/tab_contents/tab_contents_view.h"
[email protected]5327dfb2011-05-03 17:50:3668#include "content/browser/worker_host/worker_process_host.h"
[email protected]941623e2011-06-07 23:06:0469#include "content/common/desktop_notification_messages.h"
[email protected]c9b6eb62011-10-18 20:49:3970#include "grit/generated_resources.h"
[email protected]29b25d092011-06-29 20:57:3471#include "grit/ui_resources.h"
[email protected]ed24fad2011-05-10 22:44:0172#include "net/base/cookie_monster.h"
73#include "net/base/cookie_options.h"
[email protected]c9b6eb62011-10-18 20:49:3974#include "ui/base/l10n/l10n_util.h"
[email protected]ac55e292011-06-24 05:16:0875#include "ui/base/resource/resource_bundle.h"
[email protected]d977f9c2011-03-14 16:10:2676
[email protected]5778d502011-10-13 17:13:2177#if defined(OS_CHROMEOS)
78#include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
79#elif defined(USE_AURA)
[email protected]199fc7a2011-09-28 22:45:3880#include "chrome/browser/chrome_browser_main_aura.h"
81#elif defined(OS_WIN)
82#include "chrome/browser/chrome_browser_main_win.h"
83#elif defined(OS_MACOSX)
84#include "chrome/browser/chrome_browser_main_mac.h"
[email protected]199fc7a2011-09-28 22:45:3885#elif defined(OS_LINUX)
86#include "chrome/browser/chrome_browser_main_gtk.h"
87#endif
88
[email protected]b80f68432011-05-02 17:22:3089#if defined(OS_LINUX)
90#include "base/linux_util.h"
91#include "chrome/browser/crash_handler_host_linux.h"
[email protected]1fd5302c2011-05-28 04:06:4392#endif
[email protected]b80f68432011-05-02 17:22:3093
[email protected]080f34f2011-09-20 05:39:2694#if defined(TOOLKIT_VIEWS)
[email protected]74313b42011-08-24 16:51:3295#include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
96#elif defined(OS_LINUX)
97#include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
98#elif defined(OS_MACOSX)
99#include "chrome/browser/tab_contents/tab_contents_view_mac.h"
[email protected]74313b42011-08-24 16:51:32100#endif
101
[email protected]37a72af2011-06-13 05:42:01102#if defined(USE_NSS)
103#include "chrome/browser/ui/crypto_module_password_dialog.h"
104#endif
105
[email protected]b45937e2011-10-07 19:49:17106
107#if defined(USE_AURA) || defined(TOUCH_UI)
108#include "chrome/browser/renderer_host/render_widget_host_view_views.h"
109#elif defined(OS_WIN)
110#include "chrome/browser/renderer_host/render_widget_host_view_views.h"
111#include "content/browser/renderer_host/render_widget_host_view_win.h"
112#elif defined(OS_LINUX)
113#include "content/browser/renderer_host/render_widget_host_view_gtk.h"
114#elif defined(OS_MACOSX)
115#include "content/browser/renderer_host/render_widget_host_view_mac.h"
116#endif
117
[email protected]c5dbef02011-05-13 05:06:09118namespace {
119
[email protected]b8148ac2011-07-13 22:03:25120// Handles rewriting Web UI URLs.
[email protected]8d3132f62011-10-12 07:13:42121bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
[email protected]3d7474ff2011-07-27 17:47:37122 if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url))
[email protected]b8148ac2011-07-13 22:03:25123 return false;
124
125 // Special case the new tab page. In older versions of Chrome, the new tab
126 // page was hosted at chrome-internal:<blah>. This might be in people's saved
127 // sessions or bookmarks, so we say any URL with that scheme triggers the new
128 // tab page.
129 if (url->SchemeIs(chrome::kChromeInternalScheme)) {
130 // Rewrite it with the proper new tab URL.
131 *url = GURL(chrome::kChromeUINewTabURL);
132 }
133
134 return true;
135}
136
[email protected]8d3132f62011-10-12 07:13:42137// Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions
138// below. Extension, and isolated apps require different privileges to be
139// granted to their RenderProcessHosts. This classification allows us to make
140// sure URLs are served by hosts with the right set of privileges.
141enum RenderProcessHostPrivilege {
142 PRIV_NORMAL,
143 PRIV_EXTENSION,
144 PRIV_ISOLATED,
145};
146
147RenderProcessHostPrivilege GetPrivilegeRequiredByUrl(
148 const GURL& url,
149 ExtensionService* service) {
150 // Default to a normal renderer cause it is lower privileged. This should only
151 // occur if the URL on a site instance is either malformed, or uninitialized.
152 // If it is malformed, then there is no need for better privileges anyways.
153 // If it is uninitialized, but eventually settles on being an a scheme other
154 // than normal webrenderer, the navigation logic will correct us out of band
155 // anyways.
156 if (!url.is_valid())
157 return PRIV_NORMAL;
158
159 if (url.SchemeIs(chrome::kExtensionScheme)) {
160 const Extension* extension = service->GetExtensionByURL(url);
161 if (extension && extension->is_storage_isolated()) {
162 return PRIV_ISOLATED;
163 }
164
165 return PRIV_EXTENSION;
166 }
167
168 return PRIV_NORMAL;
169}
170
171RenderProcessHostPrivilege GetProcessPrivilege(
172 RenderProcessHost* process_host,
173 ExtensionProcessManager* extension_process_manager) {
174 if (extension_process_manager->IsExtensionProcess(process_host->id())) {
175 if (extension_process_manager->IsStorageIsolatedForProcess(
176 process_host->id())) {
177 return PRIV_ISOLATED;
178 }
179 return PRIV_EXTENSION;
180 }
181
182 return PRIV_NORMAL;
183}
184
[email protected]9dbfff12011-07-01 19:37:07185} // namespace
[email protected]c5dbef02011-05-13 05:06:09186
[email protected]d977f9c2011-03-14 16:10:26187namespace chrome {
188
[email protected]f967b722011-09-07 00:58:04189content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
190 const MainFunctionParams& parameters) {
[email protected]5778d502011-10-13 17:13:21191#if defined(OS_CHROMEOS)
192 return new ChromeBrowserMainPartsChromeos(parameters);
193#elif defined(USE_AURA)
[email protected]199fc7a2011-09-28 22:45:38194 return new ChromeBrowserMainPartsAura(parameters);
195#elif defined(OS_WIN)
[email protected]e6b5bc22011-09-08 22:01:56196 return new ChromeBrowserMainPartsWin(parameters);
[email protected]f967b722011-09-07 00:58:04197#elif defined(OS_MACOSX)
[email protected]46c83b62011-09-08 22:09:04198 return new ChromeBrowserMainPartsMac(parameters);
[email protected]f967b722011-09-07 00:58:04199#elif defined(OS_LINUX)
[email protected]e6b5bc22011-09-08 22:01:56200 return new ChromeBrowserMainPartsGtk(parameters);
[email protected]f967b722011-09-07 00:58:04201#else
202 return NULL;
203#endif
204}
205
[email protected]b45937e2011-10-07 19:49:17206RenderWidgetHostView* ChromeContentBrowserClient::CreateViewForWidget(
207 RenderWidgetHost* widget) {
208#if defined(USE_AURA) || defined(TOUCH_UI)
209 return new RenderWidgetHostViewViews(widget);
210#elif defined(OS_WIN)
211 if (views::Widget::IsPureViews())
212 return new RenderWidgetHostViewViews(widget);
213 return new RenderWidgetHostViewWin(widget);
214#elif defined(OS_LINUX)
215 return new RenderWidgetHostViewGtk(widget);
216#elif defined(OS_MACOSX)
217 return render_widget_host_view_mac::CreateRenderWidgetHostView(widget);
218#else
219#error Need to create your platform ViewForWidget here.
220#endif
221}
222
[email protected]74313b42011-08-24 16:51:32223TabContentsView* ChromeContentBrowserClient::CreateTabContentsView(
224 TabContents* tab_contents) {
[email protected]080f34f2011-09-20 05:39:26225#if defined(TOOLKIT_VIEWS)
[email protected]74313b42011-08-24 16:51:32226 return new TabContentsViewViews(tab_contents);
227#elif defined(OS_LINUX)
228 return new TabContentsViewGtk(tab_contents);
229#elif defined(OS_MACOSX)
230 return tab_contents_view_mac::CreateTabContentsView(tab_contents);
[email protected]74313b42011-08-24 16:51:32231#else
232#error Need to create your platform TabContentsView here.
233#endif
234}
235
[email protected]f364d1392011-04-08 21:03:10236void ChromeContentBrowserClient::RenderViewHostCreated(
237 RenderViewHost* render_view_host) {
[email protected]67372ecf2011-09-10 01:30:46238
239 SiteInstance* site_instance = render_view_host->site_instance();
240 Profile* profile = Profile::FromBrowserContext(
241 site_instance->browsing_instance()->browser_context());
242
243 new ChromeRenderViewHostObserver(render_view_host,
244 profile->GetNetworkPredictor());
[email protected]f364d1392011-04-08 21:03:10245 new ExtensionMessageHandler(render_view_host);
[email protected]d977f9c2011-03-14 16:10:26246}
247
[email protected]05fcf982011-04-19 00:44:14248void ChromeContentBrowserClient::BrowserRenderProcessHostCreated(
249 BrowserRenderProcessHost* host) {
[email protected]c47cfd62011-04-29 21:27:02250 int id = host->id();
[email protected]3d7474ff2011-07-27 17:47:37251 Profile* profile = Profile::FromBrowserContext(host->browser_context());
[email protected]05fcf982011-04-19 00:44:14252 host->channel()->AddFilter(new ChromeRenderMessageFilter(
[email protected]c47cfd62011-04-29 21:27:02253 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]05fcf982011-04-19 00:44:14254 host->channel()->AddFilter(new PrintingMessageFilter());
255 host->channel()->AddFilter(
[email protected]c47cfd62011-04-29 21:27:02256 new SearchProviderInstallStateMessageFilter(id, profile));
257 host->channel()->AddFilter(new SpellCheckMessageFilter(id));
[email protected]6f08af82011-09-15 01:19:03258 host->channel()->AddFilter(new ChromeBenchmarkingMessageFilter(
259 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]3e69bc82011-05-26 23:22:38260
[email protected]2ccf45c2011-08-19 23:35:50261 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
262 profile->IsOffTheRecord()));
[email protected]05fcf982011-04-19 00:44:14263}
264
[email protected]97e6c4c2011-05-18 16:08:51265void ChromeContentBrowserClient::PluginProcessHostCreated(
266 PluginProcessHost* host) {
267 host->AddFilter(new ChromePluginMessageFilter(host));
268}
269
[email protected]5327dfb2011-05-03 17:50:36270void ChromeContentBrowserClient::WorkerProcessHostCreated(
271 WorkerProcessHost* host) {
272 host->AddFilter(new ChromeWorkerMessageFilter(host));
273}
274
[email protected]1fd1a502011-03-30 16:55:56275content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() {
276 return ChromeWebUIFactory::GetInstance();
277}
278
[email protected]3d7474ff2011-07-27 17:47:37279GURL ChromeContentBrowserClient::GetEffectiveURL(
280 content::BrowserContext* browser_context, const GURL& url) {
281 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]36fb2c7c2011-04-04 15:49:08282 // Get the effective URL for the given actual URL. If the URL is part of an
283 // installed app, the effective URL is an extension URL with the ID of that
284 // extension as the host. This has the effect of grouping apps together in
285 // a common SiteInstance.
286 if (!profile || !profile->GetExtensionService())
287 return url;
288
289 const Extension* extension =
290 profile->GetExtensionService()->GetExtensionByWebExtent(url);
291 if (!extension)
292 return url;
293
294 // If the URL is part of an extension's web extent, convert it to an
295 // extension URL.
296 return extension->GetResourceURL(url.path());
297}
298
[email protected]056ad2a2011-07-12 02:13:55299bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
[email protected]3d7474ff2011-07-27 17:47:37300 content::BrowserContext* browser_context, const GURL& effective_url) {
[email protected]056ad2a2011-07-12 02:13:55301 // Non-extension URLs should generally use process-per-site-instance.
302 // Because we expect to use the effective URL, hosted apps URLs should have
303 // an extension scheme by now.
304 if (!effective_url.SchemeIs(chrome::kExtensionScheme))
305 return false;
306
[email protected]3d7474ff2011-07-27 17:47:37307 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]056ad2a2011-07-12 02:13:55308 if (!profile || !profile->GetExtensionService())
309 return false;
310
311 const Extension* extension =
312 profile->GetExtensionService()->GetExtensionByURL(effective_url);
313 if (!extension)
314 return false;
315
316 // If the URL is part of a hosted app that does not have the background
317 // permission, we want to give each instance its own process to improve
318 // responsiveness.
319 if (extension->GetType() == Extension::TYPE_HOSTED_APP &&
320 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground))
321 return false;
322
323 // Hosted apps that have the background permission must use process per site,
324 // since all instances can make synchronous calls to the background window.
325 // Other extensions should use process per site as well.
326 return true;
327}
328
[email protected]0f012df82011-05-19 14:15:29329bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) {
[email protected]89f550b2011-06-08 18:34:03330 return url == GURL(chrome::kChromeUICrashURL) ||
331 url == GURL(chrome::kChromeUIKillURL) ||
332 url == GURL(chrome::kChromeUIHangURL) ||
333 url == GURL(chrome::kChromeUIShorthangURL);
[email protected]0f012df82011-05-19 14:15:29334}
335
[email protected]2a5221b2011-09-27 23:07:31336bool ChromeContentBrowserClient::IsSuitableHost(
337 RenderProcessHost* process_host,
338 const GURL& site_url) {
339 Profile* profile =
340 Profile::FromBrowserContext(process_host->browser_context());
341 ExtensionProcessManager* extension_process_manager =
342 profile->GetExtensionProcessManager();
[email protected]8d3132f62011-10-12 07:13:42343 ExtensionService* service = profile->GetExtensionService();
[email protected]2a5221b2011-09-27 23:07:31344
[email protected]8d3132f62011-10-12 07:13:42345 // These may be NULL during tests. In that case, just assume any site can
346 // share any host.
347 if (!extension_process_manager || !service)
[email protected]2a5221b2011-09-27 23:07:31348 return true;
349
[email protected]8d3132f62011-10-12 07:13:42350 return GetProcessPrivilege(process_host, extension_process_manager) ==
351 GetPrivilegeRequiredByUrl(site_url, service);
[email protected]2a5221b2011-09-27 23:07:31352}
353
[email protected]e3daf3c2011-10-05 21:17:08354bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
355 const GURL& current_url,
356 const GURL& new_url) {
357 if (current_url.is_empty()) {
358 // Always choose a new process when navigating to extension URLs. The
359 // process grouping logic will combine all of a given extension's pages
360 // into the same process.
361 if (new_url.SchemeIs(chrome::kExtensionScheme))
362 return true;
363
364 return false;
365 }
366
367 // Also, we must switch if one is an extension and the other is not the exact
368 // same extension.
369 if (current_url.SchemeIs(chrome::kExtensionScheme) ||
370 new_url.SchemeIs(chrome::kExtensionScheme)) {
371 if (current_url.GetOrigin() != new_url.GetOrigin())
372 return true;
373 }
374
375 return false;
376}
377
[email protected]763ec4ca2011-04-29 15:48:12378std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
379 const std::string& alias_name) {
380 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
381}
382
[email protected]b80f68432011-05-02 17:22:30383void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
384 CommandLine* command_line, int child_process_id) {
385#if defined(USE_LINUX_BREAKPAD)
386 if (IsCrashReporterEnabled()) {
387 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
388 child_process_logging::GetClientId() + "," + base::GetLinuxDistro());
389 }
390#elif defined(OS_MACOSX)
391 if (IsCrashReporterEnabled()) {
392 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
393 child_process_logging::GetClientId());
394 }
395#endif // OS_MACOSX
396
[email protected]f1933792011-06-14 00:49:34397 if (logging::DialogsAreSuppressed())
398 command_line->AppendSwitch(switches::kNoErrorDialogs);
399
[email protected]b80f68432011-05-02 17:22:30400 std::string process_type =
401 command_line->GetSwitchValueASCII(switches::kProcessType);
[email protected]3cb054e62011-06-13 05:21:17402 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
[email protected]718eab62011-10-05 21:16:52403 if (process_type == switches::kRendererProcess) {
[email protected]b80f68432011-05-02 17:22:30404 FilePath user_data_dir =
405 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
406 if (!user_data_dir.empty())
407 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
408#if defined(OS_CHROMEOS)
409 const std::string& login_profile =
410 browser_command_line.GetSwitchValueASCII(switches::kLoginProfile);
411 if (!login_profile.empty())
412 command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile);
413#endif
414
415 RenderProcessHost* process = RenderProcessHost::FromID(child_process_id);
416
[email protected]3d7474ff2011-07-27 17:47:37417 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]718eab62011-10-05 21:16:52418
419 ExtensionProcessManager* extension_process_manager =
420 profile->GetExtensionProcessManager();
421 if (extension_process_manager->IsExtensionProcess(
422 process->id())) {
423 command_line->AppendSwitch(switches::kExtensionProcess);
424 }
425
[email protected]3d7474ff2011-07-27 17:47:37426 PrefService* prefs = profile->GetPrefs();
[email protected]b80f68432011-05-02 17:22:30427 // Currently this pref is only registered if applied via a policy.
428 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) &&
429 prefs->GetBoolean(prefs::kDisable3DAPIs)) {
430 // Turn this policy into a command line switch.
431 command_line->AppendSwitch(switches::kDisable3DAPIs);
432 }
433
434 // Disable client-side phishing detection in the renderer if it is disabled
[email protected]8c40da62011-07-13 22:58:46435 // in the Profile preferences or the browser process.
436 if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) ||
437 !g_browser_process->safe_browsing_detection_service()) {
[email protected]b80f68432011-05-02 17:22:30438 command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection);
[email protected]8c40da62011-07-13 22:58:46439 }
[email protected]4287a3d2011-06-13 23:56:51440
441 static const char* const kSwitchNames[] = {
442 switches::kAllowHTTPBackgroundPage,
443 switches::kAllowScriptingGallery,
444 switches::kAppsCheckoutURL,
445 switches::kAppsGalleryURL,
[email protected]be9d9c82011-07-13 04:17:31446 switches::kCloudPrintServiceURL,
[email protected]4287a3d2011-06-13 23:56:51447 switches::kDebugPrint,
[email protected]4287a3d2011-06-13 23:56:51448 switches::kDisablePrintPreview,
[email protected]4287a3d2011-06-13 23:56:51449 switches::kDomAutomationController,
450 switches::kDumpHistogramsOnExit,
451 switches::kEnableClickToPlay,
452 switches::kEnableCrxlessWebApps,
453 switches::kEnableExperimentalExtensionApis,
454 switches::kEnableInBrowserThumbnailing,
455 switches::kEnableIPCFuzzing,
456 switches::kEnableNaCl,
[email protected]5714ee32011-08-18 01:51:24457 switches::kEnablePrintPreview,
[email protected]4287a3d2011-06-13 23:56:51458 switches::kEnableSearchProviderApiV2,
459 switches::kEnableWatchdog,
460 switches::kExperimentalSpellcheckerFeatures,
461 switches::kMemoryProfiling,
462 switches::kMessageLoopHistogrammer,
[email protected]2a6bb0b12011-10-05 19:18:04463 switches::kNoRunningInsecureContent,
[email protected]4287a3d2011-06-13 23:56:51464 switches::kPpapiFlashArgs,
465 switches::kPpapiFlashInProcess,
466 switches::kPpapiFlashPath,
467 switches::kPpapiFlashVersion,
468 switches::kProfilingAtStart,
469 switches::kProfilingFile,
470 switches::kProfilingFlush,
[email protected]4287a3d2011-06-13 23:56:51471 switches::kSilentDumpOnDCHECK,
[email protected]6f08af82011-09-15 01:19:03472 switches::kEnableBenchmarking,
[email protected]4287a3d2011-06-13 23:56:51473 };
474
475 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
476 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:17477 } else if (process_type == switches::kUtilityProcess) {
478 if (browser_command_line.HasSwitch(
479 switches::kEnableExperimentalExtensionApis)) {
480 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
481 }
[email protected]4287a3d2011-06-13 23:56:51482 } else if (process_type == switches::kPluginProcess) {
483 static const char* const kSwitchNames[] = {
484 #if defined(OS_CHROMEOS)
485 switches::kLoginProfile,
486 #endif
487 switches::kMemoryProfiling,
488 switches::kSilentDumpOnDCHECK,
489 switches::kUserDataDir,
490 };
491
492 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
493 arraysize(kSwitchNames));
494 } else if (process_type == switches::kZygoteProcess) {
495 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:51496 switches::kUserDataDir, // Make logs go to the right file.
497 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
498 switches::kPpapiFlashInProcess,
499 switches::kPpapiFlashPath,
500 switches::kPpapiFlashVersion,
501 };
502
503 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
504 arraysize(kSwitchNames));
[email protected]b80f68432011-05-02 17:22:30505 }
[email protected]6f08af82011-09-15 01:19:03506
507 // The command line switch kEnableBenchmarking needs to be specified along
508 // with the kEnableStatsTable switch to ensure that the stats table global
509 // is initialized correctly.
510 if (command_line->HasSwitch(switches::kEnableBenchmarking))
511 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:30512}
513
514std::string ChromeContentBrowserClient::GetApplicationLocale() {
515 return g_browser_process->GetApplicationLocale();
516}
517
[email protected]b5cca982011-05-26 04:42:08518std::string ChromeContentBrowserClient::GetAcceptLangs(const TabContents* tab) {
[email protected]3d7474ff2011-07-27 17:47:37519 Profile* profile = Profile::FromBrowserContext(tab->browser_context());
520 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:08521}
522
[email protected]ac55e292011-06-24 05:16:08523SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() {
524 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
[email protected]2cc6a9292011-10-13 21:41:01525#if defined(TOUCH_UI)
526 // In touch builds, we want large default favicons for the tabstrip, but in
527 // other places (such as bookmark, manage search engines, homepage) we assume
528 // default favicons are 16x16.
529 return rb.GetBitmapNamed(IDR_DEFAULT_LARGE_FAVICON);
530#else
[email protected]ac55e292011-06-24 05:16:08531 return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
[email protected]2cc6a9292011-10-13 21:41:01532#endif
[email protected]ac55e292011-06-24 05:16:08533}
534
[email protected]a2176792011-05-08 19:30:49535bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:09536 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:19537 const GURL& first_party,
[email protected]5b52ad42011-05-26 14:26:09538 const content::ResourceContext& context) {
[email protected]8093a542011-05-13 07:29:32539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
540 ProfileIOData* io_data =
541 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]efa55212011-05-13 16:19:38542 ContentSetting setting = io_data->GetHostContentSettingsMap()->
[email protected]0a608842011-09-08 10:55:19543 GetCookieContentSetting(manifest_url, first_party, true);
[email protected]a2176792011-05-08 19:30:49544 DCHECK(setting != CONTENT_SETTING_DEFAULT);
545 return setting != CONTENT_SETTING_BLOCK;
546}
547
[email protected]ed24fad2011-05-10 22:44:01548bool ChromeContentBrowserClient::AllowGetCookie(
549 const GURL& url,
550 const GURL& first_party,
551 const net::CookieList& cookie_list,
552 const content::ResourceContext& context,
553 int render_process_id,
554 int render_view_id) {
555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]8093a542011-05-13 07:29:32556 ProfileIOData* io_data =
557 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]5b52ad42011-05-26 14:26:09558 ContentSetting setting = io_data->GetHostContentSettingsMap()->
559 GetCookieContentSetting(url, first_party, false);
560 bool allow = setting == CONTENT_SETTING_ALLOW ||
561 setting == CONTENT_SETTING_SESSION_ONLY;
[email protected]ed24fad2011-05-10 22:44:01562
[email protected]8093a542011-05-13 07:29:32563 BrowserThread::PostTask(
564 BrowserThread::UI, FROM_HERE,
565 NewRunnableFunction(
566 &TabSpecificContentSettings::CookiesRead,
567 render_process_id, render_view_id, url, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:01568 return allow;
569}
570
571bool ChromeContentBrowserClient::AllowSetCookie(
572 const GURL& url,
573 const GURL& first_party,
574 const std::string& cookie_line,
575 const content::ResourceContext& context,
576 int render_process_id,
577 int render_view_id,
578 net::CookieOptions* options) {
579 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]8093a542011-05-13 07:29:32580 ProfileIOData* io_data =
581 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]5b52ad42011-05-26 14:26:09582 ContentSetting setting = io_data->GetHostContentSettingsMap()->
583 GetCookieContentSetting(url, first_party, true);
[email protected]ed24fad2011-05-10 22:44:01584
[email protected]5b52ad42011-05-26 14:26:09585 if (setting == CONTENT_SETTING_SESSION_ONLY)
586 options->set_force_session();
[email protected]ed24fad2011-05-10 22:44:01587
[email protected]5b52ad42011-05-26 14:26:09588 bool allow = setting == CONTENT_SETTING_ALLOW ||
589 setting == CONTENT_SETTING_SESSION_ONLY;
[email protected]ed24fad2011-05-10 22:44:01590
[email protected]8093a542011-05-13 07:29:32591 BrowserThread::PostTask(
592 BrowserThread::UI, FROM_HERE,
593 NewRunnableFunction(
594 &TabSpecificContentSettings::CookieChanged,
595 render_process_id, render_view_id, url, cookie_line, *options,
596 !allow));
[email protected]ed24fad2011-05-10 22:44:01597 return allow;
598}
599
[email protected]d5a19162011-06-30 18:51:54600bool ChromeContentBrowserClient::AllowSaveLocalState(
601 const content::ResourceContext& context) {
602 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
603 ProfileIOData* io_data =
604 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
605 return !io_data->clear_local_state_on_exit()->GetValue();
606}
607
[email protected]6133f922011-07-01 21:34:34608net::URLRequestContext*
609ChromeContentBrowserClient::OverrideRequestContextForURL(
610 const GURL& url, const content::ResourceContext& context) {
611 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
612 if (url.SchemeIs(chrome::kExtensionScheme)) {
613 ProfileIOData* io_data =
614 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
615 return io_data->extensions_request_context();
616 }
617
618 return NULL;
619}
620
[email protected]317f96c92011-05-31 06:53:41621QuotaPermissionContext*
622ChromeContentBrowserClient::CreateQuotaPermissionContext() {
623 return new ChromeQuotaPermissionContext();
624}
625
[email protected]a0ce3282011-08-19 20:49:52626void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
[email protected]0609b17f2011-05-31 20:13:42627 // On Mac, this call needs to be done on the UI thread. On other platforms,
628 // do it on the FILE thread so we don't slow down UI.
629#if defined(OS_MACOSX)
630 platform_util::OpenItem(path);
631#else
632 BrowserThread::PostTask(
633 BrowserThread::FILE, FROM_HERE,
634 NewRunnableFunction(&platform_util::OpenItem, path));
635#endif
636}
637
[email protected]a0ce3282011-08-19 20:49:52638void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
639#if defined(OS_MACOSX)
640 // Mac needs to run this operation on the UI thread.
641 platform_util::ShowItemInFolder(path);
642#else
643 BrowserThread::PostTask(
644 BrowserThread::FILE, FROM_HERE,
645 NewRunnableFunction(&platform_util::ShowItemInFolder, path));
646#endif
647}
648
[email protected]848dd042011-06-04 18:24:03649void ChromeContentBrowserClient::AllowCertificateError(
650 SSLCertErrorHandler* handler,
651 bool overridable,
[email protected]8a27abf2011-09-30 21:59:58652 const base::Callback<void(SSLCertErrorHandler*, bool)>& callback) {
[email protected]f9034cf2011-07-21 12:43:41653 // If the tab is being prerendered, cancel the prerender and the request.
654 TabContents* tab = tab_util::GetTabContentsByID(
655 handler->render_process_host_id(),
656 handler->tab_contents_id());
657 if (!tab) {
658 NOTREACHED();
659 return;
660 }
661 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:50662 prerender::PrerenderManagerFactory::GetForProfile(
663 Profile::FromBrowserContext(tab->browser_context()));
[email protected]f9034cf2011-07-21 12:43:41664 if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) {
665 if (prerender_manager->prerender_tracker()->TryCancel(
666 handler->render_process_host_id(),
667 handler->tab_contents_id(),
668 prerender::FINAL_STATUS_SSL_ERROR)) {
669 handler->CancelRequest();
670 return;
671 }
672 }
673
674 // Otherwise, display an SSL blocking page.
[email protected]848dd042011-06-04 18:24:03675 SSLBlockingPage* blocking_page = new SSLBlockingPage(
676 handler, overridable, callback);
677 blocking_page->Show();
678}
679
[email protected]c99c442e2011-08-24 11:37:30680void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:45681 int render_process_id,
682 int render_view_id,
683 SSLClientAuthHandler* handler) {
684 TabContents* tab = tab_util::GetTabContentsByID(
685 render_process_id, render_view_id);
686 if (!tab) {
687 NOTREACHED();
688 return;
689 }
690
691 TabContentsWrapper* wrapper =
692 TabContentsWrapper::GetCurrentWrapperForContents(tab);
[email protected]c99c442e2011-08-24 11:37:30693 wrapper->ssl_helper()->SelectClientCertificate(handler);
[email protected]8ec26472011-06-06 16:52:45694}
695
696void ChromeContentBrowserClient::AddNewCertificate(
697 net::URLRequest* request,
698 net::X509Certificate* cert,
699 int render_process_id,
700 int render_view_id) {
701 // The handler will run the UI and delete itself when it's finished.
702 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
703}
704
[email protected]941623e2011-06-07 23:06:04705void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
706 const GURL& source_origin,
707 int callback_context,
708 int render_process_id,
709 int render_view_id) {
710 RenderViewHost* rvh = RenderViewHost::FromID(
711 render_process_id, render_view_id);
712 if (!rvh) {
713 NOTREACHED();
714 return;
715 }
716
717 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37718 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04719 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37720 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04721 service->RequestPermission(
722 source_origin, render_process_id, render_view_id, callback_context,
723 tab_util::GetTabContentsByID(render_process_id, render_view_id));
724}
725
726WebKit::WebNotificationPresenter::Permission
727 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
728 const GURL& source_url,
729 const content::ResourceContext& context) {
730 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
731 ProfileIOData* io_data =
732 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
733
734 const Extension* extension =
735 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url);
736 if (extension &&
[email protected]0d3e4a22011-06-23 19:02:52737 extension->HasAPIPermission(ExtensionAPIPermission::kNotification)) {
[email protected]941623e2011-06-07 23:06:04738 return WebKit::WebNotificationPresenter::PermissionAllowed;
739 }
740
741 // Fall back to the regular notification preferences, which works on an
742 // origin basis.
743 return io_data->GetNotificationService() ?
744 io_data->GetNotificationService()->HasPermission(source_url.GetOrigin()) :
745 WebKit::WebNotificationPresenter::PermissionNotAllowed;
746}
747
748void ChromeContentBrowserClient::ShowDesktopNotification(
749 const DesktopNotificationHostMsg_Show_Params& params,
750 int render_process_id,
751 int render_view_id,
752 bool worker) {
753 RenderViewHost* rvh = RenderViewHost::FromID(
754 render_process_id, render_view_id);
755 if (!rvh) {
756 NOTREACHED();
757 return;
758 }
759
760 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37761 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04762 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37763 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04764 service->ShowDesktopNotification(
765 params, render_process_id, render_view_id,
766 worker ? DesktopNotificationService::WorkerNotification :
767 DesktopNotificationService::PageNotification);
768}
769
770void ChromeContentBrowserClient::CancelDesktopNotification(
771 int render_process_id,
772 int render_view_id,
773 int notification_id) {
774 RenderViewHost* rvh = RenderViewHost::FromID(
775 render_process_id, render_view_id);
776 if (!rvh) {
777 NOTREACHED();
778 return;
779 }
780
781 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37782 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04783 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37784 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04785 service->CancelDesktopNotification(
786 render_process_id, render_view_id, notification_id);
787}
788
[email protected]9f3fba52011-06-08 20:37:19789bool ChromeContentBrowserClient::CanCreateWindow(
790 const GURL& source_url,
791 WindowContainerType container_type,
792 const content::ResourceContext& context) {
793 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
794 // If the opener is trying to create a background window but doesn't have
795 // the appropriate permission, fail the attempt.
796 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
797 ProfileIOData* io_data =
798 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
799 const Extension* extension =
800 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url);
801 return (extension &&
[email protected]0d3e4a22011-06-23 19:02:52802 extension->HasAPIPermission(ExtensionAPIPermission::kBackground));
[email protected]9f3fba52011-06-08 20:37:19803 }
804 return true;
805}
806
807std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
808 const GURL& url, const content::ResourceContext& context) {
809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
810 // Check if it's an extension-created worker, in which case we want to use
811 // the name of the extension.
812 ProfileIOData* io_data =
813 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
814 const Extension* extension =
815 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
816 return extension ? extension->name() : std::string();
817}
818
[email protected]3cb054e62011-06-13 05:21:17819ResourceDispatcherHost*
820 ChromeContentBrowserClient::GetResourceDispatcherHost() {
821 return g_browser_process->resource_dispatcher_host();
822}
823
824ui::Clipboard* ChromeContentBrowserClient::GetClipboard() {
825 return g_browser_process->clipboard();
826}
827
[email protected]8f6a3b852011-07-19 16:48:56828MHTMLGenerationManager*
829 ChromeContentBrowserClient::GetMHTMLGenerationManager() {
830 return g_browser_process->mhtml_generation_manager();
831}
832
[email protected]dce502762011-07-20 08:53:49833DevToolsManager* ChromeContentBrowserClient::GetDevToolsManager() {
834 return g_browser_process->devtools_manager();
835}
836
[email protected]ae6e9912011-07-27 01:18:28837net::NetLog* ChromeContentBrowserClient::GetNetLog() {
838 return g_browser_process->net_log();
839}
840
[email protected]3bc0b562011-08-24 23:51:04841speech_input::SpeechInputManager*
842 ChromeContentBrowserClient::GetSpeechInputManager() {
843 return speech_input::ChromeSpeechInputManager::GetInstance();
844}
845
[email protected]32538d92011-08-25 00:09:23846AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
847 return new ChromeAccessTokenStore();
848}
849
[email protected]dbae6b02011-06-29 23:51:41850bool ChromeContentBrowserClient::IsFastShutdownPossible() {
851 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
852 return !browser_command_line.HasSwitch(switches::kChromeFrame);
853}
854
[email protected]3d7474ff2011-07-27 17:47:37855WebPreferences ChromeContentBrowserClient::GetWebkitPrefs(
856 content::BrowserContext* browser_context, bool is_web_ui) {
857 return RenderViewHostDelegateHelper::GetWebkitPrefs(browser_context,
858 is_web_ui);
[email protected]181a95ee2011-07-12 19:26:36859}
860
861void ChromeContentBrowserClient::UpdateInspectorSetting(
862 RenderViewHost* rvh, const std::string& key, const std::string& value) {
863 RenderViewHostDelegateHelper::UpdateInspectorSetting(
[email protected]3d7474ff2011-07-27 17:47:37864 rvh->process()->browser_context(), key, value);
[email protected]181a95ee2011-07-12 19:26:36865}
866
867void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
868 RenderViewHostDelegateHelper::ClearInspectorSettings(
[email protected]3d7474ff2011-07-27 17:47:37869 rvh->process()->browser_context());
[email protected]181a95ee2011-07-12 19:26:36870}
871
[email protected]b8148ac2011-07-13 22:03:25872void ChromeContentBrowserClient::BrowserURLHandlerCreated(
873 BrowserURLHandler* handler) {
874 // Add the default URL handlers.
875 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
876 BrowserURLHandler::null_handler());
877 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
878 &ExtensionWebUI::HandleChromeURLOverrideReverse);
879
880 // about:
881 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
882 BrowserURLHandler::null_handler());
883 // chrome: & friends.
884 handler->AddHandlerPair(&HandleWebUI,
885 BrowserURLHandler::null_handler());
886}
887
888void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:37889 Profile* profile = Profile::FromBrowserContext(
890 rvh->site_instance()->GetProcess()->browser_context());
[email protected]b8148ac2011-07-13 22:03:25891 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
892 BrowsingDataRemover::EVERYTHING,
893 base::Time());
894 remover->Remove(BrowsingDataRemover::REMOVE_CACHE);
895 // BrowsingDataRemover takes care of deleting itself when done.
896}
897
898void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:37899 Profile* profile = Profile::FromBrowserContext(
900 rvh->site_instance()->GetProcess()->browser_context());
[email protected]b8148ac2011-07-13 22:03:25901 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
902 BrowsingDataRemover::EVERYTHING,
903 base::Time());
[email protected]dceaa912011-09-06 17:17:23904 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]b8148ac2011-07-13 22:03:25905 remover->Remove(remove_mask);
906 // BrowsingDataRemover takes care of deleting itself when done.
907}
908
[email protected]e1d16eb92011-08-18 23:19:32909FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
910 return download_util::GetDefaultDownloadDirectory();
911}
912
[email protected]c9b6eb62011-10-18 20:49:39913std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
914 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
915}
916
[email protected]b80f68432011-05-02 17:22:30917#if defined(OS_LINUX)
918int ChromeContentBrowserClient::GetCrashSignalFD(
[email protected]718eab62011-10-05 21:16:52919 const CommandLine& command_line) {
920 if (command_line.HasSwitch(switches::kExtensionProcess)) {
[email protected]9dbfff12011-07-01 19:37:07921 ExtensionCrashHandlerHostLinux* crash_handler =
922 ExtensionCrashHandlerHostLinux::GetInstance();
923 return crash_handler->GetDeathSignalSocket();
924 }
925
[email protected]718eab62011-10-05 21:16:52926 std::string process_type =
927 command_line.GetSwitchValueASCII(switches::kProcessType);
928
929 if (process_type == switches::kRendererProcess)
930 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
931
[email protected]b80f68432011-05-02 17:22:30932 if (process_type == switches::kPluginProcess)
933 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
934
935 if (process_type == switches::kPpapiPluginProcess)
936 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
937
938 if (process_type == switches::kGpuProcess)
939 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
940
941 return -1;
942}
[email protected]9dbfff12011-07-01 19:37:07943#endif // defined(OS_LINUX)
[email protected]b80f68432011-05-02 17:22:30944
[email protected]4a65826d2011-08-25 16:04:01945#if defined(OS_WIN)
946const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
947 return chrome::kBrowserResourcesDll;
948}
949#endif
950
[email protected]37a72af2011-06-13 05:42:01951#if defined(USE_NSS)
952crypto::CryptoModuleBlockingPasswordDelegate*
953 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
954 const GURL& url) {
955 return browser::NewCryptoModuleBlockingDialogDelegate(
956 browser::kCryptoModulePasswordKeygen, url.host());
957}
958#endif
959
[email protected]d977f9c2011-03-14 16:10:26960} // namespace chrome