[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] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 7 | #include <set> |
| 8 | #include <vector> |
| 9 | |
[email protected] | 317c58f0 | 2011-11-09 02:15:03 | [diff] [blame] | 10 | #include "base/bind.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 11 | #include "base/command_line.h" |
| 12 | #include "chrome/app/breakpad_mac.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 13 | #include "chrome/browser/browser_about_handler.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 14 | #include "chrome/browser/browser_process.h" |
[email protected] | 3b8f7e3 | 2011-07-13 11:52:23 | [diff] [blame] | 15 | #include "chrome/browser/browsing_data_remover.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 16 | #include "chrome/browser/character_encoding.h" |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 17 | #include "chrome/browser/chrome_benchmarking_message_filter.h" |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 18 | #include "chrome/browser/chrome_plugin_message_filter.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 19 | #include "chrome/browser/chrome_quota_permission_context.h" |
[email protected] | edece21 | 2011-11-16 11:56:56 | [diff] [blame] | 20 | #include "chrome/browser/content_settings/content_settings_utils.h" |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 21 | #include "chrome/browser/content_settings/cookie_settings.h" |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 22 | #include "chrome/browser/content_settings/host_content_settings_map.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 23 | #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 24 | #include "chrome/browser/download/download_util.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 25 | #include "chrome/browser/extensions/extension_info_map.h" |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 26 | #include "chrome/browser/extensions/extension_message_handler.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 27 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 28 | #include "chrome/browser/extensions/extension_web_ui.h" |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 29 | #include "chrome/browser/extensions/extension_webrequest_api.h" |
[email protected] | 32538d9 | 2011-08-25 00:09:23 | [diff] [blame] | 30 | #include "chrome/browser/geolocation/chrome_access_token_store.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 31 | #include "chrome/browser/google/google_util.h" |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 32 | #include "chrome/browser/net/chrome_net_log.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 33 | #include "chrome/browser/notifications/desktop_notification_service.h" |
| 34 | #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 35 | #include "chrome/browser/platform_util.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 36 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 37 | #include "chrome/browser/prerender/prerender_manager.h" |
[email protected] | 3085c50 | 2011-10-05 17:50:50 | [diff] [blame] | 38 | #include "chrome/browser/prerender/prerender_manager_factory.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 39 | #include "chrome/browser/prerender/prerender_tracker.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 40 | #include "chrome/browser/printing/printing_message_filter.h" |
| 41 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 42 | #include "chrome/browser/profiles/profile_io_data.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 43 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | 53a0afa | 2011-04-28 02:09:33 | [diff] [blame] | 44 | #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 45 | #include "chrome/browser/renderer_host/plugin_info_message_filter.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 46 | #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h" |
[email protected] | 3bc0b56 | 2011-08-24 23:51:04 | [diff] [blame] | 47 | #include "chrome/browser/speech/chrome_speech_input_manager.h" |
[email protected] | 8ec7126 | 2011-07-28 08:12:46 | [diff] [blame] | 48 | #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 49 | #include "chrome/browser/ssl/ssl_add_cert_handler.h" |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 50 | #include "chrome/browser/ssl/ssl_blocking_page.h" |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 51 | #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 52 | #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 53 | #include "chrome/browser/tab_contents/tab_util.h" |
| 54 | #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 55 | #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 56 | #include "chrome/common/child_process_logging.h" |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 57 | #include "chrome/common/chrome_constants.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 58 | #include "chrome/common/chrome_switches.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 59 | #include "chrome/common/extensions/extension.h" |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 60 | #include "chrome/common/extensions/extension_set.h" |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 61 | #include "chrome/common/logging_chrome.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 62 | #include "chrome/common/pref_names.h" |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 63 | #include "chrome/common/render_messages.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 64 | #include "chrome/common/url_constants.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 65 | #include "content/browser/browser_url_handler.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 66 | #include "content/browser/browsing_instance.h" |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 67 | #include "content/browser/plugin_process_host.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 68 | #include "content/browser/renderer_host/render_view_host.h" |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 69 | #include "content/browser/resource_context.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 70 | #include "content/browser/site_instance.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 71 | #include "content/browser/ssl/ssl_cert_error_handler.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 72 | #include "content/browser/ssl/ssl_client_auth_handler.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 73 | #include "content/browser/tab_contents/tab_contents.h" |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 74 | #include "content/browser/tab_contents/tab_contents_view.h" |
[email protected] | 5327dfb | 2011-05-03 17:50:36 | [diff] [blame] | 75 | #include "content/browser/worker_host/worker_process_host.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 76 | #include "content/public/browser/browser_main_parts.h" |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 77 | #include "content/public/browser/render_process_host.h" |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 78 | #include "grit/generated_resources.h" |
[email protected] | 29b25d09 | 2011-06-29 20:57:34 | [diff] [blame] | 79 | #include "grit/ui_resources.h" |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 80 | #include "net/base/cookie_monster.h" |
| 81 | #include "net/base/cookie_options.h" |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 82 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 83 | #include "ui/base/resource/resource_bundle.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 84 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 85 | #if defined(OS_WIN) |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 86 | #include "chrome/browser/chrome_browser_main_win.h" |
| 87 | #elif defined(OS_MACOSX) |
| 88 | #include "chrome/browser/chrome_browser_main_mac.h" |
[email protected] | 7ceb9901 | 2011-12-21 08:05:56 | [diff] [blame] | 89 | #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 90 | #elif defined(OS_CHROMEOS) |
| 91 | #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
[email protected] | e60c023 | 2011-11-11 19:56:35 | [diff] [blame] | 92 | #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 93 | #include "chrome/browser/chrome_browser_main_linux.h" |
| 94 | #elif defined(OS_POSIX) |
| 95 | #include "chrome/browser/chrome_browser_main_posix.h" |
| 96 | #endif |
| 97 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 98 | #if defined(TOOLKIT_USES_GTK) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 99 | #include "chrome/browser/chrome_browser_main_extra_parts_gtk.h" |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 100 | #endif |
| 101 | |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 102 | #if defined(TOOLKIT_VIEWS) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 103 | #include "chrome/browser/chrome_browser_main_extra_parts_views.h" |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 104 | #endif |
| 105 | |
| 106 | #if defined(USE_AURA) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 107 | #include "chrome/browser/chrome_browser_main_extra_parts_aura.h" |
| 108 | #endif |
| 109 | |
[email protected] | e60c023 | 2011-11-11 19:56:35 | [diff] [blame] | 110 | #if defined(OS_LINUX) || defined(OS_OPENBSD) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 111 | #include "base/linux_util.h" |
| 112 | #include "chrome/browser/crash_handler_host_linux.h" |
[email protected] | 1fd5302c | 2011-05-28 04:06:43 | [diff] [blame] | 113 | #endif |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 114 | |
[email protected] | 080f34f | 2011-09-20 05:39:26 | [diff] [blame] | 115 | #if defined(TOOLKIT_VIEWS) |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 116 | #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 117 | #elif defined(TOOLKIT_USES_GTK) |
[email protected] | 9bce777 | 2011-11-16 01:24:45 | [diff] [blame] | 118 | #include "chrome/browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h" |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 119 | #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
| 120 | #elif defined(OS_MACOSX) |
| 121 | #include "chrome/browser/tab_contents/tab_contents_view_mac.h" |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 122 | #endif |
| 123 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 124 | #if defined(USE_NSS) |
| 125 | #include "chrome/browser/ui/crypto_module_password_dialog.h" |
| 126 | #endif |
| 127 | |
[email protected] | 91ad147 | 2011-10-27 15:09:48 | [diff] [blame] | 128 | #if defined(USE_AURA) |
| 129 | #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 130 | #elif defined(OS_WIN) |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 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] | c8c7718 | 2011-12-21 15:04:47 | [diff] [blame^] | 138 | using content::AccessTokenStore; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 139 | using content::BrowserThread; |
| 140 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 141 | namespace { |
| 142 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 143 | // Handles rewriting Web UI URLs. |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 144 | bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 145 | if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url)) |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 146 | return false; |
| 147 | |
| 148 | // Special case the new tab page. In older versions of Chrome, the new tab |
| 149 | // page was hosted at chrome-internal:<blah>. This might be in people's saved |
| 150 | // sessions or bookmarks, so we say any URL with that scheme triggers the new |
| 151 | // tab page. |
| 152 | if (url->SchemeIs(chrome::kChromeInternalScheme)) { |
| 153 | // Rewrite it with the proper new tab URL. |
| 154 | *url = GURL(chrome::kChromeUINewTabURL); |
| 155 | } |
| 156 | |
| 157 | return true; |
| 158 | } |
| 159 | |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 160 | // Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions |
| 161 | // below. Extension, and isolated apps require different privileges to be |
| 162 | // granted to their RenderProcessHosts. This classification allows us to make |
| 163 | // sure URLs are served by hosts with the right set of privileges. |
| 164 | enum RenderProcessHostPrivilege { |
| 165 | PRIV_NORMAL, |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 166 | PRIV_HOSTED, |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 167 | PRIV_ISOLATED, |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 168 | PRIV_EXTENSION, |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | RenderProcessHostPrivilege GetPrivilegeRequiredByUrl( |
| 172 | const GURL& url, |
| 173 | ExtensionService* service) { |
| 174 | // Default to a normal renderer cause it is lower privileged. This should only |
| 175 | // occur if the URL on a site instance is either malformed, or uninitialized. |
| 176 | // If it is malformed, then there is no need for better privileges anyways. |
| 177 | // If it is uninitialized, but eventually settles on being an a scheme other |
| 178 | // than normal webrenderer, the navigation logic will correct us out of band |
| 179 | // anyways. |
| 180 | if (!url.is_valid()) |
| 181 | return PRIV_NORMAL; |
| 182 | |
| 183 | if (url.SchemeIs(chrome::kExtensionScheme)) { |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 184 | const Extension* extension = |
| 185 | service->extensions()->GetByID(url.host()); |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 186 | if (extension && extension->is_storage_isolated()) |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 187 | return PRIV_ISOLATED; |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 188 | if (extension && extension->is_hosted_app()) |
| 189 | return PRIV_HOSTED; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 190 | |
| 191 | return PRIV_EXTENSION; |
| 192 | } |
| 193 | |
| 194 | return PRIV_NORMAL; |
| 195 | } |
| 196 | |
| 197 | RenderProcessHostPrivilege GetProcessPrivilege( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 198 | content::RenderProcessHost* process_host, |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 199 | extensions::ProcessMap* process_map, |
| 200 | ExtensionService* service) { |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 201 | std::set<std::string> extension_ids = |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 202 | process_map->GetExtensionsInProcess(process_host->GetID()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 203 | if (extension_ids.empty()) |
[email protected] | 676f6ab | 2011-10-19 20:23:21 | [diff] [blame] | 204 | return PRIV_NORMAL; |
| 205 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 206 | for (std::set<std::string>::iterator iter = extension_ids.begin(); |
| 207 | iter != extension_ids.end(); ++iter) { |
| 208 | const Extension* extension = service->GetExtensionById(*iter, false); |
| 209 | if (extension && extension->is_storage_isolated()) |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 210 | return PRIV_ISOLATED; |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 211 | if (extension && extension->is_hosted_app()) |
| 212 | return PRIV_HOSTED; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 213 | } |
| 214 | |
[email protected] | 676f6ab | 2011-10-19 20:23:21 | [diff] [blame] | 215 | return PRIV_EXTENSION; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 216 | } |
| 217 | |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 218 | bool IsIsolatedAppInProcess(const GURL& site_url, |
| 219 | content::RenderProcessHost* process_host, |
| 220 | extensions::ProcessMap* process_map, |
| 221 | ExtensionService* service) { |
| 222 | std::set<std::string> extension_ids = |
| 223 | process_map->GetExtensionsInProcess(process_host->GetID()); |
| 224 | if (extension_ids.empty()) |
| 225 | return false; |
| 226 | |
| 227 | for (std::set<std::string>::iterator iter = extension_ids.begin(); |
| 228 | iter != extension_ids.end(); ++iter) { |
| 229 | const Extension* extension = service->GetExtensionById(*iter, false); |
| 230 | if (extension && |
| 231 | extension->is_storage_isolated() && |
| 232 | extension->url() == site_url) |
| 233 | return true; |
| 234 | } |
| 235 | |
| 236 | return false; |
| 237 | } |
| 238 | |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 239 | bool CertMatchesFilter(const net::X509Certificate& cert, |
| 240 | const base::DictionaryValue& filter) { |
| 241 | // TODO(markusheintz): This is the minimal required filter implementation. |
| 242 | // Implement a better matcher. |
| 243 | |
| 244 | // An empty filter matches any client certificate since no requirements are |
| 245 | // specified at all. |
| 246 | if (filter.empty()) |
| 247 | return true; |
| 248 | |
| 249 | std::string common_name; |
| 250 | if (filter.GetString("ISSUER.CN", &common_name) && |
| 251 | (cert.issuer().common_name == common_name)) { |
| 252 | return true; |
| 253 | } |
| 254 | return false; |
| 255 | } |
| 256 | |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 257 | } // namespace |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 258 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 259 | namespace chrome { |
| 260 | |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 261 | content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( |
| 262 | const content::MainFunctionParams& parameters) { |
| 263 | ChromeBrowserMainParts* main_parts; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 264 | // Construct the Main browser parts based on the OS type. |
| 265 | #if defined(OS_WIN) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 266 | main_parts = new ChromeBrowserMainPartsWin(parameters); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 267 | #elif defined(OS_MACOSX) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 268 | main_parts = new ChromeBrowserMainPartsMac(parameters); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 269 | #elif defined(OS_CHROMEOS) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 270 | main_parts = new ChromeBrowserMainPartsChromeos(parameters); |
[email protected] | e60c023 | 2011-11-11 19:56:35 | [diff] [blame] | 271 | #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 272 | main_parts = new ChromeBrowserMainPartsLinux(parameters); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 273 | #elif defined(OS_POSIX) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 274 | main_parts = new ChromeBrowserMainPartsPosix(parameters); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 275 | #else |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 276 | NOTREACHED(); |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 277 | main_parts = new ChromeBrowserMainParts(parameters); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 278 | #endif |
| 279 | |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 280 | // Construct additional browser parts. Stages are called in the order in |
| 281 | // which they are added. |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 282 | #if defined(TOOLKIT_USES_GTK) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 283 | main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk()); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 284 | #endif |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 285 | |
| 286 | #if defined(TOOLKIT_VIEWS) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 287 | main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 288 | #endif |
| 289 | |
| 290 | #if defined(USE_AURA) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 291 | main_parts->AddParts(new ChromeBrowserMainExtraPartsAura()); |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 292 | #endif |
| 293 | |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 294 | return main_parts; |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 295 | } |
| 296 | |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 297 | RenderWidgetHostView* ChromeContentBrowserClient::CreateViewForWidget( |
| 298 | RenderWidgetHost* widget) { |
[email protected] | 91ad147 | 2011-10-27 15:09:48 | [diff] [blame] | 299 | #if defined(USE_AURA) |
| 300 | return new RenderWidgetHostViewAura(widget); |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 301 | #elif defined(OS_WIN) |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 302 | return new RenderWidgetHostViewWin(widget); |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 303 | #elif defined(TOOLKIT_USES_GTK) |
[email protected] | b45937e | 2011-10-07 19:49:17 | [diff] [blame] | 304 | return new RenderWidgetHostViewGtk(widget); |
| 305 | #elif defined(OS_MACOSX) |
| 306 | return render_widget_host_view_mac::CreateRenderWidgetHostView(widget); |
| 307 | #else |
| 308 | #error Need to create your platform ViewForWidget here. |
| 309 | #endif |
| 310 | } |
| 311 | |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 312 | TabContentsView* ChromeContentBrowserClient::CreateTabContentsView( |
| 313 | TabContents* tab_contents) { |
[email protected] | 080f34f | 2011-09-20 05:39:26 | [diff] [blame] | 314 | #if defined(TOOLKIT_VIEWS) |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 315 | return new TabContentsViewViews(tab_contents); |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 316 | #elif defined(TOOLKIT_USES_GTK) |
[email protected] | 9bce777 | 2011-11-16 01:24:45 | [diff] [blame] | 317 | return new TabContentsViewGtk(tab_contents, |
| 318 | new ChromeTabContentsViewWrapperGtk); |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 319 | #elif defined(OS_MACOSX) |
| 320 | return tab_contents_view_mac::CreateTabContentsView(tab_contents); |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 321 | #else |
| 322 | #error Need to create your platform TabContentsView here. |
| 323 | #endif |
| 324 | } |
| 325 | |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 326 | void ChromeContentBrowserClient::RenderViewHostCreated( |
| 327 | RenderViewHost* render_view_host) { |
[email protected] | 67372ecf | 2011-09-10 01:30:46 | [diff] [blame] | 328 | |
| 329 | SiteInstance* site_instance = render_view_host->site_instance(); |
| 330 | Profile* profile = Profile::FromBrowserContext( |
| 331 | site_instance->browsing_instance()->browser_context()); |
| 332 | |
| 333 | new ChromeRenderViewHostObserver(render_view_host, |
| 334 | profile->GetNetworkPredictor()); |
[email protected] | f364d139 | 2011-04-08 21:03:10 | [diff] [blame] | 335 | new ExtensionMessageHandler(render_view_host); |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 336 | } |
| 337 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 338 | void ChromeContentBrowserClient::RenderProcessHostCreated( |
| 339 | content::RenderProcessHost* host) { |
| 340 | int id = host->GetID(); |
| 341 | Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
| 342 | host->GetChannel()->AddFilter(new ChromeRenderMessageFilter( |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 343 | id, profile, profile->GetRequestContextForRenderProcess(id))); |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 344 | host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile)); |
| 345 | host->GetChannel()->AddFilter(new PrintingMessageFilter()); |
| 346 | host->GetChannel()->AddFilter( |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 347 | new SearchProviderInstallStateMessageFilter(id, profile)); |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 348 | host->GetChannel()->AddFilter(new SpellCheckMessageFilter(id)); |
[email protected] | 7ceb9901 | 2011-12-21 08:05:56 | [diff] [blame] | 349 | #if defined(OS_MACOSX) |
| 350 | host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac()); |
| 351 | #endif |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 352 | host->GetChannel()->AddFilter(new ChromeBenchmarkingMessageFilter( |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 353 | id, profile, profile->GetRequestContextForRenderProcess(id))); |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 354 | |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 355 | host->Send(new ChromeViewMsg_SetIsIncognitoProcess( |
| 356 | profile->IsOffTheRecord())); |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 357 | |
| 358 | SendExtensionWebRequestStatusToHost(host); |
[email protected] | edece21 | 2011-11-16 11:56:56 | [diff] [blame] | 359 | |
| 360 | RendererContentSettingRules rules; |
| 361 | GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules); |
| 362 | host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 363 | } |
| 364 | |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 365 | void ChromeContentBrowserClient::PluginProcessHostCreated( |
| 366 | PluginProcessHost* host) { |
[email protected] | f6d2a3e | 2011-11-17 21:42:40 | [diff] [blame] | 367 | #if !defined(USE_AURA) |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 368 | host->AddFilter(new ChromePluginMessageFilter(host)); |
[email protected] | f6d2a3e | 2011-11-17 21:42:40 | [diff] [blame] | 369 | #endif |
[email protected] | 97e6c4c | 2011-05-18 16:08:51 | [diff] [blame] | 370 | } |
| 371 | |
[email protected] | 1fd1a50 | 2011-03-30 16:55:56 | [diff] [blame] | 372 | content::WebUIFactory* ChromeContentBrowserClient::GetWebUIFactory() { |
| 373 | return ChromeWebUIFactory::GetInstance(); |
| 374 | } |
| 375 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 376 | GURL ChromeContentBrowserClient::GetEffectiveURL( |
| 377 | content::BrowserContext* browser_context, const GURL& url) { |
| 378 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 379 | // Get the effective URL for the given actual URL. If the URL is part of an |
| 380 | // installed app, the effective URL is an extension URL with the ID of that |
| 381 | // extension as the host. This has the effect of grouping apps together in |
| 382 | // a common SiteInstance. |
| 383 | if (!profile || !profile->GetExtensionService()) |
| 384 | return url; |
| 385 | |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 386 | const Extension* extension = profile->GetExtensionService()->extensions()-> |
| 387 | GetHostedAppByURL(ExtensionURLInfo(url)); |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 388 | if (!extension) |
| 389 | return url; |
| 390 | |
[email protected] | 15877ca | 2011-11-18 22:40:52 | [diff] [blame] | 391 | // Bookmark apps do not use the hosted app process model, and should be |
| 392 | // treated as normal URLs. |
| 393 | if (extension->from_bookmark()) |
| 394 | return url; |
| 395 | |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 396 | // If the URL is part of an extension's web extent, convert it to an |
| 397 | // extension URL. |
| 398 | return extension->GetResourceURL(url.path()); |
| 399 | } |
| 400 | |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 401 | bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 402 | content::BrowserContext* browser_context, const GURL& effective_url) { |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 403 | // Non-extension URLs should generally use process-per-site-instance. |
[email protected] | 15877ca | 2011-11-18 22:40:52 | [diff] [blame] | 404 | // Because we expect to use the effective URL, URLs for hosted apps (apart |
| 405 | // from bookmark apps) should have an extension scheme by now. |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 406 | if (!effective_url.SchemeIs(chrome::kExtensionScheme)) |
| 407 | return false; |
| 408 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 409 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 410 | if (!profile || !profile->GetExtensionService()) |
| 411 | return false; |
| 412 | |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 413 | const Extension* extension = profile->GetExtensionService()->extensions()-> |
| 414 | GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 415 | if (!extension) |
| 416 | return false; |
| 417 | |
| 418 | // If the URL is part of a hosted app that does not have the background |
| 419 | // permission, we want to give each instance its own process to improve |
| 420 | // responsiveness. |
| 421 | if (extension->GetType() == Extension::TYPE_HOSTED_APP && |
| 422 | !extension->HasAPIPermission(ExtensionAPIPermission::kBackground)) |
| 423 | return false; |
| 424 | |
| 425 | // Hosted apps that have the background permission must use process per site, |
| 426 | // since all instances can make synchronous calls to the background window. |
| 427 | // Other extensions should use process per site as well. |
| 428 | return true; |
| 429 | } |
| 430 | |
[email protected] | 0f012df8 | 2011-05-19 14:15:29 | [diff] [blame] | 431 | bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 432 | return url == GURL(chrome::kChromeUICrashURL) || |
| 433 | url == GURL(chrome::kChromeUIKillURL) || |
| 434 | url == GURL(chrome::kChromeUIHangURL) || |
| 435 | url == GURL(chrome::kChromeUIShorthangURL); |
[email protected] | 0f012df8 | 2011-05-19 14:15:29 | [diff] [blame] | 436 | } |
| 437 | |
[email protected] | 46fb944 | 2011-12-09 17:57:47 | [diff] [blame] | 438 | bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { |
| 439 | return ProfileIOData::IsHandledURL(url); |
| 440 | } |
| 441 | |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 442 | bool ChromeContentBrowserClient::IsSuitableHost( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 443 | content::RenderProcessHost* process_host, |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 444 | const GURL& site_url) { |
| 445 | Profile* profile = |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 446 | Profile::FromBrowserContext(process_host->GetBrowserContext()); |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 447 | ExtensionService* service = profile->GetExtensionService(); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 448 | extensions::ProcessMap* process_map = service->process_map(); |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 449 | |
[email protected] | ffa9760 | 2011-11-17 17:55:52 | [diff] [blame] | 450 | // Don't allow the Task Manager to share a process with anything else. |
| 451 | // Otherwise it can affect the renderers it is observing. |
| 452 | // Note: we could create another RenderProcessHostPrivilege bucket for |
| 453 | // this to allow multiple chrome://tasks instances to share, but that's |
| 454 | // a very unlikely case without serious consequences. |
| 455 | if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin()) |
| 456 | return false; |
| 457 | |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 458 | // These may be NULL during tests. In that case, just assume any site can |
| 459 | // share any host. |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 460 | if (!service || !process_map) |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 461 | return true; |
| 462 | |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 463 | // Experimental: |
| 464 | // If --enable-strict-site-isolation is enabled, do not allow non-WebUI pages |
| 465 | // to share a renderer process. (We could allow pages from the same site or |
| 466 | // extensions of the same type to share, if we knew what the given process |
| 467 | // was dedicated to. Allowing no sharing is simpler for now.) This may |
| 468 | // cause resource exhaustion issues if too many sites are open at once. |
| 469 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 470 | if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) |
| 471 | return false; |
| 472 | |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 473 | // An isolated app is only allowed to share with the exact same app in order |
| 474 | // to provide complete renderer process isolation. This also works around |
| 475 | // issue http://crbug.com/85588, where different isolated apps in the same |
| 476 | // process would end up using the first app's storage contexts. |
| 477 | RenderProcessHostPrivilege privilege_required = |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 478 | GetPrivilegeRequiredByUrl(site_url, service); |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 479 | if (privilege_required == PRIV_ISOLATED) |
| 480 | return IsIsolatedAppInProcess(site_url, process_host, process_map, service); |
| 481 | |
| 482 | // Otherwise, just make sure the process privilege matches the privilege |
| 483 | // required by the site. |
| 484 | return GetProcessPrivilege(process_host, process_map, service) == |
| 485 | privilege_required; |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 486 | } |
| 487 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 488 | void ChromeContentBrowserClient::SiteInstanceGotProcess( |
| 489 | SiteInstance* site_instance) { |
| 490 | CHECK(site_instance->HasProcess()); |
| 491 | |
| 492 | Profile* profile = Profile::FromBrowserContext( |
| 493 | site_instance->browsing_instance()->browser_context()); |
| 494 | ExtensionService* service = profile->GetExtensionService(); |
| 495 | if (!service) |
| 496 | return; |
| 497 | |
| 498 | const Extension* extension = |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 499 | service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( |
| 500 | site_instance->site())); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 501 | if (!extension) |
| 502 | return; |
| 503 | |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 504 | service->process_map()->Insert(extension->id(), |
| 505 | site_instance->GetProcess()->GetID(), |
| 506 | site_instance->id()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 507 | BrowserThread::PostTask( |
| 508 | BrowserThread::IO, FROM_HERE, |
| 509 | base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, |
| 510 | profile->GetExtensionInfoMap(), |
| 511 | extension->id(), |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 512 | site_instance->GetProcess()->GetID(), |
| 513 | site_instance->id())); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | void ChromeContentBrowserClient::SiteInstanceDeleting( |
| 517 | SiteInstance* site_instance) { |
| 518 | if (!site_instance->HasProcess()) |
| 519 | return; |
| 520 | |
| 521 | Profile* profile = Profile::FromBrowserContext( |
| 522 | site_instance->browsing_instance()->browser_context()); |
| 523 | ExtensionService* service = profile->GetExtensionService(); |
| 524 | if (!service) |
| 525 | return; |
| 526 | |
| 527 | const Extension* extension = |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 528 | service->extensions()->GetExtensionOrAppByURL( |
| 529 | ExtensionURLInfo(site_instance->site())); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 530 | if (!extension) |
| 531 | return; |
| 532 | |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 533 | service->process_map()->Remove(extension->id(), |
| 534 | site_instance->GetProcess()->GetID(), |
| 535 | site_instance->id()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 536 | BrowserThread::PostTask( |
| 537 | BrowserThread::IO, FROM_HERE, |
| 538 | base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, |
| 539 | profile->GetExtensionInfoMap(), |
| 540 | extension->id(), |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 541 | site_instance->GetProcess()->GetID(), |
| 542 | site_instance->id())); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 543 | } |
| 544 | |
[email protected] | e3daf3c | 2011-10-05 21:17:08 | [diff] [blame] | 545 | bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( |
| 546 | const GURL& current_url, |
| 547 | const GURL& new_url) { |
| 548 | if (current_url.is_empty()) { |
| 549 | // Always choose a new process when navigating to extension URLs. The |
| 550 | // process grouping logic will combine all of a given extension's pages |
| 551 | // into the same process. |
| 552 | if (new_url.SchemeIs(chrome::kExtensionScheme)) |
| 553 | return true; |
| 554 | |
| 555 | return false; |
| 556 | } |
| 557 | |
| 558 | // Also, we must switch if one is an extension and the other is not the exact |
| 559 | // same extension. |
| 560 | if (current_url.SchemeIs(chrome::kExtensionScheme) || |
| 561 | new_url.SchemeIs(chrome::kExtensionScheme)) { |
| 562 | if (current_url.GetOrigin() != new_url.GetOrigin()) |
| 563 | return true; |
| 564 | } |
| 565 | |
| 566 | return false; |
| 567 | } |
| 568 | |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 569 | std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
| 570 | const std::string& alias_name) { |
| 571 | return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); |
| 572 | } |
| 573 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 574 | void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
| 575 | CommandLine* command_line, int child_process_id) { |
| 576 | #if defined(USE_LINUX_BREAKPAD) |
| 577 | if (IsCrashReporterEnabled()) { |
| 578 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 579 | child_process_logging::GetClientId() + "," + base::GetLinuxDistro()); |
| 580 | } |
| 581 | #elif defined(OS_MACOSX) |
| 582 | if (IsCrashReporterEnabled()) { |
| 583 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 584 | child_process_logging::GetClientId()); |
| 585 | } |
| 586 | #endif // OS_MACOSX |
| 587 | |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 588 | if (logging::DialogsAreSuppressed()) |
| 589 | command_line->AppendSwitch(switches::kNoErrorDialogs); |
| 590 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 591 | std::string process_type = |
| 592 | command_line->GetSwitchValueASCII(switches::kProcessType); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 593 | const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 594 | if (process_type == switches::kRendererProcess) { |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 595 | FilePath user_data_dir = |
| 596 | browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
| 597 | if (!user_data_dir.empty()) |
| 598 | command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 599 | #if defined(OS_CHROMEOS) |
| 600 | const std::string& login_profile = |
| 601 | browser_command_line.GetSwitchValueASCII(switches::kLoginProfile); |
| 602 | if (!login_profile.empty()) |
| 603 | command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile); |
| 604 | #endif |
| 605 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 606 | content::RenderProcessHost* process = |
| 607 | content::RenderProcessHost::FromID(child_process_id); |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 608 | if (process) { |
| 609 | Profile* profile = Profile::FromBrowserContext( |
| 610 | process->GetBrowserContext()); |
| 611 | extensions::ProcessMap* process_map = |
| 612 | profile->GetExtensionService()->process_map(); |
| 613 | if (process_map && process_map->Contains(process->GetID())) |
| 614 | command_line->AppendSwitch(switches::kExtensionProcess); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 615 | |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 616 | PrefService* prefs = profile->GetPrefs(); |
| 617 | // Currently this pref is only registered if applied via a policy. |
| 618 | if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && |
| 619 | prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
| 620 | // Turn this policy into a command line switch. |
| 621 | command_line->AppendSwitch(switches::kDisable3DAPIs); |
| 622 | } |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 623 | |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 624 | // Disable client-side phishing detection in the renderer if it is |
| 625 | // disabled in the Profile preferences or the browser process. |
| 626 | if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) || |
| 627 | !g_browser_process->safe_browsing_detection_service()) { |
| 628 | command_line->AppendSwitch( |
| 629 | switches::kDisableClientSidePhishingDetection); |
| 630 | } |
[email protected] | 8c40da6 | 2011-07-13 22:58:46 | [diff] [blame] | 631 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 632 | |
| 633 | static const char* const kSwitchNames[] = { |
| 634 | switches::kAllowHTTPBackgroundPage, |
[email protected] | 70f48c0 | 2011-12-02 21:27:48 | [diff] [blame] | 635 | switches::kAllowLegacyExtensionManifests, |
[email protected] | ef5e98e | 2011-12-06 09:49:18 | [diff] [blame] | 636 | switches::kAllowNaClSocketAPI, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 637 | switches::kAllowScriptingGallery, |
| 638 | switches::kAppsCheckoutURL, |
| 639 | switches::kAppsGalleryURL, |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 640 | switches::kCloudPrintServiceURL, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 641 | switches::kDebugPrint, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 642 | switches::kDisablePrintPreview, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 643 | switches::kDomAutomationController, |
| 644 | switches::kDumpHistogramsOnExit, |
| 645 | switches::kEnableClickToPlay, |
| 646 | switches::kEnableCrxlessWebApps, |
| 647 | switches::kEnableExperimentalExtensionApis, |
| 648 | switches::kEnableInBrowserThumbnailing, |
| 649 | switches::kEnableIPCFuzzing, |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 650 | switches::kEnableLazyBackgroundPages, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 651 | switches::kEnableNaCl, |
[email protected] | 9776e82e | 2011-11-15 02:17:53 | [diff] [blame] | 652 | switches::kEnablePlatformApps, |
[email protected] | 5714ee3 | 2011-08-18 01:51:24 | [diff] [blame] | 653 | switches::kEnablePrintPreview, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 654 | switches::kEnableSearchProviderApiV2, |
| 655 | switches::kEnableWatchdog, |
| 656 | switches::kExperimentalSpellcheckerFeatures, |
| 657 | switches::kMemoryProfiling, |
| 658 | switches::kMessageLoopHistogrammer, |
[email protected] | 2a6bb0b1 | 2011-10-05 19:18:04 | [diff] [blame] | 659 | switches::kNoRunningInsecureContent, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 660 | switches::kPpapiFlashArgs, |
| 661 | switches::kPpapiFlashInProcess, |
| 662 | switches::kPpapiFlashPath, |
| 663 | switches::kPpapiFlashVersion, |
| 664 | switches::kProfilingAtStart, |
| 665 | switches::kProfilingFile, |
| 666 | switches::kProfilingFlush, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 667 | switches::kSilentDumpOnDCHECK, |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 668 | switches::kEnableBenchmarking, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 669 | }; |
| 670 | |
| 671 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 672 | arraysize(kSwitchNames)); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 673 | } else if (process_type == switches::kUtilityProcess) { |
| 674 | if (browser_command_line.HasSwitch( |
| 675 | switches::kEnableExperimentalExtensionApis)) { |
| 676 | command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 677 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 678 | } else if (process_type == switches::kPluginProcess) { |
| 679 | static const char* const kSwitchNames[] = { |
| 680 | #if defined(OS_CHROMEOS) |
| 681 | switches::kLoginProfile, |
| 682 | #endif |
| 683 | switches::kMemoryProfiling, |
| 684 | switches::kSilentDumpOnDCHECK, |
| 685 | switches::kUserDataDir, |
| 686 | }; |
| 687 | |
| 688 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 689 | arraysize(kSwitchNames)); |
| 690 | } else if (process_type == switches::kZygoteProcess) { |
| 691 | static const char* const kSwitchNames[] = { |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 692 | switches::kUserDataDir, // Make logs go to the right file. |
| 693 | // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox. |
| 694 | switches::kPpapiFlashInProcess, |
| 695 | switches::kPpapiFlashPath, |
| 696 | switches::kPpapiFlashVersion, |
| 697 | }; |
| 698 | |
| 699 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 700 | arraysize(kSwitchNames)); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 701 | } |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 702 | |
| 703 | // The command line switch kEnableBenchmarking needs to be specified along |
| 704 | // with the kEnableStatsTable switch to ensure that the stats table global |
| 705 | // is initialized correctly. |
| 706 | if (command_line->HasSwitch(switches::kEnableBenchmarking)) |
| 707 | DCHECK(command_line->HasSwitch(switches::kEnableStatsTable)); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | std::string ChromeContentBrowserClient::GetApplicationLocale() { |
| 711 | return g_browser_process->GetApplicationLocale(); |
| 712 | } |
| 713 | |
[email protected] | 597a867b | 2011-11-18 18:31:20 | [diff] [blame] | 714 | std::string ChromeContentBrowserClient::GetAcceptLangs( |
| 715 | content::BrowserContext* context) { |
| 716 | Profile* profile = Profile::FromBrowserContext(context); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 717 | return profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
[email protected] | b5cca98 | 2011-05-26 04:42:08 | [diff] [blame] | 718 | } |
| 719 | |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 720 | SkBitmap* ChromeContentBrowserClient::GetDefaultFavicon() { |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 721 | ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 722 | return rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 723 | } |
| 724 | |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 725 | bool ChromeContentBrowserClient::AllowAppCache( |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 726 | const GURL& manifest_url, |
[email protected] | 0a60884 | 2011-09-08 10:55:19 | [diff] [blame] | 727 | const GURL& first_party, |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 728 | const content::ResourceContext& context) { |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 729 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 730 | ProfileIOData* io_data = |
| 731 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 732 | return io_data->GetCookieSettings()-> |
| 733 | IsSettingCookieAllowed(manifest_url, first_party); |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 734 | } |
| 735 | |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 736 | bool ChromeContentBrowserClient::AllowGetCookie( |
| 737 | const GURL& url, |
| 738 | const GURL& first_party, |
| 739 | const net::CookieList& cookie_list, |
| 740 | const content::ResourceContext& context, |
| 741 | int render_process_id, |
| 742 | int render_view_id) { |
| 743 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 744 | ProfileIOData* io_data = |
| 745 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 746 | bool allow = io_data->GetCookieSettings()-> |
| 747 | IsReadingCookieAllowed(url, first_party); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 748 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 749 | BrowserThread::PostTask( |
| 750 | BrowserThread::UI, FROM_HERE, |
[email protected] | 317c58f0 | 2011-11-09 02:15:03 | [diff] [blame] | 751 | base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id, |
| 752 | render_view_id, url, cookie_list, !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 753 | return allow; |
| 754 | } |
| 755 | |
| 756 | bool ChromeContentBrowserClient::AllowSetCookie( |
| 757 | const GURL& url, |
| 758 | const GURL& first_party, |
| 759 | const std::string& cookie_line, |
| 760 | const content::ResourceContext& context, |
| 761 | int render_process_id, |
| 762 | int render_view_id, |
| 763 | net::CookieOptions* options) { |
| 764 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 765 | ProfileIOData* io_data = |
| 766 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 767 | |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 768 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 769 | bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party); |
| 770 | |
| 771 | if (cookie_settings->IsCookieSessionOnly(url)) |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 772 | options->set_force_session(); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 773 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 774 | BrowserThread::PostTask( |
| 775 | BrowserThread::UI, FROM_HERE, |
[email protected] | 317c58f0 | 2011-11-09 02:15:03 | [diff] [blame] | 776 | base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id, |
| 777 | render_view_id, url, cookie_line, *options, !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 778 | return allow; |
| 779 | } |
| 780 | |
[email protected] | d5a1916 | 2011-06-30 18:51:54 | [diff] [blame] | 781 | bool ChromeContentBrowserClient::AllowSaveLocalState( |
| 782 | const content::ResourceContext& context) { |
| 783 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 784 | ProfileIOData* io_data = |
| 785 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 786 | return !io_data->clear_local_state_on_exit()->GetValue(); |
| 787 | } |
| 788 | |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 789 | bool ChromeContentBrowserClient::AllowWorkerDatabase( |
| 790 | int worker_route_id, |
| 791 | const GURL& url, |
| 792 | const string16& name, |
| 793 | const string16& display_name, |
| 794 | unsigned long estimated_size, |
| 795 | WorkerProcessHost* worker_process_host) { |
| 796 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 797 | ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 798 | worker_process_host->resource_context()->GetUserData(NULL)); |
| 799 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 800 | bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
| 801 | |
| 802 | // Record access to database for potential display in UI: Find the worker |
| 803 | // instance and forward the message to all attached documents. |
| 804 | WorkerProcessHost::Instances::const_iterator i; |
| 805 | for (i = worker_process_host->instances().begin(); |
| 806 | i != worker_process_host->instances().end(); ++i) { |
| 807 | if (i->worker_route_id() != worker_route_id) |
| 808 | continue; |
| 809 | const WorkerDocumentSet::DocumentInfoSet& documents = |
| 810 | i->worker_document_set()->documents(); |
| 811 | for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = |
| 812 | documents.begin(); doc != documents.end(); ++doc) { |
| 813 | BrowserThread::PostTask( |
| 814 | BrowserThread::UI, FROM_HERE, |
| 815 | base::Bind( |
| 816 | &TabSpecificContentSettings::WebDatabaseAccessed, |
| 817 | doc->render_process_id(), doc->render_view_id(), |
| 818 | url, name, display_name, !allow)); |
| 819 | } |
| 820 | break; |
| 821 | } |
| 822 | |
| 823 | return allow; |
| 824 | } |
| 825 | |
| 826 | bool ChromeContentBrowserClient::AllowWorkerFileSystem( |
| 827 | int worker_route_id, |
| 828 | const GURL& url, |
| 829 | WorkerProcessHost* worker_process_host) { |
| 830 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 831 | ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( |
| 832 | worker_process_host->resource_context()->GetUserData(NULL)); |
| 833 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 834 | bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
| 835 | |
| 836 | // Record access to file system for potential display in UI: Find the worker |
| 837 | // instance and forward the message to all attached documents. |
| 838 | WorkerProcessHost::Instances::const_iterator i; |
| 839 | for (i = worker_process_host->instances().begin(); |
| 840 | i != worker_process_host->instances().end(); ++i) { |
| 841 | if (i->worker_route_id() != worker_route_id) |
| 842 | continue; |
| 843 | const WorkerDocumentSet::DocumentInfoSet& documents = |
| 844 | i->worker_document_set()->documents(); |
| 845 | for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = |
| 846 | documents.begin(); doc != documents.end(); ++doc) { |
| 847 | BrowserThread::PostTask( |
| 848 | BrowserThread::UI, FROM_HERE, |
| 849 | base::Bind( |
| 850 | &TabSpecificContentSettings::FileSystemAccessed, |
| 851 | doc->render_process_id(), doc->render_view_id(), url, !allow)); |
| 852 | } |
| 853 | break; |
| 854 | } |
| 855 | |
| 856 | return allow; |
| 857 | } |
| 858 | |
[email protected] | 6133f92 | 2011-07-01 21:34:34 | [diff] [blame] | 859 | net::URLRequestContext* |
| 860 | ChromeContentBrowserClient::OverrideRequestContextForURL( |
| 861 | const GURL& url, const content::ResourceContext& context) { |
| 862 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 863 | if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 864 | ProfileIOData* io_data = |
| 865 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 866 | return io_data->extensions_request_context(); |
| 867 | } |
| 868 | |
| 869 | return NULL; |
| 870 | } |
| 871 | |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 872 | QuotaPermissionContext* |
| 873 | ChromeContentBrowserClient::CreateQuotaPermissionContext() { |
| 874 | return new ChromeQuotaPermissionContext(); |
| 875 | } |
| 876 | |
[email protected] | a0ce328 | 2011-08-19 20:49:52 | [diff] [blame] | 877 | void ChromeContentBrowserClient::OpenItem(const FilePath& path) { |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 878 | platform_util::OpenItem(path); |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 879 | } |
| 880 | |
[email protected] | a0ce328 | 2011-08-19 20:49:52 | [diff] [blame] | 881 | void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) { |
[email protected] | a0ce328 | 2011-08-19 20:49:52 | [diff] [blame] | 882 | platform_util::ShowItemInFolder(path); |
[email protected] | a0ce328 | 2011-08-19 20:49:52 | [diff] [blame] | 883 | } |
| 884 | |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 885 | void ChromeContentBrowserClient::AllowCertificateError( |
| 886 | SSLCertErrorHandler* handler, |
| 887 | bool overridable, |
[email protected] | 8a27abf | 2011-09-30 21:59:58 | [diff] [blame] | 888 | const base::Callback<void(SSLCertErrorHandler*, bool)>& callback) { |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 889 | // If the tab is being prerendered, cancel the prerender and the request. |
| 890 | TabContents* tab = tab_util::GetTabContentsByID( |
| 891 | handler->render_process_host_id(), |
| 892 | handler->tab_contents_id()); |
| 893 | if (!tab) { |
| 894 | NOTREACHED(); |
| 895 | return; |
| 896 | } |
| 897 | prerender::PrerenderManager* prerender_manager = |
[email protected] | 3085c50 | 2011-10-05 17:50:50 | [diff] [blame] | 898 | prerender::PrerenderManagerFactory::GetForProfile( |
| 899 | Profile::FromBrowserContext(tab->browser_context())); |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 900 | if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) { |
| 901 | if (prerender_manager->prerender_tracker()->TryCancel( |
| 902 | handler->render_process_host_id(), |
| 903 | handler->tab_contents_id(), |
| 904 | prerender::FINAL_STATUS_SSL_ERROR)) { |
| 905 | handler->CancelRequest(); |
| 906 | return; |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | // Otherwise, display an SSL blocking page. |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 911 | SSLBlockingPage* blocking_page = new SSLBlockingPage( |
| 912 | handler, overridable, callback); |
| 913 | blocking_page->Show(); |
| 914 | } |
| 915 | |
[email protected] | c99c442e | 2011-08-24 11:37:30 | [diff] [blame] | 916 | void ChromeContentBrowserClient::SelectClientCertificate( |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 917 | int render_process_id, |
| 918 | int render_view_id, |
| 919 | SSLClientAuthHandler* handler) { |
| 920 | TabContents* tab = tab_util::GetTabContentsByID( |
| 921 | render_process_id, render_view_id); |
| 922 | if (!tab) { |
| 923 | NOTREACHED(); |
| 924 | return; |
| 925 | } |
| 926 | |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 927 | net::SSLCertRequestInfo* cert_request_info = handler->cert_request_info(); |
| 928 | GURL requesting_url("https://" + cert_request_info->host_and_port); |
| 929 | DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://" |
| 930 | << cert_request_info->host_and_port; |
| 931 | |
| 932 | Profile* profile = Profile::FromBrowserContext(tab->browser_context()); |
| 933 | DCHECK(profile); |
| 934 | scoped_ptr<Value> filter( |
| 935 | profile->GetHostContentSettingsMap()->GetWebsiteSetting( |
| 936 | requesting_url, |
| 937 | requesting_url, |
| 938 | CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 939 | std::string(), NULL)); |
| 940 | |
| 941 | if (filter.get()) { |
| 942 | // Try to automatically select a client certificate. |
| 943 | if (filter->IsType(Value::TYPE_DICTIONARY)) { |
| 944 | DictionaryValue* filter_dict = |
| 945 | static_cast<DictionaryValue*>(filter.get()); |
| 946 | |
| 947 | const std::vector<scoped_refptr<net::X509Certificate> >& |
| 948 | all_client_certs = cert_request_info->client_certs; |
| 949 | for (size_t i = 0; i < all_client_certs.size(); ++i) { |
| 950 | if (CertMatchesFilter(*all_client_certs[i], *filter_dict)) { |
| 951 | // Use the first certificate that is matched by the filter. |
| 952 | handler->CertificateSelected(all_client_certs[i]); |
| 953 | return; |
| 954 | } |
| 955 | } |
| 956 | } else { |
| 957 | NOTREACHED(); |
| 958 | } |
| 959 | } |
| 960 | |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 961 | TabContentsWrapper* wrapper = |
| 962 | TabContentsWrapper::GetCurrentWrapperForContents(tab); |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 963 | if (!wrapper) { |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 964 | // If there is no TabContentsWrapper for the given TabContents then we can't |
| 965 | // show the user a dialog to select a client certificate. So we simply |
[email protected] | 2a349e9 | 2011-12-07 12:00:14 | [diff] [blame] | 966 | // proceed with no client certificate. |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 967 | handler->CertificateSelected(NULL); |
| 968 | return; |
| 969 | } |
| 970 | wrapper->ssl_helper()->ShowClientCertificateRequestDialog(handler); |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | void ChromeContentBrowserClient::AddNewCertificate( |
| 974 | net::URLRequest* request, |
| 975 | net::X509Certificate* cert, |
| 976 | int render_process_id, |
| 977 | int render_view_id) { |
| 978 | // The handler will run the UI and delete itself when it's finished. |
| 979 | new SSLAddCertHandler(request, cert, render_process_id, render_view_id); |
| 980 | } |
| 981 | |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 982 | void ChromeContentBrowserClient::RequestDesktopNotificationPermission( |
| 983 | const GURL& source_origin, |
| 984 | int callback_context, |
| 985 | int render_process_id, |
| 986 | int render_view_id) { |
| 987 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 988 | render_process_id, render_view_id); |
| 989 | if (!rvh) { |
| 990 | NOTREACHED(); |
| 991 | return; |
| 992 | } |
| 993 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 994 | content::RenderProcessHost* process = rvh->process(); |
| 995 | Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 996 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 997 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 998 | service->RequestPermission( |
| 999 | source_origin, render_process_id, render_view_id, callback_context, |
| 1000 | tab_util::GetTabContentsByID(render_process_id, render_view_id)); |
| 1001 | } |
| 1002 | |
| 1003 | WebKit::WebNotificationPresenter::Permission |
| 1004 | ChromeContentBrowserClient::CheckDesktopNotificationPermission( |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1005 | const GURL& source_origin, |
| 1006 | const content::ResourceContext& context, |
| 1007 | int render_process_id) { |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1008 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1009 | ProfileIOData* io_data = |
| 1010 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 1011 | |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1012 | if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission( |
| 1013 | source_origin, render_process_id, |
| 1014 | ExtensionAPIPermission::kNotification)) |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1015 | return WebKit::WebNotificationPresenter::PermissionAllowed; |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1016 | |
| 1017 | // Fall back to the regular notification preferences, which works on an |
| 1018 | // origin basis. |
| 1019 | return io_data->GetNotificationService() ? |
[email protected] | c7df61b | 2011-11-07 22:06:37 | [diff] [blame] | 1020 | io_data->GetNotificationService()->HasPermission(source_origin) : |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1021 | WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 1022 | } |
| 1023 | |
| 1024 | void ChromeContentBrowserClient::ShowDesktopNotification( |
[email protected] | 0ee57e2 | 2011-11-12 01:59:17 | [diff] [blame] | 1025 | const content::ShowDesktopNotificationHostMsgParams& params, |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1026 | int render_process_id, |
| 1027 | int render_view_id, |
| 1028 | bool worker) { |
| 1029 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 1030 | render_process_id, render_view_id); |
| 1031 | if (!rvh) { |
| 1032 | NOTREACHED(); |
| 1033 | return; |
| 1034 | } |
| 1035 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1036 | content::RenderProcessHost* process = rvh->process(); |
| 1037 | Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1038 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1039 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1040 | service->ShowDesktopNotification( |
| 1041 | params, render_process_id, render_view_id, |
| 1042 | worker ? DesktopNotificationService::WorkerNotification : |
| 1043 | DesktopNotificationService::PageNotification); |
| 1044 | } |
| 1045 | |
| 1046 | void ChromeContentBrowserClient::CancelDesktopNotification( |
| 1047 | int render_process_id, |
| 1048 | int render_view_id, |
| 1049 | int notification_id) { |
| 1050 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 1051 | render_process_id, render_view_id); |
| 1052 | if (!rvh) { |
| 1053 | NOTREACHED(); |
| 1054 | return; |
| 1055 | } |
| 1056 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1057 | content::RenderProcessHost* process = rvh->process(); |
| 1058 | Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1059 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1060 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1061 | service->CancelDesktopNotification( |
| 1062 | render_process_id, render_view_id, notification_id); |
| 1063 | } |
| 1064 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1065 | bool ChromeContentBrowserClient::CanCreateWindow( |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1066 | const GURL& source_origin, |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1067 | WindowContainerType container_type, |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1068 | const content::ResourceContext& context, |
| 1069 | int render_process_id) { |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1070 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1071 | // If the opener is trying to create a background window but doesn't have |
| 1072 | // the appropriate permission, fail the attempt. |
| 1073 | if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
| 1074 | ProfileIOData* io_data = |
| 1075 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1076 | return io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission( |
| 1077 | source_origin, render_process_id, ExtensionAPIPermission::kBackground); |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1078 | } |
| 1079 | return true; |
| 1080 | } |
| 1081 | |
| 1082 | std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
| 1083 | const GURL& url, const content::ResourceContext& context) { |
| 1084 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1085 | // Check if it's an extension-created worker, in which case we want to use |
| 1086 | // the name of the extension. |
| 1087 | ProfileIOData* io_data = |
| 1088 | reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
| 1089 | const Extension* extension = |
| 1090 | io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); |
| 1091 | return extension ? extension->name() : std::string(); |
| 1092 | } |
| 1093 | |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 1094 | ResourceDispatcherHost* |
| 1095 | ChromeContentBrowserClient::GetResourceDispatcherHost() { |
| 1096 | return g_browser_process->resource_dispatcher_host(); |
| 1097 | } |
| 1098 | |
| 1099 | ui::Clipboard* ChromeContentBrowserClient::GetClipboard() { |
| 1100 | return g_browser_process->clipboard(); |
| 1101 | } |
| 1102 | |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 1103 | MHTMLGenerationManager* |
| 1104 | ChromeContentBrowserClient::GetMHTMLGenerationManager() { |
| 1105 | return g_browser_process->mhtml_generation_manager(); |
| 1106 | } |
| 1107 | |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 1108 | net::NetLog* ChromeContentBrowserClient::GetNetLog() { |
| 1109 | return g_browser_process->net_log(); |
| 1110 | } |
| 1111 | |
[email protected] | 3bc0b56 | 2011-08-24 23:51:04 | [diff] [blame] | 1112 | speech_input::SpeechInputManager* |
| 1113 | ChromeContentBrowserClient::GetSpeechInputManager() { |
| 1114 | return speech_input::ChromeSpeechInputManager::GetInstance(); |
| 1115 | } |
| 1116 | |
[email protected] | 32538d9 | 2011-08-25 00:09:23 | [diff] [blame] | 1117 | AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() { |
| 1118 | return new ChromeAccessTokenStore(); |
| 1119 | } |
| 1120 | |
[email protected] | dbae6b0 | 2011-06-29 23:51:41 | [diff] [blame] | 1121 | bool ChromeContentBrowserClient::IsFastShutdownPossible() { |
| 1122 | const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 1123 | return !browser_command_line.HasSwitch(switches::kChromeFrame); |
| 1124 | } |
| 1125 | |
[email protected] | 5092c28 | 2011-10-29 21:48:37 | [diff] [blame] | 1126 | WebPreferences ChromeContentBrowserClient::GetWebkitPrefs(RenderViewHost* rvh) { |
| 1127 | return RenderViewHostDelegateHelper::GetWebkitPrefs(rvh); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | void ChromeContentBrowserClient::UpdateInspectorSetting( |
| 1131 | RenderViewHost* rvh, const std::string& key, const std::string& value) { |
| 1132 | RenderViewHostDelegateHelper::UpdateInspectorSetting( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1133 | rvh->process()->GetBrowserContext(), key, value); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) { |
| 1137 | RenderViewHostDelegateHelper::ClearInspectorSettings( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1138 | rvh->process()->GetBrowserContext()); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 1139 | } |
| 1140 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 1141 | void ChromeContentBrowserClient::BrowserURLHandlerCreated( |
| 1142 | BrowserURLHandler* handler) { |
| 1143 | // Add the default URL handlers. |
| 1144 | handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, |
| 1145 | BrowserURLHandler::null_handler()); |
| 1146 | handler->AddHandlerPair(BrowserURLHandler::null_handler(), |
| 1147 | &ExtensionWebUI::HandleChromeURLOverrideReverse); |
| 1148 | |
[email protected] | b3adbd0 | 2011-11-30 22:23:27 | [diff] [blame] | 1149 | // about: handler. Must come before chrome: handler, since it will |
| 1150 | // rewrite about: urls to chrome: URLs and then expect chrome: to |
| 1151 | // actually handle them. |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 1152 | handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 1153 | BrowserURLHandler::null_handler()); |
| 1154 | // chrome: & friends. |
| 1155 | handler->AddHandlerPair(&HandleWebUI, |
| 1156 | BrowserURLHandler::null_handler()); |
| 1157 | } |
| 1158 | |
| 1159 | void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1160 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1161 | rvh->site_instance()->GetProcess()->GetBrowserContext()); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 1162 | BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
| 1163 | BrowsingDataRemover::EVERYTHING, |
| 1164 | base::Time()); |
| 1165 | remover->Remove(BrowsingDataRemover::REMOVE_CACHE); |
| 1166 | // BrowsingDataRemover takes care of deleting itself when done. |
| 1167 | } |
| 1168 | |
| 1169 | void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1170 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1171 | rvh->site_instance()->GetProcess()->GetBrowserContext()); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 1172 | BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
| 1173 | BrowsingDataRemover::EVERYTHING, |
| 1174 | base::Time()); |
[email protected] | dceaa91 | 2011-09-06 17:17:23 | [diff] [blame] | 1175 | int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 1176 | remover->Remove(remove_mask); |
| 1177 | // BrowsingDataRemover takes care of deleting itself when done. |
| 1178 | } |
| 1179 | |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 1180 | FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
| 1181 | return download_util::GetDefaultDownloadDirectory(); |
| 1182 | } |
| 1183 | |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 1184 | std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
| 1185 | return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
| 1186 | } |
| 1187 | |
[email protected] | e60c023 | 2011-11-11 19:56:35 | [diff] [blame] | 1188 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1189 | int ChromeContentBrowserClient::GetCrashSignalFD( |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 1190 | const CommandLine& command_line) { |
| 1191 | if (command_line.HasSwitch(switches::kExtensionProcess)) { |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 1192 | ExtensionCrashHandlerHostLinux* crash_handler = |
| 1193 | ExtensionCrashHandlerHostLinux::GetInstance(); |
| 1194 | return crash_handler->GetDeathSignalSocket(); |
| 1195 | } |
| 1196 | |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 1197 | std::string process_type = |
| 1198 | command_line.GetSwitchValueASCII(switches::kProcessType); |
| 1199 | |
| 1200 | if (process_type == switches::kRendererProcess) |
| 1201 | return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 1202 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1203 | if (process_type == switches::kPluginProcess) |
| 1204 | return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 1205 | |
| 1206 | if (process_type == switches::kPpapiPluginProcess) |
| 1207 | return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 1208 | |
| 1209 | if (process_type == switches::kGpuProcess) |
| 1210 | return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 1211 | |
| 1212 | return -1; |
| 1213 | } |
[email protected] | e60c023 | 2011-11-11 19:56:35 | [diff] [blame] | 1214 | #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1215 | |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 1216 | #if defined(OS_WIN) |
| 1217 | const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { |
| 1218 | return chrome::kBrowserResourcesDll; |
| 1219 | } |
| 1220 | #endif |
| 1221 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 1222 | #if defined(USE_NSS) |
| 1223 | crypto::CryptoModuleBlockingPasswordDelegate* |
| 1224 | ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 1225 | const GURL& url) { |
| 1226 | return browser::NewCryptoModuleBlockingDialogDelegate( |
| 1227 | browser::kCryptoModulePasswordKeygen, url.host()); |
| 1228 | } |
| 1229 | #endif |
| 1230 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 1231 | } // namespace chrome |