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