[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/chrome_content_browser_client.h" |
| 6 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 7 | #include "base/command_line.h" |
| 8 | #include "chrome/app/breakpad_mac.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 9 | #include "chrome/browser/browser_about_handler.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 10 | #include "chrome/browser/browser_process.h" |
[email protected] | 3b8f7e3 | 2011-07-13 11:52:23 | [diff] [blame] | 11 | #include "chrome/browser/browsing_data_remover.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 12 | #include "chrome/browser/character_encoding.h" |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 13 | #include "chrome/browser/chrome_plugin_message_filter.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 14 | #include "chrome/browser/chrome_quota_permission_context.h" |
[email protected] | 5327dfb | 2011-05-03 17:50:36 | [diff] [blame] | 15 | #include "chrome/browser/chrome_worker_message_filter.h" |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 16 | #include "chrome/browser/content_settings/host_content_settings_map.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 17 | #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 18 | #include "chrome/browser/download/download_util.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 19 | #include "chrome/browser/extensions/extension_info_map.h" |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 20 | #include "chrome/browser/extensions/extension_message_handler.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 21 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 22 | #include "chrome/browser/extensions/extension_web_ui.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 23 | #include "chrome/browser/google/google_util.h" |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 24 | #include "chrome/browser/net/chrome_net_log.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 25 | #include "chrome/browser/notifications/desktop_notification_service.h" |
| 26 | #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 27 | #include "chrome/browser/platform_util.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 28 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 29 | #include "chrome/browser/prerender/prerender_manager.h" |
| 30 | #include "chrome/browser/prerender/prerender_tracker.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 31 | #include "chrome/browser/printing/printing_message_filter.h" |
| 32 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 33 | #include "chrome/browser/profiles/profile_io_data.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 34 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | 53a0afa | 2011-04-28 02:09:33 | [diff] [blame] | 35 | #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 36 | #include "chrome/browser/renderer_host/text_input_client_message_filter.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 37 | #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h" |
[email protected] | 8ec7126 | 2011-07-28 08:12:46 | [diff] [blame] | 38 | #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 39 | #include "chrome/browser/ssl/ssl_add_cert_handler.h" |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 40 | #include "chrome/browser/ssl/ssl_blocking_page.h" |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 41 | #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 42 | #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 43 | #include "chrome/browser/tab_contents/tab_util.h" |
| 44 | #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 45 | #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 46 | #include "chrome/common/child_process_logging.h" |
| 47 | #include "chrome/common/chrome_switches.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 48 | #include "chrome/common/extensions/extension.h" |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 49 | #include "chrome/common/logging_chrome.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 50 | #include "chrome/common/pref_names.h" |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 51 | #include "chrome/common/render_messages.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 52 | #include "chrome/common/url_constants.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 53 | #include "content/browser/browser_url_handler.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 54 | #include "content/browser/browsing_instance.h" |
[email protected] | b46442d7e | 2011-06-29 02:16:06 | [diff] [blame] | 55 | #include "content/browser/debugger/devtools_handler.h" |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 56 | #include "content/browser/plugin_process_host.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 57 | #include "content/browser/renderer_host/browser_render_process_host.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 58 | #include "content/browser/renderer_host/render_view_host.h" |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 59 | #include "content/browser/resource_context.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 60 | #include "content/browser/site_instance.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 61 | #include "content/browser/ssl/ssl_cert_error_handler.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 62 | #include "content/browser/ssl/ssl_client_auth_handler.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 63 | #include "content/browser/tab_contents/tab_contents.h" |
[email protected] | 5327dfb | 2011-05-03 17:50:36 | [diff] [blame] | 64 | #include "content/browser/worker_host/worker_process_host.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 65 | #include "content/common/desktop_notification_messages.h" |
[email protected] | 29b25d09 | 2011-06-29 20:57:34 | [diff] [blame] | 66 | #include "grit/ui_resources.h" |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 67 | #include "net/base/cookie_monster.h" |
| 68 | #include "net/base/cookie_options.h" |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 69 | #include "ui/base/resource/resource_bundle.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 70 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 71 | #if defined(OS_LINUX) |
| 72 | #include "base/linux_util.h" |
| 73 | #include "chrome/browser/crash_handler_host_linux.h" |
[email protected] | 1fd5302c | 2011-05-28 04:06:43 | [diff] [blame] | 74 | #endif |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 75 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 76 | #if defined(USE_NSS) |
| 77 | #include "chrome/browser/ui/crypto_module_password_dialog.h" |
| 78 | #endif |
| 79 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 80 | namespace { |
| 81 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 82 | // Handles rewriting Web UI URLs. |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 83 | static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
| 84 | if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url)) |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 85 | return false; |
| 86 | |
| 87 | // Special case the new tab page. In older versions of Chrome, the new tab |
| 88 | // page was hosted at chrome-internal:<blah>. This might be in people's saved |
| 89 | // sessions or bookmarks, so we say any URL with that scheme triggers the new |
| 90 | // tab page. |
| 91 | if (url->SchemeIs(chrome::kChromeInternalScheme)) { |
| 92 | // Rewrite it with the proper new tab URL. |
| 93 | *url = GURL(chrome::kChromeUINewTabURL); |
| 94 | } |
| 95 | |
| 96 | return true; |
| 97 | } |
| 98 | |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 99 | } // namespace |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 100 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 101 | namespace chrome { |
| 102 | |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 103 | void ChromeContentBrowserClient::RenderViewHostCreated( |
| 104 | RenderViewHost* render_view_host) { |
[email protected] | b50391416 | 2011-08-19 16:02:50 | [diff] [blame^] | 105 | new ChromeRenderViewHostObserver(render_view_host); |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 106 | new DevToolsHandler(render_view_host); |
| 107 | new ExtensionMessageHandler(render_view_host); |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 108 | } |
| 109 | |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 110 | void ChromeContentBrowserClient::BrowserRenderProcessHostCreated( |
| 111 | BrowserRenderProcessHost* host) { |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 112 | int id = host->id(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 113 | Profile* profile = Profile::FromBrowserContext(host->browser_context()); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 114 | host->channel()->AddFilter(new ChromeRenderMessageFilter( |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 115 | id, profile, profile->GetRequestContextForRenderProcess(id))); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 116 | host->channel()->AddFilter(new PrintingMessageFilter()); |
| 117 | host->channel()->AddFilter( |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 118 | new SearchProviderInstallStateMessageFilter(id, profile)); |
| 119 | host->channel()->AddFilter(new SpellCheckMessageFilter(id)); |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 120 | #if defined(OS_MACOSX) |
| 121 | host->channel()->AddFilter(new TextInputClientMessageFilter(host->id())); |
| 122 | #endif |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 123 | |
| 124 | host->Send(new ViewMsg_SetIsIncognitoProcess(profile->IsOffTheRecord())); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 125 | } |
| 126 | |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 127 | void ChromeContentBrowserClient::PluginProcessHostCreated( |
| 128 | PluginProcessHost* host) { |
| 129 | host->AddFilter(new ChromePluginMessageFilter(host)); |
| 130 | } |
| 131 | |
[email protected] | 5327dfb | 2011-05-03 17:50:36 | [diff] [blame] | 132 | void ChromeContentBrowserClient::WorkerProcessHostCreated( |
| 133 | WorkerProcessHost* host) { |
| 134 | host->AddFilter(new ChromeWorkerMessageFilter(host)); |
| 135 | } |
| 136 | |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 137 | content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() { |
| 138 | return ChromeWebUIFactory::GetInstance(); |
| 139 | } |
| 140 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 141 | GURL ChromeContentBrowserClient::GetEffectiveURL( |
| 142 | content::BrowserContext* browser_context, const GURL& url) { |
| 143 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 144 | // Get the effective URL for the given actual URL. If the URL is part of an |
| 145 | // installed app, the effective URL is an extension URL with the ID of that |
| 146 | // extension as the host. This has the effect of grouping apps together in |
| 147 | // a common SiteInstance. |
| 148 | if (!profile || !profile->GetExtensionService()) |
| 149 | return url; |
| 150 | |
| 151 | const Extension* extension = |
| 152 | profile->GetExtensionService()->GetExtensionByWebExtent(url); |
| 153 | if (!extension) |
| 154 | return url; |
| 155 | |
| 156 | // If the URL is part of an extension's web extent, convert it to an |
| 157 | // extension URL. |
| 158 | return extension->GetResourceURL(url.path()); |
| 159 | } |
| 160 | |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 161 | bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 162 | content::BrowserContext* browser_context, const GURL& effective_url) { |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 163 | // Non-extension URLs should generally use process-per-site-instance. |
| 164 | // Because we expect to use the effective URL, hosted apps URLs should have |
| 165 | // an extension scheme by now. |
| 166 | if (!effective_url.SchemeIs(chrome::kExtensionScheme)) |
| 167 | return false; |
| 168 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 169 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 170 | if (!profile || !profile->GetExtensionService()) |
| 171 | return false; |
| 172 | |
| 173 | const Extension* extension = |
| 174 | profile->GetExtensionService()->GetExtensionByURL(effective_url); |
| 175 | if (!extension) |
| 176 | return false; |
| 177 | |
| 178 | // If the URL is part of a hosted app that does not have the background |
| 179 | // permission, we want to give each instance its own process to improve |
| 180 | // responsiveness. |
| 181 | if (extension->GetType() == Extension::TYPE_HOSTED_APP && |
| 182 | !extension->HasAPIPermission(ExtensionAPIPermission::kBackground)) |
| 183 | return false; |
| 184 | |
| 185 | // Hosted apps that have the background permission must use process per site, |
| 186 | // since all instances can make synchronous calls to the background window. |
| 187 | // Other extensions should use process per site as well. |
| 188 | return true; |
| 189 | } |
| 190 | |
[email protected] | 0f012df8 | 2011-05-19 14:15:29 | [diff] [blame] | 191 | bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 192 | return url == GURL(chrome::kChromeUICrashURL) || |
| 193 | url == GURL(chrome::kChromeUIKillURL) || |
| 194 | url == GURL(chrome::kChromeUIHangURL) || |
| 195 | url == GURL(chrome::kChromeUIShorthangURL); |
[email protected] | 0f012df8 | 2011-05-19 14:15:29 | [diff] [blame] | 196 | } |
| 197 | |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 198 | std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
| 199 | const std::string& alias_name) { |
| 200 | return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); |
| 201 | } |
| 202 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 203 | void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
| 204 | CommandLine* command_line, int child_process_id) { |
| 205 | #if defined(USE_LINUX_BREAKPAD) |
| 206 | if (IsCrashReporterEnabled()) { |
| 207 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 208 | child_process_logging::GetClientId() + "," + base::GetLinuxDistro()); |
| 209 | } |
| 210 | #elif defined(OS_MACOSX) |
| 211 | if (IsCrashReporterEnabled()) { |
| 212 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 213 | child_process_logging::GetClientId()); |
| 214 | } |
| 215 | #endif // OS_MACOSX |
| 216 | |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 217 | if (logging::DialogsAreSuppressed()) |
| 218 | command_line->AppendSwitch(switches::kNoErrorDialogs); |
| 219 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 220 | std::string process_type = |
| 221 | command_line->GetSwitchValueASCII(switches::kProcessType); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 222 | const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 223 | if (process_type == switches::kExtensionProcess || |
| 224 | process_type == switches::kRendererProcess) { |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 225 | FilePath user_data_dir = |
| 226 | browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
| 227 | if (!user_data_dir.empty()) |
| 228 | command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 229 | #if defined(OS_CHROMEOS) |
| 230 | const std::string& login_profile = |
| 231 | browser_command_line.GetSwitchValueASCII(switches::kLoginProfile); |
| 232 | if (!login_profile.empty()) |
| 233 | command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile); |
| 234 | #endif |
| 235 | |
| 236 | RenderProcessHost* process = RenderProcessHost::FromID(child_process_id); |
| 237 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 238 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
| 239 | PrefService* prefs = profile->GetPrefs(); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 240 | // Currently this pref is only registered if applied via a policy. |
| 241 | if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && |
| 242 | prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
| 243 | // Turn this policy into a command line switch. |
| 244 | command_line->AppendSwitch(switches::kDisable3DAPIs); |
| 245 | } |
| 246 | |
| 247 | // Disable client-side phishing detection in the renderer if it is disabled |
[email protected] | 8c40da6 | 2011-07-13 22:58:46 | [diff] [blame] | 248 | // in the Profile preferences or the browser process. |
| 249 | if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) || |
| 250 | !g_browser_process->safe_browsing_detection_service()) { |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 251 | command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection); |
[email protected] | 8c40da6 | 2011-07-13 22:58:46 | [diff] [blame] | 252 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 253 | |
| 254 | static const char* const kSwitchNames[] = { |
| 255 | switches::kAllowHTTPBackgroundPage, |
| 256 | switches::kAllowScriptingGallery, |
| 257 | switches::kAppsCheckoutURL, |
| 258 | switches::kAppsGalleryURL, |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 259 | switches::kCloudPrintServiceURL, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 260 | switches::kDebugPrint, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 261 | switches::kDisablePrintPreview, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 262 | switches::kDomAutomationController, |
| 263 | switches::kDumpHistogramsOnExit, |
| 264 | switches::kEnableClickToPlay, |
| 265 | switches::kEnableCrxlessWebApps, |
| 266 | switches::kEnableExperimentalExtensionApis, |
| 267 | switches::kEnableInBrowserThumbnailing, |
[email protected] | d0cf438c | 2011-08-18 03:08:52 | [diff] [blame] | 268 | switches::kEnableInlineWebstoreInstall, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 269 | switches::kEnableIPCFuzzing, |
| 270 | switches::kEnableNaCl, |
[email protected] | 5714ee3 | 2011-08-18 01:51:24 | [diff] [blame] | 271 | switches::kEnablePrintPreview, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 272 | switches::kEnableResourceContentSettings, |
| 273 | switches::kEnableSearchProviderApiV2, |
| 274 | switches::kEnableWatchdog, |
| 275 | switches::kExperimentalSpellcheckerFeatures, |
| 276 | switches::kMemoryProfiling, |
| 277 | switches::kMessageLoopHistogrammer, |
| 278 | switches::kPpapiFlashArgs, |
| 279 | switches::kPpapiFlashInProcess, |
| 280 | switches::kPpapiFlashPath, |
| 281 | switches::kPpapiFlashVersion, |
| 282 | switches::kProfilingAtStart, |
| 283 | switches::kProfilingFile, |
| 284 | switches::kProfilingFlush, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 285 | switches::kSilentDumpOnDCHECK, |
| 286 | }; |
| 287 | |
| 288 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 289 | arraysize(kSwitchNames)); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 290 | } else if (process_type == switches::kUtilityProcess) { |
| 291 | if (browser_command_line.HasSwitch( |
| 292 | switches::kEnableExperimentalExtensionApis)) { |
| 293 | command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 294 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 295 | } else if (process_type == switches::kPluginProcess) { |
| 296 | static const char* const kSwitchNames[] = { |
| 297 | #if defined(OS_CHROMEOS) |
| 298 | switches::kLoginProfile, |
| 299 | #endif |
| 300 | switches::kMemoryProfiling, |
| 301 | switches::kSilentDumpOnDCHECK, |
| 302 | switches::kUserDataDir, |
| 303 | }; |
| 304 | |
| 305 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 306 | arraysize(kSwitchNames)); |
| 307 | } else if (process_type == switches::kZygoteProcess) { |
| 308 | static const char* const kSwitchNames[] = { |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 309 | switches::kUserDataDir, // Make logs go to the right file. |
| 310 | // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox. |
| 311 | switches::kPpapiFlashInProcess, |
| 312 | switches::kPpapiFlashPath, |
| 313 | switches::kPpapiFlashVersion, |
| 314 | }; |
| 315 | |
| 316 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 317 | arraysize(kSwitchNames)); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 318 | } |
| 319 | } |
| 320 | |
| 321 | std::string ChromeContentBrowserClient::GetApplicationLocale() { |
| 322 | return g_browser_process->GetApplicationLocale(); |
| 323 | } |
| 324 | |
[email protected] | b5cca98 | 2011-05-26 04:42:08 | [diff] [blame] | 325 | std::string ChromeContentBrowserClient::GetAcceptLangs(const TabContents* tab) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 326 | Profile* profile = Profile::FromBrowserContext(tab->browser_context()); |
| 327 | return profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
[email protected] | b5cca98 | 2011-05-26 04:42:08 | [diff] [blame] | 328 | } |
| 329 | |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 330 | SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() { |
| 331 | ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 332 | return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 333 | } |
| 334 | |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 335 | bool ChromeContentBrowserClient::AllowAppCache( |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 336 | const GURL& manifest_url, |
| 337 | const content::ResourceContext& context) { |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 338 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 339 | ProfileIOData* io_data = |
| 340 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 341 | // FIXME(jochen): get the correct top-level origin. |
[email protected] | efa5521 | 2011-05-13 16:19:38 | [diff] [blame] | 342 | ContentSetting setting = io_data->GetHostContentSettingsMap()-> |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 343 | GetCookieContentSetting(manifest_url, manifest_url, true); |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 344 | DCHECK(setting != CONTENT_SETTING_DEFAULT); |
| 345 | return setting != CONTENT_SETTING_BLOCK; |
| 346 | } |
| 347 | |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 348 | bool ChromeContentBrowserClient::AllowGetCookie( |
| 349 | const GURL& url, |
| 350 | const GURL& first_party, |
| 351 | const net::CookieList& cookie_list, |
| 352 | const content::ResourceContext& context, |
| 353 | int render_process_id, |
| 354 | int render_view_id) { |
| 355 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 356 | ProfileIOData* io_data = |
| 357 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 358 | ContentSetting setting = io_data->GetHostContentSettingsMap()-> |
| 359 | GetCookieContentSetting(url, first_party, false); |
| 360 | bool allow = setting == CONTENT_SETTING_ALLOW || |
| 361 | setting == CONTENT_SETTING_SESSION_ONLY; |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 362 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 363 | BrowserThread::PostTask( |
| 364 | BrowserThread::UI, FROM_HERE, |
| 365 | NewRunnableFunction( |
| 366 | &TabSpecificContentSettings::CookiesRead, |
| 367 | render_process_id, render_view_id, url, cookie_list, !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 368 | return allow; |
| 369 | } |
| 370 | |
| 371 | bool ChromeContentBrowserClient::AllowSetCookie( |
| 372 | const GURL& url, |
| 373 | const GURL& first_party, |
| 374 | const std::string& cookie_line, |
| 375 | const content::ResourceContext& context, |
| 376 | int render_process_id, |
| 377 | int render_view_id, |
| 378 | net::CookieOptions* options) { |
| 379 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 380 | ProfileIOData* io_data = |
| 381 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 382 | ContentSetting setting = io_data->GetHostContentSettingsMap()-> |
| 383 | GetCookieContentSetting(url, first_party, true); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 384 | |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 385 | if (setting == CONTENT_SETTING_SESSION_ONLY) |
| 386 | options->set_force_session(); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 387 | |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 388 | bool allow = setting == CONTENT_SETTING_ALLOW || |
| 389 | setting == CONTENT_SETTING_SESSION_ONLY; |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 390 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 391 | BrowserThread::PostTask( |
| 392 | BrowserThread::UI, FROM_HERE, |
| 393 | NewRunnableFunction( |
| 394 | &TabSpecificContentSettings::CookieChanged, |
| 395 | render_process_id, render_view_id, url, cookie_line, *options, |
| 396 | !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 397 | return allow; |
| 398 | } |
| 399 | |
[email protected] | d5a1916 | 2011-06-30 18:51:54 | [diff] [blame] | 400 | bool ChromeContentBrowserClient::AllowSaveLocalState( |
| 401 | const content::ResourceContext& context) { |
| 402 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 403 | ProfileIOData* io_data = |
| 404 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 405 | return !io_data->clear_local_state_on_exit()->GetValue(); |
| 406 | } |
| 407 | |
[email protected] | 6133f92 | 2011-07-01 21:34:34 | [diff] [blame] | 408 | net::URLRequestContext* |
| 409 | ChromeContentBrowserClient::OverrideRequestContextForURL( |
| 410 | const GURL& url, const content::ResourceContext& context) { |
| 411 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 412 | if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 413 | ProfileIOData* io_data = |
| 414 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 415 | return io_data->extensions_request_context(); |
| 416 | } |
| 417 | |
| 418 | return NULL; |
| 419 | } |
| 420 | |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 421 | QuotaPermissionContext* |
| 422 | ChromeContentBrowserClient::CreateQuotaPermissionContext() { |
| 423 | return new ChromeQuotaPermissionContext(); |
| 424 | } |
| 425 | |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 426 | void ChromeContentBrowserClient::RevealFolderInOS(const FilePath& path) { |
| 427 | // On Mac, this call needs to be done on the UI thread. On other platforms, |
| 428 | // do it on the FILE thread so we don't slow down UI. |
| 429 | #if defined(OS_MACOSX) |
| 430 | platform_util::OpenItem(path); |
| 431 | #else |
| 432 | BrowserThread::PostTask( |
| 433 | BrowserThread::FILE, FROM_HERE, |
| 434 | NewRunnableFunction(&platform_util::OpenItem, path)); |
| 435 | #endif |
| 436 | } |
| 437 | |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 438 | void ChromeContentBrowserClient::AllowCertificateError( |
| 439 | SSLCertErrorHandler* handler, |
| 440 | bool overridable, |
| 441 | Callback2<SSLCertErrorHandler*, bool>::Type* callback) { |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 442 | // If the tab is being prerendered, cancel the prerender and the request. |
| 443 | TabContents* tab = tab_util::GetTabContentsByID( |
| 444 | handler->render_process_host_id(), |
| 445 | handler->tab_contents_id()); |
| 446 | if (!tab) { |
| 447 | NOTREACHED(); |
| 448 | return; |
| 449 | } |
| 450 | prerender::PrerenderManager* prerender_manager = |
[email protected] | cafe4ad | 2011-07-28 18:34:56 | [diff] [blame] | 451 | Profile::FromBrowserContext(tab->browser_context())-> |
| 452 | GetPrerenderManager(); |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 453 | if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) { |
| 454 | if (prerender_manager->prerender_tracker()->TryCancel( |
| 455 | handler->render_process_host_id(), |
| 456 | handler->tab_contents_id(), |
| 457 | prerender::FINAL_STATUS_SSL_ERROR)) { |
| 458 | handler->CancelRequest(); |
| 459 | return; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | // Otherwise, display an SSL blocking page. |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 464 | SSLBlockingPage* blocking_page = new SSLBlockingPage( |
| 465 | handler, overridable, callback); |
| 466 | blocking_page->Show(); |
| 467 | } |
| 468 | |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 469 | void ChromeContentBrowserClient::ShowClientCertificateRequestDialog( |
| 470 | int render_process_id, |
| 471 | int render_view_id, |
| 472 | SSLClientAuthHandler* handler) { |
| 473 | TabContents* tab = tab_util::GetTabContentsByID( |
| 474 | render_process_id, render_view_id); |
| 475 | if (!tab) { |
| 476 | NOTREACHED(); |
| 477 | return; |
| 478 | } |
| 479 | |
| 480 | TabContentsWrapper* wrapper = |
| 481 | TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 482 | wrapper->ssl_helper()->ShowClientCertificateRequestDialog(handler); |
| 483 | } |
| 484 | |
| 485 | void ChromeContentBrowserClient::AddNewCertificate( |
| 486 | net::URLRequest* request, |
| 487 | net::X509Certificate* cert, |
| 488 | int render_process_id, |
| 489 | int render_view_id) { |
| 490 | // The handler will run the UI and delete itself when it's finished. |
| 491 | new SSLAddCertHandler(request, cert, render_process_id, render_view_id); |
| 492 | } |
| 493 | |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 494 | void ChromeContentBrowserClient::RequestDesktopNotificationPermission( |
| 495 | const GURL& source_origin, |
| 496 | int callback_context, |
| 497 | int render_process_id, |
| 498 | int render_view_id) { |
| 499 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 500 | render_process_id, render_view_id); |
| 501 | if (!rvh) { |
| 502 | NOTREACHED(); |
| 503 | return; |
| 504 | } |
| 505 | |
| 506 | RenderProcessHost* process = rvh->process(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 507 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 508 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 509 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 510 | service->RequestPermission( |
| 511 | source_origin, render_process_id, render_view_id, callback_context, |
| 512 | tab_util::GetTabContentsByID(render_process_id, render_view_id)); |
| 513 | } |
| 514 | |
| 515 | WebKit::WebNotificationPresenter::Permission |
| 516 | ChromeContentBrowserClient::CheckDesktopNotificationPermission( |
| 517 | const GURL& source_url, |
| 518 | const content::ResourceContext& context) { |
| 519 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 520 | ProfileIOData* io_data = |
| 521 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 522 | |
| 523 | const Extension* extension = |
| 524 | io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url); |
| 525 | if (extension && |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 526 | extension->HasAPIPermission(ExtensionAPIPermission::kNotification)) { |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 527 | return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 528 | } |
| 529 | |
| 530 | // Fall back to the regular notification preferences, which works on an |
| 531 | // origin basis. |
| 532 | return io_data->GetNotificationService() ? |
| 533 | io_data->GetNotificationService()->HasPermission(source_url.GetOrigin()) : |
| 534 | WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 535 | } |
| 536 | |
| 537 | void ChromeContentBrowserClient::ShowDesktopNotification( |
| 538 | const DesktopNotificationHostMsg_Show_Params& params, |
| 539 | int render_process_id, |
| 540 | int render_view_id, |
| 541 | bool worker) { |
| 542 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 543 | render_process_id, render_view_id); |
| 544 | if (!rvh) { |
| 545 | NOTREACHED(); |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | RenderProcessHost* process = rvh->process(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 550 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 551 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 552 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 553 | service->ShowDesktopNotification( |
| 554 | params, render_process_id, render_view_id, |
| 555 | worker ? DesktopNotificationService::WorkerNotification : |
| 556 | DesktopNotificationService::PageNotification); |
| 557 | } |
| 558 | |
| 559 | void ChromeContentBrowserClient::CancelDesktopNotification( |
| 560 | int render_process_id, |
| 561 | int render_view_id, |
| 562 | int notification_id) { |
| 563 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 564 | render_process_id, render_view_id); |
| 565 | if (!rvh) { |
| 566 | NOTREACHED(); |
| 567 | return; |
| 568 | } |
| 569 | |
| 570 | RenderProcessHost* process = rvh->process(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 571 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 572 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 573 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 574 | service->CancelDesktopNotification( |
| 575 | render_process_id, render_view_id, notification_id); |
| 576 | } |
| 577 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 578 | bool ChromeContentBrowserClient::CanCreateWindow( |
| 579 | const GURL& source_url, |
| 580 | WindowContainerType container_type, |
| 581 | const content::ResourceContext& context) { |
| 582 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 583 | // If the opener is trying to create a background window but doesn't have |
| 584 | // the appropriate permission, fail the attempt. |
| 585 | if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
| 586 | ProfileIOData* io_data = |
| 587 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 588 | const Extension* extension = |
| 589 | io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url); |
| 590 | return (extension && |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 591 | extension->HasAPIPermission(ExtensionAPIPermission::kBackground)); |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 592 | } |
| 593 | return true; |
| 594 | } |
| 595 | |
| 596 | std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
| 597 | const GURL& url, const content::ResourceContext& context) { |
| 598 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 599 | // Check if it's an extension-created worker, in which case we want to use |
| 600 | // the name of the extension. |
| 601 | ProfileIOData* io_data = |
| 602 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 603 | const Extension* extension = |
| 604 | io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); |
| 605 | return extension ? extension->name() : std::string(); |
| 606 | } |
| 607 | |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 608 | ResourceDispatcherHost* |
| 609 | ChromeContentBrowserClient::GetResourceDispatcherHost() { |
| 610 | return g_browser_process->resource_dispatcher_host(); |
| 611 | } |
| 612 | |
| 613 | ui::Clipboard* ChromeContentBrowserClient::GetClipboard() { |
| 614 | return g_browser_process->clipboard(); |
| 615 | } |
| 616 | |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 617 | MHTMLGenerationManager* |
| 618 | ChromeContentBrowserClient::GetMHTMLGenerationManager() { |
| 619 | return g_browser_process->mhtml_generation_manager(); |
| 620 | } |
| 621 | |
[email protected] | dce50276 | 2011-07-20 08:53:49 | [diff] [blame] | 622 | DevToolsManager* ChromeContentBrowserClient::GetDevToolsManager() { |
| 623 | return g_browser_process->devtools_manager(); |
| 624 | } |
| 625 | |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 626 | net::NetLog* ChromeContentBrowserClient::GetNetLog() { |
| 627 | return g_browser_process->net_log(); |
| 628 | } |
| 629 | |
[email protected] | dbae6b0 | 2011-06-29 23:51:41 | [diff] [blame] | 630 | bool ChromeContentBrowserClient::IsFastShutdownPossible() { |
| 631 | const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 632 | return !browser_command_line.HasSwitch(switches::kChromeFrame); |
| 633 | } |
| 634 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 635 | WebPreferences ChromeContentBrowserClient::GetWebkitPrefs( |
| 636 | content::BrowserContext* browser_context, bool is_web_ui) { |
| 637 | return RenderViewHostDelegateHelper::GetWebkitPrefs(browser_context, |
| 638 | is_web_ui); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | void ChromeContentBrowserClient::UpdateInspectorSetting( |
| 642 | RenderViewHost* rvh, const std::string& key, const std::string& value) { |
| 643 | RenderViewHostDelegateHelper::UpdateInspectorSetting( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 644 | rvh->process()->browser_context(), key, value); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) { |
| 648 | RenderViewHostDelegateHelper::ClearInspectorSettings( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 649 | rvh->process()->browser_context()); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 650 | } |
| 651 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 652 | void ChromeContentBrowserClient::BrowserURLHandlerCreated( |
| 653 | BrowserURLHandler* handler) { |
| 654 | // Add the default URL handlers. |
| 655 | handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, |
| 656 | BrowserURLHandler::null_handler()); |
| 657 | handler->AddHandlerPair(BrowserURLHandler::null_handler(), |
| 658 | &ExtensionWebUI::HandleChromeURLOverrideReverse); |
| 659 | |
| 660 | // about: |
| 661 | handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 662 | BrowserURLHandler::null_handler()); |
| 663 | // chrome: & friends. |
| 664 | handler->AddHandlerPair(&HandleWebUI, |
| 665 | BrowserURLHandler::null_handler()); |
| 666 | } |
| 667 | |
| 668 | void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 669 | Profile* profile = Profile::FromBrowserContext( |
| 670 | rvh->site_instance()->GetProcess()->browser_context()); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 671 | BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
| 672 | BrowsingDataRemover::EVERYTHING, |
| 673 | base::Time()); |
| 674 | remover->Remove(BrowsingDataRemover::REMOVE_CACHE); |
| 675 | // BrowsingDataRemover takes care of deleting itself when done. |
| 676 | } |
| 677 | |
| 678 | void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 679 | Profile* profile = Profile::FromBrowserContext( |
| 680 | rvh->site_instance()->GetProcess()->browser_context()); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 681 | BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
| 682 | BrowsingDataRemover::EVERYTHING, |
| 683 | base::Time()); |
| 684 | int remove_mask = BrowsingDataRemover::REMOVE_COOKIES; |
| 685 | remover->Remove(remove_mask); |
| 686 | // BrowsingDataRemover takes care of deleting itself when done. |
| 687 | } |
| 688 | |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 689 | FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
| 690 | return download_util::GetDefaultDownloadDirectory(); |
| 691 | } |
| 692 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 693 | #if defined(OS_LINUX) |
| 694 | int ChromeContentBrowserClient::GetCrashSignalFD( |
| 695 | const std::string& process_type) { |
| 696 | if (process_type == switches::kRendererProcess) |
| 697 | return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 698 | |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 699 | if (process_type == switches::kExtensionProcess) { |
| 700 | ExtensionCrashHandlerHostLinux* crash_handler = |
| 701 | ExtensionCrashHandlerHostLinux::GetInstance(); |
| 702 | return crash_handler->GetDeathSignalSocket(); |
| 703 | } |
| 704 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 705 | if (process_type == switches::kPluginProcess) |
| 706 | return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 707 | |
| 708 | if (process_type == switches::kPpapiPluginProcess) |
| 709 | return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 710 | |
| 711 | if (process_type == switches::kGpuProcess) |
| 712 | return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 713 | |
| 714 | return -1; |
| 715 | } |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 716 | #endif // defined(OS_LINUX) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 717 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 718 | #if defined(USE_NSS) |
| 719 | crypto::CryptoModuleBlockingPasswordDelegate* |
| 720 | ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 721 | const GURL& url) { |
| 722 | return browser::NewCryptoModuleBlockingDialogDelegate( |
| 723 | browser::kCryptoModulePasswordKeygen, url.host()); |
| 724 | } |
| 725 | #endif |
| 726 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 727 | } // namespace chrome |