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