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