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