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