[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] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 13 | #include "chrome/browser/chrome_benchmarking_message_filter.h" |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 14 | #include "chrome/browser/chrome_plugin_message_filter.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 15 | #include "chrome/browser/chrome_quota_permission_context.h" |
[email protected] | 5327dfb | 2011-05-03 17:50:36 | [diff] [blame] | 16 | #include "chrome/browser/chrome_worker_message_filter.h" |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 17 | #include "chrome/browser/content_settings/host_content_settings_map.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 18 | #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 19 | #include "chrome/browser/download/download_util.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 20 | #include "chrome/browser/extensions/extension_info_map.h" |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 21 | #include "chrome/browser/extensions/extension_message_handler.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 22 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 23 | #include "chrome/browser/extensions/extension_web_ui.h" |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 24 | #include "chrome/browser/extensions/extension_webrequest_api.h" |
[email protected] | 32538d9 | 2011-08-25 00:09:23 | [diff] [blame] | 25 | #include "chrome/browser/geolocation/chrome_access_token_store.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 26 | #include "chrome/browser/google/google_util.h" |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 27 | #include "chrome/browser/net/chrome_net_log.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 28 | #include "chrome/browser/notifications/desktop_notification_service.h" |
| 29 | #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 30 | #include "chrome/browser/platform_util.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 31 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 32 | #include "chrome/browser/prerender/prerender_manager.h" |
[email protected] | 3085c50 | 2011-10-05 17:50:50 | [diff] [blame] | 33 | #include "chrome/browser/prerender/prerender_manager_factory.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 34 | #include "chrome/browser/prerender/prerender_tracker.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 35 | #include "chrome/browser/printing/printing_message_filter.h" |
| 36 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 37 | #include "chrome/browser/profiles/profile_io_data.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 38 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | 53a0afa | 2011-04-28 02:09:33 | [diff] [blame] | 39 | #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 40 | #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h" |
[email protected] | 3bc0b56 | 2011-08-24 23:51:04 | [diff] [blame] | 41 | #include "chrome/browser/speech/chrome_speech_input_manager.h" |
[email protected] | 8ec7126 | 2011-07-28 08:12:46 | [diff] [blame] | 42 | #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 43 | #include "chrome/browser/ssl/ssl_add_cert_handler.h" |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 44 | #include "chrome/browser/ssl/ssl_blocking_page.h" |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 45 | #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 46 | #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 47 | #include "chrome/browser/tab_contents/tab_util.h" |
| 48 | #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 49 | #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 50 | #include "chrome/common/child_process_logging.h" |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 51 | #include "chrome/common/chrome_constants.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 52 | #include "chrome/common/chrome_switches.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 53 | #include "chrome/common/extensions/extension.h" |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 54 | #include "chrome/common/logging_chrome.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 55 | #include "chrome/common/pref_names.h" |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 56 | #include "chrome/common/render_messages.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 57 | #include "chrome/common/url_constants.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 58 | #include "content/browser/browser_url_handler.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 59 | #include "content/browser/browsing_instance.h" |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 60 | #include "content/browser/plugin_process_host.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 61 | #include "content/browser/renderer_host/browser_render_process_host.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 62 | #include "content/browser/renderer_host/render_view_host.h" |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 63 | #include "content/browser/resource_context.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 64 | #include "content/browser/site_instance.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 65 | #include "content/browser/ssl/ssl_cert_error_handler.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 66 | #include "content/browser/ssl/ssl_client_auth_handler.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 67 | #include "content/browser/tab_contents/tab_contents.h" |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 68 | #include "content/browser/tab_contents/tab_contents_view.h" |
[email protected] | 5327dfb | 2011-05-03 17:50:36 | [diff] [blame] | 69 | #include "content/browser/worker_host/worker_process_host.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 70 | #include "content/common/desktop_notification_messages.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 71 | #include "content/public/browser/browser_main_parts.h" |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 72 | #include "grit/generated_resources.h" |
[email protected] | 29b25d09 | 2011-06-29 20:57:34 | [diff] [blame] | 73 | #include "grit/ui_resources.h" |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 74 | #include "net/base/cookie_monster.h" |
| 75 | #include "net/base/cookie_options.h" |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 76 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 77 | #include "ui/base/resource/resource_bundle.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 78 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 79 | #if defined(OS_WIN) |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 80 | #include "chrome/browser/chrome_browser_main_win.h" |
| 81 | #elif defined(OS_MACOSX) |
| 82 | #include "chrome/browser/chrome_browser_main_mac.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 83 | #elif defined(OS_CHROMEOS) |
| 84 | #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
| 85 | #elif defined(OS_LINUX) |
| 86 | #include "chrome/browser/chrome_browser_main_linux.h" |
| 87 | #elif defined(OS_POSIX) |
| 88 | #include "chrome/browser/chrome_browser_main_posix.h" |
| 89 | #endif |
| 90 | |
| 91 | #if defined(USE_AURA) |
| 92 | #include "chrome/browser/chrome_browser_parts_aura.h" |
| 93 | #endif |
| 94 | |
| 95 | #if defined(TOOLKIT_USES_GTK) |
| 96 | #include "chrome/browser/chrome_browser_parts_gtk.h" |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 97 | #endif |
| 98 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 99 | #if defined(OS_LINUX) |
| 100 | #include "base/linux_util.h" |
| 101 | #include "chrome/browser/crash_handler_host_linux.h" |
[email protected] | 1fd5302c | 2011-05-28 04:06:43 | [diff] [blame] | 102 | #endif |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 103 | |
[email protected] | 080f34f | 2011-09-20 05:39:26 | [diff] [blame] | 104 | #if defined(TOOLKIT_VIEWS) |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 105 | #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 106 | #elif defined(TOOLKIT_USES_GTK) |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 107 | #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
| 108 | #elif defined(OS_MACOSX) |
| 109 | #include "chrome/browser/tab_contents/tab_contents_view_mac.h" |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 110 | #endif |
| 111 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 112 | #if defined(USE_NSS) |
| 113 | #include "chrome/browser/ui/crypto_module_password_dialog.h" |
| 114 | #endif |
| 115 | |
[email protected] | 91ad147 | 2011-10-27 15:09:48 | [diff] [blame^] | 116 | #if defined(USE_AURA) |
| 117 | #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 118 | #elif defined(TOUCH_UI) |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 119 | #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
| 120 | #elif defined(OS_WIN) |
| 121 | #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
| 122 | #include "content/browser/renderer_host/render_widget_host_view_win.h" |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 123 | #elif defined(TOOLKIT_USES_GTK) |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 124 | #include "content/browser/renderer_host/render_widget_host_view_gtk.h" |
| 125 | #elif defined(OS_MACOSX) |
| 126 | #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 127 | #endif |
| 128 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 129 | namespace { |
| 130 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 131 | // Handles rewriting Web UI URLs. |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 132 | bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 133 | if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url)) |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 134 | return false; |
| 135 | |
| 136 | // Special case the new tab page. In older versions of Chrome, the new tab |
| 137 | // page was hosted at chrome-internal:<blah>. This might be in people's saved |
| 138 | // sessions or bookmarks, so we say any URL with that scheme triggers the new |
| 139 | // tab page. |
| 140 | if (url->SchemeIs(chrome::kChromeInternalScheme)) { |
| 141 | // Rewrite it with the proper new tab URL. |
| 142 | *url = GURL(chrome::kChromeUINewTabURL); |
| 143 | } |
| 144 | |
| 145 | return true; |
| 146 | } |
| 147 | |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 148 | // Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions |
| 149 | // below. Extension, and isolated apps require different privileges to be |
| 150 | // granted to their RenderProcessHosts. This classification allows us to make |
| 151 | // sure URLs are served by hosts with the right set of privileges. |
| 152 | enum RenderProcessHostPrivilege { |
| 153 | PRIV_NORMAL, |
| 154 | PRIV_EXTENSION, |
| 155 | PRIV_ISOLATED, |
| 156 | }; |
| 157 | |
| 158 | RenderProcessHostPrivilege GetPrivilegeRequiredByUrl( |
| 159 | const GURL& url, |
| 160 | ExtensionService* service) { |
| 161 | // Default to a normal renderer cause it is lower privileged. This should only |
| 162 | // occur if the URL on a site instance is either malformed, or uninitialized. |
| 163 | // If it is malformed, then there is no need for better privileges anyways. |
| 164 | // If it is uninitialized, but eventually settles on being an a scheme other |
| 165 | // than normal webrenderer, the navigation logic will correct us out of band |
| 166 | // anyways. |
| 167 | if (!url.is_valid()) |
| 168 | return PRIV_NORMAL; |
| 169 | |
| 170 | if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 171 | const Extension* extension = service->GetExtensionByURL(url); |
| 172 | if (extension && extension->is_storage_isolated()) { |
| 173 | return PRIV_ISOLATED; |
| 174 | } |
| 175 | |
| 176 | return PRIV_EXTENSION; |
| 177 | } |
| 178 | |
| 179 | return PRIV_NORMAL; |
| 180 | } |
| 181 | |
| 182 | RenderProcessHostPrivilege GetProcessPrivilege( |
| 183 | RenderProcessHost* process_host, |
| 184 | ExtensionProcessManager* extension_process_manager) { |
[email protected] | 676f6ab | 2011-10-19 20:23:21 | [diff] [blame] | 185 | if (!extension_process_manager->IsExtensionProcess(process_host->id())) |
| 186 | return PRIV_NORMAL; |
| 187 | |
| 188 | std::set<const Extension*> extensions_for_process( |
| 189 | extension_process_manager->GetExtensionsForProcess(process_host->id())); |
| 190 | for (std::set<const Extension*>::iterator iter = |
| 191 | extensions_for_process.begin(); |
| 192 | iter != extensions_for_process.end(); ++iter) { |
| 193 | if ((*iter)->is_storage_isolated()) |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 194 | return PRIV_ISOLATED; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 195 | } |
| 196 | |
[email protected] | 676f6ab | 2011-10-19 20:23:21 | [diff] [blame] | 197 | return PRIV_EXTENSION; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 198 | } |
| 199 | |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 200 | } // namespace |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 201 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 202 | namespace chrome { |
| 203 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 204 | void ChromeContentBrowserClient::CreateBrowserMainParts( |
| 205 | const MainFunctionParams& parameters, |
| 206 | std::vector<content::BrowserMainParts*>* parts_list) { |
| 207 | // Construct the Main browser parts based on the OS type. |
| 208 | #if defined(OS_WIN) |
| 209 | parts_list->push_back(new ChromeBrowserMainPartsWin(parameters)); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 210 | #elif defined(OS_MACOSX) |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 211 | parts_list->push_back(new ChromeBrowserMainPartsMac(parameters)); |
| 212 | #elif defined(OS_CHROMEOS) |
| 213 | parts_list->push_back(new ChromeBrowserMainPartsChromeos(parameters)); |
| 214 | #elif defined(OS_LINUX) |
| 215 | parts_list->push_back(new ChromeBrowserMainPartsLinux(parameters)); |
| 216 | #elif defined(OS_POSIX) |
| 217 | parts_list->push_back(new ChromeBrowserMainPartsPosix(parameters)); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 218 | #else |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 219 | NOTREACHED(); |
| 220 | parts_list->push_back(new ChromeBrowserMainParts(parameters)); |
| 221 | #endif |
| 222 | |
| 223 | // Construct additional browser parts. |
| 224 | #if defined(USE_AURA) |
| 225 | parts_list->push_back(new ChromeBrowserPartsAura()); |
| 226 | #endif |
| 227 | #if defined(TOOLKIT_USES_GTK) |
| 228 | parts_list->push_back(new ChromeBrowserPartsGtk()); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 229 | #endif |
| 230 | } |
| 231 | |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 232 | RenderWidgetHostView* ChromeContentBrowserClient::CreateViewForWidget( |
| 233 | RenderWidgetHost* widget) { |
[email protected] | 91ad147 | 2011-10-27 15:09:48 | [diff] [blame^] | 234 | #if defined(USE_AURA) |
| 235 | return new RenderWidgetHostViewAura(widget); |
| 236 | #elif defined(TOUCH_UI) |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 237 | return new RenderWidgetHostViewViews(widget); |
| 238 | #elif defined(OS_WIN) |
| 239 | if (views::Widget::IsPureViews()) |
| 240 | return new RenderWidgetHostViewViews(widget); |
| 241 | return new RenderWidgetHostViewWin(widget); |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 242 | #elif defined(TOOLKIT_USES_GTK) |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 243 | return new RenderWidgetHostViewGtk(widget); |
| 244 | #elif defined(OS_MACOSX) |
| 245 | return render_widget_host_view_mac::CreateRenderWidgetHostView(widget); |
| 246 | #else |
| 247 | #error Need to create your platform ViewForWidget here. |
| 248 | #endif |
| 249 | } |
| 250 | |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 251 | TabContentsView* ChromeContentBrowserClient::CreateTabContentsView( |
| 252 | TabContents* tab_contents) { |
[email protected] | 080f34f | 2011-09-20 05:39:26 | [diff] [blame] | 253 | #if defined(TOOLKIT_VIEWS) |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 254 | return new TabContentsViewViews(tab_contents); |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 255 | #elif defined(TOOLKIT_USES_GTK) |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 256 | return new TabContentsViewGtk(tab_contents); |
| 257 | #elif defined(OS_MACOSX) |
| 258 | return tab_contents_view_mac::CreateTabContentsView(tab_contents); |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 259 | #else |
| 260 | #error Need to create your platform TabContentsView here. |
| 261 | #endif |
| 262 | } |
| 263 | |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 264 | void ChromeContentBrowserClient::RenderViewHostCreated( |
| 265 | RenderViewHost* render_view_host) { |
[email protected] | 67372ecf | 2011-09-10 01:30:46 | [diff] [blame] | 266 | |
| 267 | SiteInstance* site_instance = render_view_host->site_instance(); |
| 268 | Profile* profile = Profile::FromBrowserContext( |
| 269 | site_instance->browsing_instance()->browser_context()); |
| 270 | |
| 271 | new ChromeRenderViewHostObserver(render_view_host, |
| 272 | profile->GetNetworkPredictor()); |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 273 | new ExtensionMessageHandler(render_view_host); |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 274 | } |
| 275 | |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 276 | void ChromeContentBrowserClient::BrowserRenderProcessHostCreated( |
| 277 | BrowserRenderProcessHost* host) { |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 278 | int id = host->id(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 279 | Profile* profile = Profile::FromBrowserContext(host->browser_context()); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 280 | host->channel()->AddFilter(new ChromeRenderMessageFilter( |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 281 | id, profile, profile->GetRequestContextForRenderProcess(id))); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 282 | host->channel()->AddFilter(new PrintingMessageFilter()); |
| 283 | host->channel()->AddFilter( |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 284 | new SearchProviderInstallStateMessageFilter(id, profile)); |
| 285 | host->channel()->AddFilter(new SpellCheckMessageFilter(id)); |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 286 | host->channel()->AddFilter(new ChromeBenchmarkingMessageFilter( |
| 287 | id, profile, profile->GetRequestContextForRenderProcess(id))); |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 288 | |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 289 | host->Send(new ChromeViewMsg_SetIsIncognitoProcess( |
| 290 | profile->IsOffTheRecord())); |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 291 | |
| 292 | SendExtensionWebRequestStatusToHost(host); |
[email protected] | c1440609 | 2011-10-27 13:43:42 | [diff] [blame] | 293 | ContentSettingsForOneType settings; |
| 294 | HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
| 295 | map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_IMAGES, "", &settings); |
| 296 | host->Send(new ChromeViewMsg_SetImageSettingRules(settings)); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 297 | } |
| 298 | |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 299 | void ChromeContentBrowserClient::PluginProcessHostCreated( |
| 300 | PluginProcessHost* host) { |
| 301 | host->AddFilter(new ChromePluginMessageFilter(host)); |
| 302 | } |
| 303 | |
[email protected] | 5327dfb | 2011-05-03 17:50:36 | [diff] [blame] | 304 | void ChromeContentBrowserClient::WorkerProcessHostCreated( |
| 305 | WorkerProcessHost* host) { |
| 306 | host->AddFilter(new ChromeWorkerMessageFilter(host)); |
| 307 | } |
| 308 | |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 309 | content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() { |
| 310 | return ChromeWebUIFactory::GetInstance(); |
| 311 | } |
| 312 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 313 | GURL ChromeContentBrowserClient::GetEffectiveURL( |
| 314 | content::BrowserContext* browser_context, const GURL& url) { |
| 315 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 316 | // Get the effective URL for the given actual URL. If the URL is part of an |
| 317 | // installed app, the effective URL is an extension URL with the ID of that |
| 318 | // extension as the host. This has the effect of grouping apps together in |
| 319 | // a common SiteInstance. |
| 320 | if (!profile || !profile->GetExtensionService()) |
| 321 | return url; |
| 322 | |
| 323 | const Extension* extension = |
| 324 | profile->GetExtensionService()->GetExtensionByWebExtent(url); |
| 325 | if (!extension) |
| 326 | return url; |
| 327 | |
| 328 | // If the URL is part of an extension's web extent, convert it to an |
| 329 | // extension URL. |
| 330 | return extension->GetResourceURL(url.path()); |
| 331 | } |
| 332 | |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 333 | bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 334 | content::BrowserContext* browser_context, const GURL& effective_url) { |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 335 | // Non-extension URLs should generally use process-per-site-instance. |
| 336 | // Because we expect to use the effective URL, hosted apps URLs should have |
| 337 | // an extension scheme by now. |
| 338 | if (!effective_url.SchemeIs(chrome::kExtensionScheme)) |
| 339 | return false; |
| 340 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 341 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 342 | if (!profile || !profile->GetExtensionService()) |
| 343 | return false; |
| 344 | |
| 345 | const Extension* extension = |
| 346 | profile->GetExtensionService()->GetExtensionByURL(effective_url); |
| 347 | if (!extension) |
| 348 | return false; |
| 349 | |
| 350 | // If the URL is part of a hosted app that does not have the background |
| 351 | // permission, we want to give each instance its own process to improve |
| 352 | // responsiveness. |
| 353 | if (extension->GetType() == Extension::TYPE_HOSTED_APP && |
| 354 | !extension->HasAPIPermission(ExtensionAPIPermission::kBackground)) |
| 355 | return false; |
| 356 | |
| 357 | // Hosted apps that have the background permission must use process per site, |
| 358 | // since all instances can make synchronous calls to the background window. |
| 359 | // Other extensions should use process per site as well. |
| 360 | return true; |
| 361 | } |
| 362 | |
[email protected] | 0f012df8 | 2011-05-19 14:15:29 | [diff] [blame] | 363 | bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 364 | return url == GURL(chrome::kChromeUICrashURL) || |
| 365 | url == GURL(chrome::kChromeUIKillURL) || |
| 366 | url == GURL(chrome::kChromeUIHangURL) || |
| 367 | url == GURL(chrome::kChromeUIShorthangURL); |
[email protected] | 0f012df8 | 2011-05-19 14:15:29 | [diff] [blame] | 368 | } |
| 369 | |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 370 | bool ChromeContentBrowserClient::IsSuitableHost( |
| 371 | RenderProcessHost* process_host, |
| 372 | const GURL& site_url) { |
| 373 | Profile* profile = |
| 374 | Profile::FromBrowserContext(process_host->browser_context()); |
| 375 | ExtensionProcessManager* extension_process_manager = |
| 376 | profile->GetExtensionProcessManager(); |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 377 | ExtensionService* service = profile->GetExtensionService(); |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 378 | |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 379 | // These may be NULL during tests. In that case, just assume any site can |
| 380 | // share any host. |
| 381 | if (!extension_process_manager || !service) |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 382 | return true; |
| 383 | |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 384 | // Experimental: |
| 385 | // If --enable-strict-site-isolation is enabled, do not allow non-WebUI pages |
| 386 | // to share a renderer process. (We could allow pages from the same site or |
| 387 | // extensions of the same type to share, if we knew what the given process |
| 388 | // was dedicated to. Allowing no sharing is simpler for now.) This may |
| 389 | // cause resource exhaustion issues if too many sites are open at once. |
| 390 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 391 | if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) |
| 392 | return false; |
| 393 | |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 394 | return GetProcessPrivilege(process_host, extension_process_manager) == |
| 395 | GetPrivilegeRequiredByUrl(site_url, service); |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 396 | } |
| 397 | |
[email protected] | e3daf3c | 2011-10-05 21:17:08 | [diff] [blame] | 398 | bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( |
| 399 | const GURL& current_url, |
| 400 | const GURL& new_url) { |
| 401 | if (current_url.is_empty()) { |
| 402 | // Always choose a new process when navigating to extension URLs. The |
| 403 | // process grouping logic will combine all of a given extension's pages |
| 404 | // into the same process. |
| 405 | if (new_url.SchemeIs(chrome::kExtensionScheme)) |
| 406 | return true; |
| 407 | |
| 408 | return false; |
| 409 | } |
| 410 | |
| 411 | // Also, we must switch if one is an extension and the other is not the exact |
| 412 | // same extension. |
| 413 | if (current_url.SchemeIs(chrome::kExtensionScheme) || |
| 414 | new_url.SchemeIs(chrome::kExtensionScheme)) { |
| 415 | if (current_url.GetOrigin() != new_url.GetOrigin()) |
| 416 | return true; |
| 417 | } |
| 418 | |
| 419 | return false; |
| 420 | } |
| 421 | |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 422 | std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
| 423 | const std::string& alias_name) { |
| 424 | return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); |
| 425 | } |
| 426 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 427 | void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
| 428 | CommandLine* command_line, int child_process_id) { |
| 429 | #if defined(USE_LINUX_BREAKPAD) |
| 430 | if (IsCrashReporterEnabled()) { |
| 431 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 432 | child_process_logging::GetClientId() + "," + base::GetLinuxDistro()); |
| 433 | } |
| 434 | #elif defined(OS_MACOSX) |
| 435 | if (IsCrashReporterEnabled()) { |
| 436 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 437 | child_process_logging::GetClientId()); |
| 438 | } |
| 439 | #endif // OS_MACOSX |
| 440 | |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 441 | if (logging::DialogsAreSuppressed()) |
| 442 | command_line->AppendSwitch(switches::kNoErrorDialogs); |
| 443 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 444 | std::string process_type = |
| 445 | command_line->GetSwitchValueASCII(switches::kProcessType); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 446 | const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 447 | if (process_type == switches::kRendererProcess) { |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 448 | FilePath user_data_dir = |
| 449 | browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
| 450 | if (!user_data_dir.empty()) |
| 451 | command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 452 | #if defined(OS_CHROMEOS) |
| 453 | const std::string& login_profile = |
| 454 | browser_command_line.GetSwitchValueASCII(switches::kLoginProfile); |
| 455 | if (!login_profile.empty()) |
| 456 | command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile); |
| 457 | #endif |
| 458 | |
| 459 | RenderProcessHost* process = RenderProcessHost::FromID(child_process_id); |
| 460 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 461 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 462 | |
| 463 | ExtensionProcessManager* extension_process_manager = |
| 464 | profile->GetExtensionProcessManager(); |
| 465 | if (extension_process_manager->IsExtensionProcess( |
| 466 | process->id())) { |
| 467 | command_line->AppendSwitch(switches::kExtensionProcess); |
| 468 | } |
| 469 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 470 | PrefService* prefs = profile->GetPrefs(); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 471 | // Currently this pref is only registered if applied via a policy. |
| 472 | if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && |
| 473 | prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
| 474 | // Turn this policy into a command line switch. |
| 475 | command_line->AppendSwitch(switches::kDisable3DAPIs); |
| 476 | } |
| 477 | |
| 478 | // Disable client-side phishing detection in the renderer if it is disabled |
[email protected] | 8c40da6 | 2011-07-13 22:58:46 | [diff] [blame] | 479 | // in the Profile preferences or the browser process. |
| 480 | if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) || |
| 481 | !g_browser_process->safe_browsing_detection_service()) { |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 482 | command_line->AppendSwitch(switches::kDisableClientSidePhishingDetection); |
[email protected] | 8c40da6 | 2011-07-13 22:58:46 | [diff] [blame] | 483 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 484 | |
| 485 | static const char* const kSwitchNames[] = { |
| 486 | switches::kAllowHTTPBackgroundPage, |
| 487 | switches::kAllowScriptingGallery, |
| 488 | switches::kAppsCheckoutURL, |
| 489 | switches::kAppsGalleryURL, |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 490 | switches::kCloudPrintServiceURL, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 491 | switches::kDebugPrint, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 492 | switches::kDisablePrintPreview, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 493 | switches::kDomAutomationController, |
| 494 | switches::kDumpHistogramsOnExit, |
| 495 | switches::kEnableClickToPlay, |
| 496 | switches::kEnableCrxlessWebApps, |
| 497 | switches::kEnableExperimentalExtensionApis, |
| 498 | switches::kEnableInBrowserThumbnailing, |
| 499 | switches::kEnableIPCFuzzing, |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 500 | switches::kEnableLazyBackgroundPages, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 501 | switches::kEnableNaCl, |
[email protected] | 5714ee3 | 2011-08-18 01:51:24 | [diff] [blame] | 502 | switches::kEnablePrintPreview, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 503 | switches::kEnableSearchProviderApiV2, |
| 504 | switches::kEnableWatchdog, |
| 505 | switches::kExperimentalSpellcheckerFeatures, |
| 506 | switches::kMemoryProfiling, |
| 507 | switches::kMessageLoopHistogrammer, |
[email protected] | 2a6bb0b1 | 2011-10-05 19:18:04 | [diff] [blame] | 508 | switches::kNoRunningInsecureContent, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 509 | switches::kPpapiFlashArgs, |
| 510 | switches::kPpapiFlashInProcess, |
| 511 | switches::kPpapiFlashPath, |
| 512 | switches::kPpapiFlashVersion, |
| 513 | switches::kProfilingAtStart, |
| 514 | switches::kProfilingFile, |
| 515 | switches::kProfilingFlush, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 516 | switches::kSilentDumpOnDCHECK, |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 517 | switches::kEnableBenchmarking, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 518 | }; |
| 519 | |
| 520 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 521 | arraysize(kSwitchNames)); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 522 | } else if (process_type == switches::kUtilityProcess) { |
| 523 | if (browser_command_line.HasSwitch( |
| 524 | switches::kEnableExperimentalExtensionApis)) { |
| 525 | command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 526 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 527 | } else if (process_type == switches::kPluginProcess) { |
| 528 | static const char* const kSwitchNames[] = { |
| 529 | #if defined(OS_CHROMEOS) |
| 530 | switches::kLoginProfile, |
| 531 | #endif |
| 532 | switches::kMemoryProfiling, |
| 533 | switches::kSilentDumpOnDCHECK, |
| 534 | switches::kUserDataDir, |
| 535 | }; |
| 536 | |
| 537 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 538 | arraysize(kSwitchNames)); |
| 539 | } else if (process_type == switches::kZygoteProcess) { |
| 540 | static const char* const kSwitchNames[] = { |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 541 | switches::kUserDataDir, // Make logs go to the right file. |
| 542 | // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox. |
| 543 | switches::kPpapiFlashInProcess, |
| 544 | switches::kPpapiFlashPath, |
| 545 | switches::kPpapiFlashVersion, |
| 546 | }; |
| 547 | |
| 548 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 549 | arraysize(kSwitchNames)); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 550 | } |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 551 | |
| 552 | // The command line switch kEnableBenchmarking needs to be specified along |
| 553 | // with the kEnableStatsTable switch to ensure that the stats table global |
| 554 | // is initialized correctly. |
| 555 | if (command_line->HasSwitch(switches::kEnableBenchmarking)) |
| 556 | DCHECK(command_line->HasSwitch(switches::kEnableStatsTable)); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | std::string ChromeContentBrowserClient::GetApplicationLocale() { |
| 560 | return g_browser_process->GetApplicationLocale(); |
| 561 | } |
| 562 | |
[email protected] | b5cca98 | 2011-05-26 04:42:08 | [diff] [blame] | 563 | std::string ChromeContentBrowserClient::GetAcceptLangs(const TabContents* tab) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 564 | Profile* profile = Profile::FromBrowserContext(tab->browser_context()); |
| 565 | return profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
[email protected] | b5cca98 | 2011-05-26 04:42:08 | [diff] [blame] | 566 | } |
| 567 | |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 568 | SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() { |
| 569 | ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
[email protected] | 2cc6a929 | 2011-10-13 21:41:01 | [diff] [blame] | 570 | #if defined(TOUCH_UI) |
| 571 | // In touch builds, we want large default favicons for the tabstrip, but in |
| 572 | // other places (such as bookmark, manage search engines, homepage) we assume |
| 573 | // default favicons are 16x16. |
| 574 | return rb.GetBitmapNamed(IDR_DEFAULT_LARGE_FAVICON); |
| 575 | #else |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 576 | return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
[email protected] | 2cc6a929 | 2011-10-13 21:41:01 | [diff] [blame] | 577 | #endif |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 578 | } |
| 579 | |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 580 | bool ChromeContentBrowserClient::AllowAppCache( |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 581 | const GURL& manifest_url, |
[email protected] | 0a60884 | 2011-09-08 10:55:19 | [diff] [blame] | 582 | const GURL& first_party, |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 583 | const content::ResourceContext& context) { |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 584 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 585 | ProfileIOData* io_data = |
| 586 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | efa5521 | 2011-05-13 16:19:38 | [diff] [blame] | 587 | ContentSetting setting = io_data->GetHostContentSettingsMap()-> |
[email protected] | 0a60884 | 2011-09-08 10:55:19 | [diff] [blame] | 588 | GetCookieContentSetting(manifest_url, first_party, true); |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 589 | DCHECK(setting != CONTENT_SETTING_DEFAULT); |
| 590 | return setting != CONTENT_SETTING_BLOCK; |
| 591 | } |
| 592 | |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 593 | bool ChromeContentBrowserClient::AllowGetCookie( |
| 594 | const GURL& url, |
| 595 | const GURL& first_party, |
| 596 | const net::CookieList& cookie_list, |
| 597 | const content::ResourceContext& context, |
| 598 | int render_process_id, |
| 599 | int render_view_id) { |
| 600 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 601 | ProfileIOData* io_data = |
| 602 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 603 | ContentSetting setting = io_data->GetHostContentSettingsMap()-> |
| 604 | GetCookieContentSetting(url, first_party, false); |
| 605 | bool allow = setting == CONTENT_SETTING_ALLOW || |
| 606 | setting == CONTENT_SETTING_SESSION_ONLY; |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 607 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 608 | BrowserThread::PostTask( |
| 609 | BrowserThread::UI, FROM_HERE, |
| 610 | NewRunnableFunction( |
| 611 | &TabSpecificContentSettings::CookiesRead, |
| 612 | render_process_id, render_view_id, url, cookie_list, !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 613 | return allow; |
| 614 | } |
| 615 | |
| 616 | bool ChromeContentBrowserClient::AllowSetCookie( |
| 617 | const GURL& url, |
| 618 | const GURL& first_party, |
| 619 | const std::string& cookie_line, |
| 620 | const content::ResourceContext& context, |
| 621 | int render_process_id, |
| 622 | int render_view_id, |
| 623 | net::CookieOptions* options) { |
| 624 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 625 | ProfileIOData* io_data = |
| 626 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 627 | ContentSetting setting = io_data->GetHostContentSettingsMap()-> |
| 628 | GetCookieContentSetting(url, first_party, true); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 629 | |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 630 | if (setting == CONTENT_SETTING_SESSION_ONLY) |
| 631 | options->set_force_session(); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 632 | |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 633 | bool allow = setting == CONTENT_SETTING_ALLOW || |
| 634 | setting == CONTENT_SETTING_SESSION_ONLY; |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 635 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 636 | BrowserThread::PostTask( |
| 637 | BrowserThread::UI, FROM_HERE, |
| 638 | NewRunnableFunction( |
| 639 | &TabSpecificContentSettings::CookieChanged, |
| 640 | render_process_id, render_view_id, url, cookie_line, *options, |
| 641 | !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 642 | return allow; |
| 643 | } |
| 644 | |
[email protected] | d5a1916 | 2011-06-30 18:51:54 | [diff] [blame] | 645 | bool ChromeContentBrowserClient::AllowSaveLocalState( |
| 646 | const content::ResourceContext& context) { |
| 647 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 648 | ProfileIOData* io_data = |
| 649 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 650 | return !io_data->clear_local_state_on_exit()->GetValue(); |
| 651 | } |
| 652 | |
[email protected] | 6133f92 | 2011-07-01 21:34:34 | [diff] [blame] | 653 | net::URLRequestContext* |
| 654 | ChromeContentBrowserClient::OverrideRequestContextForURL( |
| 655 | const GURL& url, const content::ResourceContext& context) { |
| 656 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 657 | if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 658 | ProfileIOData* io_data = |
| 659 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 660 | return io_data->extensions_request_context(); |
| 661 | } |
| 662 | |
| 663 | return NULL; |
| 664 | } |
| 665 | |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 666 | QuotaPermissionContext* |
| 667 | ChromeContentBrowserClient::CreateQuotaPermissionContext() { |
| 668 | return new ChromeQuotaPermissionContext(); |
| 669 | } |
| 670 | |
[email protected] | a0ce328 | 2011-08-19 20:49:52 | [diff] [blame] | 671 | void ChromeContentBrowserClient::OpenItem(const FilePath& path) { |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 672 | // On Mac, this call needs to be done on the UI thread. On other platforms, |
| 673 | // do it on the FILE thread so we don't slow down UI. |
| 674 | #if defined(OS_MACOSX) |
| 675 | platform_util::OpenItem(path); |
| 676 | #else |
| 677 | BrowserThread::PostTask( |
| 678 | BrowserThread::FILE, FROM_HERE, |
| 679 | NewRunnableFunction(&platform_util::OpenItem, path)); |
| 680 | #endif |
| 681 | } |
| 682 | |
[email protected] | a0ce328 | 2011-08-19 20:49:52 | [diff] [blame] | 683 | void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) { |
| 684 | #if defined(OS_MACOSX) |
| 685 | // Mac needs to run this operation on the UI thread. |
| 686 | platform_util::ShowItemInFolder(path); |
| 687 | #else |
| 688 | BrowserThread::PostTask( |
| 689 | BrowserThread::FILE, FROM_HERE, |
| 690 | NewRunnableFunction(&platform_util::ShowItemInFolder, path)); |
| 691 | #endif |
| 692 | } |
| 693 | |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 694 | void ChromeContentBrowserClient::AllowCertificateError( |
| 695 | SSLCertErrorHandler* handler, |
| 696 | bool overridable, |
[email protected] | 8a27abf | 2011-09-30 21:59:58 | [diff] [blame] | 697 | const base::Callback<void(SSLCertErrorHandler*, bool)>& callback) { |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 698 | // If the tab is being prerendered, cancel the prerender and the request. |
| 699 | TabContents* tab = tab_util::GetTabContentsByID( |
| 700 | handler->render_process_host_id(), |
| 701 | handler->tab_contents_id()); |
| 702 | if (!tab) { |
| 703 | NOTREACHED(); |
| 704 | return; |
| 705 | } |
| 706 | prerender::PrerenderManager* prerender_manager = |
[email protected] | 3085c50 | 2011-10-05 17:50:50 | [diff] [blame] | 707 | prerender::PrerenderManagerFactory::GetForProfile( |
| 708 | Profile::FromBrowserContext(tab->browser_context())); |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 709 | if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) { |
| 710 | if (prerender_manager->prerender_tracker()->TryCancel( |
| 711 | handler->render_process_host_id(), |
| 712 | handler->tab_contents_id(), |
| 713 | prerender::FINAL_STATUS_SSL_ERROR)) { |
| 714 | handler->CancelRequest(); |
| 715 | return; |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | // Otherwise, display an SSL blocking page. |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 720 | SSLBlockingPage* blocking_page = new SSLBlockingPage( |
| 721 | handler, overridable, callback); |
| 722 | blocking_page->Show(); |
| 723 | } |
| 724 | |
[email protected] | c99c442e | 2011-08-24 11:37:30 | [diff] [blame] | 725 | void ChromeContentBrowserClient::SelectClientCertificate( |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 726 | int render_process_id, |
| 727 | int render_view_id, |
| 728 | SSLClientAuthHandler* handler) { |
| 729 | TabContents* tab = tab_util::GetTabContentsByID( |
| 730 | render_process_id, render_view_id); |
| 731 | if (!tab) { |
| 732 | NOTREACHED(); |
| 733 | return; |
| 734 | } |
| 735 | |
| 736 | TabContentsWrapper* wrapper = |
| 737 | TabContentsWrapper::GetCurrentWrapperForContents(tab); |
[email protected] | c99c442e | 2011-08-24 11:37:30 | [diff] [blame] | 738 | wrapper->ssl_helper()->SelectClientCertificate(handler); |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | void ChromeContentBrowserClient::AddNewCertificate( |
| 742 | net::URLRequest* request, |
| 743 | net::X509Certificate* cert, |
| 744 | int render_process_id, |
| 745 | int render_view_id) { |
| 746 | // The handler will run the UI and delete itself when it's finished. |
| 747 | new SSLAddCertHandler(request, cert, render_process_id, render_view_id); |
| 748 | } |
| 749 | |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 750 | void ChromeContentBrowserClient::RequestDesktopNotificationPermission( |
| 751 | const GURL& source_origin, |
| 752 | int callback_context, |
| 753 | int render_process_id, |
| 754 | int render_view_id) { |
| 755 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 756 | render_process_id, render_view_id); |
| 757 | if (!rvh) { |
| 758 | NOTREACHED(); |
| 759 | return; |
| 760 | } |
| 761 | |
| 762 | RenderProcessHost* process = rvh->process(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 763 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 764 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 765 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 766 | service->RequestPermission( |
| 767 | source_origin, render_process_id, render_view_id, callback_context, |
| 768 | tab_util::GetTabContentsByID(render_process_id, render_view_id)); |
| 769 | } |
| 770 | |
| 771 | WebKit::WebNotificationPresenter::Permission |
| 772 | ChromeContentBrowserClient::CheckDesktopNotificationPermission( |
| 773 | const GURL& source_url, |
| 774 | const content::ResourceContext& context) { |
| 775 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 776 | ProfileIOData* io_data = |
| 777 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 778 | |
| 779 | const Extension* extension = |
| 780 | io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url); |
| 781 | if (extension && |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 782 | extension->HasAPIPermission(ExtensionAPIPermission::kNotification)) { |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 783 | return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 784 | } |
| 785 | |
| 786 | // Fall back to the regular notification preferences, which works on an |
| 787 | // origin basis. |
| 788 | return io_data->GetNotificationService() ? |
| 789 | io_data->GetNotificationService()->HasPermission(source_url.GetOrigin()) : |
| 790 | WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 791 | } |
| 792 | |
| 793 | void ChromeContentBrowserClient::ShowDesktopNotification( |
| 794 | const DesktopNotificationHostMsg_Show_Params& params, |
| 795 | int render_process_id, |
| 796 | int render_view_id, |
| 797 | bool worker) { |
| 798 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 799 | render_process_id, render_view_id); |
| 800 | if (!rvh) { |
| 801 | NOTREACHED(); |
| 802 | return; |
| 803 | } |
| 804 | |
| 805 | RenderProcessHost* process = rvh->process(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 806 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 807 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 808 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 809 | service->ShowDesktopNotification( |
| 810 | params, render_process_id, render_view_id, |
| 811 | worker ? DesktopNotificationService::WorkerNotification : |
| 812 | DesktopNotificationService::PageNotification); |
| 813 | } |
| 814 | |
| 815 | void ChromeContentBrowserClient::CancelDesktopNotification( |
| 816 | int render_process_id, |
| 817 | int render_view_id, |
| 818 | int notification_id) { |
| 819 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 820 | render_process_id, render_view_id); |
| 821 | if (!rvh) { |
| 822 | NOTREACHED(); |
| 823 | return; |
| 824 | } |
| 825 | |
| 826 | RenderProcessHost* process = rvh->process(); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 827 | Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 828 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 829 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 830 | service->CancelDesktopNotification( |
| 831 | render_process_id, render_view_id, notification_id); |
| 832 | } |
| 833 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 834 | bool ChromeContentBrowserClient::CanCreateWindow( |
| 835 | const GURL& source_url, |
| 836 | WindowContainerType container_type, |
| 837 | const content::ResourceContext& context) { |
| 838 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 839 | // If the opener is trying to create a background window but doesn't have |
| 840 | // the appropriate permission, fail the attempt. |
| 841 | if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
| 842 | ProfileIOData* io_data = |
| 843 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 844 | const Extension* extension = |
| 845 | io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url); |
| 846 | return (extension && |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 847 | extension->HasAPIPermission(ExtensionAPIPermission::kBackground)); |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 848 | } |
| 849 | return true; |
| 850 | } |
| 851 | |
| 852 | std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
| 853 | const GURL& url, const content::ResourceContext& context) { |
| 854 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 855 | // Check if it's an extension-created worker, in which case we want to use |
| 856 | // the name of the extension. |
| 857 | ProfileIOData* io_data = |
| 858 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 859 | const Extension* extension = |
| 860 | io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); |
| 861 | return extension ? extension->name() : std::string(); |
| 862 | } |
| 863 | |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 864 | ResourceDispatcherHost* |
| 865 | ChromeContentBrowserClient::GetResourceDispatcherHost() { |
| 866 | return g_browser_process->resource_dispatcher_host(); |
| 867 | } |
| 868 | |
| 869 | ui::Clipboard* ChromeContentBrowserClient::GetClipboard() { |
| 870 | return g_browser_process->clipboard(); |
| 871 | } |
| 872 | |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 873 | MHTMLGenerationManager* |
| 874 | ChromeContentBrowserClient::GetMHTMLGenerationManager() { |
| 875 | return g_browser_process->mhtml_generation_manager(); |
| 876 | } |
| 877 | |
[email protected] | dce50276 | 2011-07-20 08:53:49 | [diff] [blame] | 878 | DevToolsManager* ChromeContentBrowserClient::GetDevToolsManager() { |
| 879 | return g_browser_process->devtools_manager(); |
| 880 | } |
| 881 | |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 882 | net::NetLog* ChromeContentBrowserClient::GetNetLog() { |
| 883 | return g_browser_process->net_log(); |
| 884 | } |
| 885 | |
[email protected] | 3bc0b56 | 2011-08-24 23:51:04 | [diff] [blame] | 886 | speech_input::SpeechInputManager* |
| 887 | ChromeContentBrowserClient::GetSpeechInputManager() { |
| 888 | return speech_input::ChromeSpeechInputManager::GetInstance(); |
| 889 | } |
| 890 | |
[email protected] | 32538d9 | 2011-08-25 00:09:23 | [diff] [blame] | 891 | AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() { |
| 892 | return new ChromeAccessTokenStore(); |
| 893 | } |
| 894 | |
[email protected] | dbae6b0 | 2011-06-29 23:51:41 | [diff] [blame] | 895 | bool ChromeContentBrowserClient::IsFastShutdownPossible() { |
| 896 | const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 897 | return !browser_command_line.HasSwitch(switches::kChromeFrame); |
| 898 | } |
| 899 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 900 | WebPreferences ChromeContentBrowserClient::GetWebkitPrefs( |
| 901 | content::BrowserContext* browser_context, bool is_web_ui) { |
| 902 | return RenderViewHostDelegateHelper::GetWebkitPrefs(browser_context, |
| 903 | is_web_ui); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | void ChromeContentBrowserClient::UpdateInspectorSetting( |
| 907 | RenderViewHost* rvh, const std::string& key, const std::string& value) { |
| 908 | RenderViewHostDelegateHelper::UpdateInspectorSetting( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 909 | rvh->process()->browser_context(), key, value); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) { |
| 913 | RenderViewHostDelegateHelper::ClearInspectorSettings( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 914 | rvh->process()->browser_context()); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 915 | } |
| 916 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 917 | void ChromeContentBrowserClient::BrowserURLHandlerCreated( |
| 918 | BrowserURLHandler* handler) { |
| 919 | // Add the default URL handlers. |
| 920 | handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, |
| 921 | BrowserURLHandler::null_handler()); |
| 922 | handler->AddHandlerPair(BrowserURLHandler::null_handler(), |
| 923 | &ExtensionWebUI::HandleChromeURLOverrideReverse); |
| 924 | |
| 925 | // about: |
| 926 | handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 927 | BrowserURLHandler::null_handler()); |
| 928 | // chrome: & friends. |
| 929 | handler->AddHandlerPair(&HandleWebUI, |
| 930 | BrowserURLHandler::null_handler()); |
| 931 | } |
| 932 | |
| 933 | void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 934 | Profile* profile = Profile::FromBrowserContext( |
| 935 | rvh->site_instance()->GetProcess()->browser_context()); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 936 | BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
| 937 | BrowsingDataRemover::EVERYTHING, |
| 938 | base::Time()); |
| 939 | remover->Remove(BrowsingDataRemover::REMOVE_CACHE); |
| 940 | // BrowsingDataRemover takes care of deleting itself when done. |
| 941 | } |
| 942 | |
| 943 | void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 944 | Profile* profile = Profile::FromBrowserContext( |
| 945 | rvh->site_instance()->GetProcess()->browser_context()); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 946 | BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
| 947 | BrowsingDataRemover::EVERYTHING, |
| 948 | base::Time()); |
[email protected] | dceaa91 | 2011-09-06 17:17:23 | [diff] [blame] | 949 | int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 950 | remover->Remove(remove_mask); |
| 951 | // BrowsingDataRemover takes care of deleting itself when done. |
| 952 | } |
| 953 | |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 954 | FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
| 955 | return download_util::GetDefaultDownloadDirectory(); |
| 956 | } |
| 957 | |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 958 | std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
| 959 | return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
| 960 | } |
| 961 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 962 | #if defined(OS_LINUX) |
| 963 | int ChromeContentBrowserClient::GetCrashSignalFD( |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 964 | const CommandLine& command_line) { |
| 965 | if (command_line.HasSwitch(switches::kExtensionProcess)) { |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 966 | ExtensionCrashHandlerHostLinux* crash_handler = |
| 967 | ExtensionCrashHandlerHostLinux::GetInstance(); |
| 968 | return crash_handler->GetDeathSignalSocket(); |
| 969 | } |
| 970 | |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 971 | std::string process_type = |
| 972 | command_line.GetSwitchValueASCII(switches::kProcessType); |
| 973 | |
| 974 | if (process_type == switches::kRendererProcess) |
| 975 | return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 976 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 977 | if (process_type == switches::kPluginProcess) |
| 978 | return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 979 | |
| 980 | if (process_type == switches::kPpapiPluginProcess) |
| 981 | return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 982 | |
| 983 | if (process_type == switches::kGpuProcess) |
| 984 | return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 985 | |
| 986 | return -1; |
| 987 | } |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 988 | #endif // defined(OS_LINUX) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 989 | |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 990 | #if defined(OS_WIN) |
| 991 | const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { |
| 992 | return chrome::kBrowserResourcesDll; |
| 993 | } |
| 994 | #endif |
| 995 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 996 | #if defined(USE_NSS) |
| 997 | crypto::CryptoModuleBlockingPasswordDelegate* |
| 998 | ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 999 | const GURL& url) { |
| 1000 | return browser::NewCryptoModuleBlockingDialogDelegate( |
| 1001 | browser::kCryptoModulePasswordKeygen, url.host()); |
| 1002 | } |
| 1003 | #endif |
| 1004 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 1005 | } // namespace chrome |