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