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