blob: b5e0f6c02af184307654f6430d6f08ae92ff9fc6 [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,
[email protected]06024c62011-10-20 20:57:12460 switches::kEnableLazyBackgroundPages,
[email protected]4287a3d2011-06-13 23:56:51461 switches::kEnableNaCl,
[email protected]5714ee32011-08-18 01:51:24462 switches::kEnablePrintPreview,
[email protected]4287a3d2011-06-13 23:56:51463 switches::kEnableSearchProviderApiV2,
464 switches::kEnableWatchdog,
465 switches::kExperimentalSpellcheckerFeatures,
466 switches::kMemoryProfiling,
467 switches::kMessageLoopHistogrammer,
[email protected]2a6bb0b12011-10-05 19:18:04468 switches::kNoRunningInsecureContent,
[email protected]4287a3d2011-06-13 23:56:51469 switches::kPpapiFlashArgs,
470 switches::kPpapiFlashInProcess,
471 switches::kPpapiFlashPath,
472 switches::kPpapiFlashVersion,
473 switches::kProfilingAtStart,
474 switches::kProfilingFile,
475 switches::kProfilingFlush,
[email protected]4287a3d2011-06-13 23:56:51476 switches::kSilentDumpOnDCHECK,
[email protected]6f08af82011-09-15 01:19:03477 switches::kEnableBenchmarking,
[email protected]4287a3d2011-06-13 23:56:51478 };
479
480 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
481 arraysize(kSwitchNames));
[email protected]3cb054e62011-06-13 05:21:17482 } else if (process_type == switches::kUtilityProcess) {
483 if (browser_command_line.HasSwitch(
484 switches::kEnableExperimentalExtensionApis)) {
485 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
486 }
[email protected]4287a3d2011-06-13 23:56:51487 } else if (process_type == switches::kPluginProcess) {
488 static const char* const kSwitchNames[] = {
489 #if defined(OS_CHROMEOS)
490 switches::kLoginProfile,
491 #endif
492 switches::kMemoryProfiling,
493 switches::kSilentDumpOnDCHECK,
494 switches::kUserDataDir,
495 };
496
497 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
498 arraysize(kSwitchNames));
499 } else if (process_type == switches::kZygoteProcess) {
500 static const char* const kSwitchNames[] = {
[email protected]4287a3d2011-06-13 23:56:51501 switches::kUserDataDir, // Make logs go to the right file.
502 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
503 switches::kPpapiFlashInProcess,
504 switches::kPpapiFlashPath,
505 switches::kPpapiFlashVersion,
506 };
507
508 command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
509 arraysize(kSwitchNames));
[email protected]b80f68432011-05-02 17:22:30510 }
[email protected]6f08af82011-09-15 01:19:03511
512 // The command line switch kEnableBenchmarking needs to be specified along
513 // with the kEnableStatsTable switch to ensure that the stats table global
514 // is initialized correctly.
515 if (command_line->HasSwitch(switches::kEnableBenchmarking))
516 DCHECK(command_line->HasSwitch(switches::kEnableStatsTable));
[email protected]b80f68432011-05-02 17:22:30517}
518
519std::string ChromeContentBrowserClient::GetApplicationLocale() {
520 return g_browser_process->GetApplicationLocale();
521}
522
[email protected]b5cca982011-05-26 04:42:08523std::string ChromeContentBrowserClient::GetAcceptLangs(const TabContents* tab) {
[email protected]3d7474ff2011-07-27 17:47:37524 Profile* profile = Profile::FromBrowserContext(tab->browser_context());
525 return profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
[email protected]b5cca982011-05-26 04:42:08526}
527
[email protected]ac55e292011-06-24 05:16:08528SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() {
529 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
[email protected]2cc6a9292011-10-13 21:41:01530#if defined(TOUCH_UI)
531 // In touch builds, we want large default favicons for the tabstrip, but in
532 // other places (such as bookmark, manage search engines, homepage) we assume
533 // default favicons are 16x16.
534 return rb.GetBitmapNamed(IDR_DEFAULT_LARGE_FAVICON);
535#else
[email protected]ac55e292011-06-24 05:16:08536 return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
[email protected]2cc6a9292011-10-13 21:41:01537#endif
[email protected]ac55e292011-06-24 05:16:08538}
539
[email protected]a2176792011-05-08 19:30:49540bool ChromeContentBrowserClient::AllowAppCache(
[email protected]5b52ad42011-05-26 14:26:09541 const GURL& manifest_url,
[email protected]0a608842011-09-08 10:55:19542 const GURL& first_party,
[email protected]5b52ad42011-05-26 14:26:09543 const content::ResourceContext& context) {
[email protected]8093a542011-05-13 07:29:32544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
545 ProfileIOData* io_data =
546 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]efa55212011-05-13 16:19:38547 ContentSetting setting = io_data->GetHostContentSettingsMap()->
[email protected]0a608842011-09-08 10:55:19548 GetCookieContentSetting(manifest_url, first_party, true);
[email protected]a2176792011-05-08 19:30:49549 DCHECK(setting != CONTENT_SETTING_DEFAULT);
550 return setting != CONTENT_SETTING_BLOCK;
551}
552
[email protected]ed24fad2011-05-10 22:44:01553bool ChromeContentBrowserClient::AllowGetCookie(
554 const GURL& url,
555 const GURL& first_party,
556 const net::CookieList& cookie_list,
557 const content::ResourceContext& context,
558 int render_process_id,
559 int render_view_id) {
560 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]8093a542011-05-13 07:29:32561 ProfileIOData* io_data =
562 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]5b52ad42011-05-26 14:26:09563 ContentSetting setting = io_data->GetHostContentSettingsMap()->
564 GetCookieContentSetting(url, first_party, false);
565 bool allow = setting == CONTENT_SETTING_ALLOW ||
566 setting == CONTENT_SETTING_SESSION_ONLY;
[email protected]ed24fad2011-05-10 22:44:01567
[email protected]8093a542011-05-13 07:29:32568 BrowserThread::PostTask(
569 BrowserThread::UI, FROM_HERE,
570 NewRunnableFunction(
571 &TabSpecificContentSettings::CookiesRead,
572 render_process_id, render_view_id, url, cookie_list, !allow));
[email protected]ed24fad2011-05-10 22:44:01573 return allow;
574}
575
576bool ChromeContentBrowserClient::AllowSetCookie(
577 const GURL& url,
578 const GURL& first_party,
579 const std::string& cookie_line,
580 const content::ResourceContext& context,
581 int render_process_id,
582 int render_view_id,
583 net::CookieOptions* options) {
584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
[email protected]8093a542011-05-13 07:29:32585 ProfileIOData* io_data =
586 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
[email protected]5b52ad42011-05-26 14:26:09587 ContentSetting setting = io_data->GetHostContentSettingsMap()->
588 GetCookieContentSetting(url, first_party, true);
[email protected]ed24fad2011-05-10 22:44:01589
[email protected]5b52ad42011-05-26 14:26:09590 if (setting == CONTENT_SETTING_SESSION_ONLY)
591 options->set_force_session();
[email protected]ed24fad2011-05-10 22:44:01592
[email protected]5b52ad42011-05-26 14:26:09593 bool allow = setting == CONTENT_SETTING_ALLOW ||
594 setting == CONTENT_SETTING_SESSION_ONLY;
[email protected]ed24fad2011-05-10 22:44:01595
[email protected]8093a542011-05-13 07:29:32596 BrowserThread::PostTask(
597 BrowserThread::UI, FROM_HERE,
598 NewRunnableFunction(
599 &TabSpecificContentSettings::CookieChanged,
600 render_process_id, render_view_id, url, cookie_line, *options,
601 !allow));
[email protected]ed24fad2011-05-10 22:44:01602 return allow;
603}
604
[email protected]d5a19162011-06-30 18:51:54605bool ChromeContentBrowserClient::AllowSaveLocalState(
606 const content::ResourceContext& context) {
607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
608 ProfileIOData* io_data =
609 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
610 return !io_data->clear_local_state_on_exit()->GetValue();
611}
612
[email protected]6133f922011-07-01 21:34:34613net::URLRequestContext*
614ChromeContentBrowserClient::OverrideRequestContextForURL(
615 const GURL& url, const content::ResourceContext& context) {
616 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
617 if (url.SchemeIs(chrome::kExtensionScheme)) {
618 ProfileIOData* io_data =
619 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
620 return io_data->extensions_request_context();
621 }
622
623 return NULL;
624}
625
[email protected]317f96c92011-05-31 06:53:41626QuotaPermissionContext*
627ChromeContentBrowserClient::CreateQuotaPermissionContext() {
628 return new ChromeQuotaPermissionContext();
629}
630
[email protected]a0ce3282011-08-19 20:49:52631void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
[email protected]0609b17f2011-05-31 20:13:42632 // On Mac, this call needs to be done on the UI thread. On other platforms,
633 // do it on the FILE thread so we don't slow down UI.
634#if defined(OS_MACOSX)
635 platform_util::OpenItem(path);
636#else
637 BrowserThread::PostTask(
638 BrowserThread::FILE, FROM_HERE,
639 NewRunnableFunction(&platform_util::OpenItem, path));
640#endif
641}
642
[email protected]a0ce3282011-08-19 20:49:52643void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
644#if defined(OS_MACOSX)
645 // Mac needs to run this operation on the UI thread.
646 platform_util::ShowItemInFolder(path);
647#else
648 BrowserThread::PostTask(
649 BrowserThread::FILE, FROM_HERE,
650 NewRunnableFunction(&platform_util::ShowItemInFolder, path));
651#endif
652}
653
[email protected]848dd042011-06-04 18:24:03654void ChromeContentBrowserClient::AllowCertificateError(
655 SSLCertErrorHandler* handler,
656 bool overridable,
[email protected]8a27abf2011-09-30 21:59:58657 const base::Callback<void(SSLCertErrorHandler*, bool)>& callback) {
[email protected]f9034cf2011-07-21 12:43:41658 // If the tab is being prerendered, cancel the prerender and the request.
659 TabContents* tab = tab_util::GetTabContentsByID(
660 handler->render_process_host_id(),
661 handler->tab_contents_id());
662 if (!tab) {
663 NOTREACHED();
664 return;
665 }
666 prerender::PrerenderManager* prerender_manager =
[email protected]3085c502011-10-05 17:50:50667 prerender::PrerenderManagerFactory::GetForProfile(
668 Profile::FromBrowserContext(tab->browser_context()));
[email protected]f9034cf2011-07-21 12:43:41669 if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) {
670 if (prerender_manager->prerender_tracker()->TryCancel(
671 handler->render_process_host_id(),
672 handler->tab_contents_id(),
673 prerender::FINAL_STATUS_SSL_ERROR)) {
674 handler->CancelRequest();
675 return;
676 }
677 }
678
679 // Otherwise, display an SSL blocking page.
[email protected]848dd042011-06-04 18:24:03680 SSLBlockingPage* blocking_page = new SSLBlockingPage(
681 handler, overridable, callback);
682 blocking_page->Show();
683}
684
[email protected]c99c442e2011-08-24 11:37:30685void ChromeContentBrowserClient::SelectClientCertificate(
[email protected]8ec26472011-06-06 16:52:45686 int render_process_id,
687 int render_view_id,
688 SSLClientAuthHandler* handler) {
689 TabContents* tab = tab_util::GetTabContentsByID(
690 render_process_id, render_view_id);
691 if (!tab) {
692 NOTREACHED();
693 return;
694 }
695
696 TabContentsWrapper* wrapper =
697 TabContentsWrapper::GetCurrentWrapperForContents(tab);
[email protected]c99c442e2011-08-24 11:37:30698 wrapper->ssl_helper()->SelectClientCertificate(handler);
[email protected]8ec26472011-06-06 16:52:45699}
700
701void ChromeContentBrowserClient::AddNewCertificate(
702 net::URLRequest* request,
703 net::X509Certificate* cert,
704 int render_process_id,
705 int render_view_id) {
706 // The handler will run the UI and delete itself when it's finished.
707 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
708}
709
[email protected]941623e2011-06-07 23:06:04710void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
711 const GURL& source_origin,
712 int callback_context,
713 int render_process_id,
714 int render_view_id) {
715 RenderViewHost* rvh = RenderViewHost::FromID(
716 render_process_id, render_view_id);
717 if (!rvh) {
718 NOTREACHED();
719 return;
720 }
721
722 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37723 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04724 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37725 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04726 service->RequestPermission(
727 source_origin, render_process_id, render_view_id, callback_context,
728 tab_util::GetTabContentsByID(render_process_id, render_view_id));
729}
730
731WebKit::WebNotificationPresenter::Permission
732 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
733 const GURL& source_url,
734 const content::ResourceContext& context) {
735 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
736 ProfileIOData* io_data =
737 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
738
739 const Extension* extension =
740 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url);
741 if (extension &&
[email protected]0d3e4a22011-06-23 19:02:52742 extension->HasAPIPermission(ExtensionAPIPermission::kNotification)) {
[email protected]941623e2011-06-07 23:06:04743 return WebKit::WebNotificationPresenter::PermissionAllowed;
744 }
745
746 // Fall back to the regular notification preferences, which works on an
747 // origin basis.
748 return io_data->GetNotificationService() ?
749 io_data->GetNotificationService()->HasPermission(source_url.GetOrigin()) :
750 WebKit::WebNotificationPresenter::PermissionNotAllowed;
751}
752
753void ChromeContentBrowserClient::ShowDesktopNotification(
754 const DesktopNotificationHostMsg_Show_Params& params,
755 int render_process_id,
756 int render_view_id,
757 bool worker) {
758 RenderViewHost* rvh = RenderViewHost::FromID(
759 render_process_id, render_view_id);
760 if (!rvh) {
761 NOTREACHED();
762 return;
763 }
764
765 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37766 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04767 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37768 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04769 service->ShowDesktopNotification(
770 params, render_process_id, render_view_id,
771 worker ? DesktopNotificationService::WorkerNotification :
772 DesktopNotificationService::PageNotification);
773}
774
775void ChromeContentBrowserClient::CancelDesktopNotification(
776 int render_process_id,
777 int render_view_id,
778 int notification_id) {
779 RenderViewHost* rvh = RenderViewHost::FromID(
780 render_process_id, render_view_id);
781 if (!rvh) {
782 NOTREACHED();
783 return;
784 }
785
786 RenderProcessHost* process = rvh->process();
[email protected]3d7474ff2011-07-27 17:47:37787 Profile* profile = Profile::FromBrowserContext(process->browser_context());
[email protected]941623e2011-06-07 23:06:04788 DesktopNotificationService* service =
[email protected]3d7474ff2011-07-27 17:47:37789 DesktopNotificationServiceFactory::GetForProfile(profile);
[email protected]941623e2011-06-07 23:06:04790 service->CancelDesktopNotification(
791 render_process_id, render_view_id, notification_id);
792}
793
[email protected]9f3fba52011-06-08 20:37:19794bool ChromeContentBrowserClient::CanCreateWindow(
795 const GURL& source_url,
796 WindowContainerType container_type,
797 const content::ResourceContext& context) {
798 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
799 // If the opener is trying to create a background window but doesn't have
800 // the appropriate permission, fail the attempt.
801 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
802 ProfileIOData* io_data =
803 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
804 const Extension* extension =
805 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url);
806 return (extension &&
[email protected]0d3e4a22011-06-23 19:02:52807 extension->HasAPIPermission(ExtensionAPIPermission::kBackground));
[email protected]9f3fba52011-06-08 20:37:19808 }
809 return true;
810}
811
812std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
813 const GURL& url, const content::ResourceContext& context) {
814 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
815 // Check if it's an extension-created worker, in which case we want to use
816 // the name of the extension.
817 ProfileIOData* io_data =
818 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
819 const Extension* extension =
820 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
821 return extension ? extension->name() : std::string();
822}
823
[email protected]3cb054e62011-06-13 05:21:17824ResourceDispatcherHost*
825 ChromeContentBrowserClient::GetResourceDispatcherHost() {
826 return g_browser_process->resource_dispatcher_host();
827}
828
829ui::Clipboard* ChromeContentBrowserClient::GetClipboard() {
830 return g_browser_process->clipboard();
831}
832
[email protected]8f6a3b852011-07-19 16:48:56833MHTMLGenerationManager*
834 ChromeContentBrowserClient::GetMHTMLGenerationManager() {
835 return g_browser_process->mhtml_generation_manager();
836}
837
[email protected]dce502762011-07-20 08:53:49838DevToolsManager* ChromeContentBrowserClient::GetDevToolsManager() {
839 return g_browser_process->devtools_manager();
840}
841
[email protected]ae6e9912011-07-27 01:18:28842net::NetLog* ChromeContentBrowserClient::GetNetLog() {
843 return g_browser_process->net_log();
844}
845
[email protected]3bc0b562011-08-24 23:51:04846speech_input::SpeechInputManager*
847 ChromeContentBrowserClient::GetSpeechInputManager() {
848 return speech_input::ChromeSpeechInputManager::GetInstance();
849}
850
[email protected]32538d92011-08-25 00:09:23851AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() {
852 return new ChromeAccessTokenStore();
853}
854
[email protected]dbae6b02011-06-29 23:51:41855bool ChromeContentBrowserClient::IsFastShutdownPossible() {
856 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
857 return !browser_command_line.HasSwitch(switches::kChromeFrame);
858}
859
[email protected]3d7474ff2011-07-27 17:47:37860WebPreferences ChromeContentBrowserClient::GetWebkitPrefs(
861 content::BrowserContext* browser_context, bool is_web_ui) {
862 return RenderViewHostDelegateHelper::GetWebkitPrefs(browser_context,
863 is_web_ui);
[email protected]181a95ee2011-07-12 19:26:36864}
865
866void ChromeContentBrowserClient::UpdateInspectorSetting(
867 RenderViewHost* rvh, const std::string& key, const std::string& value) {
868 RenderViewHostDelegateHelper::UpdateInspectorSetting(
[email protected]3d7474ff2011-07-27 17:47:37869 rvh->process()->browser_context(), key, value);
[email protected]181a95ee2011-07-12 19:26:36870}
871
872void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
873 RenderViewHostDelegateHelper::ClearInspectorSettings(
[email protected]3d7474ff2011-07-27 17:47:37874 rvh->process()->browser_context());
[email protected]181a95ee2011-07-12 19:26:36875}
876
[email protected]b8148ac2011-07-13 22:03:25877void ChromeContentBrowserClient::BrowserURLHandlerCreated(
878 BrowserURLHandler* handler) {
879 // Add the default URL handlers.
880 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
881 BrowserURLHandler::null_handler());
882 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
883 &ExtensionWebUI::HandleChromeURLOverrideReverse);
884
885 // about:
886 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
887 BrowserURLHandler::null_handler());
888 // chrome: & friends.
889 handler->AddHandlerPair(&HandleWebUI,
890 BrowserURLHandler::null_handler());
891}
892
893void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:37894 Profile* profile = Profile::FromBrowserContext(
895 rvh->site_instance()->GetProcess()->browser_context());
[email protected]b8148ac2011-07-13 22:03:25896 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
897 BrowsingDataRemover::EVERYTHING,
898 base::Time());
899 remover->Remove(BrowsingDataRemover::REMOVE_CACHE);
900 // BrowsingDataRemover takes care of deleting itself when done.
901}
902
903void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
[email protected]3d7474ff2011-07-27 17:47:37904 Profile* profile = Profile::FromBrowserContext(
905 rvh->site_instance()->GetProcess()->browser_context());
[email protected]b8148ac2011-07-13 22:03:25906 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
907 BrowsingDataRemover::EVERYTHING,
908 base::Time());
[email protected]dceaa912011-09-06 17:17:23909 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
[email protected]b8148ac2011-07-13 22:03:25910 remover->Remove(remove_mask);
911 // BrowsingDataRemover takes care of deleting itself when done.
912}
913
[email protected]e1d16eb92011-08-18 23:19:32914FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
915 return download_util::GetDefaultDownloadDirectory();
916}
917
[email protected]c9b6eb62011-10-18 20:49:39918std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
919 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
920}
921
[email protected]b80f68432011-05-02 17:22:30922#if defined(OS_LINUX)
923int ChromeContentBrowserClient::GetCrashSignalFD(
[email protected]718eab62011-10-05 21:16:52924 const CommandLine& command_line) {
925 if (command_line.HasSwitch(switches::kExtensionProcess)) {
[email protected]9dbfff12011-07-01 19:37:07926 ExtensionCrashHandlerHostLinux* crash_handler =
927 ExtensionCrashHandlerHostLinux::GetInstance();
928 return crash_handler->GetDeathSignalSocket();
929 }
930
[email protected]718eab62011-10-05 21:16:52931 std::string process_type =
932 command_line.GetSwitchValueASCII(switches::kProcessType);
933
934 if (process_type == switches::kRendererProcess)
935 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
936
[email protected]b80f68432011-05-02 17:22:30937 if (process_type == switches::kPluginProcess)
938 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
939
940 if (process_type == switches::kPpapiPluginProcess)
941 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
942
943 if (process_type == switches::kGpuProcess)
944 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
945
946 return -1;
947}
[email protected]9dbfff12011-07-01 19:37:07948#endif // defined(OS_LINUX)
[email protected]b80f68432011-05-02 17:22:30949
[email protected]4a65826d2011-08-25 16:04:01950#if defined(OS_WIN)
951const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
952 return chrome::kBrowserResourcesDll;
953}
954#endif
955
[email protected]37a72af2011-06-13 05:42:01956#if defined(USE_NSS)
957crypto::CryptoModuleBlockingPasswordDelegate*
958 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
959 const GURL& url) {
960 return browser::NewCryptoModuleBlockingDialogDelegate(
961 browser::kCryptoModulePasswordKeygen, url.host());
962}
963#endif
964
[email protected]d977f9c2011-03-14 16:10:26965} // namespace chrome