blob: 67a8da0997c29a1de1f205d0d2e24d19d198170e [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) {
[email protected]676f6ab2011-10-19 20:23:21174 if (!extension_process_manager->IsExtensionProcess(process_host->id()))
175 return PRIV_NORMAL;
176
177 std::set<const Extension*> extensions_for_process(
178 extension_process_manager->GetExtensionsForProcess(process_host->id()));
179 for (std::set<const Extension*>::iterator iter =
180 extensions_for_process.begin();
181 iter != extensions_for_process.end(); ++iter) {
182 if ((*iter)->is_storage_isolated())
[email protected]8d3132f62011-10-12 07:13:42183 return PRIV_ISOLATED;
[email protected]8d3132f62011-10-12 07:13:42184 }
185
[email protected]676f6ab2011-10-19 20:23:21186 return PRIV_EXTENSION;
[email protected]8d3132f62011-10-12 07:13:42187}
188
[email protected]9dbfff12011-07-01 19:37:07189} // namespace
[email protected]c5dbef02011-05-13 05:06:09190
[email protected]d977f9c2011-03-14 16:10:26191namespace chrome {
192
[email protected]f967b722011-09-07 00:58:04193content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
194 const MainFunctionParams& parameters) {
[email protected]5778d502011-10-13 17:13:21195#if defined(OS_CHROMEOS)
196 return new ChromeBrowserMainPartsChromeos(parameters);
197#elif defined(USE_AURA)
[email protected]199fc7a2011-09-28 22:45:38198 return new ChromeBrowserMainPartsAura(parameters);
199#elif defined(OS_WIN)
[email protected]e6b5bc22011-09-08 22:01:56200 return new ChromeBrowserMainPartsWin(parameters);
[email protected]f967b722011-09-07 00:58:04201#elif defined(OS_MACOSX)
[email protected]46c83b62011-09-08 22:09:04202 return new ChromeBrowserMainPartsMac(parameters);
[email protected]f967b722011-09-07 00:58:04203#elif defined(OS_LINUX)
[email protected]e6b5bc22011-09-08 22:01:56204 return new ChromeBrowserMainPartsGtk(parameters);
[email protected]f967b722011-09-07 00:58:04205#else
206 return NULL;
207#endif
208}
209
[email protected]b45937e2011-10-07 19:49:17210RenderWidgetHostView* ChromeContentBrowserClient::CreateViewForWidget(
211 RenderWidgetHost* widget) {
212#if defined(USE_AURA) || defined(TOUCH_UI)
213 return new RenderWidgetHostViewViews(widget);
214#elif defined(OS_WIN)
215 if (views::Widget::IsPureViews())
216 return new RenderWidgetHostViewViews(widget);
217 return new RenderWidgetHostViewWin(widget);
218#elif defined(OS_LINUX)
219 return new RenderWidgetHostViewGtk(widget);
220#elif defined(OS_MACOSX)
221 return render_widget_host_view_mac::CreateRenderWidgetHostView(widget);
222#else
223#error Need to create your platform ViewForWidget here.
224#endif
225}
226
[email protected]74313b42011-08-24 16:51:32227TabContentsView* ChromeContentBrowserClient::CreateTabContentsView(
228 TabContents* tab_contents) {
[email protected]080f34f2011-09-20 05:39:26229#if defined(TOOLKIT_VIEWS)
[email protected]74313b42011-08-24 16:51:32230 return new TabContentsViewViews(tab_contents);
231#elif defined(OS_LINUX)
232 return new TabContentsViewGtk(tab_contents);
233#elif defined(OS_MACOSX)
234 return tab_contents_view_mac::CreateTabContentsView(tab_contents);
[email protected]74313b42011-08-24 16:51:32235#else
236#error Need to create your platform TabContentsView here.
237#endif
238}
239
[email protected]f364d1392011-04-08 21:03:10240void ChromeContentBrowserClient::RenderViewHostCreated(
241 RenderViewHost* render_view_host) {
[email protected]67372ecf2011-09-10 01:30:46242
243 SiteInstance* site_instance = render_view_host->site_instance();
244 Profile* profile = Profile::FromBrowserContext(
245 site_instance->browsing_instance()->browser_context());
246
247 new ChromeRenderViewHostObserver(render_view_host,
248 profile->GetNetworkPredictor());
[email protected]f364d1392011-04-08 21:03:10249 new ExtensionMessageHandler(render_view_host);
[email protected]d977f9c2011-03-14 16:10:26250}
251
[email protected]05fcf982011-04-19 00:44:14252void ChromeContentBrowserClient::BrowserRenderProcessHostCreated(
253 BrowserRenderProcessHost* host) {
[email protected]c47cfd62011-04-29 21:27:02254 int id = host->id();
[email protected]3d7474ff2011-07-27 17:47:37255 Profile* profile = Profile::FromBrowserContext(host->browser_context());
[email protected]05fcf982011-04-19 00:44:14256 host->channel()->AddFilter(new ChromeRenderMessageFilter(
[email protected]c47cfd62011-04-29 21:27:02257 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]05fcf982011-04-19 00:44:14258 host->channel()->AddFilter(new PrintingMessageFilter());
259 host->channel()->AddFilter(
[email protected]c47cfd62011-04-29 21:27:02260 new SearchProviderInstallStateMessageFilter(id, profile));
261 host->channel()->AddFilter(new SpellCheckMessageFilter(id));
[email protected]6f08af82011-09-15 01:19:03262 host->channel()->AddFilter(new ChromeBenchmarkingMessageFilter(
263 id, profile, profile->GetRequestContextForRenderProcess(id)));
[email protected]3e69bc82011-05-26 23:22:38264
[email protected]2ccf45c2011-08-19 23:35:50265 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
266 profile->IsOffTheRecord()));
[email protected]05fcf982011-04-19 00:44:14267}
268
[email protected]97e6c4c2011-05-18 16:08:51269void ChromeContentBrowserClient::PluginProcessHostCreated(
270 PluginProcessHost* host) {
271 host->AddFilter(new ChromePluginMessageFilter(host));
272}
273
[email protected]5327dfb2011-05-03 17:50:36274void ChromeContentBrowserClient::WorkerProcessHostCreated(
275 WorkerProcessHost* host) {
276 host->AddFilter(new ChromeWorkerMessageFilter(host));
277}
278
[email protected]1fd1a502011-03-30 16:55:56279content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() {
280 return ChromeWebUIFactory::GetInstance();
281}
282
[email protected]3d7474ff2011-07-27 17:47:37283GURL ChromeContentBrowserClient::GetEffectiveURL(
284 content::BrowserContext* browser_context, const GURL& url) {
285 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]36fb2c7c2011-04-04 15:49:08286 // Get the effective URL for the given actual URL. If the URL is part of an
287 // installed app, the effective URL is an extension URL with the ID of that
288 // extension as the host. This has the effect of grouping apps together in
289 // a common SiteInstance.
290 if (!profile || !profile->GetExtensionService())
291 return url;
292
293 const Extension* extension =
294 profile->GetExtensionService()->GetExtensionByWebExtent(url);
295 if (!extension)
296 return url;
297
298 // If the URL is part of an extension's web extent, convert it to an
299 // extension URL.
300 return extension->GetResourceURL(url.path());
301}
302
[email protected]056ad2a2011-07-12 02:13:55303bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
[email protected]3d7474ff2011-07-27 17:47:37304 content::BrowserContext* browser_context, const GURL& effective_url) {
[email protected]056ad2a2011-07-12 02:13:55305 // Non-extension URLs should generally use process-per-site-instance.
306 // Because we expect to use the effective URL, hosted apps URLs should have
307 // an extension scheme by now.
308 if (!effective_url.SchemeIs(chrome::kExtensionScheme))
309 return false;
310
[email protected]3d7474ff2011-07-27 17:47:37311 Profile* profile = Profile::FromBrowserContext(browser_context);
[email protected]056ad2a2011-07-12 02:13:55312 if (!profile || !profile->GetExtensionService())
313 return false;
314
315 const Extension* extension =
316 profile->GetExtensionService()->GetExtensionByURL(effective_url);
317 if (!extension)
318 return false;
319
320 // If the URL is part of a hosted app that does not have the background
321 // permission, we want to give each instance its own process to improve
322 // responsiveness.
323 if (extension->GetType() == Extension::TYPE_HOSTED_APP &&
324 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground))
325 return false;
326
327 // Hosted apps that have the background permission must use process per site,
328 // since all instances can make synchronous calls to the background window.
329 // Other extensions should use process per site as well.
330 return true;
331}
332
[email protected]0f012df82011-05-19 14:15:29333bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) {
[email protected]89f550b2011-06-08 18:34:03334 return url == GURL(chrome::kChromeUICrashURL) ||
335 url == GURL(chrome::kChromeUIKillURL) ||
336 url == GURL(chrome::kChromeUIHangURL) ||
337 url == GURL(chrome::kChromeUIShorthangURL);
[email protected]0f012df82011-05-19 14:15:29338}
339
[email protected]2a5221b2011-09-27 23:07:31340bool ChromeContentBrowserClient::IsSuitableHost(
341 RenderProcessHost* process_host,
342 const GURL& site_url) {
343 Profile* profile =
344 Profile::FromBrowserContext(process_host->browser_context());
345 ExtensionProcessManager* extension_process_manager =
346 profile->GetExtensionProcessManager();
[email protected]8d3132f62011-10-12 07:13:42347 ExtensionService* service = profile->GetExtensionService();
[email protected]2a5221b2011-09-27 23:07:31348
[email protected]8d3132f62011-10-12 07:13:42349 // These may be NULL during tests. In that case, just assume any site can
350 // share any host.
351 if (!extension_process_manager || !service)
[email protected]2a5221b2011-09-27 23:07:31352 return true;
353
[email protected]8d3132f62011-10-12 07:13:42354 return GetProcessPrivilege(process_host, extension_process_manager) ==
355 GetPrivilegeRequiredByUrl(site_url, service);
[email protected]2a5221b2011-09-27 23:07:31356}
357
[email protected]e3daf3c2011-10-05 21:17:08358bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
359 const GURL& current_url,
360 const GURL& new_url) {
361 if (current_url.is_empty()) {
362 // Always choose a new process when navigating to extension URLs. The
363 // process grouping logic will combine all of a given extension's pages
364 // into the same process.
365 if (new_url.SchemeIs(chrome::kExtensionScheme))
366 return true;
367
368 return false;
369 }
370
371 // Also, we must switch if one is an extension and the other is not the exact
372 // same extension.
373 if (current_url.SchemeIs(chrome::kExtensionScheme) ||
374 new_url.SchemeIs(chrome::kExtensionScheme)) {
375 if (current_url.GetOrigin() != new_url.GetOrigin())
376 return true;
377 }
378
379 return false;
380}
381
[email protected]763ec4ca2011-04-29 15:48:12382std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
383 const std::string& alias_name) {
384 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
385}
386
[email protected]b80f68432011-05-02 17:22:30387void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
388 CommandLine* command_line, int child_process_id) {
389#if defined(USE_LINUX_BREAKPAD)
390 if (IsCrashReporterEnabled()) {
391 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
392 child_process_logging::GetClientId() + "," + base::GetLinuxDistro());
393 }
394#elif defined(OS_MACOSX)
395 if (IsCrashReporterEnabled()) {
396 command_line->AppendSwitchASCII(switches::kEnableCrashReporter,
397 child_process_logging::GetClientId());
398 }
399#endif // OS_MACOSX
400
[email protected]f1933792011-06-14 00:49:34401 if (logging::DialogsAreSuppressed())
402 command_line->AppendSwitch(switches::kNoErrorDialogs);
403
[email protected]b80f68432011-05-02 17:22:30404 std::string process_type =
405 command_line->GetSwitchValueASCII(switches::kProcessType);
[email protected]3cb054e62011-06-13 05:21:17406 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
[email protected]718eab62011-10-05 21:16:52407 if (process_type == switches::kRendererProcess) {
[email protected]b80f68432011-05-02 17:22:30408 FilePath user_data_dir =
409 browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
410 if (!user_data_dir.empty())
411 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
412#if defined(OS_CHROMEOS)
413 const std::string& login_profile =
414 browser_command_line.GetSwitchValueASCII(switches::kLoginProfile);
415 if (!login_profile.empty())
416 command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile);
417#endif
418
419 RenderProcessHost* process = RenderProcessHost::FromID(child_process_id);
420
[email protected]3d7474ff2011-07-27 17:47:37421 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]718eab62011-10-05 21:16:52422
423 ExtensionProcessManager* extension_process_manager =
424 profile->GetExtensionProcessManager();
425 if (extension_process_manager->IsExtensionProcess(
426 process->id())) {
427 command_line->AppendSwitch(switches::kExtensionProcess);
428 }
429
[email protected]3d7474ff2011-07-27 17:47:37430 PrefService* prefs = profile->GetPrefs();
[email protected]b80f68432011-05-02 17:22:30431 // Currently this pref is only registered if applied via a policy.
432 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) &&
433 prefs->GetBoolean(prefs::kDisable3DAPIs)) {
434 // Turn this policy into a command line switch.
435 command_line->AppendSwitch(switches::kDisable3DAPIs);
436 }
437
438 // Disable client-side phishing detection in the renderer if it is disabled
[email protected]8c40da62011-07-13 22:58:46439 // in the Profile preferences or the browser process.
440 if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) ||
441 !g_browser_process->safe_browsing_detection_service()) {
[email protected]b80f68432011-05-02 17:22:30442 command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection);
[email protected]8c40da62011-07-13 22:58:46443 }
[email protected]4287a3d2011-06-13 23:56:51444
445 static const char* const kSwitchNames[] = {
446 switches::kAllowHTTPBackgroundPage,
447 switches::kAllowScriptingGallery,
448 switches::kAppsCheckoutURL,
449 switches::kAppsGalleryURL,
[email protected]be9d9c82011-07-13 04:17:31450 switches::kCloudPrintServiceURL,
[email protected]4287a3d2011-06-13 23:56:51451 switches::kDebugPrint,
[email protected]4287a3d2011-06-13 23:56:51452 switches::kDisablePrintPreview,
[email protected]4287a3d2011-06-13 23:56:51453 switches::kDomAutomationController,
454 switches::kDumpHistogramsOnExit,
455 switches::kEnableClickToPlay,
456 switches::kEnableCrxlessWebApps,
457 switches::kEnableExperimentalExtensionApis,
458 switches::kEnableInBrowserThumbnailing,
459 switches::kEnableIPCFuzzing,
460 switches::kEnableNaCl,
[email protected]5714ee32011-08-18 01:51:24461 switches::kEnablePrintPreview,
[email protected]4287a3d2011-06-13 23:56:51462 switches::kEnableSearchProviderApiV2,
463 switches::kEnableWatchdog,
464 switches::kExperimentalSpellcheckerFeatures,
465 switches::kMemoryProfiling,
466 switches::kMessageLoopHistogrammer,
[email protected]2a6bb0b12011-10-05 19:18:04467 switches::kNoRunningInsecureContent,
[email protected]4287a3d2011-06-13 23:56:51468 switches::kPpapiFlashArgs,
469 switches::kPpapiFlashInProcess,
470 switches::kPpapiFlashPath,
471 switches::kPpapiFlashVersion,
472 switches::kProfilingAtStart,
473 switches::kProfilingFile,
474 switches::kProfilingFlush,
[email protected]4287a3d2011-06-13 23:56:51475 switches::kSilentDumpOnDCHECK,
[email protected]6f08af82011-09-15 01:19:03476 switches::kEnableBenchmarking,
[email protected]4287a3d2011-06-13 23:56:51477 };
478
479 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
480 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:17481 } else if (process_type == switches::kUtilityProcess) {
482 if (browser_command_line.HasSwitch(
483 switches::kEnableExperimentalExtensionApis)) {
484 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
485 }
[email protected]4287a3d2011-06-13 23:56:51486 } else if (process_type == switches::kPluginProcess) {
487 static const char* const kSwitchNames[] = {
488 #if defined(OS_CHROMEOS)
489 switches::kLoginProfile,
490 #endif
491 switches::kMemoryProfiling,
492 switches::kSilentDumpOnDCHECK,
493 switches::kUserDataDir,
494 };
495
496 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
497 arraysize(kSwitchNames));
498 } else if (process_type == switches::kZygoteProcess) {
499 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:51500 switches::kUserDataDir, // Make logs go to the right file.
501 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
502 switches::kPpapiFlashInProcess,
503 switches::kPpapiFlashPath,
504 switches::kPpapiFlashVersion,
505 };
506
507 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
508 arraysize(kSwitchNames));
[email protected]b80f68432011-05-02 17:22:30509 }
[email protected]6f08af82011-09-15 01:19:03510
511 // The command line switch kEnableBenchmarking needs to be specified along
512 // with the kEnableStatsTable switch to ensure that the stats table global
513 // is initialized correctly.
514 if (command_line->HasSwitch(switches::kEnableBenchmarking))
515 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:30516}
517
518std::string ChromeContentBrowserClient::GetApplicationLocale() {
519 return g_browser_process->GetApplicationLocale();
520}
521
[email protected]b5cca982011-05-26 04:42:08522std::string ChromeContentBrowserClient::GetAcceptLangs(const TabContents* tab) {
[email protected]3d7474ff2011-07-27 17:47:37523 Profile* profile = Profile::FromBrowserContext(tab->browser_context());
524 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:08525}
526
[email protected]ac55e292011-06-24 05:16:08527SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() {
528 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
[email protected]2cc6a9292011-10-13 21:41:01529#if defined(TOUCH_UI)
530 // In touch builds, we want large default favicons for the tabstrip, but in
531 // other places (such as bookmark, manage search engines, homepage) we assume
532 // default favicons are 16x16.
533 return rb.GetBitmapNamed(IDR_DEFAULT_LARGE_FAVICON);
534#else
[email protected]ac55e292011-06-24 05:16:08535 return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
[email protected]2cc6a9292011-10-13 21:41:01536#endif
[email protected]ac55e292011-06-24 05:16:08537}
538
[email protected]a2176792011-05-08 19:30:49539bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:09540 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:19541 const GURL& first_party,
[email protected]5b52ad42011-05-26 14:26:09542 const content::ResourceContext& context) {
[email protected]8093a542011-05-13 07:29:32543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
544 ProfileIOData* io_data =
545 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]efa55212011-05-13 16:19:38546 ContentSetting setting = io_data->GetHostContentSettingsMap()->
[email protected]0a608842011-09-08 10:55:19547 GetCookieContentSetting(manifest_url, first_party, true);
[email protected]a2176792011-05-08 19:30:49548 DCHECK(setting != CONTENT_SETTING_DEFAULT);
549 return setting != CONTENT_SETTING_BLOCK;
550}
551
[email protected]ed24fad2011-05-10 22:44:01552bool ChromeContentBrowserClient::AllowGetCookie(
553 const GURL& url,
554 const GURL& first_party,
555 const net::CookieList& cookie_list,
556 const content::ResourceContext& context,
557 int render_process_id,
558 int render_view_id) {
559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]8093a542011-05-13 07:29:32560 ProfileIOData* io_data =
561 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]5b52ad42011-05-26 14:26:09562 ContentSetting setting = io_data->GetHostContentSettingsMap()->
563 GetCookieContentSetting(url, first_party, false);
564 bool allow = setting == CONTENT_SETTING_ALLOW ||
565 setting == CONTENT_SETTING_SESSION_ONLY;
[email protected]ed24fad2011-05-10 22:44:01566
[email protected]8093a542011-05-13 07:29:32567 BrowserThread::PostTask(
568 BrowserThread::UI, FROM_HERE,
569 NewRunnableFunction(
570 &TabSpecificContentSettings::CookiesRead,
571 render_process_id, render_view_id, url, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:01572 return allow;
573}
574
575bool ChromeContentBrowserClient::AllowSetCookie(
576 const GURL& url,
577 const GURL& first_party,
578 const std::string& cookie_line,
579 const content::ResourceContext& context,
580 int render_process_id,
581 int render_view_id,
582 net::CookieOptions* options) {
583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]8093a542011-05-13 07:29:32584 ProfileIOData* io_data =
585 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]5b52ad42011-05-26 14:26:09586 ContentSetting setting = io_data->GetHostContentSettingsMap()->
587 GetCookieContentSetting(url, first_party, true);
[email protected]ed24fad2011-05-10 22:44:01588
[email protected]5b52ad42011-05-26 14:26:09589 if (setting == CONTENT_SETTING_SESSION_ONLY)
590 options->set_force_session();
[email protected]ed24fad2011-05-10 22:44:01591
[email protected]5b52ad42011-05-26 14:26:09592 bool allow = setting == CONTENT_SETTING_ALLOW ||
593 setting == CONTENT_SETTING_SESSION_ONLY;
[email protected]ed24fad2011-05-10 22:44:01594
[email protected]8093a542011-05-13 07:29:32595 BrowserThread::PostTask(
596 BrowserThread::UI, FROM_HERE,
597 NewRunnableFunction(
598 &TabSpecificContentSettings::CookieChanged,
599 render_process_id, render_view_id, url, cookie_line, *options,
600 !allow));
[email protected]ed24fad2011-05-10 22:44:01601 return allow;
602}
603
[email protected]d5a19162011-06-30 18:51:54604bool ChromeContentBrowserClient::AllowSaveLocalState(
605 const content::ResourceContext& context) {
606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
607 ProfileIOData* io_data =
608 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
609 return !io_data->clear_local_state_on_exit()->GetValue();
610}
611
[email protected]6133f922011-07-01 21:34:34612net::URLRequestContext*
613ChromeContentBrowserClient::OverrideRequestContextForURL(
614 const GURL& url, const content::ResourceContext& context) {
615 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
616 if (url.SchemeIs(chrome::kExtensionScheme)) {
617 ProfileIOData* io_data =
618 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
619 return io_data->extensions_request_context();
620 }
621
622 return NULL;
623}
624
[email protected]317f96c92011-05-31 06:53:41625QuotaPermissionContext*
626ChromeContentBrowserClient::CreateQuotaPermissionContext() {
627 return new ChromeQuotaPermissionContext();
628}
629
[email protected]a0ce3282011-08-19 20:49:52630void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
[email protected]0609b17f2011-05-31 20:13:42631 // On Mac, this call needs to be done on the UI thread. On other platforms,
632 // do it on the FILE thread so we don't slow down UI.
633#if defined(OS_MACOSX)
634 platform_util::OpenItem(path);
635#else
636 BrowserThread::PostTask(
637 BrowserThread::FILE, FROM_HERE,
638 NewRunnableFunction(&platform_util::OpenItem, path));
639#endif
640}
641
[email protected]a0ce3282011-08-19 20:49:52642void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
643#if defined(OS_MACOSX)
644 // Mac needs to run this operation on the UI thread.
645 platform_util::ShowItemInFolder(path);
646#else
647 BrowserThread::PostTask(
648 BrowserThread::FILE, FROM_HERE,
649 NewRunnableFunction(&platform_util::ShowItemInFolder, path));
650#endif
651}
652
[email protected]848dd042011-06-04 18:24:03653void ChromeContentBrowserClient::AllowCertificateError(
654 SSLCertErrorHandler* handler,
655 bool overridable,
[email protected]8a27abf2011-09-30 21:59:58656 const base::Callback<void(SSLCertErrorHandler*, bool)>& callback) {
[email protected]f9034cf2011-07-21 12:43:41657 // If the tab is being prerendered, cancel the prerender and the request.
658 TabContents* tab = tab_util::GetTabContentsByID(
659 handler->render_process_host_id(),
660 handler->tab_contents_id());
661 if (!tab) {
662 NOTREACHED();
663 return;
664 }
665 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:50666 prerender::PrerenderManagerFactory::GetForProfile(
667 Profile::FromBrowserContext(tab->browser_context()));
[email protected]f9034cf2011-07-21 12:43:41668 if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) {
669 if (prerender_manager->prerender_tracker()->TryCancel(
670 handler->render_process_host_id(),
671 handler->tab_contents_id(),
672 prerender::FINAL_STATUS_SSL_ERROR)) {
673 handler->CancelRequest();
674 return;
675 }
676 }
677
678 // Otherwise, display an SSL blocking page.
[email protected]848dd042011-06-04 18:24:03679 SSLBlockingPage* blocking_page = new SSLBlockingPage(
680 handler, overridable, callback);
681 blocking_page->Show();
682}
683
[email protected]c99c442e2011-08-24 11:37:30684void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:45685 int render_process_id,
686 int render_view_id,
687 SSLClientAuthHandler* handler) {
688 TabContents* tab = tab_util::GetTabContentsByID(
689 render_process_id, render_view_id);
690 if (!tab) {
691 NOTREACHED();
692 return;
693 }
694
695 TabContentsWrapper* wrapper =
696 TabContentsWrapper::GetCurrentWrapperForContents(tab);
[email protected]c99c442e2011-08-24 11:37:30697 wrapper->ssl_helper()->SelectClientCertificate(handler);
[email protected]8ec26472011-06-06 16:52:45698}
699
700void ChromeContentBrowserClient::AddNewCertificate(
701 net::URLRequest* request,
702 net::X509Certificate* cert,
703 int render_process_id,
704 int render_view_id) {
705 // The handler will run the UI and delete itself when it's finished.
706 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
707}
708
[email protected]941623e2011-06-07 23:06:04709void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
710 const GURL& source_origin,
711 int callback_context,
712 int render_process_id,
713 int render_view_id) {
714 RenderViewHost* rvh = RenderViewHost::FromID(
715 render_process_id, render_view_id);
716 if (!rvh) {
717 NOTREACHED();
718 return;
719 }
720
721 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37722 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04723 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37724 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04725 service->RequestPermission(
726 source_origin, render_process_id, render_view_id, callback_context,
727 tab_util::GetTabContentsByID(render_process_id, render_view_id));
728}
729
730WebKit::WebNotificationPresenter::Permission
731 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
732 const GURL& source_url,
733 const content::ResourceContext& context) {
734 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
735 ProfileIOData* io_data =
736 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
737
738 const Extension* extension =
739 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url);
740 if (extension &&
[email protected]0d3e4a22011-06-23 19:02:52741 extension->HasAPIPermission(ExtensionAPIPermission::kNotification)) {
[email protected]941623e2011-06-07 23:06:04742 return WebKit::WebNotificationPresenter::PermissionAllowed;
743 }
744
745 // Fall back to the regular notification preferences, which works on an
746 // origin basis.
747 return io_data->GetNotificationService() ?
748 io_data->GetNotificationService()->HasPermission(source_url.GetOrigin()) :
749 WebKit::WebNotificationPresenter::PermissionNotAllowed;
750}
751
752void ChromeContentBrowserClient::ShowDesktopNotification(
753 const DesktopNotificationHostMsg_Show_Params& params,
754 int render_process_id,
755 int render_view_id,
756 bool worker) {
757 RenderViewHost* rvh = RenderViewHost::FromID(
758 render_process_id, render_view_id);
759 if (!rvh) {
760 NOTREACHED();
761 return;
762 }
763
764 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37765 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04766 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37767 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04768 service->ShowDesktopNotification(
769 params, render_process_id, render_view_id,
770 worker ? DesktopNotificationService::WorkerNotification :
771 DesktopNotificationService::PageNotification);
772}
773
774void ChromeContentBrowserClient::CancelDesktopNotification(
775 int render_process_id,
776 int render_view_id,
777 int notification_id) {
778 RenderViewHost* rvh = RenderViewHost::FromID(
779 render_process_id, render_view_id);
780 if (!rvh) {
781 NOTREACHED();
782 return;
783 }
784
785 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37786 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04787 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37788 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04789 service->CancelDesktopNotification(
790 render_process_id, render_view_id, notification_id);
791}
792
[email protected]9f3fba52011-06-08 20:37:19793bool ChromeContentBrowserClient::CanCreateWindow(
794 const GURL& source_url,
795 WindowContainerType container_type,
796 const content::ResourceContext& context) {
797 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
798 // If the opener is trying to create a background window but doesn't have
799 // the appropriate permission, fail the attempt.
800 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
801 ProfileIOData* io_data =
802 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
803 const Extension* extension =
804 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url);
805 return (extension &&
[email protected]0d3e4a22011-06-23 19:02:52806 extension->HasAPIPermission(ExtensionAPIPermission::kBackground));
[email protected]9f3fba52011-06-08 20:37:19807 }
808 return true;
809}
810
811std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
812 const GURL& url, const content::ResourceContext& context) {
813 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
814 // Check if it's an extension-created worker, in which case we want to use
815 // the name of the extension.
816 ProfileIOData* io_data =
817 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
818 const Extension* extension =
819 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
820 return extension ? extension->name() : std::string();
821}
822
[email protected]3cb054e62011-06-13 05:21:17823ResourceDispatcherHost*
824 ChromeContentBrowserClient::GetResourceDispatcherHost() {
825 return g_browser_process->resource_dispatcher_host();
826}
827
828ui::Clipboard* ChromeContentBrowserClient::GetClipboard() {
829 return g_browser_process->clipboard();
830}
831
[email protected]8f6a3b852011-07-19 16:48:56832MHTMLGenerationManager*
833 ChromeContentBrowserClient::GetMHTMLGenerationManager() {
834 return g_browser_process->mhtml_generation_manager();
835}
836
[email protected]dce502762011-07-20 08:53:49837DevToolsManager* ChromeContentBrowserClient::GetDevToolsManager() {
838 return g_browser_process->devtools_manager();
839}
840
[email protected]ae6e9912011-07-27 01:18:28841net::NetLog* ChromeContentBrowserClient::GetNetLog() {
842 return g_browser_process->net_log();
843}
844
[email protected]3bc0b562011-08-24 23:51:04845speech_input::SpeechInputManager*
846 ChromeContentBrowserClient::GetSpeechInputManager() {
847 return speech_input::ChromeSpeechInputManager::GetInstance();
848}
849
[email protected]32538d92011-08-25 00:09:23850AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
851 return new ChromeAccessTokenStore();
852}
853
[email protected]dbae6b02011-06-29 23:51:41854bool ChromeContentBrowserClient::IsFastShutdownPossible() {
855 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
856 return !browser_command_line.HasSwitch(switches::kChromeFrame);
857}
858
[email protected]3d7474ff2011-07-27 17:47:37859WebPreferences ChromeContentBrowserClient::GetWebkitPrefs(
860 content::BrowserContext* browser_context, bool is_web_ui) {
861 return RenderViewHostDelegateHelper::GetWebkitPrefs(browser_context,
862 is_web_ui);
[email protected]181a95ee2011-07-12 19:26:36863}
864
865void ChromeContentBrowserClient::UpdateInspectorSetting(
866 RenderViewHost* rvh, const std::string& key, const std::string& value) {
867 RenderViewHostDelegateHelper::UpdateInspectorSetting(
[email protected]3d7474ff2011-07-27 17:47:37868 rvh->process()->browser_context(), key, value);
[email protected]181a95ee2011-07-12 19:26:36869}
870
871void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
872 RenderViewHostDelegateHelper::ClearInspectorSettings(
[email protected]3d7474ff2011-07-27 17:47:37873 rvh->process()->browser_context());
[email protected]181a95ee2011-07-12 19:26:36874}
875
[email protected]b8148ac2011-07-13 22:03:25876void ChromeContentBrowserClient::BrowserURLHandlerCreated(
877 BrowserURLHandler* handler) {
878 // Add the default URL handlers.
879 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
880 BrowserURLHandler::null_handler());
881 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
882 &ExtensionWebUI::HandleChromeURLOverrideReverse);
883
884 // about:
885 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
886 BrowserURLHandler::null_handler());
887 // chrome: & friends.
888 handler->AddHandlerPair(&HandleWebUI,
889 BrowserURLHandler::null_handler());
890}
891
892void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:37893 Profile* profile = Profile::FromBrowserContext(
894 rvh->site_instance()->GetProcess()->browser_context());
[email protected]b8148ac2011-07-13 22:03:25895 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
896 BrowsingDataRemover::EVERYTHING,
897 base::Time());
898 remover->Remove(BrowsingDataRemover::REMOVE_CACHE);
899 // BrowsingDataRemover takes care of deleting itself when done.
900}
901
902void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:37903 Profile* profile = Profile::FromBrowserContext(
904 rvh->site_instance()->GetProcess()->browser_context());
[email protected]b8148ac2011-07-13 22:03:25905 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
906 BrowsingDataRemover::EVERYTHING,
907 base::Time());
[email protected]dceaa912011-09-06 17:17:23908 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]b8148ac2011-07-13 22:03:25909 remover->Remove(remove_mask);
910 // BrowsingDataRemover takes care of deleting itself when done.
911}
912
[email protected]e1d16eb92011-08-18 23:19:32913FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
914 return download_util::GetDefaultDownloadDirectory();
915}
916
[email protected]c9b6eb62011-10-18 20:49:39917std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
918 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
919}
920
[email protected]b80f68432011-05-02 17:22:30921#if defined(OS_LINUX)
922int ChromeContentBrowserClient::GetCrashSignalFD(
[email protected]718eab62011-10-05 21:16:52923 const CommandLine& command_line) {
924 if (command_line.HasSwitch(switches::kExtensionProcess)) {
[email protected]9dbfff12011-07-01 19:37:07925 ExtensionCrashHandlerHostLinux* crash_handler =
926 ExtensionCrashHandlerHostLinux::GetInstance();
927 return crash_handler->GetDeathSignalSocket();
928 }
929
[email protected]718eab62011-10-05 21:16:52930 std::string process_type =
931 command_line.GetSwitchValueASCII(switches::kProcessType);
932
933 if (process_type == switches::kRendererProcess)
934 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
935
[email protected]b80f68432011-05-02 17:22:30936 if (process_type == switches::kPluginProcess)
937 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
938
939 if (process_type == switches::kPpapiPluginProcess)
940 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
941
942 if (process_type == switches::kGpuProcess)
943 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
944
945 return -1;
946}
[email protected]9dbfff12011-07-01 19:37:07947#endif // defined(OS_LINUX)
[email protected]b80f68432011-05-02 17:22:30948
[email protected]4a65826d2011-08-25 16:04:01949#if defined(OS_WIN)
950const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
951 return chrome::kBrowserResourcesDll;
952}
953#endif
954
[email protected]37a72af2011-06-13 05:42:01955#if defined(USE_NSS)
956crypto::CryptoModuleBlockingPasswordDelegate*
957 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
958 const GURL& url) {
959 return browser::NewCryptoModuleBlockingDialogDelegate(
960 browser::kCryptoModulePasswordKeygen, url.host());
961}
962#endif
963
[email protected]d977f9c2011-03-14 16:10:26964} // namespace chrome