[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] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 13 | #include "base/lazy_instance.h" |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 14 | #include "base/path_service.h" |
[email protected] | 3853a4c | 2013-02-11 17:15:57 | [diff] [blame] | 15 | #include "base/prefs/pref_service.h" |
[email protected] | e746341 | 2013-06-10 22:53:46 | [diff] [blame] | 16 | #include "base/strings/string_number_conversions.h" |
[email protected] | 135cb80 | 2013-06-09 16:44:20 | [diff] [blame] | 17 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 30a306f4 | 2013-06-10 03:09:03 | [diff] [blame] | 18 | #include "base/threading/sequenced_worker_pool.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 19 | #include "chrome/app/breakpad_mac.h" |
[email protected] | 056efdc | 2013-04-06 00:14:53 | [diff] [blame] | 20 | #include "chrome/browser/app_mode/app_mode_utils.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 21 | #include "chrome/browser/browser_about_handler.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 22 | #include "chrome/browser/browser_process.h" |
[email protected] | 5c12979 | 2013-07-10 02:08:48 | [diff] [blame] | 23 | #include "chrome/browser/browser_shutdown.h" |
[email protected] | b0cb5e8 | 2012-07-19 19:22:47 | [diff] [blame] | 24 | #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 25 | #include "chrome/browser/browsing_data/browsing_data_remover.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 26 | #include "chrome/browser/character_encoding.h" |
[email protected] | 4353551 | 2013-02-20 20:41:41 | [diff] [blame] | 27 | #include "chrome/browser/chrome_net_benchmarking_message_filter.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 28 | #include "chrome/browser/chrome_quota_permission_context.h" |
[email protected] | edece21 | 2011-11-16 11:56:56 | [diff] [blame] | 29 | #include "chrome/browser/content_settings/content_settings_utils.h" |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 30 | #include "chrome/browser/content_settings/cookie_settings.h" |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 31 | #include "chrome/browser/content_settings/host_content_settings_map.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 32 | #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
[email protected] | 9d06d88d | 2012-02-23 22:37:08 | [diff] [blame] | 33 | #include "chrome/browser/defaults.h" |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 34 | #include "chrome/browser/download/download_util.h" |
[email protected] | 17263b2 | 2013-05-16 03:29:22 | [diff] [blame] | 35 | #include "chrome/browser/extensions/activity_log/activity_log.h" |
[email protected] | 2b33dcd0 | 2012-03-18 01:34:16 | [diff] [blame] | 36 | #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
[email protected] | 1deace2 | 2013-05-22 06:14:46 | [diff] [blame] | 37 | #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 38 | #include "chrome/browser/extensions/extension_host.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 39 | #include "chrome/browser/extensions/extension_info_map.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 40 | #include "chrome/browser/extensions/extension_process_manager.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 41 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 42 | #include "chrome/browser/extensions/extension_system.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 43 | #include "chrome/browser/extensions/extension_web_ui.h" |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 44 | #include "chrome/browser/extensions/extension_webkit_preferences.h" |
[email protected] | eb4832a | 2012-12-08 01:57:52 | [diff] [blame] | 45 | #include "chrome/browser/extensions/suggest_permission_util.h" |
[email protected] | 32538d9 | 2011-08-25 00:09:23 | [diff] [blame] | 46 | #include "chrome/browser/geolocation/chrome_access_token_store.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 47 | #include "chrome/browser/google/google_util.h" |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 48 | #include "chrome/browser/guestview/adview/adview_guest.h" |
| 49 | #include "chrome/browser/guestview/guestview_constants.h" |
| 50 | #include "chrome/browser/guestview/webview/webview_guest.h" |
[email protected] | 11158e2d | 2013-02-01 02:31:56 | [diff] [blame] | 51 | #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
[email protected] | 95132f5 | 2013-04-12 02:19:04 | [diff] [blame] | 52 | #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" |
[email protected] | 01e5975 | 2013-06-18 00:17:35 | [diff] [blame] | 53 | #include "chrome/browser/nacl_host/nacl_host_message_filter.h" |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 54 | #include "chrome/browser/nacl_host/nacl_process_host.h" |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 55 | #include "chrome/browser/net/chrome_net_log.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 56 | #include "chrome/browser/notifications/desktop_notification_service.h" |
| 57 | #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 58 | #include "chrome/browser/platform_util.h" |
[email protected] | c2295f7 | 2013-01-03 22:18:56 | [diff] [blame] | 59 | #include "chrome/browser/plugins/plugin_info_message_filter.h" |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 60 | #include "chrome/browser/prefs/scoped_user_pref_update.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 61 | #include "chrome/browser/prerender/prerender_manager.h" |
[email protected] | 3085c50 | 2011-10-05 17:50:50 | [diff] [blame] | 62 | #include "chrome/browser/prerender/prerender_manager_factory.h" |
[email protected] | 2736c03 | 2012-05-11 18:06:07 | [diff] [blame] | 63 | #include "chrome/browser/prerender/prerender_message_filter.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 64 | #include "chrome/browser/prerender/prerender_tracker.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 65 | #include "chrome/browser/printing/printing_message_filter.h" |
[email protected] | 7e75e4a | 2013-05-17 17:20:03 | [diff] [blame] | 66 | #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 67 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 68 | #include "chrome/browser/profiles/profile_io_data.h" |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 69 | #include "chrome/browser/profiles/profile_manager.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 70 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 71 | #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" |
[email protected] | a7b8e43d | 2013-03-18 18:52:43 | [diff] [blame] | 72 | #include "chrome/browser/search/instant_service.h" |
| 73 | #include "chrome/browser/search/instant_service_factory.h" |
| 74 | #include "chrome/browser/search/search.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 75 | #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h" |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 76 | #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
[email protected] | 7a06d28 | 2013-05-03 04:39:33 | [diff] [blame] | 77 | #include "chrome/browser/speech/tts_message_filter.h" |
[email protected] | 8ec7126 | 2011-07-28 08:12:46 | [diff] [blame] | 78 | #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
[email protected] | 3b45550 | 2012-12-11 18:22:58 | [diff] [blame] | 79 | #include "chrome/browser/ssl/ssl_add_certificate.h" |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 80 | #include "chrome/browser/ssl/ssl_blocking_page.h" |
[email protected] | 11feec32 | 2012-09-18 03:58:52 | [diff] [blame] | 81 | #include "chrome/browser/ssl/ssl_tab_helper.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 82 | #include "chrome/browser/tab_contents/tab_util.h" |
[email protected] | a28e330 | 2013-02-03 03:50:43 | [diff] [blame] | 83 | #include "chrome/browser/ui/chrome_select_file_policy.h" |
[email protected] | 329ac97 | 2013-06-21 15:24:25 | [diff] [blame] | 84 | #include "chrome/browser/ui/sync/sync_promo_ui.h" |
[email protected] | b5d7342 | 2012-06-02 23:46:44 | [diff] [blame] | 85 | #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
[email protected] | 863f70a | 2012-01-27 02:05:50 | [diff] [blame] | 86 | #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 87 | #include "chrome/browser/user_style_sheet_watcher.h" |
[email protected] | 13169ab | 2012-04-06 07:48:15 | [diff] [blame] | 88 | #include "chrome/browser/user_style_sheet_watcher_factory.h" |
[email protected] | 1352ca9 | 2013-04-30 02:30:27 | [diff] [blame] | 89 | #include "chrome/browser/validation_message_message_filter.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 90 | #include "chrome/common/child_process_logging.h" |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 91 | #include "chrome/common/chrome_constants.h" |
[email protected] | a7944aa | 2012-10-15 10:12:14 | [diff] [blame] | 92 | #include "chrome/common/chrome_paths.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 93 | #include "chrome/common/chrome_switches.h" |
[email protected] | 9367eabc | 2013-03-01 01:29:29 | [diff] [blame] | 94 | #include "chrome/common/extensions/background_info.h" |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 95 | #include "chrome/common/extensions/extension.h" |
[email protected] | 395045c | 2012-05-22 15:04:38 | [diff] [blame] | 96 | #include "chrome/common/extensions/extension_process_policy.h" |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 97 | #include "chrome/common/extensions/extension_set.h" |
[email protected] | 561e33d5 | 2013-04-03 06:58:43 | [diff] [blame] | 98 | #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
[email protected] | b7131323 | 2013-05-06 06:16:29 | [diff] [blame] | 99 | #include "chrome/common/extensions/manifest_handlers/shared_module_info.h" |
[email protected] | dda5482 | 2013-06-15 01:26:39 | [diff] [blame] | 100 | #include "chrome/common/extensions/permissions/permissions_data.h" |
[email protected] | 157cc90 | 2012-11-02 06:31:58 | [diff] [blame] | 101 | #include "chrome/common/extensions/permissions/socket_permission.h" |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 102 | #include "chrome/common/logging_chrome.h" |
[email protected] | 9d45049 | 2013-06-13 23:08:37 | [diff] [blame] | 103 | #include "chrome/common/pepper_permission_util.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 104 | #include "chrome/common/pref_names.h" |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 105 | #include "chrome/common/render_messages.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 106 | #include "chrome/common/url_constants.h" |
[email protected] | e8f3f998 | 2013-05-10 20:59:53 | [diff] [blame] | 107 | #include "chromeos/chromeos_constants.h" |
[email protected] | d5d38325 | 2013-07-04 14:44:32 | [diff] [blame] | 108 | #include "components/nacl/common/nacl_process_type.h" |
[email protected] | 75fee37 | 2013-03-06 00:42:44 | [diff] [blame] | 109 | #include "components/user_prefs/pref_registry_syncable.h" |
[email protected] | e0ada9c | 2012-03-20 03:54:43 | [diff] [blame] | 110 | #include "content/public/browser/browser_child_process_host.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 111 | #include "content/public/browser/browser_main_parts.h" |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 112 | #include "content/public/browser/browser_ppapi_host.h" |
[email protected] | 30a306f4 | 2013-06-10 03:09:03 | [diff] [blame] | 113 | #include "content/public/browser/browser_thread.h" |
[email protected] | 825b166 | 2012-03-12 19:07:31 | [diff] [blame] | 114 | #include "content/public/browser/browser_url_handler.h" |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 115 | #include "content/public/browser/child_process_data.h" |
[email protected] | b953542 | 2012-02-09 01:47:59 | [diff] [blame] | 116 | #include "content/public/browser/child_process_security_policy.h" |
[email protected] | cb643093 | 2012-10-31 00:53:36 | [diff] [blame] | 117 | #include "content/public/browser/compositor_util.h" |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 118 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 119 | #include "content/public/browser/render_view_host.h" |
[email protected] | ce96786 | 2012-02-09 22:47:05 | [diff] [blame] | 120 | #include "content/public/browser/resource_context.h" |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 121 | #include "content/public/browser/site_instance.h" |
[email protected] | 91ee368 | 2012-01-19 15:02:19 | [diff] [blame] | 122 | #include "content/public/browser/web_contents.h" |
[email protected] | 8643e6d | 2012-01-18 20:26:10 | [diff] [blame] | 123 | #include "content/public/browser/web_contents_view.h" |
[email protected] | e0ada9c | 2012-03-20 03:54:43 | [diff] [blame] | 124 | #include "content/public/common/child_process_host.h" |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 125 | #include "content/public/common/content_descriptors.h" |
[email protected] | cb2edf2 | 2013-04-01 20:25:23 | [diff] [blame] | 126 | #include "extensions/browser/view_type_utils.h" |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 127 | #include "extensions/common/constants.h" |
[email protected] | 49d9b14 | 2013-07-19 08:50:27 | [diff] [blame] | 128 | #include "extensions/common/switches.h" |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 129 | #include "grit/generated_resources.h" |
[email protected] | 2a28133 | 2012-07-11 22:20:23 | [diff] [blame] | 130 | #include "grit/ui_resources.h" |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 131 | #include "net/base/escape.h" |
[email protected] | 3b45550 | 2012-12-11 18:22:58 | [diff] [blame] | 132 | #include "net/base/mime_util.h" |
[email protected] | 5b9bc35 | 2012-07-18 13:13:34 | [diff] [blame] | 133 | #include "net/cookies/canonical_cookie.h" |
[email protected] | aa84a7e | 2012-03-15 21:29:06 | [diff] [blame] | 134 | #include "net/cookies/cookie_options.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 135 | #include "net/ssl/ssl_cert_request_info.h" |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 136 | #include "ppapi/host/ppapi_host.h" |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 137 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 138 | #include "ui/base/resource/resource_bundle.h" |
[email protected] | fb1aac1 | 2013-05-14 05:30:24 | [diff] [blame] | 139 | #include "ui/message_center/message_center_util.h" |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 140 | #include "webkit/browser/fileapi/external_mount_points.h" |
[email protected] | fab55e7 | 2013-05-31 07:06:18 | [diff] [blame] | 141 | #include "webkit/common/webpreferences.h" |
[email protected] | a085aed7 | 2012-04-24 05:32:04 | [diff] [blame] | 142 | #include "webkit/plugins/plugin_switches.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 143 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 144 | #if defined(OS_WIN) |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 145 | #include "chrome/browser/chrome_browser_main_win.h" |
[email protected] | 34f4868 | 2013-03-20 00:30:18 | [diff] [blame] | 146 | #include "sandbox/win/src/sandbox_policy.h" |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 147 | #elif defined(OS_MACOSX) |
| 148 | #include "chrome/browser/chrome_browser_main_mac.h" |
[email protected] | 7ceb9901 | 2011-12-21 08:05:56 | [diff] [blame] | 149 | #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 150 | #elif defined(OS_CHROMEOS) |
| 151 | #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 152 | #include "chrome/browser/chromeos/drive/file_system_backend_delegate.h" |
| 153 | #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
[email protected] | 5c91525 | 2013-05-07 13:15:39 | [diff] [blame] | 154 | #include "chrome/browser/chromeos/login/startup_utils.h" |
[email protected] | fe69558d | 2012-03-12 11:34:49 | [diff] [blame] | 155 | #include "chrome/browser/chromeos/login/user_manager.h" |
[email protected] | 5c91525 | 2013-05-07 13:15:39 | [diff] [blame] | 156 | #include "chrome/browser/chromeos/system/statistics_provider.h" |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 157 | #include "chromeos/chromeos_switches.h" |
[email protected] | 81ce2c4 | 2012-03-24 01:43:26 | [diff] [blame] | 158 | #elif defined(OS_LINUX) |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 159 | #include "chrome/browser/chrome_browser_main_linux.h" |
[email protected] | 81054f81 | 2012-08-30 00:47:09 | [diff] [blame] | 160 | #elif defined(OS_ANDROID) |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 161 | #include "chrome/browser/android/crash_dump_manager.h" |
[email protected] | 81054f81 | 2012-08-30 00:47:09 | [diff] [blame] | 162 | #include "chrome/browser/chrome_browser_main_android.h" |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 163 | #include "chrome/common/descriptors_android.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 164 | #elif defined(OS_POSIX) |
| 165 | #include "chrome/browser/chrome_browser_main_posix.h" |
| 166 | #endif |
| 167 | |
[email protected] | 6653c19 | 2012-04-10 22:52:44 | [diff] [blame] | 168 | #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 169 | #include "base/linux_util.h" |
[email protected] | 1602cde | 2012-06-26 15:09:12 | [diff] [blame] | 170 | #include "chrome/browser/crash_handler_host_linux.h" |
[email protected] | 1fd5302c | 2011-05-28 04:06:43 | [diff] [blame] | 171 | #endif |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 172 | |
[email protected] | 1e87df3 | 2012-09-12 04:53:19 | [diff] [blame] | 173 | #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 174 | #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 175 | #endif |
| 176 | |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 177 | #if defined(OS_ANDROID) |
| 178 | #include "ui/base/ui_base_paths.h" |
| 179 | #endif |
| 180 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 181 | #if defined(USE_NSS) |
| 182 | #include "chrome/browser/ui/crypto_module_password_dialog.h" |
| 183 | #endif |
| 184 | |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 185 | #if !defined(OS_CHROMEOS) |
| 186 | #include "chrome/browser/signin/signin_manager.h" |
| 187 | #include "chrome/browser/signin/signin_manager_factory.h" |
| 188 | #endif |
| 189 | |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 190 | #if !defined(OS_ANDROID) |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 191 | #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 192 | #endif |
| 193 | |
[email protected] | 6ef98b5a | 2013-05-31 23:58:31 | [diff] [blame] | 194 | #if defined(ENABLE_WEBRTC) |
| 195 | #include "chrome/browser/media/webrtc_logging_handler_host.h" |
| 196 | #endif |
| 197 | |
[email protected] | 855e18b | 2013-07-08 21:02:00 | [diff] [blame] | 198 | #if defined(ENABLE_INPUT_SPEECH) |
| 199 | #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate_bubble_ui.h" |
| 200 | #endif |
| 201 | |
[email protected] | 02a3dc12 | 2013-06-13 15:07:53 | [diff] [blame] | 202 | #if defined(FILE_MANAGER_EXTENSION) |
| 203 | #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" |
| 204 | #endif |
| 205 | |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 206 | #if defined(TOOLKIT_GTK) |
| 207 | #include "chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.h" |
| 208 | #endif |
| 209 | |
| 210 | #if defined(TOOLKIT_VIEWS) |
| 211 | #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" |
| 212 | #endif |
| 213 | |
| 214 | #if defined(USE_ASH) |
| 215 | #include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h" |
| 216 | #endif |
| 217 | |
| 218 | #if defined(USE_AURA) |
| 219 | #include "chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h" |
| 220 | #endif |
| 221 | |
| 222 | #if defined(USE_X11) |
| 223 | #include "chrome/browser/chrome_browser_main_extra_parts_x11.h" |
| 224 | #endif |
| 225 | |
[email protected] | c7abd42 | 2012-09-25 00:20:08 | [diff] [blame] | 226 | using base::FileDescriptor; |
[email protected] | c8c7718 | 2011-12-21 15:04:47 | [diff] [blame] | 227 | using content::AccessTokenStore; |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 228 | using content::BrowserChildProcessHostIterator; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 229 | using content::BrowserThread; |
[email protected] | 825b166 | 2012-03-12 19:07:31 | [diff] [blame] | 230 | using content::BrowserURLHandler; |
[email protected] | b953542 | 2012-02-09 01:47:59 | [diff] [blame] | 231 | using content::ChildProcessSecurityPolicy; |
[email protected] | c7abd42 | 2012-09-25 00:20:08 | [diff] [blame] | 232 | using content::FileDescriptorInfo; |
[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 233 | using content::QuotaPermissionContext; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 234 | using content::RenderViewHost; |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 235 | using content::SiteInstance; |
[email protected] | 83ff91c | 2012-01-05 20:54:13 | [diff] [blame] | 236 | using content::WebContents; |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 237 | using extensions::APIPermission; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 238 | using extensions::Extension; |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 239 | using extensions::Manifest; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 240 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 241 | namespace { |
| 242 | |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 243 | // Cached version of the locale so we can return the locale on the I/O |
| 244 | // thread. |
| 245 | base::LazyInstance<std::string> g_io_thread_application_locale; |
| 246 | |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 247 | #if defined(ENABLE_PLUGINS) |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 248 | const char* kPredefinedAllowedSocketOrigins[] = { |
| 249 | "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client |
[email protected] | b95bf50 | 2012-04-06 07:41:18 | [diff] [blame] | 250 | "pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client) |
[email protected] | 9913268 | 2012-04-24 19:00:45 | [diff] [blame] | 251 | "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126 |
| 252 | "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop |
| 253 | "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop |
| 254 | "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop |
[email protected] | a450b6be | 2012-05-22 19:30:35 | [diff] [blame] | 255 | "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary |
[email protected] | 9040a0c2 | 2012-06-22 19:06:54 | [diff] [blame] | 256 | "cbkkbcmdlboombapidmoeolnmdacpkch", // see crbug.com/129089 |
| 257 | "hhnbmknkdabfoieppbbljkhkfjcmcbjh", // see crbug.com/134099 |
| 258 | "mablfbjkhmhkmefkjjacnbaikjkipphg", // see crbug.com/134099 |
| 259 | "pdeelgamlgannhelgoegilelnnojegoh", // see crbug.com/134099 |
| 260 | "cabapfdbkniadpollkckdnedaanlciaj", // see crbug.com/134099 |
| 261 | "mapljbgnjledlpdmlchihnmeclmefbba", // see crbug.com/134099 |
[email protected] | 4dc30b8 | 2012-08-15 00:24:38 | [diff] [blame] | 262 | "ghbfeebgmiidnnmeobbbaiamklmpbpii", // see crbug.com/134099 |
[email protected] | 45db05f | 2012-12-10 21:52:58 | [diff] [blame] | 263 | "jdfhpkjeckflbbleddjlpimecpbjdeep", // see crbug.com/142514 |
[email protected] | b7131323 | 2013-05-06 06:16:29 | [diff] [blame] | 264 | "iabmpiboiopbgfabjmgeedhcmjenhbla", // see crbug.com/165080 |
[email protected] | f6599915a | 2013-06-20 20:03:50 | [diff] [blame] | 265 | "B7CF8A292249681AF81771650BA4CEEAF19A4560", // see crbug.com/165080 |
[email protected] | b7131323 | 2013-05-06 06:16:29 | [diff] [blame] | 266 | "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/234789 |
| 267 | "7525AF4F66763A70A883C4700529F647B470E4D2", // see crbug.com/238084 |
| 268 | "0B549507088E1564D672F7942EB87CA4DAD73972", // see crbug.com/238084 |
| 269 | "864288364E239573E777D3E0E36864E590E95C74" // see crbug.com/238084 |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 270 | }; |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 271 | #endif |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 272 | |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 273 | // Returns a copy of the given url with its host set to given host and path set |
| 274 | // to given path. Other parts of the url will be the same. |
| 275 | GURL ReplaceURLHostAndPath(const GURL& url, |
| 276 | const std::string& host, |
| 277 | const std::string& path) { |
| 278 | url_canon::Replacements<char> replacements; |
| 279 | replacements.SetHost(host.c_str(), |
| 280 | url_parse::Component(0, host.length())); |
| 281 | replacements.SetPath(path.c_str(), |
| 282 | url_parse::Component(0, path.length())); |
| 283 | return url.ReplaceComponents(replacements); |
| 284 | } |
| 285 | |
| 286 | // Maps "foo://bar/baz/" to "foo://chrome/bar/baz/". |
| 287 | GURL AddUberHost(const GURL& url) { |
| 288 | const std::string uber_host = chrome::kChromeUIUberHost; |
| 289 | const std::string new_path = url.host() + url.path(); |
| 290 | |
| 291 | return ReplaceURLHostAndPath(url, uber_host, new_path); |
| 292 | } |
| 293 | |
[email protected] | 045bf7c | 2012-09-28 20:27:36 | [diff] [blame] | 294 | // If url->host() is "chrome" and url->path() has characters other than the |
| 295 | // first slash, changes the url from "foo://chrome/bar/" to "foo://bar/" and |
| 296 | // returns true. Otherwise returns false. |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 297 | bool RemoveUberHost(GURL* url) { |
| 298 | if (url->host() != chrome::kChromeUIUberHost) |
| 299 | return false; |
| 300 | |
[email protected] | 045bf7c | 2012-09-28 20:27:36 | [diff] [blame] | 301 | if (url->path().empty() || url->path() == "/") |
| 302 | return false; |
| 303 | |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 304 | const std::string old_path = url->path(); |
| 305 | |
| 306 | const std::string::size_type separator = old_path.find('/', 1); |
| 307 | std::string new_host; |
| 308 | std::string new_path; |
| 309 | if (separator == std::string::npos) { |
[email protected] | 045bf7c | 2012-09-28 20:27:36 | [diff] [blame] | 310 | new_host = old_path.substr(1); |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 311 | } else { |
| 312 | new_host = old_path.substr(1, separator - 1); |
| 313 | new_path = old_path.substr(separator); |
| 314 | } |
| 315 | |
[email protected] | 44e8add | 2013-06-13 17:29:15 | [diff] [blame] | 316 | // Do not allow URLs with paths empty before the first slash since we can't |
| 317 | // have an empty host. (e.g "foo://chrome//") |
| 318 | if (new_host.empty()) |
| 319 | return false; |
| 320 | |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 321 | *url = ReplaceURLHostAndPath(*url, new_host, new_path); |
| 322 | |
[email protected] | 44e8add | 2013-06-13 17:29:15 | [diff] [blame] | 323 | DCHECK(url->is_valid()); |
| 324 | |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 325 | return true; |
| 326 | } |
| 327 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 328 | // Handles rewriting Web UI URLs. |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 329 | bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 330 | // Do not handle special URLs such as "about:foo" |
| 331 | if (!url->host().empty()) { |
| 332 | const GURL chrome_url = AddUberHost(*url); |
| 333 | |
| 334 | // Handle valid "chrome://chrome/foo" URLs so the reverse handler will |
| 335 | // be called. |
| 336 | if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( |
| 337 | browser_context, chrome_url)) |
| 338 | return true; |
| 339 | } |
| 340 | |
[email protected] | 863f70a | 2012-01-27 02:05:50 | [diff] [blame] | 341 | if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( |
| 342 | browser_context, *url)) |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 343 | return false; |
| 344 | |
[email protected] | fe69558d | 2012-03-12 11:34:49 | [diff] [blame] | 345 | #if defined(OS_CHROMEOS) |
| 346 | // Special case : in ChromeOS in Guest mode bookmarks and history are |
| 347 | // disabled for security reasons. New tab page explains the reasons, so |
| 348 | // we redirect user to new tab page. |
| 349 | if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { |
| 350 | if (url->SchemeIs(chrome::kChromeUIScheme) && |
| 351 | (url->DomainIs(chrome::kChromeUIBookmarksHost) || |
| 352 | url->DomainIs(chrome::kChromeUIHistoryHost))) { |
| 353 | // Rewrite with new tab URL |
| 354 | *url = GURL(chrome::kChromeUINewTabURL); |
| 355 | } |
| 356 | } |
| 357 | #endif |
| 358 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 359 | // Special case the new tab page. In older versions of Chrome, the new tab |
| 360 | // page was hosted at chrome-internal:<blah>. This might be in people's saved |
| 361 | // sessions or bookmarks, so we say any URL with that scheme triggers the new |
| 362 | // tab page. |
| 363 | if (url->SchemeIs(chrome::kChromeInternalScheme)) { |
| 364 | // Rewrite it with the proper new tab URL. |
| 365 | *url = GURL(chrome::kChromeUINewTabURL); |
| 366 | } |
| 367 | |
| 368 | return true; |
| 369 | } |
| 370 | |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 371 | // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to |
| 372 | // "chrome://foo/". |
| 373 | bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) { |
| 374 | if (!url->is_valid() || !url->SchemeIs(chrome::kChromeUIScheme)) |
| 375 | return false; |
| 376 | |
| 377 | return RemoveUberHost(url); |
| 378 | } |
| 379 | |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 380 | // Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions |
| 381 | // below. Extension, and isolated apps require different privileges to be |
| 382 | // granted to their RenderProcessHosts. This classification allows us to make |
| 383 | // sure URLs are served by hosts with the right set of privileges. |
| 384 | enum RenderProcessHostPrivilege { |
| 385 | PRIV_NORMAL, |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 386 | PRIV_HOSTED, |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 387 | PRIV_ISOLATED, |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 388 | PRIV_EXTENSION, |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 389 | }; |
| 390 | |
| 391 | RenderProcessHostPrivilege GetPrivilegeRequiredByUrl( |
| 392 | const GURL& url, |
| 393 | ExtensionService* service) { |
| 394 | // Default to a normal renderer cause it is lower privileged. This should only |
| 395 | // occur if the URL on a site instance is either malformed, or uninitialized. |
| 396 | // If it is malformed, then there is no need for better privileges anyways. |
| 397 | // If it is uninitialized, but eventually settles on being an a scheme other |
| 398 | // than normal webrenderer, the navigation logic will correct us out of band |
| 399 | // anyways. |
| 400 | if (!url.is_valid()) |
| 401 | return PRIV_NORMAL; |
| 402 | |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 403 | if (url.SchemeIs(extensions::kExtensionScheme)) { |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 404 | const Extension* extension = |
| 405 | service->extensions()->GetByID(url.host()); |
[email protected] | 561e33d5 | 2013-04-03 06:58:43 | [diff] [blame] | 406 | if (extension && |
| 407 | extensions::AppIsolationInfo::HasIsolatedStorage(extension)) |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 408 | return PRIV_ISOLATED; |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 409 | if (extension && extension->is_hosted_app()) |
| 410 | return PRIV_HOSTED; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 411 | |
| 412 | return PRIV_EXTENSION; |
| 413 | } |
| 414 | |
| 415 | return PRIV_NORMAL; |
| 416 | } |
| 417 | |
| 418 | RenderProcessHostPrivilege GetProcessPrivilege( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 419 | content::RenderProcessHost* process_host, |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 420 | extensions::ProcessMap* process_map, |
| 421 | ExtensionService* service) { |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 422 | std::set<std::string> extension_ids = |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 423 | process_map->GetExtensionsInProcess(process_host->GetID()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 424 | if (extension_ids.empty()) |
[email protected] | 676f6ab | 2011-10-19 20:23:21 | [diff] [blame] | 425 | return PRIV_NORMAL; |
| 426 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 427 | for (std::set<std::string>::iterator iter = extension_ids.begin(); |
| 428 | iter != extension_ids.end(); ++iter) { |
| 429 | const Extension* extension = service->GetExtensionById(*iter, false); |
[email protected] | 561e33d5 | 2013-04-03 06:58:43 | [diff] [blame] | 430 | if (extension && |
| 431 | extensions::AppIsolationInfo::HasIsolatedStorage(extension)) |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 432 | return PRIV_ISOLATED; |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 433 | if (extension && extension->is_hosted_app()) |
| 434 | return PRIV_HOSTED; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 435 | } |
| 436 | |
[email protected] | 676f6ab | 2011-10-19 20:23:21 | [diff] [blame] | 437 | return PRIV_EXTENSION; |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 438 | } |
| 439 | |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 440 | bool CertMatchesFilter(const net::X509Certificate& cert, |
| 441 | const base::DictionaryValue& filter) { |
| 442 | // TODO(markusheintz): This is the minimal required filter implementation. |
| 443 | // Implement a better matcher. |
| 444 | |
| 445 | // An empty filter matches any client certificate since no requirements are |
| 446 | // specified at all. |
| 447 | if (filter.empty()) |
| 448 | return true; |
| 449 | |
| 450 | std::string common_name; |
| 451 | if (filter.GetString("ISSUER.CN", &common_name) && |
| 452 | (cert.issuer().common_name == common_name)) { |
| 453 | return true; |
| 454 | } |
| 455 | return false; |
| 456 | } |
| 457 | |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 458 | // Fills |map| with the per-script font prefs under path |map_name|. |
| 459 | void FillFontFamilyMap(const PrefService* prefs, |
| 460 | const char* map_name, |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 461 | webkit_glue::ScriptFontFamilyMap* map) { |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 462 | for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
| 463 | const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
| 464 | std::string pref_name = base::StringPrintf("%s.%s", map_name, script); |
| 465 | std::string font_family = prefs->GetString(pref_name.c_str()); |
[email protected] | d047106 | 2012-10-26 09:00:23 | [diff] [blame] | 466 | if (!font_family.empty()) |
| 467 | (*map)[script] = UTF8ToUTF16(font_family); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 468 | } |
| 469 | } |
| 470 | |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 471 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 472 | int GetCrashSignalFD(const CommandLine& command_line) { |
| 473 | if (command_line.HasSwitch(switches::kExtensionProcess)) { |
| 474 | ExtensionCrashHandlerHostLinux* crash_handler = |
| 475 | ExtensionCrashHandlerHostLinux::GetInstance(); |
| 476 | return crash_handler->GetDeathSignalSocket(); |
| 477 | } |
| 478 | |
| 479 | std::string process_type = |
| 480 | command_line.GetSwitchValueASCII(switches::kProcessType); |
| 481 | |
| 482 | if (process_type == switches::kRendererProcess) |
| 483 | return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 484 | |
| 485 | if (process_type == switches::kPluginProcess) |
| 486 | return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 487 | |
| 488 | if (process_type == switches::kPpapiPluginProcess) |
| 489 | return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 490 | |
| 491 | if (process_type == switches::kGpuProcess) |
| 492 | return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 493 | |
| 494 | return -1; |
| 495 | } |
| 496 | #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 497 | |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 498 | #if !defined(OS_CHROMEOS) |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 499 | GURL GetEffectiveURLForSignin(const GURL& url) { |
| 500 | CHECK(SigninManager::IsWebBasedSigninFlowURL(url)); |
| 501 | |
| 502 | GURL effective_url(SigninManager::kChromeSigninEffectiveSite); |
[email protected] | fab8bbed4 | 2013-03-07 01:13:03 | [diff] [blame] | 503 | // Copy the path because the argument to SetPathStr must outlive |
| 504 | // the Replacements object. |
| 505 | const std::string path_copy(url.path()); |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 506 | GURL::Replacements replacements; |
[email protected] | fab8bbed4 | 2013-03-07 01:13:03 | [diff] [blame] | 507 | replacements.SetPathStr(path_copy); |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 508 | effective_url = effective_url.ReplaceComponents(replacements); |
| 509 | return effective_url; |
| 510 | } |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 511 | #endif |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 512 | |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 513 | void SetApplicationLocaleOnIOThread(const std::string& locale) { |
| 514 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 515 | g_io_thread_application_locale.Get() = locale; |
| 516 | } |
| 517 | |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 518 | } // namespace |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 519 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 520 | namespace chrome { |
| 521 | |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 522 | ChromeContentBrowserClient::ChromeContentBrowserClient() { |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 523 | #if defined(ENABLE_PLUGINS) |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 524 | for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| 525 | allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 526 | #endif |
[email protected] | 1deace2 | 2013-05-22 06:14:46 | [diff] [blame] | 527 | |
| 528 | permissions_policy_delegate_.reset( |
| 529 | new extensions::BrowserPermissionsPolicyDelegate()); |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | ChromeContentBrowserClient::~ChromeContentBrowserClient() { |
| 533 | } |
| 534 | |
[email protected] | bca1838 | 2012-06-25 19:15:23 | [diff] [blame] | 535 | // static |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 536 | void ChromeContentBrowserClient::RegisterProfilePrefs( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 537 | user_prefs::PrefRegistrySyncable* registry) { |
| 538 | registry->RegisterBooleanPref( |
| 539 | prefs::kDisable3DAPIs, |
| 540 | false, |
| 541 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 542 | registry->RegisterBooleanPref( |
| 543 | prefs::kEnableHyperlinkAuditing, |
| 544 | true, |
| 545 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 546 | registry->RegisterBooleanPref( |
| 547 | prefs::kEnableMemoryInfo, |
| 548 | false, |
| 549 | user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
[email protected] | bca1838 | 2012-06-25 19:15:23 | [diff] [blame] | 550 | } |
| 551 | |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 552 | // static |
| 553 | void ChromeContentBrowserClient::SetApplicationLocale( |
| 554 | const std::string& locale) { |
| 555 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 556 | |
| 557 | // This object is guaranteed to outlive all threads so we don't have to |
| 558 | // worry about the lack of refcounting and can just post as Unretained. |
| 559 | // |
| 560 | // The common case is that this function is called early in Chrome startup |
| 561 | // before any threads are created (it will also be called later if the user |
| 562 | // changes the pref). In this case, there will be no threads created and |
| 563 | // posting will fail. When there are no threads, we can just set the string |
| 564 | // without worrying about threadsafety. |
| 565 | if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 566 | base::Bind(&SetApplicationLocaleOnIOThread, locale))) { |
| 567 | g_io_thread_application_locale.Get() = locale; |
| 568 | } |
| 569 | } |
| 570 | |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 571 | content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( |
| 572 | const content::MainFunctionParams& parameters) { |
| 573 | ChromeBrowserMainParts* main_parts; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 574 | // Construct the Main browser parts based on the OS type. |
| 575 | #if defined(OS_WIN) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 576 | main_parts = new ChromeBrowserMainPartsWin(parameters); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 577 | #elif defined(OS_MACOSX) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 578 | main_parts = new ChromeBrowserMainPartsMac(parameters); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 579 | #elif defined(OS_CHROMEOS) |
[email protected] | 2c624d0 | 2012-11-15 19:37:22 | [diff] [blame] | 580 | main_parts = new chromeos::ChromeBrowserMainPartsChromeos(parameters); |
[email protected] | 81ce2c4 | 2012-03-24 01:43:26 | [diff] [blame] | 581 | #elif defined(OS_LINUX) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 582 | main_parts = new ChromeBrowserMainPartsLinux(parameters); |
[email protected] | 6e677a34 | 2012-02-11 01:21:14 | [diff] [blame] | 583 | #elif defined(OS_ANDROID) |
[email protected] | 81054f81 | 2012-08-30 00:47:09 | [diff] [blame] | 584 | main_parts = new ChromeBrowserMainPartsAndroid(parameters); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 585 | #elif defined(OS_POSIX) |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 586 | main_parts = new ChromeBrowserMainPartsPosix(parameters); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 587 | #else |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 588 | NOTREACHED(); |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 589 | main_parts = new ChromeBrowserMainParts(parameters); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 590 | #endif |
| 591 | |
[email protected] | 7e75e4a | 2013-05-17 17:20:03 | [diff] [blame] | 592 | chrome::AddProfilesExtraParts(main_parts); |
| 593 | |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 594 | // Construct additional browser parts. Stages are called in the order in |
| 595 | // which they are added. |
[email protected] | a13283cc | 2012-04-05 00:21:22 | [diff] [blame] | 596 | #if defined(TOOLKIT_GTK) |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 597 | main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk()); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 598 | #endif |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 599 | |
| 600 | #if defined(TOOLKIT_VIEWS) |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 601 | main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 602 | #endif |
| 603 | |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 604 | #if defined(USE_ASH) |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 605 | main_parts->AddParts(new ChromeBrowserMainExtraPartsAsh()); |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 606 | #endif |
| 607 | |
[email protected] | e050ef14 | 2012-03-21 01:04:24 | [diff] [blame] | 608 | #if defined(USE_AURA) |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 609 | main_parts->AddParts(new ChromeBrowserMainExtraPartsAura()); |
| 610 | #endif |
| 611 | |
| 612 | #if defined(USE_X11) |
| 613 | main_parts->AddParts(new ChromeBrowserMainExtraPartsX11()); |
[email protected] | e050ef14 | 2012-03-21 01:04:24 | [diff] [blame] | 614 | #endif |
| 615 | |
[email protected] | 95132f5 | 2013-04-12 02:19:04 | [diff] [blame] | 616 | chrome::AddMetricsExtraParts(main_parts); |
| 617 | |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 618 | return main_parts; |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 619 | } |
| 620 | |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 621 | std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 622 | content::BrowserContext* browser_context, |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 623 | const GURL& site) { |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 624 | std::string partition_id; |
| 625 | |
| 626 | // The partition ID for webview guest processes is the string value of its |
| 627 | // SiteInstance URL - "chrome-guest://app_id/persist?partition". |
| 628 | if (site.SchemeIs(chrome::kGuestScheme)) |
| 629 | partition_id = site.spec(); |
| 630 | |
[email protected] | 056efdc | 2013-04-06 00:14:53 | [diff] [blame] | 631 | DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 632 | return partition_id; |
| 633 | } |
| 634 | |
| 635 | bool ChromeContentBrowserClient::IsValidStoragePartitionId( |
| 636 | content::BrowserContext* browser_context, |
| 637 | const std::string& partition_id) { |
| 638 | // The default ID is empty and is always valid. |
| 639 | if (partition_id.empty()) |
| 640 | return true; |
| 641 | |
| 642 | return GURL(partition_id).is_valid(); |
| 643 | } |
| 644 | |
| 645 | void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( |
| 646 | content::BrowserContext* browser_context, |
| 647 | const GURL& site, |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 648 | bool can_be_default, |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 649 | std::string* partition_domain, |
| 650 | std::string* partition_name, |
| 651 | bool* in_memory) { |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 652 | // Default to the browser-wide storage partition and override based on |site| |
| 653 | // below. |
| 654 | partition_domain->clear(); |
| 655 | partition_name->clear(); |
| 656 | *in_memory = false; |
| 657 | |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 658 | // For the webview tag, we create special guest processes, which host the |
| 659 | // tag content separately from the main application that embeds the tag. |
| 660 | // A webview tag can specify both the partition name and whether the storage |
| 661 | // for that partition should be persisted. Each tag gets a SiteInstance with |
| 662 | // a specially formatted URL, based on the application it is hosted by and |
| 663 | // the partition requested by it. The format for that URL is: |
| 664 | // chrome-guest://partition_domain/persist?partition_name |
| 665 | if (site.SchemeIs(chrome::kGuestScheme)) { |
| 666 | // Since guest URLs are only used for packaged apps, there must be an app |
| 667 | // id in the URL. |
| 668 | CHECK(site.has_host()); |
| 669 | *partition_domain = site.host(); |
| 670 | // Since persistence is optional, the path must either be empty or the |
| 671 | // literal string. |
| 672 | *in_memory = (site.path() != "/persist"); |
| 673 | // The partition name is user supplied value, which we have encoded when the |
| 674 | // URL was created, so it needs to be decoded. |
| 675 | *partition_name = net::UnescapeURLComponent(site.query(), |
| 676 | net::UnescapeRule::NORMAL); |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 677 | } else if (site.SchemeIs(extensions::kExtensionScheme)) { |
| 678 | // If |can_be_default| is false, the caller is stating that the |site| |
| 679 | // should be parsed as if it had isolated storage. In particular it is |
| 680 | // important to NOT check ExtensionService for the is_storage_isolated() |
| 681 | // attribute because this code path is run during Extension uninstall |
| 682 | // to do cleanup after the Extension has already been unloaded from the |
| 683 | // ExtensionService. |
| 684 | bool is_isolated = !can_be_default; |
| 685 | if (can_be_default) { |
| 686 | const Extension* extension = NULL; |
| 687 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 688 | ExtensionService* extension_service = |
| 689 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 690 | if (extension_service) { |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 691 | extension = |
| 692 | extension_service->extensions()->GetExtensionOrAppByURL(site); |
[email protected] | 561e33d5 | 2013-04-03 06:58:43 | [diff] [blame] | 693 | if (extension && |
| 694 | extensions::AppIsolationInfo::HasIsolatedStorage(extension)) { |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 695 | is_isolated = true; |
| 696 | } |
| 697 | } |
| 698 | } |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 699 | |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 700 | if (is_isolated) { |
| 701 | CHECK(site.has_host()); |
| 702 | // For extensions with isolated storage, the the host of the |site| is |
| 703 | // the |partition_domain|. The |in_memory| and |partition_name| are only |
| 704 | // used in guest schemes so they are cleared here. |
| 705 | *partition_domain = site.host(); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 706 | *in_memory = false; |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 707 | partition_name->clear(); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 708 | } |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 709 | } |
| 710 | |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 711 | // Assert that if |can_be_default| is false, the code above must have found a |
| 712 | // non-default partition. If this fails, the caller has a serious logic |
| 713 | // error about which StoragePartition they expect to be in and it is not |
| 714 | // safe to continue. |
| 715 | CHECK(can_be_default || !partition_domain->empty()); |
[email protected] | d7c7c98a | 2012-07-12 21:27:44 | [diff] [blame] | 716 | } |
| 717 | |
[email protected] | 38b098f | 2012-03-14 21:11:57 | [diff] [blame] | 718 | content::WebContentsViewDelegate* |
| 719 | ChromeContentBrowserClient::GetWebContentsViewDelegate( |
| 720 | content::WebContents* web_contents) { |
[email protected] | d3322029 | 2012-07-04 01:41:27 | [diff] [blame] | 721 | return chrome::CreateWebContentsViewDelegate(web_contents); |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 722 | } |
| 723 | |
[email protected] | 2466568 | 2013-02-25 20:59:38 | [diff] [blame] | 724 | // Check if the extension activity log is enabled for the profile. |
| 725 | static bool IsExtensionActivityLogEnabledForProfile(Profile* profile) { |
[email protected] | 770d6a8 | 2013-06-09 13:08:33 | [diff] [blame] | 726 | // crbug.com/247908 - This should be IsLogEnabled except for an issue |
| 727 | // in chrome_frame_net_tests |
| 728 | return extensions::ActivityLog::IsLogEnabledOnAnyProfile(); |
[email protected] | 2466568 | 2013-02-25 20:59:38 | [diff] [blame] | 729 | } |
| 730 | |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 731 | void ChromeContentBrowserClient::GuestWebContentsCreated( |
| 732 | WebContents* guest_web_contents, |
| 733 | WebContents* opener_web_contents, |
[email protected] | 4c0e827 | 2013-07-03 23:39:22 | [diff] [blame] | 734 | content::BrowserPluginGuestDelegate** guest_delegate, |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 735 | scoped_ptr<base::DictionaryValue> extra_params) { |
| 736 | if (opener_web_contents) { |
| 737 | GuestView* guest = GuestView::FromWebContents(opener_web_contents); |
| 738 | if (!guest) { |
| 739 | NOTREACHED(); |
| 740 | return; |
| 741 | } |
| 742 | |
| 743 | switch (guest->GetViewType()) { |
| 744 | case GuestView::WEBVIEW: { |
[email protected] | 4c0e827 | 2013-07-03 23:39:22 | [diff] [blame] | 745 | *guest_delegate = new WebViewGuest(guest_web_contents); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 746 | break; |
| 747 | } |
| 748 | case GuestView::ADVIEW: { |
[email protected] | 4c0e827 | 2013-07-03 23:39:22 | [diff] [blame] | 749 | *guest_delegate = new AdViewGuest(guest_web_contents); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 750 | break; |
| 751 | } |
| 752 | default: |
| 753 | NOTREACHED(); |
| 754 | break; |
| 755 | } |
| 756 | return; |
| 757 | } |
| 758 | |
| 759 | if (!extra_params) { |
| 760 | NOTREACHED(); |
| 761 | return; |
| 762 | } |
| 763 | std::string api_type; |
| 764 | extra_params->GetString(guestview::kAttributeApi, &api_type); |
| 765 | |
| 766 | if (api_type == "adview") { |
[email protected] | 4c0e827 | 2013-07-03 23:39:22 | [diff] [blame] | 767 | *guest_delegate = new AdViewGuest(guest_web_contents); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 768 | } else if (api_type == "webview") { |
[email protected] | 4c0e827 | 2013-07-03 23:39:22 | [diff] [blame] | 769 | *guest_delegate = new WebViewGuest(guest_web_contents); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 770 | } else { |
| 771 | NOTREACHED(); |
| 772 | } |
| 773 | } |
| 774 | |
[email protected] | 44295a1 | 2013-06-05 08:45:46 | [diff] [blame] | 775 | void ChromeContentBrowserClient::GuestWebContentsAttached( |
| 776 | WebContents* guest_web_contents, |
| 777 | WebContents* embedder_web_contents, |
[email protected] | 5715566a | 2013-06-25 00:04:53 | [diff] [blame] | 778 | int browser_plugin_instance_id, |
| 779 | const base::DictionaryValue& extra_params) { |
[email protected] | 44703cc7 | 2013-01-24 04:56:06 | [diff] [blame] | 780 | Profile* profile = Profile::FromBrowserContext( |
| 781 | embedder_web_contents->GetBrowserContext()); |
| 782 | ExtensionService* service = |
| 783 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 784 | if (!service) { |
| 785 | NOTREACHED(); |
[email protected] | 44703cc7 | 2013-01-24 04:56:06 | [diff] [blame] | 786 | return; |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 787 | } |
[email protected] | 44703cc7 | 2013-01-24 04:56:06 | [diff] [blame] | 788 | const GURL& url = embedder_web_contents->GetSiteInstance()->GetSiteURL(); |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 789 | const Extension* extension = |
| 790 | service->extensions()->GetExtensionOrAppByURL(url); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 791 | if (!extension) { |
[email protected] | 1869937 | 2013-06-25 20:42:55 | [diff] [blame] | 792 | NOTREACHED(); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 793 | return; |
[email protected] | 1869937 | 2013-06-25 20:42:55 | [diff] [blame] | 794 | } |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 795 | |
| 796 | GuestView* guest = GuestView::FromWebContents(guest_web_contents); |
| 797 | if (!guest) { |
| 798 | NOTREACHED(); |
| 799 | return; |
| 800 | } |
| 801 | guest->Attach(embedder_web_contents, |
| 802 | extension->id(), |
| 803 | browser_plugin_instance_id, |
| 804 | extra_params); |
[email protected] | 44703cc7 | 2013-01-24 04:56:06 | [diff] [blame] | 805 | } |
| 806 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 807 | void ChromeContentBrowserClient::RenderProcessHostCreated( |
| 808 | content::RenderProcessHost* host) { |
| 809 | int id = host->GetID(); |
| 810 | Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
[email protected] | 4353551 | 2013-02-20 20:41:41 | [diff] [blame] | 811 | net::URLRequestContextGetter* context = |
| 812 | profile->GetRequestContextForRenderProcess(id); |
| 813 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 814 | host->GetChannel()->AddFilter(new ChromeRenderMessageFilter( |
[email protected] | 4353551 | 2013-02-20 20:41:41 | [diff] [blame] | 815 | id, profile, context)); |
[email protected] | ebd7196 | 2012-12-20 02:56:55 | [diff] [blame] | 816 | #if defined(ENABLE_PLUGINS) |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 817 | host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile)); |
[email protected] | ebd7196 | 2012-12-20 02:56:55 | [diff] [blame] | 818 | #endif |
[email protected] | 658677f | 2012-06-09 06:04:02 | [diff] [blame] | 819 | #if defined(ENABLE_PRINTING) |
[email protected] | 0045b0f4 | 2012-07-26 11:52:08 | [diff] [blame] | 820 | host->GetChannel()->AddFilter(new PrintingMessageFilter(id, profile)); |
[email protected] | 058e573 | 2012-03-01 22:48:03 | [diff] [blame] | 821 | #endif |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 822 | host->GetChannel()->AddFilter( |
[email protected] | c47cfd6 | 2011-04-29 21:27:02 | [diff] [blame] | 823 | new SearchProviderInstallStateMessageFilter(id, profile)); |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 824 | host->GetChannel()->AddFilter(new SpellCheckMessageFilter(id)); |
[email protected] | 7ceb9901 | 2011-12-21 08:05:56 | [diff] [blame] | 825 | #if defined(OS_MACOSX) |
[email protected] | 628cad4d | 2013-04-13 00:36:21 | [diff] [blame] | 826 | host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac(id)); |
[email protected] | 7ceb9901 | 2011-12-21 08:05:56 | [diff] [blame] | 827 | #endif |
[email protected] | 4353551 | 2013-02-20 20:41:41 | [diff] [blame] | 828 | host->GetChannel()->AddFilter(new ChromeNetBenchmarkingMessageFilter( |
| 829 | id, profile, context)); |
[email protected] | 2736c03 | 2012-05-11 18:06:07 | [diff] [blame] | 830 | host->GetChannel()->AddFilter( |
| 831 | new prerender::PrerenderMessageFilter(id, profile)); |
[email protected] | 1352ca9 | 2013-04-30 02:30:27 | [diff] [blame] | 832 | host->GetChannel()->AddFilter(new ValidationMessageMessageFilter(id)); |
[email protected] | 7a06d28 | 2013-05-03 04:39:33 | [diff] [blame] | 833 | host->GetChannel()->AddFilter(new TtsMessageFilter(id, profile)); |
[email protected] | 6ef98b5a | 2013-05-31 23:58:31 | [diff] [blame] | 834 | #if defined(ENABLE_WEBRTC) |
| 835 | host->GetChannel()->AddFilter(new WebRtcLoggingHandlerHost()); |
| 836 | #endif |
[email protected] | 01e5975 | 2013-06-18 00:17:35 | [diff] [blame] | 837 | #if !defined(DISABLE_NACL) |
[email protected] | 14230ca | 2013-06-26 23:33:03 | [diff] [blame] | 838 | ExtensionInfoMap* extension_info_map = |
| 839 | extensions::ExtensionSystem::Get(profile)->info_map(); |
| 840 | host->GetChannel()->AddFilter(new NaClHostMessageFilter( |
| 841 | id, profile->IsOffTheRecord(), |
| 842 | profile->GetPath(), extension_info_map, |
| 843 | context)); |
[email protected] | 01e5975 | 2013-06-18 00:17:35 | [diff] [blame] | 844 | #endif |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 845 | |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 846 | host->Send(new ChromeViewMsg_SetIsIncognitoProcess( |
| 847 | profile->IsOffTheRecord())); |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 848 | |
[email protected] | 2466568 | 2013-02-25 20:59:38 | [diff] [blame] | 849 | host->Send(new ChromeViewMsg_SetExtensionActivityLogEnabled( |
| 850 | IsExtensionActivityLogEnabledForProfile(profile))); |
| 851 | |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 852 | SendExtensionWebRequestStatusToHost(host); |
[email protected] | edece21 | 2011-11-16 11:56:56 | [diff] [blame] | 853 | |
| 854 | RendererContentSettingRules rules; |
| 855 | GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules); |
| 856 | host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 857 | } |
| 858 | |
[email protected] | 95c9555 | 2013-05-03 04:21:22 | [diff] [blame] | 859 | GURL ChromeContentBrowserClient::GetPossiblyPrivilegedURL( |
| 860 | content::BrowserContext* browser_context, |
| 861 | const GURL& url, |
| 862 | bool is_renderer_initiated, |
| 863 | content::SiteInstance* current_instance) { |
| 864 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 865 | if (!profile) |
| 866 | return url; |
| 867 | |
| 868 | // Only return the privileged instant URL if we are entering from a browser- |
| 869 | // initiated navigation or if we are already in the instant process. |
| 870 | bool is_instant_process = false; |
| 871 | int process_id = current_instance->GetProcess()->GetID(); |
| 872 | InstantService* instant_service = |
| 873 | InstantServiceFactory::GetForProfile(profile); |
| 874 | if (instant_service) |
| 875 | is_instant_process = instant_service->IsInstantProcess(process_id); |
| 876 | |
| 877 | DCHECK_EQ(is_instant_process, |
| 878 | chrome::IsPrivilegedURLForInstant(current_instance->GetSiteURL())); |
| 879 | if (!is_renderer_initiated || is_instant_process) { |
| 880 | // If the input |url| should be assigned to the Instant renderer, make its |
| 881 | // privileged URL distinct from other URLs on the search provider's domain. |
| 882 | if (chrome::ShouldAssignURLToInstantRenderer(url, profile)) |
| 883 | return chrome::GetPrivilegedURLForInstant(url, profile); |
| 884 | } |
| 885 | |
| 886 | return url; |
| 887 | } |
| 888 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 889 | GURL ChromeContentBrowserClient::GetEffectiveURL( |
| 890 | content::BrowserContext* browser_context, const GURL& url) { |
| 891 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 892 | if (!profile) |
| 893 | return url; |
| 894 | |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 895 | #if !defined(OS_CHROMEOS) |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 896 | // If the input |url| should be assigned to the Signin renderer, make its |
| 897 | // effective URL distinct from other URLs on the signin service's domain. |
| 898 | // Note that the signin renderer will be allowed to sign the user in to |
| 899 | // Chrome. |
| 900 | if (SigninManager::IsWebBasedSigninFlowURL(url)) |
| 901 | return GetEffectiveURLForSignin(url); |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 902 | #endif |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 903 | |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 904 | // If the input |url| is part of an installed app, the effective URL is an |
| 905 | // extension URL with the ID of that extension as the host. This has the |
| 906 | // effect of grouping apps together in a common SiteInstance. |
| 907 | ExtensionService* extension_service = |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 908 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 909 | if (!extension_service) |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 910 | return url; |
| 911 | |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 912 | const Extension* extension = extension_service->extensions()-> |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 913 | GetHostedAppByURL(url); |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 914 | if (!extension) |
| 915 | return url; |
| 916 | |
[email protected] | 15877ca | 2011-11-18 22:40:52 | [diff] [blame] | 917 | // Bookmark apps do not use the hosted app process model, and should be |
| 918 | // treated as normal URLs. |
| 919 | if (extension->from_bookmark()) |
| 920 | return url; |
| 921 | |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 922 | // If the URL is part of an extension's web extent, convert it to an |
| 923 | // extension URL. |
| 924 | return extension->GetResourceURL(url.path()); |
| 925 | } |
| 926 | |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 927 | bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 928 | content::BrowserContext* browser_context, const GURL& effective_url) { |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 929 | // Non-extension, non-Instant URLs should generally use |
| 930 | // process-per-site-instance. Because we expect to use the effective URL, |
| 931 | // URLs for hosted apps (apart from bookmark apps) should have an extension |
| 932 | // scheme by now. |
| 933 | |
| 934 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 935 | if (!profile) |
| 936 | return false; |
| 937 | |
[email protected] | df113a1 | 2013-07-24 04:56:08 | [diff] [blame] | 938 | if (chrome::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 939 | return true; |
| 940 | |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 941 | #if !defined(OS_CHROMEOS) |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 942 | if (SigninManager::IsWebBasedSigninFlowURL(effective_url)) |
| 943 | return true; |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 944 | #endif |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 945 | |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 946 | if (!effective_url.SchemeIs(extensions::kExtensionScheme)) |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 947 | return false; |
| 948 | |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 949 | ExtensionService* extension_service = |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 950 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 951 | if (!extension_service) |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 952 | return false; |
| 953 | |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 954 | const Extension* extension = |
| 955 | extension_service->extensions()->GetExtensionOrAppByURL(effective_url); |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 956 | if (!extension) |
| 957 | return false; |
| 958 | |
| 959 | // 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] | 960 | // permission, or that does not allow JavaScript access to the background |
| 961 | // page, we want to give each instance its own process to improve |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 962 | // responsiveness. |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 963 | if (extension->GetType() == Manifest::TYPE_HOSTED_APP) { |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 964 | if (!extension->HasAPIPermission(APIPermission::kBackground) || |
[email protected] | 9367eabc | 2013-03-01 01:29:29 | [diff] [blame] | 965 | !extensions::BackgroundInfo::AllowJSAccess(extension)) { |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 966 | return false; |
| 967 | } |
| 968 | } |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 969 | |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 970 | // Hosted apps that have script access to their background page must use |
| 971 | // process per site, since all instances can make synchronous calls to the |
| 972 | // background window. Other extensions should use process per site as well. |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 973 | return true; |
| 974 | } |
| 975 | |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 976 | // These are treated as WebUI schemes but do not get WebUI bindings. |
[email protected] | 8f89dd41 | 2013-04-17 02:35:41 | [diff] [blame] | 977 | void ChromeContentBrowserClient::GetAdditionalWebUISchemes( |
| 978 | std::vector<std::string>* additional_schemes) { |
| 979 | additional_schemes->push_back(chrome::kChromeSearchScheme); |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 980 | } |
| 981 | |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 982 | net::URLRequestContextGetter* |
| 983 | ChromeContentBrowserClient::CreateRequestContext( |
| 984 | content::BrowserContext* browser_context, |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 985 | content::ProtocolHandlerMap* protocol_handlers) { |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 986 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 987 | return profile->CreateRequestContext(protocol_handlers); |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | net::URLRequestContextGetter* |
| 991 | ChromeContentBrowserClient::CreateRequestContextForStoragePartition( |
| 992 | content::BrowserContext* browser_context, |
[email protected] | 152ea30 | 2013-02-11 04:08:40 | [diff] [blame] | 993 | const base::FilePath& partition_path, |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 994 | bool in_memory, |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 995 | content::ProtocolHandlerMap* protocol_handlers) { |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 996 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 997 | return profile->CreateRequestContextForStoragePartition( |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 998 | partition_path, in_memory, protocol_handlers); |
[email protected] | 6bd3007 | 2013-02-08 18:17:11 | [diff] [blame] | 999 | } |
| 1000 | |
[email protected] | 46fb944 | 2011-12-09 17:57:47 | [diff] [blame] | 1001 | bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { |
| 1002 | return ProfileIOData::IsHandledURL(url); |
| 1003 | } |
| 1004 | |
[email protected] | c4365fa4 | 2013-05-14 01:08:24 | [diff] [blame] | 1005 | bool ChromeContentBrowserClient::CanCommitURL( |
| 1006 | content::RenderProcessHost* process_host, |
| 1007 | const GURL& url) { |
| 1008 | // We need to let most extension URLs commit in any process, since this can |
| 1009 | // be allowed due to web_accessible_resources. Most hosted app URLs may also |
| 1010 | // load in any process (e.g., in an iframe). However, the Chrome Web Store |
| 1011 | // cannot be loaded in iframes and should never be requested outside its |
| 1012 | // process. |
| 1013 | Profile* profile = |
| 1014 | Profile::FromBrowserContext(process_host->GetBrowserContext()); |
| 1015 | ExtensionService* service = |
| 1016 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 1017 | if (!service) |
| 1018 | return true; |
| 1019 | const Extension* new_extension = |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 1020 | service->extensions()->GetExtensionOrAppByURL(url); |
[email protected] | c4365fa4 | 2013-05-14 01:08:24 | [diff] [blame] | 1021 | if (new_extension && |
| 1022 | new_extension->is_hosted_app() && |
| 1023 | new_extension->id() == extension_misc::kWebStoreAppId && |
| 1024 | !service->process_map()->Contains(new_extension->id(), |
| 1025 | process_host->GetID())) { |
| 1026 | return false; |
| 1027 | } |
| 1028 | |
| 1029 | return true; |
| 1030 | } |
| 1031 | |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1032 | bool ChromeContentBrowserClient::IsSuitableHost( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1033 | content::RenderProcessHost* process_host, |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1034 | const GURL& site_url) { |
| 1035 | Profile* profile = |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1036 | Profile::FromBrowserContext(process_host->GetBrowserContext()); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1037 | // This may be NULL during tests. In that case, just assume any site can |
| 1038 | // share any host. |
| 1039 | if (!profile) |
| 1040 | return true; |
| 1041 | |
[email protected] | d43f99fe | 2013-04-03 00:20:14 | [diff] [blame] | 1042 | // Instant URLs should only be in the instant process and instant process |
| 1043 | // should only have Instant URLs. |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1044 | InstantService* instant_service = |
| 1045 | InstantServiceFactory::GetForProfile(profile); |
[email protected] | d43f99fe | 2013-04-03 00:20:14 | [diff] [blame] | 1046 | if (instant_service) { |
| 1047 | bool is_instant_process = instant_service->IsInstantProcess( |
| 1048 | process_host->GetID()); |
| 1049 | bool should_be_in_instant_process = |
| 1050 | chrome::ShouldAssignURLToInstantRenderer(site_url, profile); |
| 1051 | if (is_instant_process || should_be_in_instant_process) |
| 1052 | return is_instant_process && should_be_in_instant_process; |
| 1053 | } |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1054 | |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 1055 | #if !defined(OS_CHROMEOS) |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 1056 | SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); |
| 1057 | if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID())) |
| 1058 | return SigninManager::IsWebBasedSigninFlowURL(site_url); |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 1059 | #endif |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 1060 | |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 1061 | ExtensionService* service = |
| 1062 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1063 | extensions::ProcessMap* process_map = service->process_map(); |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1064 | |
[email protected] | ffa9760 | 2011-11-17 17:55:52 | [diff] [blame] | 1065 | // Don't allow the Task Manager to share a process with anything else. |
| 1066 | // Otherwise it can affect the renderers it is observing. |
| 1067 | // Note: we could create another RenderProcessHostPrivilege bucket for |
| 1068 | // this to allow multiple chrome://tasks instances to share, but that's |
| 1069 | // a very unlikely case without serious consequences. |
| 1070 | if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin()) |
| 1071 | return false; |
| 1072 | |
[email protected] | 8d3132f6 | 2011-10-12 07:13:42 | [diff] [blame] | 1073 | // These may be NULL during tests. In that case, just assume any site can |
| 1074 | // share any host. |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1075 | if (!service || !process_map) |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1076 | return true; |
| 1077 | |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 1078 | // Otherwise, just make sure the process privilege matches the privilege |
| 1079 | // required by the site. |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 1080 | RenderProcessHostPrivilege privilege_required = |
| 1081 | GetPrivilegeRequiredByUrl(site_url, service); |
[email protected] | eec0b33c | 2011-12-05 22:09:45 | [diff] [blame] | 1082 | return GetProcessPrivilege(process_host, process_map, service) == |
| 1083 | privilege_required; |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1084 | } |
| 1085 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1086 | // This function is trying to limit the amount of processes used by extensions |
| 1087 | // with background pages. It uses a globally set percentage of processes to |
| 1088 | // run such extensions and if the limit is exceeded, it returns true, to |
| 1089 | // indicate to the content module to group extensions together. |
| 1090 | bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( |
| 1091 | content::BrowserContext* browser_context, const GURL& url) { |
| 1092 | // It has to be a valid URL for us to check for an extension. |
| 1093 | if (!url.is_valid()) |
| 1094 | return false; |
| 1095 | |
| 1096 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | 2ee3da9d6 | 2012-12-05 20:17:19 | [diff] [blame] | 1097 | ExtensionService* service = !profile ? NULL : |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 1098 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1099 | if (!service) |
| 1100 | return false; |
| 1101 | |
| 1102 | // We have to have a valid extension with background page to proceed. |
| 1103 | const Extension* extension = |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 1104 | service->extensions()->GetExtensionOrAppByURL(url); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1105 | if (!extension) |
| 1106 | return false; |
[email protected] | 9367eabc | 2013-03-01 01:29:29 | [diff] [blame] | 1107 | if (!extensions::BackgroundInfo::HasBackgroundPage(extension)) |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1108 | return false; |
| 1109 | |
| 1110 | std::set<int> process_ids; |
| 1111 | size_t max_process_count = |
| 1112 | content::RenderProcessHost::GetMaxRendererProcessCount(); |
| 1113 | |
| 1114 | // Go through all profiles to ensure we have total count of extension |
| 1115 | // processes containing background pages, otherwise one profile can |
| 1116 | // starve the other. |
| 1117 | std::vector<Profile*> profiles = g_browser_process->profile_manager()-> |
| 1118 | GetLoadedProfiles(); |
| 1119 | for (size_t i = 0; i < profiles.size(); ++i) { |
[email protected] | be93bba0 | 2012-10-24 16:44:03 | [diff] [blame] | 1120 | ExtensionProcessManager* epm = |
| 1121 | extensions::ExtensionSystem::Get(profiles[i])->process_manager(); |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 1122 | for (ExtensionProcessManager::const_iterator iter = |
| 1123 | epm->background_hosts().begin(); |
| 1124 | iter != epm->background_hosts().end(); ++iter) { |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 1125 | const extensions::ExtensionHost* host = *iter; |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 1126 | process_ids.insert(host->render_process_host()->GetID()); |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | if (process_ids.size() > |
| 1131 | (max_process_count * chrome::kMaxShareOfExtensionProcesses)) { |
| 1132 | return true; |
| 1133 | } |
| 1134 | |
| 1135 | return false; |
| 1136 | } |
| 1137 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1138 | void ChromeContentBrowserClient::SiteInstanceGotProcess( |
| 1139 | SiteInstance* site_instance) { |
| 1140 | CHECK(site_instance->HasProcess()); |
| 1141 | |
| 1142 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 72daaa9 | 2012-01-18 13:39:02 | [diff] [blame] | 1143 | site_instance->GetBrowserContext()); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1144 | if (!profile) |
| 1145 | return; |
| 1146 | |
| 1147 | // Remember the ID of the Instant process to signal the renderer process |
| 1148 | // on startup in |AppendExtraCommandLineSwitches| below. |
[email protected] | 165fe42 | 2013-03-27 06:34:03 | [diff] [blame] | 1149 | if (chrome::ShouldAssignURLToInstantRenderer( |
[email protected] | 7c60f504 | 2013-02-14 03:39:32 | [diff] [blame] | 1150 | site_instance->GetSiteURL(), profile)) { |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1151 | InstantService* instant_service = |
| 1152 | InstantServiceFactory::GetForProfile(profile); |
| 1153 | if (instant_service) |
| 1154 | instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); |
| 1155 | } |
| 1156 | |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 1157 | #if !defined(OS_CHROMEOS) |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 1158 | // We only expect there to be one signin process as we use process-per-site |
| 1159 | // for signin URLs. The signin process will be cleared from SigninManager |
| 1160 | // when the renderer is destroyed. |
| 1161 | if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { |
| 1162 | SigninManager* signin_manager = |
| 1163 | SigninManagerFactory::GetForProfile(profile); |
| 1164 | if (signin_manager) |
| 1165 | signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID()); |
[email protected] | 1deace2 | 2013-05-22 06:14:46 | [diff] [blame] | 1166 | BrowserThread::PostTask( |
| 1167 | BrowserThread::IO, FROM_HERE, |
| 1168 | base::Bind(&ExtensionInfoMap::SetSigninProcess, |
| 1169 | extensions::ExtensionSystem::Get(profile)->info_map(), |
| 1170 | site_instance->GetProcess()->GetID())); |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 1171 | } |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 1172 | #endif |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 1173 | |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 1174 | ExtensionService* service = |
| 1175 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1176 | if (!service) |
| 1177 | return; |
| 1178 | |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 1179 | const Extension* extension = service->extensions()->GetExtensionOrAppByURL( |
| 1180 | site_instance->GetSiteURL()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1181 | if (!extension) |
| 1182 | return; |
| 1183 | |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 1184 | service->process_map()->Insert(extension->id(), |
| 1185 | site_instance->GetProcess()->GetID(), |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 1186 | site_instance->GetId()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1187 | BrowserThread::PostTask( |
| 1188 | BrowserThread::IO, FROM_HERE, |
| 1189 | base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 1190 | extensions::ExtensionSystem::Get(profile)->info_map(), |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1191 | extension->id(), |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 1192 | site_instance->GetProcess()->GetID(), |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 1193 | site_instance->GetId())); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | void ChromeContentBrowserClient::SiteInstanceDeleting( |
| 1197 | SiteInstance* site_instance) { |
| 1198 | if (!site_instance->HasProcess()) |
| 1199 | return; |
| 1200 | |
| 1201 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 72daaa9 | 2012-01-18 13:39:02 | [diff] [blame] | 1202 | site_instance->GetBrowserContext()); |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 1203 | ExtensionService* service = |
| 1204 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1205 | if (!service) |
| 1206 | return; |
| 1207 | |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 1208 | const Extension* extension = service->extensions()->GetExtensionOrAppByURL( |
| 1209 | site_instance->GetSiteURL()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1210 | if (!extension) |
| 1211 | return; |
| 1212 | |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 1213 | service->process_map()->Remove(extension->id(), |
| 1214 | site_instance->GetProcess()->GetID(), |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 1215 | site_instance->GetId()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1216 | BrowserThread::PostTask( |
| 1217 | BrowserThread::IO, FROM_HERE, |
| 1218 | base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 1219 | extensions::ExtensionSystem::Get(profile)->info_map(), |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1220 | extension->id(), |
[email protected] | 6bc04fd8 | 2011-12-04 02:29:35 | [diff] [blame] | 1221 | site_instance->GetProcess()->GetID(), |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 1222 | site_instance->GetId())); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1223 | } |
| 1224 | |
[email protected] | f0576397 | 2012-06-06 18:17:26 | [diff] [blame] | 1225 | bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( |
[email protected] | e9841fbd | 2013-02-22 23:12:14 | [diff] [blame] | 1226 | SiteInstance* site_instance, |
[email protected] | e3daf3c | 2011-10-05 21:17:08 | [diff] [blame] | 1227 | const GURL& current_url, |
| 1228 | const GURL& new_url) { |
[email protected] | f0576397 | 2012-06-06 18:17:26 | [diff] [blame] | 1229 | if (current_url.is_empty()) { |
| 1230 | // Always choose a new process when navigating to extension URLs. The |
| 1231 | // process grouping logic will combine all of a given extension's pages |
| 1232 | // into the same process. |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 1233 | if (new_url.SchemeIs(extensions::kExtensionScheme)) |
[email protected] | f0576397 | 2012-06-06 18:17:26 | [diff] [blame] | 1234 | return true; |
[email protected] | e3daf3c | 2011-10-05 21:17:08 | [diff] [blame] | 1235 | |
[email protected] | f0576397 | 2012-06-06 18:17:26 | [diff] [blame] | 1236 | return false; |
| 1237 | } |
| 1238 | |
| 1239 | // Also, we must switch if one is an extension and the other is not the exact |
| 1240 | // same extension. |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 1241 | if (current_url.SchemeIs(extensions::kExtensionScheme) || |
| 1242 | new_url.SchemeIs(extensions::kExtensionScheme)) { |
[email protected] | f0576397 | 2012-06-06 18:17:26 | [diff] [blame] | 1243 | if (current_url.GetOrigin() != new_url.GetOrigin()) |
| 1244 | return true; |
| 1245 | } |
| 1246 | |
[email protected] | e9841fbd | 2013-02-22 23:12:14 | [diff] [blame] | 1247 | // The checks below only matter if we can retrieve which extensions are |
| 1248 | // installed. |
| 1249 | Profile* profile = |
| 1250 | Profile::FromBrowserContext(site_instance->GetBrowserContext()); |
| 1251 | ExtensionService* service = |
| 1252 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 1253 | if (!service) |
| 1254 | return false; |
| 1255 | |
| 1256 | // We must swap if the URL is for an extension and we are not using an |
| 1257 | // extension process. |
| 1258 | const Extension* new_extension = |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 1259 | service->extensions()->GetExtensionOrAppByURL(new_url); |
[email protected] | e9841fbd | 2013-02-22 23:12:14 | [diff] [blame] | 1260 | // Ignore all hosted apps except the Chrome Web Store, since they do not |
| 1261 | // require their own BrowsingInstance (e.g., postMessage is ok). |
| 1262 | if (new_extension && |
| 1263 | new_extension->is_hosted_app() && |
| 1264 | new_extension->id() != extension_misc::kWebStoreAppId) |
| 1265 | new_extension = NULL; |
| 1266 | if (new_extension && |
| 1267 | site_instance->HasProcess() && |
| 1268 | !service->process_map()->Contains(new_extension->id(), |
| 1269 | site_instance->GetProcess()->GetID())) |
| 1270 | return true; |
| 1271 | |
[email protected] | f0576397 | 2012-06-06 18:17:26 | [diff] [blame] | 1272 | return false; |
[email protected] | e3daf3c | 2011-10-05 21:17:08 | [diff] [blame] | 1273 | } |
| 1274 | |
[email protected] | 395045c | 2012-05-22 15:04:38 | [diff] [blame] | 1275 | bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( |
| 1276 | content::ResourceContext* resource_context, const GURL& current_url, |
| 1277 | const GURL& new_url) { |
| 1278 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 1279 | return extensions::CrossesExtensionProcessBoundary( |
| 1280 | io_data->GetExtensionInfoMap()->extensions(), |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 1281 | current_url, new_url, false); |
[email protected] | 395045c | 2012-05-22 15:04:38 | [diff] [blame] | 1282 | } |
| 1283 | |
[email protected] | 3d83199 | 2013-07-04 01:13:29 | [diff] [blame] | 1284 | bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { |
| 1285 | return !url.SchemeIs(chrome::kChromeNativeScheme); |
| 1286 | } |
| 1287 | |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 1288 | std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
| 1289 | const std::string& alias_name) { |
| 1290 | return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); |
| 1291 | } |
| 1292 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1293 | void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
| 1294 | CommandLine* command_line, int child_process_id) { |
[email protected] | 9742508 | 2013-07-16 03:10:07 | [diff] [blame] | 1295 | #if defined(OS_MACOSX) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1296 | if (IsCrashReporterEnabled()) { |
| 1297 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 1298 | child_process_logging::GetClientId()); |
| 1299 | } |
[email protected] | 9742508 | 2013-07-16 03:10:07 | [diff] [blame] | 1300 | #elif defined(OS_POSIX) |
| 1301 | if (IsCrashReporterEnabled()) { |
| 1302 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
| 1303 | child_process_logging::GetClientId() + "," + base::GetLinuxDistro()); |
| 1304 | } |
| 1305 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1306 | #endif // OS_MACOSX |
| 1307 | |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 1308 | if (logging::DialogsAreSuppressed()) |
| 1309 | command_line->AppendSwitch(switches::kNoErrorDialogs); |
| 1310 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1311 | std::string process_type = |
| 1312 | command_line->GetSwitchValueASCII(switches::kProcessType); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 1313 | const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | 9206f2a0 | 2013-03-20 01:10:32 | [diff] [blame] | 1314 | |
| 1315 | if (browser_command_line.HasSwitch(switches::kChromeFrame)) |
| 1316 | command_line->AppendSwitch(switches::kChromeFrame); |
| 1317 | |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 1318 | if (process_type == switches::kRendererProcess) { |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 1319 | base::FilePath user_data_dir = |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1320 | browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
| 1321 | if (!user_data_dir.empty()) |
| 1322 | command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 1323 | #if defined(OS_CHROMEOS) |
| 1324 | const std::string& login_profile = |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 1325 | browser_command_line.GetSwitchValueASCII( |
| 1326 | chromeos::switches::kLoginProfile); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1327 | if (!login_profile.empty()) |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 1328 | command_line->AppendSwitchASCII( |
| 1329 | chromeos::switches::kLoginProfile, login_profile); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1330 | #endif |
| 1331 | |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1332 | content::RenderProcessHost* process = |
| 1333 | content::RenderProcessHost::FromID(child_process_id); |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 1334 | if (process) { |
| 1335 | Profile* profile = Profile::FromBrowserContext( |
| 1336 | process->GetBrowserContext()); |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 1337 | ExtensionService* extension_service = |
| 1338 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 1339 | if (extension_service) { |
| 1340 | extensions::ProcessMap* process_map = extension_service->process_map(); |
[email protected] | c8598d4 | 2012-09-25 21:17:00 | [diff] [blame] | 1341 | if (process_map && process_map->Contains(process->GetID())) |
| 1342 | command_line->AppendSwitch(switches::kExtensionProcess); |
| 1343 | } |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1344 | |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 1345 | PrefService* prefs = profile->GetPrefs(); |
| 1346 | // Currently this pref is only registered if applied via a policy. |
| 1347 | if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && |
| 1348 | prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
| 1349 | // Turn this policy into a command line switch. |
| 1350 | command_line->AppendSwitch(switches::kDisable3DAPIs); |
| 1351 | } |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 1352 | |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 1353 | // Disable client-side phishing detection in the renderer if it is |
| 1354 | // disabled in the Profile preferences or the browser process. |
| 1355 | if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) || |
| 1356 | !g_browser_process->safe_browsing_detection_service()) { |
| 1357 | command_line->AppendSwitch( |
| 1358 | switches::kDisableClientSidePhishingDetection); |
| 1359 | } |
[email protected] | 0045b0f4 | 2012-07-26 11:52:08 | [diff] [blame] | 1360 | |
| 1361 | if (!prefs->GetBoolean(prefs::kPrintPreviewDisabled)) |
[email protected] | 47c7ec8 | 2012-01-18 03:29:21 | [diff] [blame] | 1362 | command_line->AppendSwitch(switches::kRendererPrintPreview); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1363 | |
| 1364 | InstantService* instant_service = |
| 1365 | InstantServiceFactory::GetForProfile(profile); |
| 1366 | if (instant_service && |
| 1367 | instant_service->IsInstantProcess(process->GetID())) |
| 1368 | command_line->AppendSwitch(switches::kInstantProcess); |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 1369 | |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 1370 | #if !defined(OS_CHROMEOS) |
[email protected] | 970c63e | 2013-03-07 00:25:30 | [diff] [blame] | 1371 | SigninManager* signin_manager = |
| 1372 | SigninManagerFactory::GetForProfile(profile); |
| 1373 | if (signin_manager && signin_manager->IsSigninProcess(process->GetID())) |
| 1374 | command_line->AppendSwitch(switches::kSigninProcess); |
[email protected] | d5bcd06f | 2013-04-21 08:07:24 | [diff] [blame] | 1375 | #endif |
[email protected] | 47c7ec8 | 2012-01-18 03:29:21 | [diff] [blame] | 1376 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1377 | |
[email protected] | 8755298 | 2012-11-02 17:21:40 | [diff] [blame] | 1378 | if (content::IsThreadedCompositingEnabled()) |
| 1379 | command_line->AppendSwitch(switches::kEnableThreadedCompositing); |
| 1380 | |
[email protected] | 16dc4245 | 2013-04-09 04:37:19 | [diff] [blame] | 1381 | if (message_center::IsRichNotificationEnabled()) |
| 1382 | command_line->AppendSwitch(switches::kDisableHTMLNotifications); |
[email protected] | 16dc4245 | 2013-04-09 04:37:19 | [diff] [blame] | 1383 | |
[email protected] | 47c7ec8 | 2012-01-18 03:29:21 | [diff] [blame] | 1384 | // Please keep this in alphabetical order. |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1385 | static const char* const kSwitchNames[] = { |
[email protected] | 000f3ad | 2013-05-16 02:19:17 | [diff] [blame] | 1386 | autofill::switches::kDisableInteractiveAutocomplete, |
[email protected] | e217c563 | 2013-04-12 19:11:48 | [diff] [blame] | 1387 | autofill::switches::kEnableExperimentalFormFilling, |
[email protected] | 000f3ad | 2013-05-16 02:19:17 | [diff] [blame] | 1388 | autofill::switches::kEnableInteractiveAutocomplete, |
[email protected] | 49d9b14 | 2013-07-19 08:50:27 | [diff] [blame] | 1389 | extensions::switches::kAllowLegacyExtensionManifests, |
| 1390 | extensions::switches::kAllowScriptingGallery, |
| 1391 | extensions::switches::kExtensionsOnChromeURLs, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1392 | switches::kAllowHTTPBackgroundPage, |
[email protected] | 9d45049 | 2013-06-13 23:08:37 | [diff] [blame] | 1393 | // TODO(victorhsieh): remove the following flag once we move PPAPI FileIO |
| 1394 | // to browser. |
| 1395 | switches::kAllowNaClFileHandleAPI, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1396 | switches::kAppsCheckoutURL, |
| 1397 | switches::kAppsGalleryURL, |
[email protected] | be9d9c8 | 2011-07-13 04:17:31 | [diff] [blame] | 1398 | switches::kCloudPrintServiceURL, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1399 | switches::kDebugPrint, |
[email protected] | 382fb0d | 2012-02-25 00:19:50 | [diff] [blame] | 1400 | switches::kDisableBundledPpapiFlash, |
[email protected] | e9dfe22 | 2012-05-11 22:05:53 | [diff] [blame] | 1401 | switches::kDisableExtensionsResourceWhitelist, |
[email protected] | b0553c7e | 2012-09-19 21:36:11 | [diff] [blame] | 1402 | switches::kDisableScriptedPrintThrottling, |
[email protected] | e9cddd5 | 2013-03-23 17:37:53 | [diff] [blame] | 1403 | switches::kEnableAdview, |
| 1404 | switches::kEnableAdviewSrcAttribute, |
[email protected] | 1f4da9e | 2013-06-27 05:23:44 | [diff] [blame] | 1405 | switches::kEnableAppWindowControls, |
[email protected] | 47c7ec8 | 2012-01-18 03:29:21 | [diff] [blame] | 1406 | switches::kEnableBenchmarking, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1407 | switches::kEnableExperimentalExtensionApis, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1408 | switches::kEnableIPCFuzzing, |
| 1409 | switches::kEnableNaCl, |
[email protected] | ce304ce | 2013-02-22 21:54:45 | [diff] [blame] | 1410 | switches::kEnableNetBenchmarking, |
[email protected] | bcbe765 | 2012-02-22 00:08:48 | [diff] [blame] | 1411 | switches::kEnablePasswordGeneration, |
[email protected] | 284b03c | 2012-08-13 17:55:05 | [diff] [blame] | 1412 | switches::kEnablePnacl, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1413 | switches::kEnableWatchdog, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1414 | switches::kMemoryProfiling, |
| 1415 | switches::kMessageLoopHistogrammer, |
[email protected] | f45c5f3 | 2012-04-18 19:26:37 | [diff] [blame] | 1416 | switches::kNoJsRandomness, |
[email protected] | f45c5f3 | 2012-04-18 19:26:37 | [diff] [blame] | 1417 | switches::kPlaybackMode, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1418 | switches::kPpapiFlashArgs, |
| 1419 | switches::kPpapiFlashInProcess, |
| 1420 | switches::kPpapiFlashPath, |
| 1421 | switches::kPpapiFlashVersion, |
| 1422 | switches::kProfilingAtStart, |
| 1423 | switches::kProfilingFile, |
| 1424 | switches::kProfilingFlush, |
[email protected] | f45c5f3 | 2012-04-18 19:26:37 | [diff] [blame] | 1425 | switches::kRecordMode, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1426 | switches::kSilentDumpOnDCHECK, |
[email protected] | 199def2 | 2013-02-21 17:52:29 | [diff] [blame] | 1427 | switches::kSpdyProxyAuthOrigin, |
[email protected] | a446534d | 2012-02-09 00:07:38 | [diff] [blame] | 1428 | switches::kWhitelistedExtensionID, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1429 | }; |
| 1430 | |
| 1431 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 1432 | arraysize(kSwitchNames)); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 1433 | } else if (process_type == switches::kUtilityProcess) { |
[email protected] | a446534d | 2012-02-09 00:07:38 | [diff] [blame] | 1434 | static const char* const kSwitchNames[] = { |
[email protected] | 49d9b14 | 2013-07-19 08:50:27 | [diff] [blame] | 1435 | extensions::switches::kExtensionsOnChromeURLs, |
[email protected] | eb653f8 | 2012-05-24 02:31:35 | [diff] [blame] | 1436 | switches::kAllowHTTPBackgroundPage, |
[email protected] | a446534d | 2012-02-09 00:07:38 | [diff] [blame] | 1437 | switches::kEnableExperimentalExtensionApis, |
| 1438 | switches::kWhitelistedExtensionID, |
| 1439 | }; |
| 1440 | |
| 1441 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 1442 | arraysize(kSwitchNames)); |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1443 | } else if (process_type == switches::kPluginProcess) { |
| 1444 | static const char* const kSwitchNames[] = { |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 1445 | #if defined(OS_CHROMEOS) |
| 1446 | chromeos::switches::kLoginProfile, |
| 1447 | #endif |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1448 | switches::kMemoryProfiling, |
| 1449 | switches::kSilentDumpOnDCHECK, |
| 1450 | switches::kUserDataDir, |
| 1451 | }; |
| 1452 | |
| 1453 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 1454 | arraysize(kSwitchNames)); |
| 1455 | } else if (process_type == switches::kZygoteProcess) { |
| 1456 | static const char* const kSwitchNames[] = { |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1457 | switches::kUserDataDir, // Make logs go to the right file. |
| 1458 | // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox. |
[email protected] | 382fb0d | 2012-02-25 00:19:50 | [diff] [blame] | 1459 | switches::kDisableBundledPpapiFlash, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 1460 | switches::kPpapiFlashInProcess, |
| 1461 | switches::kPpapiFlashPath, |
| 1462 | switches::kPpapiFlashVersion, |
| 1463 | }; |
| 1464 | |
| 1465 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 1466 | arraysize(kSwitchNames)); |
[email protected] | d56ecf92 | 2012-02-15 16:03:11 | [diff] [blame] | 1467 | } else if (process_type == switches::kGpuProcess) { |
[email protected] | f01b88a | 2013-02-27 22:04:00 | [diff] [blame] | 1468 | base::FilePath user_data_dir = |
| 1469 | browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
| 1470 | if (!user_data_dir.empty()) |
| 1471 | command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
[email protected] | d56ecf92 | 2012-02-15 16:03:11 | [diff] [blame] | 1472 | // If --ignore-gpu-blacklist is passed in, don't send in crash reports |
| 1473 | // because GPU is expected to be unreliable. |
| 1474 | if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) && |
| 1475 | !command_line->HasSwitch(switches::kDisableBreakpad)) |
| 1476 | command_line->AppendSwitch(switches::kDisableBreakpad); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1477 | } |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 1478 | |
| 1479 | // The command line switch kEnableBenchmarking needs to be specified along |
| 1480 | // with the kEnableStatsTable switch to ensure that the stats table global |
| 1481 | // is initialized correctly. |
| 1482 | if (command_line->HasSwitch(switches::kEnableBenchmarking)) |
| 1483 | DCHECK(command_line->HasSwitch(switches::kEnableStatsTable)); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1484 | } |
| 1485 | |
| 1486 | std::string ChromeContentBrowserClient::GetApplicationLocale() { |
[email protected] | e9a32a5 | 2012-06-14 23:32:43 | [diff] [blame] | 1487 | if (BrowserThread::CurrentlyOn(BrowserThread::IO)) |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 1488 | return g_io_thread_application_locale.Get(); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 1489 | return g_browser_process->GetApplicationLocale(); |
| 1490 | } |
| 1491 | |
[email protected] | 597a867b | 2011-11-18 18:31:20 | [diff] [blame] | 1492 | std::string ChromeContentBrowserClient::GetAcceptLangs( |
| 1493 | content::BrowserContext* context) { |
| 1494 | Profile* profile = Profile::FromBrowserContext(context); |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1495 | return profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
[email protected] | b5cca98 | 2011-05-26 04:42:08 | [diff] [blame] | 1496 | } |
| 1497 | |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 1498 | gfx::ImageSkia* ChromeContentBrowserClient::GetDefaultFavicon() { |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 1499 | ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 1500 | return rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 1501 | } |
| 1502 | |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 1503 | bool ChromeContentBrowserClient::AllowAppCache( |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 1504 | const GURL& manifest_url, |
[email protected] | 0a60884 | 2011-09-08 10:55:19 | [diff] [blame] | 1505 | const GURL& first_party, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1506 | content::ResourceContext* context) { |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 1507 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1508 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 1509 | return io_data->GetCookieSettings()-> |
| 1510 | IsSettingCookieAllowed(manifest_url, first_party); |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 1511 | } |
| 1512 | |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 1513 | bool ChromeContentBrowserClient::AllowGetCookie( |
| 1514 | const GURL& url, |
| 1515 | const GURL& first_party, |
| 1516 | const net::CookieList& cookie_list, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1517 | content::ResourceContext* context, |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 1518 | int render_process_id, |
| 1519 | int render_view_id) { |
| 1520 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1521 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 1522 | bool allow = io_data->GetCookieSettings()-> |
| 1523 | IsReadingCookieAllowed(url, first_party); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 1524 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 1525 | BrowserThread::PostTask( |
| 1526 | BrowserThread::UI, FROM_HERE, |
[email protected] | 317c58f0 | 2011-11-09 02:15:03 | [diff] [blame] | 1527 | base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id, |
[email protected] | fd473d1 | 2012-04-05 11:38:43 | [diff] [blame] | 1528 | render_view_id, url, first_party, cookie_list, !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 1529 | return allow; |
| 1530 | } |
| 1531 | |
| 1532 | bool ChromeContentBrowserClient::AllowSetCookie( |
| 1533 | const GURL& url, |
| 1534 | const GURL& first_party, |
| 1535 | const std::string& cookie_line, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1536 | content::ResourceContext* context, |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 1537 | int render_process_id, |
| 1538 | int render_view_id, |
| 1539 | net::CookieOptions* options) { |
| 1540 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1541 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 1542 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 1543 | bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party); |
| 1544 | |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 1545 | BrowserThread::PostTask( |
| 1546 | BrowserThread::UI, FROM_HERE, |
[email protected] | 317c58f0 | 2011-11-09 02:15:03 | [diff] [blame] | 1547 | base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id, |
[email protected] | fd473d1 | 2012-04-05 11:38:43 | [diff] [blame] | 1548 | render_view_id, url, first_party, cookie_line, *options, |
| 1549 | !allow)); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 1550 | return allow; |
| 1551 | } |
| 1552 | |
[email protected] | d5a1916 | 2011-06-30 18:51:54 | [diff] [blame] | 1553 | bool ChromeContentBrowserClient::AllowSaveLocalState( |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1554 | content::ResourceContext* context) { |
[email protected] | d5a1916 | 2011-06-30 18:51:54 | [diff] [blame] | 1555 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1556 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | bf510ed | 2012-06-05 08:31:43 | [diff] [blame] | 1557 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 1558 | ContentSetting setting = cookie_settings->GetDefaultCookieSetting(NULL); |
[email protected] | 1848cdc | 2012-02-17 10:48:26 | [diff] [blame] | 1559 | |
[email protected] | bf510ed | 2012-06-05 08:31:43 | [diff] [blame] | 1560 | // TODO(bauerb): Should we also disallow local state if the default is BLOCK? |
| 1561 | // Could we even support per-origin settings? |
| 1562 | return setting != CONTENT_SETTING_SESSION_ONLY; |
[email protected] | d5a1916 | 2011-06-30 18:51:54 | [diff] [blame] | 1563 | } |
| 1564 | |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1565 | bool ChromeContentBrowserClient::AllowWorkerDatabase( |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1566 | const GURL& url, |
| 1567 | const string16& name, |
| 1568 | const string16& display_name, |
| 1569 | unsigned long estimated_size, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1570 | content::ResourceContext* context, |
[email protected] | 6215105 | 2012-02-01 18:40:48 | [diff] [blame] | 1571 | const std::vector<std::pair<int, int> >& render_views) { |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1572 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1573 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1574 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 1575 | bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
| 1576 | |
[email protected] | 6215105 | 2012-02-01 18:40:48 | [diff] [blame] | 1577 | // Record access to database for potential display in UI. |
| 1578 | std::vector<std::pair<int, int> >::const_iterator i; |
| 1579 | for (i = render_views.begin(); i != render_views.end(); ++i) { |
| 1580 | BrowserThread::PostTask( |
| 1581 | BrowserThread::UI, FROM_HERE, |
| 1582 | base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed, |
| 1583 | i->first, i->second, url, name, display_name, !allow)); |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1584 | } |
| 1585 | |
| 1586 | return allow; |
| 1587 | } |
| 1588 | |
| 1589 | bool ChromeContentBrowserClient::AllowWorkerFileSystem( |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1590 | const GURL& url, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1591 | content::ResourceContext* context, |
[email protected] | 6215105 | 2012-02-01 18:40:48 | [diff] [blame] | 1592 | const std::vector<std::pair<int, int> >& render_views) { |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1593 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1594 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1595 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 1596 | bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
| 1597 | |
[email protected] | 6215105 | 2012-02-01 18:40:48 | [diff] [blame] | 1598 | // Record access to file system for potential display in UI. |
| 1599 | std::vector<std::pair<int, int> >::const_iterator i; |
| 1600 | for (i = render_views.begin(); i != render_views.end(); ++i) { |
| 1601 | BrowserThread::PostTask( |
| 1602 | BrowserThread::UI, FROM_HERE, |
| 1603 | base::Bind(&TabSpecificContentSettings::FileSystemAccessed, |
| 1604 | i->first, i->second, url, !allow)); |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | return allow; |
| 1608 | } |
| 1609 | |
[email protected] | 7c5ff9a | 2012-03-02 07:42:49 | [diff] [blame] | 1610 | bool ChromeContentBrowserClient::AllowWorkerIndexedDB( |
| 1611 | const GURL& url, |
| 1612 | const string16& name, |
| 1613 | content::ResourceContext* context, |
| 1614 | const std::vector<std::pair<int, int> >& render_views) { |
| 1615 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1616 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 1617 | CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
| 1618 | bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
| 1619 | |
| 1620 | // Record access to IndexedDB for potential display in UI. |
| 1621 | std::vector<std::pair<int, int> >::const_iterator i; |
| 1622 | for (i = render_views.begin(); i != render_views.end(); ++i) { |
| 1623 | BrowserThread::PostTask( |
| 1624 | BrowserThread::UI, FROM_HERE, |
| 1625 | base::Bind(&TabSpecificContentSettings::IndexedDBAccessed, |
| 1626 | i->first, i->second, url, name, !allow)); |
| 1627 | } |
| 1628 | |
| 1629 | return allow; |
| 1630 | } |
| 1631 | |
[email protected] | 6133f92 | 2011-07-01 21:34:34 | [diff] [blame] | 1632 | net::URLRequestContext* |
| 1633 | ChromeContentBrowserClient::OverrideRequestContextForURL( |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1634 | const GURL& url, content::ResourceContext* context) { |
[email protected] | 6133f92 | 2011-07-01 21:34:34 | [diff] [blame] | 1635 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 1636 | if (url.SchemeIs(extensions::kExtensionScheme)) { |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1637 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 6133f92 | 2011-07-01 21:34:34 | [diff] [blame] | 1638 | return io_data->extensions_request_context(); |
| 1639 | } |
| 1640 | |
| 1641 | return NULL; |
| 1642 | } |
| 1643 | |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 1644 | QuotaPermissionContext* |
| 1645 | ChromeContentBrowserClient::CreateQuotaPermissionContext() { |
| 1646 | return new ChromeQuotaPermissionContext(); |
| 1647 | } |
| 1648 | |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 1649 | void ChromeContentBrowserClient::AllowCertificateError( |
[email protected] | 4cf611e3 | 2012-02-13 16:06:17 | [diff] [blame] | 1650 | int render_process_id, |
| 1651 | int render_view_id, |
| 1652 | int cert_error, |
| 1653 | const net::SSLInfo& ssl_info, |
| 1654 | const GURL& request_url, |
[email protected] | a2f7688 | 2013-02-25 21:36:02 | [diff] [blame] | 1655 | ResourceType::Type resource_type, |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 1656 | bool overridable, |
[email protected] | d9be4770 | 2012-05-16 03:41:22 | [diff] [blame] | 1657 | bool strict_enforcement, |
[email protected] | 4cf611e3 | 2012-02-13 16:06:17 | [diff] [blame] | 1658 | const base::Callback<void(bool)>& callback, |
[email protected] | 8c965c2 | 2013-05-23 19:28:00 | [diff] [blame] | 1659 | content::CertificateRequestResultType* result) { |
[email protected] | a2f7688 | 2013-02-25 21:36:02 | [diff] [blame] | 1660 | if (resource_type != ResourceType::MAIN_FRAME) { |
| 1661 | // A sub-resource has a certificate error. The user doesn't really |
| 1662 | // have a context for making the right decision, so block the |
| 1663 | // request hard, without an info bar to allow showing the insecure |
| 1664 | // content. |
[email protected] | 8c965c2 | 2013-05-23 19:28:00 | [diff] [blame] | 1665 | *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY; |
[email protected] | a2f7688 | 2013-02-25 21:36:02 | [diff] [blame] | 1666 | return; |
| 1667 | } |
| 1668 | |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 1669 | // If the tab is being prerendered, cancel the prerender and the request. |
[email protected] | 83ff91c | 2012-01-05 20:54:13 | [diff] [blame] | 1670 | WebContents* tab = tab_util::GetWebContentsByID( |
[email protected] | 4cf611e3 | 2012-02-13 16:06:17 | [diff] [blame] | 1671 | render_process_id, render_view_id); |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 1672 | if (!tab) { |
| 1673 | NOTREACHED(); |
| 1674 | return; |
| 1675 | } |
| 1676 | prerender::PrerenderManager* prerender_manager = |
[email protected] | 3085c50 | 2011-10-05 17:50:50 | [diff] [blame] | 1677 | prerender::PrerenderManagerFactory::GetForProfile( |
[email protected] | 627e051 | 2011-12-21 22:55:30 | [diff] [blame] | 1678 | Profile::FromBrowserContext(tab->GetBrowserContext())); |
[email protected] | 3a6ec76 | 2012-10-17 16:01:01 | [diff] [blame] | 1679 | if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab, |
| 1680 | NULL)) { |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 1681 | if (prerender_manager->prerender_tracker()->TryCancel( |
[email protected] | 4cf611e3 | 2012-02-13 16:06:17 | [diff] [blame] | 1682 | render_process_id, render_view_id, |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 1683 | prerender::FINAL_STATUS_SSL_ERROR)) { |
[email protected] | 8c965c2 | 2013-05-23 19:28:00 | [diff] [blame] | 1684 | *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 1685 | return; |
| 1686 | } |
| 1687 | } |
| 1688 | |
[email protected] | 1e87df3 | 2012-09-12 04:53:19 | [diff] [blame] | 1689 | #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
[email protected] | eb0b9dd | 2012-09-19 21:36:23 | [diff] [blame] | 1690 | captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper = |
| 1691 | captive_portal::CaptivePortalTabHelper::FromWebContents(tab); |
| 1692 | if (captive_portal_tab_helper) |
| 1693 | captive_portal_tab_helper->OnSSLCertError(ssl_info); |
[email protected] | 1e87df3 | 2012-09-12 04:53:19 | [diff] [blame] | 1694 | #endif |
| 1695 | |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 1696 | // Otherwise, display an SSL blocking page. |
[email protected] | d9be4770 | 2012-05-16 03:41:22 | [diff] [blame] | 1697 | new SSLBlockingPage(tab, cert_error, ssl_info, request_url, overridable, |
| 1698 | strict_enforcement, callback); |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 1699 | } |
| 1700 | |
[email protected] | c99c442e | 2011-08-24 11:37:30 | [diff] [blame] | 1701 | void ChromeContentBrowserClient::SelectClientCertificate( |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 1702 | int render_process_id, |
| 1703 | int render_view_id, |
[email protected] | 7a593db | 2012-02-13 21:19:40 | [diff] [blame] | 1704 | const net::HttpNetworkSession* network_session, |
| 1705 | net::SSLCertRequestInfo* cert_request_info, |
| 1706 | const base::Callback<void(net::X509Certificate*)>& callback) { |
[email protected] | 83ff91c | 2012-01-05 20:54:13 | [diff] [blame] | 1707 | WebContents* tab = tab_util::GetWebContentsByID( |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 1708 | render_process_id, render_view_id); |
| 1709 | if (!tab) { |
| 1710 | NOTREACHED(); |
| 1711 | return; |
| 1712 | } |
| 1713 | |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 1714 | GURL requesting_url("https://" + cert_request_info->host_and_port); |
| 1715 | DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://" |
| 1716 | << cert_request_info->host_and_port; |
| 1717 | |
[email protected] | 627e051 | 2011-12-21 22:55:30 | [diff] [blame] | 1718 | Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 1719 | scoped_ptr<Value> filter( |
| 1720 | profile->GetHostContentSettingsMap()->GetWebsiteSetting( |
| 1721 | requesting_url, |
| 1722 | requesting_url, |
| 1723 | CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 1724 | std::string(), NULL)); |
| 1725 | |
| 1726 | if (filter.get()) { |
| 1727 | // Try to automatically select a client certificate. |
| 1728 | if (filter->IsType(Value::TYPE_DICTIONARY)) { |
| 1729 | DictionaryValue* filter_dict = |
| 1730 | static_cast<DictionaryValue*>(filter.get()); |
| 1731 | |
| 1732 | const std::vector<scoped_refptr<net::X509Certificate> >& |
| 1733 | all_client_certs = cert_request_info->client_certs; |
| 1734 | for (size_t i = 0; i < all_client_certs.size(); ++i) { |
[email protected] | dc24976f | 2013-06-02 21:15:09 | [diff] [blame] | 1735 | if (CertMatchesFilter(*all_client_certs[i].get(), *filter_dict)) { |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 1736 | // Use the first certificate that is matched by the filter. |
[email protected] | dc24976f | 2013-06-02 21:15:09 | [diff] [blame] | 1737 | callback.Run(all_client_certs[i].get()); |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 1738 | return; |
| 1739 | } |
| 1740 | } |
| 1741 | } else { |
| 1742 | NOTREACHED(); |
| 1743 | } |
| 1744 | } |
| 1745 | |
[email protected] | 11feec32 | 2012-09-18 03:58:52 | [diff] [blame] | 1746 | SSLTabHelper* ssl_tab_helper = SSLTabHelper::FromWebContents(tab); |
| 1747 | if (!ssl_tab_helper) { |
| 1748 | // If there is no SSLTabHelper for the given WebContents then we can't |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 1749 | // show the user a dialog to select a client certificate. So we simply |
[email protected] | 2a349e9 | 2011-12-07 12:00:14 | [diff] [blame] | 1750 | // proceed with no client certificate. |
[email protected] | 7a593db | 2012-02-13 21:19:40 | [diff] [blame] | 1751 | callback.Run(NULL); |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 1752 | return; |
| 1753 | } |
[email protected] | 11feec32 | 2012-09-18 03:58:52 | [diff] [blame] | 1754 | ssl_tab_helper->ShowClientCertificateRequestDialog( |
[email protected] | 7a593db | 2012-02-13 21:19:40 | [diff] [blame] | 1755 | network_session, cert_request_info, callback); |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 1756 | } |
| 1757 | |
[email protected] | 3b45550 | 2012-12-11 18:22:58 | [diff] [blame] | 1758 | void ChromeContentBrowserClient::AddCertificate( |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 1759 | net::URLRequest* request, |
[email protected] | 3b45550 | 2012-12-11 18:22:58 | [diff] [blame] | 1760 | net::CertificateMimeType cert_type, |
| 1761 | const void* cert_data, |
| 1762 | size_t cert_size, |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 1763 | int render_process_id, |
| 1764 | int render_view_id) { |
[email protected] | 3b45550 | 2012-12-11 18:22:58 | [diff] [blame] | 1765 | chrome::SSLAddCertificate(request, cert_type, cert_data, cert_size, |
| 1766 | render_process_id, render_view_id); |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 1767 | } |
| 1768 | |
[email protected] | dc73a7b | 2012-03-25 15:27:18 | [diff] [blame] | 1769 | content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { |
[email protected] | 11158e2d | 2013-02-01 02:31:56 | [diff] [blame] | 1770 | return MediaCaptureDevicesDispatcher::GetInstance(); |
[email protected] | dc73a7b | 2012-03-25 15:27:18 | [diff] [blame] | 1771 | } |
| 1772 | |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1773 | void ChromeContentBrowserClient::RequestDesktopNotificationPermission( |
| 1774 | const GURL& source_origin, |
| 1775 | int callback_context, |
| 1776 | int render_process_id, |
| 1777 | int render_view_id) { |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1778 | #if defined(ENABLE_NOTIFICATIONS) |
[email protected] | d0d9c3ee | 2012-06-19 03:07:02 | [diff] [blame] | 1779 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1780 | WebContents* contents = |
| 1781 | tab_util::GetWebContentsByID(render_process_id, render_view_id); |
| 1782 | if (!contents) { |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1783 | NOTREACHED(); |
| 1784 | return; |
| 1785 | } |
| 1786 | |
[email protected] | d0d9c3ee | 2012-06-19 03:07:02 | [diff] [blame] | 1787 | // Skip showing the infobar if the request comes from an extension, and that |
| 1788 | // extension has the 'notify' permission. (If the extension does not have the |
| 1789 | // permission, the user will still be prompted.) |
| 1790 | Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
[email protected] | c7cd594 | 2013-04-30 03:31:01 | [diff] [blame] | 1791 | ExtensionInfoMap* extension_info_map = |
| 1792 | extensions::ExtensionSystem::Get(profile)->info_map(); |
| 1793 | DesktopNotificationService* notification_service = |
| 1794 | DesktopNotificationServiceFactory::GetForProfile(profile); |
| 1795 | const Extension* extension = NULL; |
| 1796 | if (extension_info_map) { |
| 1797 | ExtensionSet extensions; |
| 1798 | extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( |
| 1799 | source_origin, render_process_id, |
| 1800 | extensions::APIPermission::kNotification, &extensions); |
| 1801 | for (ExtensionSet::const_iterator iter = extensions.begin(); |
| 1802 | iter != extensions.end(); ++iter) { |
| 1803 | if (notification_service->IsExtensionEnabled((*iter)->id())) { |
[email protected] | cadac62 | 2013-06-11 16:46:36 | [diff] [blame] | 1804 | extension = iter->get(); |
[email protected] | c7cd594 | 2013-04-30 03:31:01 | [diff] [blame] | 1805 | break; |
| 1806 | } |
| 1807 | } |
| 1808 | } |
[email protected] | eb4832a | 2012-12-08 01:57:52 | [diff] [blame] | 1809 | RenderViewHost* rvh = |
| 1810 | RenderViewHost::FromID(render_process_id, render_view_id); |
| 1811 | if (IsExtensionWithPermissionOrSuggestInConsole( |
| 1812 | APIPermission::kNotification, extension, rvh)) { |
[email protected] | d0d9c3ee | 2012-06-19 03:07:02 | [diff] [blame] | 1813 | if (rvh) |
| 1814 | rvh->DesktopNotificationPermissionRequestDone(callback_context); |
| 1815 | return; |
| 1816 | } |
| 1817 | |
[email protected] | c7cd594 | 2013-04-30 03:31:01 | [diff] [blame] | 1818 | notification_service->RequestPermission(source_origin, render_process_id, |
[email protected] | d0d9c3ee | 2012-06-19 03:07:02 | [diff] [blame] | 1819 | render_view_id, callback_context, contents); |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1820 | #else |
| 1821 | NOTIMPLEMENTED(); |
| 1822 | #endif |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1823 | } |
| 1824 | |
| 1825 | WebKit::WebNotificationPresenter::Permission |
| 1826 | ChromeContentBrowserClient::CheckDesktopNotificationPermission( |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1827 | const GURL& source_origin, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1828 | content::ResourceContext* context, |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1829 | int render_process_id) { |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1830 | #if defined(ENABLE_NOTIFICATIONS) |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1831 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 5c12979 | 2013-07-10 02:08:48 | [diff] [blame] | 1832 | // Sometimes a notification may be invoked during the shutdown. |
| 1833 | // See http://crbug.com/256638 |
| 1834 | if (browser_shutdown::IsTryingToQuit()) |
| 1835 | return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 1836 | |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1837 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1838 | |
[email protected] | c7cd594 | 2013-04-30 03:31:01 | [diff] [blame] | 1839 | DesktopNotificationService* notification_service = |
| 1840 | io_data->GetNotificationService(); |
| 1841 | if (notification_service) { |
| 1842 | ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap(); |
| 1843 | ExtensionSet extensions; |
| 1844 | extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( |
| 1845 | source_origin, render_process_id, |
| 1846 | extensions::APIPermission::kNotification, &extensions); |
| 1847 | for (ExtensionSet::const_iterator iter = extensions.begin(); |
| 1848 | iter != extensions.end(); ++iter) { |
| 1849 | if (notification_service->IsExtensionEnabled((*iter)->id())) |
| 1850 | return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 1851 | } |
| 1852 | |
| 1853 | return notification_service->HasPermission(source_origin); |
| 1854 | } |
| 1855 | |
| 1856 | return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1857 | #else |
| 1858 | return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 1859 | #endif |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1860 | } |
| 1861 | |
| 1862 | void ChromeContentBrowserClient::ShowDesktopNotification( |
[email protected] | 0ee57e2 | 2011-11-12 01:59:17 | [diff] [blame] | 1863 | const content::ShowDesktopNotificationHostMsgParams& params, |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1864 | int render_process_id, |
| 1865 | int render_view_id, |
| 1866 | bool worker) { |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1867 | #if defined(ENABLE_NOTIFICATIONS) |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1868 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 1869 | render_process_id, render_view_id); |
| 1870 | if (!rvh) { |
| 1871 | NOTREACHED(); |
| 1872 | return; |
| 1873 | } |
| 1874 | |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 1875 | content::RenderProcessHost* process = rvh->GetProcess(); |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1876 | Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1877 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1878 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1879 | service->ShowDesktopNotification( |
| 1880 | params, render_process_id, render_view_id, |
| 1881 | worker ? DesktopNotificationService::WorkerNotification : |
| 1882 | DesktopNotificationService::PageNotification); |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1883 | #else |
| 1884 | NOTIMPLEMENTED(); |
| 1885 | #endif |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1886 | } |
| 1887 | |
| 1888 | void ChromeContentBrowserClient::CancelDesktopNotification( |
| 1889 | int render_process_id, |
| 1890 | int render_view_id, |
| 1891 | int notification_id) { |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1892 | #if defined(ENABLE_NOTIFICATIONS) |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1893 | RenderViewHost* rvh = RenderViewHost::FromID( |
| 1894 | render_process_id, render_view_id); |
| 1895 | if (!rvh) { |
| 1896 | NOTREACHED(); |
| 1897 | return; |
| 1898 | } |
| 1899 | |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 1900 | content::RenderProcessHost* process = rvh->GetProcess(); |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1901 | Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1902 | DesktopNotificationService* service = |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1903 | DesktopNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1904 | service->CancelDesktopNotification( |
| 1905 | render_process_id, render_view_id, notification_id); |
[email protected] | 5fd2e84 | 2012-03-01 00:29:11 | [diff] [blame] | 1906 | #else |
| 1907 | NOTIMPLEMENTED(); |
| 1908 | #endif |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 1909 | } |
| 1910 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1911 | bool ChromeContentBrowserClient::CanCreateWindow( |
[email protected] | 2b751a1 | 2012-03-06 03:00:35 | [diff] [blame] | 1912 | const GURL& opener_url, |
[email protected] | 34eec7ffe3 | 2011-11-02 23:49:02 | [diff] [blame] | 1913 | const GURL& source_origin, |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1914 | WindowContainerType container_type, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1915 | content::ResourceContext* context, |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 1916 | int render_process_id, |
| 1917 | bool* no_javascript_access) { |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1918 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 1919 | |
| 1920 | *no_javascript_access = false; |
| 1921 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1922 | // If the opener is trying to create a background window but doesn't have |
| 1923 | // the appropriate permission, fail the attempt. |
| 1924 | if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1925 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 1926 | ExtensionInfoMap* map = io_data->GetExtensionInfoMap(); |
| 1927 | |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 1928 | if (!map->SecurityOriginHasAPIPermission( |
| 1929 | source_origin, |
| 1930 | render_process_id, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 1931 | APIPermission::kBackground)) { |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 1932 | return false; |
| 1933 | } |
| 1934 | |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 1935 | // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may |
| 1936 | // return a recently installed Extension even if this CanCreateWindow call |
| 1937 | // 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] | 1938 | // because the permission check above would have caused an early return |
| 1939 | // already. We must use the full URL to find hosted apps, though, and not |
| 1940 | // just the origin. |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 1941 | const Extension* extension = |
| 1942 | map->extensions().GetExtensionOrAppByURL(opener_url); |
[email protected] | 9367eabc | 2013-03-01 01:29:29 | [diff] [blame] | 1943 | if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 1944 | *no_javascript_access = true; |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1945 | } |
[email protected] | 056efdc | 2013-04-06 00:14:53 | [diff] [blame] | 1946 | |
| 1947 | // No new browser window (popup or tab) in app mode. |
| 1948 | if (container_type == WINDOW_CONTAINER_TYPE_NORMAL && |
| 1949 | chrome::IsRunningInForcedAppMode()) { |
| 1950 | return false; |
| 1951 | } |
| 1952 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1953 | return true; |
| 1954 | } |
| 1955 | |
| 1956 | std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1957 | const GURL& url, content::ResourceContext* context) { |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1958 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1959 | // Check if it's an extension-created worker, in which case we want to use |
| 1960 | // the name of the extension. |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 1961 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 1962 | const Extension* extension = |
| 1963 | io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); |
| 1964 | return extension ? extension->name() : std::string(); |
| 1965 | } |
| 1966 | |
[email protected] | 9990736 | 2012-01-11 05:41:40 | [diff] [blame] | 1967 | void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { |
| 1968 | return g_browser_process->ResourceDispatcherHostCreated(); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 1969 | } |
| 1970 | |
[email protected] | 7a06d28 | 2013-05-03 04:39:33 | [diff] [blame] | 1971 | // TODO(tommi): Rename from Get to Create. |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 1972 | content::SpeechRecognitionManagerDelegate* |
| 1973 | ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() { |
[email protected] | 855e18b | 2013-07-08 21:02:00 | [diff] [blame] | 1974 | #if defined(ENABLE_INPUT_SPEECH) |
| 1975 | return new speech::ChromeSpeechRecognitionManagerDelegateBubbleUI(); |
[email protected] | a03f2d3 | 2012-03-14 00:26:32 | [diff] [blame] | 1976 | #else |
[email protected] | 855e18b | 2013-07-08 21:02:00 | [diff] [blame] | 1977 | // Platforms who don't implement x-webkit-speech (a.k.a INPUT_SPEECH) just |
| 1978 | // need the base delegate without the bubble UI. |
| 1979 | return new speech::ChromeSpeechRecognitionManagerDelegate(); |
[email protected] | a03f2d3 | 2012-03-14 00:26:32 | [diff] [blame] | 1980 | #endif |
[email protected] | 66cfec6 | 2012-02-24 17:57:51 | [diff] [blame] | 1981 | } |
| 1982 | |
[email protected] | ae6e991 | 2011-07-27 01:18:28 | [diff] [blame] | 1983 | net::NetLog* ChromeContentBrowserClient::GetNetLog() { |
| 1984 | return g_browser_process->net_log(); |
| 1985 | } |
| 1986 | |
[email protected] | 32538d9 | 2011-08-25 00:09:23 | [diff] [blame] | 1987 | AccessTokenStore* ChromeContentBrowserClient::CreateAccessTokenStore() { |
| 1988 | return new ChromeAccessTokenStore(); |
| 1989 | } |
| 1990 | |
[email protected] | dbae6b0 | 2011-06-29 23:51:41 | [diff] [blame] | 1991 | bool ChromeContentBrowserClient::IsFastShutdownPossible() { |
[email protected] | 263ff4f | 2013-01-04 20:23:01 | [diff] [blame] | 1992 | return true; |
[email protected] | dbae6b0 | 2011-06-29 23:51:41 | [diff] [blame] | 1993 | } |
| 1994 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 1995 | void ChromeContentBrowserClient::OverrideWebkitPrefs( |
[email protected] | 2e21fe29 | 2012-03-02 22:52:32 | [diff] [blame] | 1996 | RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) { |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 1997 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 1998 | rvh->GetProcess()->GetBrowserContext()); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 1999 | PrefService* prefs = profile->GetPrefs(); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2000 | |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2001 | FillFontFamilyMap(prefs, prefs::kWebKitStandardFontFamilyMap, |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2002 | &web_prefs->standard_font_family_map); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2003 | FillFontFamilyMap(prefs, prefs::kWebKitFixedFontFamilyMap, |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2004 | &web_prefs->fixed_font_family_map); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2005 | FillFontFamilyMap(prefs, prefs::kWebKitSerifFontFamilyMap, |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2006 | &web_prefs->serif_font_family_map); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2007 | FillFontFamilyMap(prefs, prefs::kWebKitSansSerifFontFamilyMap, |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2008 | &web_prefs->sans_serif_font_family_map); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2009 | FillFontFamilyMap(prefs, prefs::kWebKitCursiveFontFamilyMap, |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2010 | &web_prefs->cursive_font_family_map); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2011 | FillFontFamilyMap(prefs, prefs::kWebKitFantasyFontFamilyMap, |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2012 | &web_prefs->fantasy_font_family_map); |
[email protected] | 85edc23 | 2012-10-05 08:56:03 | [diff] [blame] | 2013 | FillFontFamilyMap(prefs, prefs::kWebKitPictographFontFamilyMap, |
| 2014 | &web_prefs->pictograph_font_family_map); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2015 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2016 | web_prefs->default_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2017 | prefs->GetInteger(prefs::kWebKitDefaultFontSize); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2018 | web_prefs->default_fixed_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2019 | prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2020 | web_prefs->minimum_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2021 | prefs->GetInteger(prefs::kWebKitMinimumFontSize); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2022 | web_prefs->minimum_logical_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2023 | prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2024 | |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2025 | web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2026 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2027 | web_prefs->javascript_can_open_windows_automatically = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2028 | prefs->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2029 | web_prefs->dom_paste_enabled = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2030 | prefs->GetBoolean(prefs::kWebKitDomPasteEnabled); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2031 | web_prefs->shrinks_standalone_images_to_fit = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2032 | prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit); |
| 2033 | const DictionaryValue* inspector_settings = |
| 2034 | prefs->GetDictionary(prefs::kWebKitInspectorSettings); |
| 2035 | if (inspector_settings) { |
[email protected] | c40ef1c | 2013-02-25 18:42:18 | [diff] [blame] | 2036 | for (DictionaryValue::Iterator iter(*inspector_settings); !iter.IsAtEnd(); |
| 2037 | iter.Advance()) { |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2038 | std::string value; |
[email protected] | c40ef1c | 2013-02-25 18:42:18 | [diff] [blame] | 2039 | if (iter.value().GetAsString(&value)) { |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2040 | web_prefs->inspector_settings.push_back( |
[email protected] | c40ef1c | 2013-02-25 18:42:18 | [diff] [blame] | 2041 | std::make_pair(iter.key(), value)); |
| 2042 | } |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2043 | } |
| 2044 | } |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2045 | web_prefs->tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2046 | |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2047 | if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled)) |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2048 | web_prefs->javascript_enabled = false; |
| 2049 | if (!prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled)) |
| 2050 | web_prefs->web_security_enabled = false; |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2051 | if (!prefs->GetBoolean(prefs::kWebKitPluginsEnabled)) |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2052 | web_prefs->plugins_enabled = false; |
| 2053 | if (!prefs->GetBoolean(prefs::kWebKitJavaEnabled)) |
| 2054 | web_prefs->java_enabled = false; |
| 2055 | web_prefs->loads_images_automatically = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2056 | prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2057 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2058 | if (prefs->GetBoolean(prefs::kDisable3DAPIs)) |
| 2059 | web_prefs->experimental_webgl_enabled = false; |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2060 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2061 | web_prefs->memory_info_enabled = |
| 2062 | prefs->GetBoolean(prefs::kEnableMemoryInfo); |
| 2063 | web_prefs->allow_displaying_insecure_content = |
| 2064 | prefs->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent); |
| 2065 | web_prefs->allow_running_insecure_content = |
| 2066 | prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent); |
[email protected] | d3b935f | 2012-10-19 23:14:32 | [diff] [blame] | 2067 | #if defined(OS_ANDROID) |
| 2068 | web_prefs->font_scale_factor = |
| 2069 | static_cast<float>(prefs->GetDouble(prefs::kWebKitFontScaleFactor)); |
| 2070 | web_prefs->force_enable_zoom = |
| 2071 | prefs->GetBoolean(prefs::kWebKitForceEnableZoom); |
[email protected] | 0b60abd | 2013-03-13 16:34:45 | [diff] [blame] | 2072 | #if defined(GOOGLE_TV) |
| 2073 | web_prefs->user_gesture_required_for_media_playback = false; |
| 2074 | #endif |
[email protected] | d3b935f | 2012-10-19 23:14:32 | [diff] [blame] | 2075 | #endif |
[email protected] | 5c91525 | 2013-05-07 13:15:39 | [diff] [blame] | 2076 | |
[email protected] | af4256d5 | 2013-06-04 20:39:07 | [diff] [blame] | 2077 | #if defined(OS_ANDROID) |
| 2078 | web_prefs->password_echo_enabled = |
| 2079 | prefs->GetBoolean(prefs::kWebKitPasswordEchoEnabled); |
| 2080 | #else |
[email protected] | 9d06d88d | 2012-02-23 22:37:08 | [diff] [blame] | 2081 | web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled; |
[email protected] | af4256d5 | 2013-06-04 20:39:07 | [diff] [blame] | 2082 | #endif |
| 2083 | |
[email protected] | 5c91525 | 2013-05-07 13:15:39 | [diff] [blame] | 2084 | #if defined(OS_CHROMEOS) |
| 2085 | // Enable password echo during OOBE when keyboard driven flag is set. |
| 2086 | if (chromeos::UserManager::IsInitialized() && |
| 2087 | !chromeos::UserManager::Get()->IsUserLoggedIn() && |
| 2088 | !chromeos::StartupUtils::IsOobeCompleted()) { |
| 2089 | bool keyboard_driven_oobe = false; |
| 2090 | chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag( |
[email protected] | 0071aed3 | 2013-06-19 13:39:55 | [diff] [blame] | 2091 | chromeos::system::kOemKeyboardDrivenOobeKey, &keyboard_driven_oobe); |
[email protected] | 5c91525 | 2013-05-07 13:15:39 | [diff] [blame] | 2092 | if (keyboard_driven_oobe) |
| 2093 | web_prefs->password_echo_enabled = true; |
| 2094 | } |
| 2095 | #endif |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2096 | |
[email protected] | 46f8e74 | 2013-05-03 18:37:14 | [diff] [blame] | 2097 | #if defined(OS_ANDROID) |
| 2098 | web_prefs->user_style_sheet_enabled = false; |
| 2099 | #else |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2100 | // The user stylesheet watcher may not exist in a testing profile. |
[email protected] | 13169ab | 2012-04-06 07:48:15 | [diff] [blame] | 2101 | UserStyleSheetWatcher* user_style_sheet_watcher = |
[email protected] | cadac62 | 2013-06-11 16:46:36 | [diff] [blame] | 2102 | UserStyleSheetWatcherFactory::GetForProfile(profile).get(); |
[email protected] | 13169ab | 2012-04-06 07:48:15 | [diff] [blame] | 2103 | if (user_style_sheet_watcher) { |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2104 | web_prefs->user_style_sheet_enabled = true; |
| 2105 | web_prefs->user_style_sheet_location = |
[email protected] | 13169ab | 2012-04-06 07:48:15 | [diff] [blame] | 2106 | user_style_sheet_watcher->user_style_sheet(); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2107 | } else { |
| 2108 | web_prefs->user_style_sheet_enabled = false; |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2109 | } |
[email protected] | 46f8e74 | 2013-05-03 18:37:14 | [diff] [blame] | 2110 | #endif |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2111 | |
[email protected] | cfadadd | 2013-04-03 04:43:02 | [diff] [blame] | 2112 | web_prefs->asynchronous_spell_checking_enabled = true; |
| 2113 | web_prefs->unified_textchecker_enabled = true; |
[email protected] | dd5d0fb | 2012-01-18 03:37:57 | [diff] [blame] | 2114 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2115 | web_prefs->uses_universal_detector = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2116 | prefs->GetBoolean(prefs::kWebKitUsesUniversalDetector); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2117 | web_prefs->text_areas_are_resizable = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2118 | prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2119 | web_prefs->hyperlink_auditing_enabled = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2120 | prefs->GetBoolean(prefs::kEnableHyperlinkAuditing); |
| 2121 | |
| 2122 | // Make sure we will set the default_encoding with canonical encoding name. |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2123 | web_prefs->default_encoding = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2124 | CharacterEncoding::GetCanonicalEncodingNameByAliasName( |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2125 | web_prefs->default_encoding); |
| 2126 | if (web_prefs->default_encoding.empty()) { |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 2127 | prefs->ClearPref(prefs::kDefaultCharset); |
| 2128 | web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2129 | } |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2130 | DCHECK(!web_prefs->default_encoding.empty()); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2131 | |
[email protected] | 88ecf66d | 2012-12-11 22:53:47 | [diff] [blame] | 2132 | if (content::IsForceCompositingModeEnabled()) |
| 2133 | web_prefs->force_compositing_mode = true; |
| 2134 | |
[email protected] | 299d7f1 | 2012-05-23 05:31:15 | [diff] [blame] | 2135 | WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
[email protected] | cb2edf2 | 2013-04-01 20:25:23 | [diff] [blame] | 2136 | extensions::ViewType view_type = extensions::GetViewType(web_contents); |
[email protected] | 06bdd2b | 2012-11-30 18:47:13 | [diff] [blame] | 2137 | ExtensionService* service = |
| 2138 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2139 | if (service) { |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 2140 | const GURL& url = rvh->GetSiteInstance()->GetSiteURL(); |
| 2141 | const Extension* extension = service->extensions()->GetByID(url.host()); |
| 2142 | // Ensure that we are only granting extension preferences to URLs with |
| 2143 | // the correct scheme. Without this check, chrome-guest:// schemes used by |
| 2144 | // webview tags as well as hosts that happen to match the id of an |
| 2145 | // installed extension would get the wrong preferences. |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 2146 | if (url.SchemeIs(extensions::kExtensionScheme)) { |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 2147 | extension_webkit_preferences::SetPreferences( |
| 2148 | extension, view_type, web_prefs); |
| 2149 | } |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2150 | } |
| 2151 | |
[email protected] | cb2edf2 | 2013-04-01 20:25:23 | [diff] [blame] | 2152 | if (view_type == extensions::VIEW_TYPE_NOTIFICATION) { |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2153 | web_prefs->allow_scripts_to_close_windows = true; |
[email protected] | cb2edf2 | 2013-04-01 20:25:23 | [diff] [blame] | 2154 | } else if (view_type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) { |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2155 | // Disable all kinds of acceleration for background pages. |
| 2156 | // See http://crbug.com/96005 and http://crbug.com/96006 |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 2157 | web_prefs->force_compositing_mode = false; |
| 2158 | web_prefs->accelerated_compositing_enabled = false; |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2159 | } |
[email protected] | 2e21fe29 | 2012-03-02 22:52:32 | [diff] [blame] | 2160 | |
| 2161 | #if defined(FILE_MANAGER_EXTENSION) |
| 2162 | // Override the default of suppressing HW compositing for WebUI pages for the |
| 2163 | // file manager, which is implemented using WebUI but wants HW acceleration |
| 2164 | // for video decode & render. |
[email protected] | 02a3dc12 | 2013-06-13 15:07:53 | [diff] [blame] | 2165 | if (url.SchemeIs(extensions::kExtensionScheme) && |
| 2166 | url.host() == kFileBrowserDomain) { |
[email protected] | 2e21fe29 | 2012-03-02 22:52:32 | [diff] [blame] | 2167 | web_prefs->accelerated_compositing_enabled = true; |
| 2168 | web_prefs->accelerated_2d_canvas_enabled = true; |
| 2169 | } |
| 2170 | #endif |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 2171 | } |
| 2172 | |
| 2173 | void ChromeContentBrowserClient::UpdateInspectorSetting( |
| 2174 | RenderViewHost* rvh, const std::string& key, const std::string& value) { |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2175 | content::BrowserContext* browser_context = |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 2176 | rvh->GetProcess()->GetBrowserContext(); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 2177 | DictionaryPrefUpdate update( |
| 2178 | Profile::FromBrowserContext(browser_context)->GetPrefs(), |
| 2179 | prefs::kWebKitInspectorSettings); |
| 2180 | DictionaryValue* inspector_settings = update.Get(); |
| 2181 | inspector_settings->SetWithoutPathExpansion(key, |
| 2182 | Value::CreateStringValue(value)); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 2183 | } |
| 2184 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 2185 | void ChromeContentBrowserClient::BrowserURLHandlerCreated( |
| 2186 | BrowserURLHandler* handler) { |
| 2187 | // Add the default URL handlers. |
| 2188 | handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, |
| 2189 | BrowserURLHandler::null_handler()); |
| 2190 | handler->AddHandlerPair(BrowserURLHandler::null_handler(), |
| 2191 | &ExtensionWebUI::HandleChromeURLOverrideReverse); |
| 2192 | |
[email protected] | b3adbd0 | 2011-11-30 22:23:27 | [diff] [blame] | 2193 | // about: handler. Must come before chrome: handler, since it will |
| 2194 | // rewrite about: urls to chrome: URLs and then expect chrome: to |
| 2195 | // actually handle them. |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 2196 | handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 2197 | BrowserURLHandler::null_handler()); |
[email protected] | 231dba2 | 2013-07-25 23:53:03 | [diff] [blame^] | 2198 | |
| 2199 | // Handler to rewrite chrome://newtab for InstantExtended. |
| 2200 | handler->AddHandlerPair(&chrome::HandleNewTabURLRewrite, |
| 2201 | &chrome::HandleNewTabURLReverseRewrite); |
| 2202 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 2203 | // chrome: & friends. |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 2204 | handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 2205 | } |
| 2206 | |
| 2207 | void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 2208 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 2209 | rvh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
[email protected] | 38b892b4 | 2012-09-04 13:25:47 | [diff] [blame] | 2210 | BrowsingDataRemover* remover = |
| 2211 | BrowsingDataRemover::CreateForUnboundedRange(profile); |
[email protected] | 3d4d4cf | 2012-06-04 10:40:55 | [diff] [blame] | 2212 | remover->Remove(BrowsingDataRemover::REMOVE_CACHE, |
| 2213 | BrowsingDataHelper::UNPROTECTED_WEB); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 2214 | // BrowsingDataRemover takes care of deleting itself when done. |
| 2215 | } |
| 2216 | |
| 2217 | void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 2218 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 2219 | rvh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
[email protected] | 38b892b4 | 2012-09-04 13:25:47 | [diff] [blame] | 2220 | BrowsingDataRemover* remover = |
| 2221 | BrowsingDataRemover::CreateForUnboundedRange(profile); |
[email protected] | dceaa91 | 2011-09-06 17:17:23 | [diff] [blame] | 2222 | int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
[email protected] | 3d4d4cf | 2012-06-04 10:40:55 | [diff] [blame] | 2223 | remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 2224 | // BrowsingDataRemover takes care of deleting itself when done. |
| 2225 | } |
| 2226 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 2227 | base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 2228 | return download_util::GetDefaultDownloadDirectory(); |
| 2229 | } |
| 2230 | |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 2231 | std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
| 2232 | return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
| 2233 | } |
| 2234 | |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 2235 | void ChromeContentBrowserClient::DidCreatePpapiPlugin( |
| 2236 | content::BrowserPpapiHost* browser_host) { |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 2237 | #if defined(ENABLE_PLUGINS) |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 2238 | browser_host->GetPpapiHost()->AddHostFactoryFilter( |
| 2239 | scoped_ptr<ppapi::host::HostFactory>( |
| 2240 | new ChromeBrowserPepperHostFactory(browser_host))); |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 2241 | #endif |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 2242 | } |
| 2243 | |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 2244 | content::BrowserPpapiHost* |
| 2245 | ChromeContentBrowserClient::GetExternalBrowserPpapiHost( |
| 2246 | int plugin_process_id) { |
[email protected] | f3b35769 | 2013-03-22 05:16:13 | [diff] [blame] | 2247 | BrowserChildProcessHostIterator iter(PROCESS_TYPE_NACL_LOADER); |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 2248 | while (!iter.Done()) { |
| 2249 | NaClProcessHost* host = static_cast<NaClProcessHost*>(iter.GetDelegate()); |
| 2250 | if (host->process() && |
| 2251 | host->process()->GetData().id == plugin_process_id) { |
| 2252 | // Found the plugin. |
| 2253 | return host->browser_ppapi_host(); |
| 2254 | } |
| 2255 | ++iter; |
| 2256 | } |
| 2257 | return NULL; |
| 2258 | } |
| 2259 | |
[email protected] | 7b38b19 | 2013-03-23 18:39:31 | [diff] [blame] | 2260 | bool ChromeContentBrowserClient::SupportsBrowserPlugin( |
| 2261 | content::BrowserContext* browser_context, const GURL& site_url) { |
| 2262 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2263 | switches::kEnableBrowserPluginForAllViewTypes)) |
| 2264 | return true; |
| 2265 | |
| 2266 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 2267 | ExtensionService* service = |
| 2268 | extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 2269 | if (!service) |
| 2270 | return false; |
| 2271 | |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 2272 | const Extension* extension = |
| 2273 | service->extensions()->GetExtensionOrAppByURL(site_url); |
[email protected] | 7b38b19 | 2013-03-23 18:39:31 | [diff] [blame] | 2274 | if (!extension) |
| 2275 | return false; |
| 2276 | |
[email protected] | c2d2f10 | 2013-04-29 16:42:58 | [diff] [blame] | 2277 | return extension->HasAPIPermission(APIPermission::kWebView) || |
| 2278 | extension->HasAPIPermission(APIPermission::kAdView); |
[email protected] | 7b38b19 | 2013-03-23 18:39:31 | [diff] [blame] | 2279 | } |
| 2280 | |
[email protected] | 38cd8f7f | 2012-06-15 22:06:07 | [diff] [blame] | 2281 | bool ChromeContentBrowserClient::AllowPepperSocketAPI( |
[email protected] | 157cc90 | 2012-11-02 06:31:58 | [diff] [blame] | 2282 | content::BrowserContext* browser_context, |
| 2283 | const GURL& url, |
[email protected] | dda5482 | 2013-06-15 01:26:39 | [diff] [blame] | 2284 | bool private_api, |
[email protected] | 157cc90 | 2012-11-02 06:31:58 | [diff] [blame] | 2285 | const content::SocketPermissionRequest& params) { |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 2286 | #if defined(ENABLE_PLUGINS) |
[email protected] | 9d45049 | 2013-06-13 23:08:37 | [diff] [blame] | 2287 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 2288 | const ExtensionSet* extension_set = NULL; |
| 2289 | if (profile) { |
| 2290 | extension_set = extensions::ExtensionSystem::Get(profile)-> |
| 2291 | extension_service()->extensions(); |
| 2292 | } |
[email protected] | dda5482 | 2013-06-15 01:26:39 | [diff] [blame] | 2293 | |
| 2294 | if (private_api) { |
| 2295 | // Access to private socket APIs is controlled by the whitelist. |
| 2296 | if (IsExtensionOrSharedModuleWhitelisted(url, extension_set, |
| 2297 | allowed_socket_origins_)) { |
| 2298 | return true; |
| 2299 | } |
| 2300 | } else { |
| 2301 | // Access to public socket APIs is controlled by extension permissions. |
| 2302 | if (url.is_valid() && url.SchemeIs(extensions::kExtensionScheme) && |
| 2303 | extension_set) { |
| 2304 | const Extension* extension = extension_set->GetByID(url.host()); |
| 2305 | if (extension) { |
| 2306 | extensions::SocketPermission::CheckParam check_params( |
| 2307 | params.type, params.host, params.port); |
| 2308 | if (extensions::PermissionsData::CheckAPIPermissionWithParam( |
| 2309 | extension, extensions::APIPermission::kSocket, &check_params)) { |
| 2310 | return true; |
| 2311 | } |
| 2312 | } |
| 2313 | } |
| 2314 | } |
| 2315 | |
| 2316 | // Allow both public and private APIs if the command line says so. |
| 2317 | return IsHostAllowedByCommandLine(url, extension_set, |
| 2318 | switches::kAllowNaClSocketAPI); |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 2319 | #else |
[email protected] | a658d45 | 2012-03-02 12:45:29 | [diff] [blame] | 2320 | return false; |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 2321 | #endif |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 2322 | } |
| 2323 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 2324 | base::FilePath ChromeContentBrowserClient::GetHyphenDictionaryDirectory() { |
| 2325 | base::FilePath directory; |
[email protected] | a7944aa | 2012-10-15 10:12:14 | [diff] [blame] | 2326 | PathService::Get(chrome::DIR_APP_DICTIONARIES, &directory); |
| 2327 | return directory.Append(FILE_PATH_LITERAL("Hyphen")); |
| 2328 | } |
| 2329 | |
[email protected] | a28e330 | 2013-02-03 03:50:43 | [diff] [blame] | 2330 | ui::SelectFilePolicy* ChromeContentBrowserClient::CreateSelectFilePolicy( |
| 2331 | WebContents* web_contents) { |
| 2332 | return new ChromeSelectFilePolicy(web_contents); |
| 2333 | } |
| 2334 | |
[email protected] | 7d942470 | 2013-04-14 13:14:16 | [diff] [blame] | 2335 | void ChromeContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
| 2336 | std::vector<std::string>* additional_allowed_schemes) { |
| 2337 | ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
| 2338 | additional_allowed_schemes); |
| 2339 | additional_allowed_schemes->push_back(kChromeUIScheme); |
| 2340 | additional_allowed_schemes->push_back(extensions::kExtensionScheme); |
| 2341 | } |
| 2342 | |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 2343 | void ChromeContentBrowserClient::GetAdditionalFileSystemBackends( |
[email protected] | 0ff5eb5 | 2013-07-10 20:35:31 | [diff] [blame] | 2344 | content::BrowserContext* browser_context, |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 2345 | const base::FilePath& storage_partition_path, |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 2346 | ScopedVector<fileapi::FileSystemBackend>* additional_backends) { |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 2347 | #if !defined(OS_ANDROID) |
[email protected] | 30a306f4 | 2013-06-10 03:09:03 | [diff] [blame] | 2348 | base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 2349 | additional_backends->push_back(new MediaFileSystemBackend( |
[email protected] | 30a306f4 | 2013-06-10 03:09:03 | [diff] [blame] | 2350 | storage_partition_path, |
| 2351 | pool->GetSequencedTaskRunner(pool->GetNamedSequenceToken( |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 2352 | MediaFileSystemBackend::kMediaTaskRunnerName)).get())); |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 2353 | #endif |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 2354 | #if defined(OS_CHROMEOS) |
[email protected] | 0ff5eb5 | 2013-07-10 20:35:31 | [diff] [blame] | 2355 | fileapi::ExternalMountPoints* external_mount_points = |
| 2356 | content::BrowserContext::GetMountPoints(browser_context); |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 2357 | DCHECK(external_mount_points); |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 2358 | chromeos::FileSystemBackend* backend = |
| 2359 | new chromeos::FileSystemBackend( |
[email protected] | 0ff5eb5 | 2013-07-10 20:35:31 | [diff] [blame] | 2360 | new drive::FileSystemBackendDelegate(browser_context), |
| 2361 | browser_context->GetSpecialStoragePolicy(), |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 2362 | external_mount_points, |
| 2363 | fileapi::ExternalMountPoints::GetSystemInstance()); |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 2364 | backend->AddSystemMountPoints(); |
| 2365 | DCHECK(backend->CanHandleType(fileapi::kFileSystemTypeExternal)); |
| 2366 | additional_backends->push_back(backend); |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 2367 | #endif |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 2368 | } |
| 2369 | |
[email protected] | e60c023 | 2011-11-11 19:56:35 | [diff] [blame] | 2370 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 2371 | void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 2372 | const CommandLine& command_line, |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 2373 | int child_process_id, |
[email protected] | c7abd42 | 2012-09-25 00:20:08 | [diff] [blame] | 2374 | std::vector<FileDescriptorInfo>* mappings) { |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 2375 | #if defined(OS_ANDROID) |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 2376 | base::FilePath data_path; |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 2377 | PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); |
| 2378 | DCHECK(!data_path.empty()); |
| 2379 | |
| 2380 | int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 2381 | base::FilePath chrome_pak = data_path.AppendASCII("chrome.pak"); |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 2382 | base::PlatformFile f = |
| 2383 | base::CreatePlatformFile(chrome_pak, flags, NULL, NULL); |
| 2384 | DCHECK(f != base::kInvalidPlatformFileValue); |
| 2385 | mappings->push_back(FileDescriptorInfo(kAndroidChromePakDescriptor, |
| 2386 | FileDescriptor(f, true))); |
| 2387 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 2388 | base::FilePath chrome_resources_pak = |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 2389 | data_path.AppendASCII("chrome_100_percent.pak"); |
| 2390 | f = base::CreatePlatformFile(chrome_resources_pak, flags, NULL, NULL); |
| 2391 | DCHECK(f != base::kInvalidPlatformFileValue); |
[email protected] | 7359238 | 2013-01-18 19:22:37 | [diff] [blame] | 2392 | mappings->push_back(FileDescriptorInfo(kAndroidChrome100PercentPakDescriptor, |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 2393 | FileDescriptor(f, true))); |
| 2394 | |
| 2395 | const std::string locale = GetApplicationLocale(); |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 2396 | base::FilePath locale_pak = ResourceBundle::GetSharedInstance(). |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 2397 | GetLocaleFilePath(locale, false); |
| 2398 | f = base::CreatePlatformFile(locale_pak, flags, NULL, NULL); |
| 2399 | DCHECK(f != base::kInvalidPlatformFileValue); |
| 2400 | mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor, |
| 2401 | FileDescriptor(f, true))); |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 2402 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 2403 | base::FilePath resources_pack_path; |
[email protected] | 7359238 | 2013-01-18 19:22:37 | [diff] [blame] | 2404 | PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 2405 | f = base::CreatePlatformFile(resources_pack_path, flags, NULL, NULL); |
| 2406 | DCHECK(f != base::kInvalidPlatformFileValue); |
| 2407 | mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor, |
| 2408 | FileDescriptor(f, true))); |
| 2409 | |
[email protected] | 82174aa | 2013-01-22 21:53:43 | [diff] [blame] | 2410 | if (IsCrashReporterEnabled()) { |
| 2411 | f = CrashDumpManager::GetInstance()->CreateMinidumpFile(child_process_id); |
| 2412 | if (f == base::kInvalidPlatformFileValue) { |
| 2413 | LOG(ERROR) << "Failed to create file for minidump, crash reporting will " |
| 2414 | "be disabled for this process."; |
| 2415 | } else { |
| 2416 | mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor, |
| 2417 | FileDescriptor(f, true))); |
| 2418 | } |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 2419 | } |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 2420 | |
| 2421 | #else |
| 2422 | int crash_signal_fd = GetCrashSignalFD(command_line); |
| 2423 | if (crash_signal_fd >= 0) { |
| 2424 | mappings->push_back(FileDescriptorInfo(kCrashDumpSignal, |
| 2425 | FileDescriptor(crash_signal_fd, |
| 2426 | false))); |
| 2427 | } |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 2428 | #endif // defined(OS_ANDROID) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2429 | } |
[email protected] | e60c023 | 2011-11-11 19:56:35 | [diff] [blame] | 2430 | #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2431 | |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 2432 | #if defined(OS_WIN) |
| 2433 | const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { |
| 2434 | return chrome::kBrowserResourcesDll; |
| 2435 | } |
[email protected] | 34f4868 | 2013-03-20 00:30:18 | [diff] [blame] | 2436 | |
| 2437 | void ChromeContentBrowserClient::PreSpawnRenderer( |
| 2438 | sandbox::TargetPolicy* policy, |
| 2439 | bool* success) { |
| 2440 | // This code is duplicated in nacl_exe_win_64.cc. |
| 2441 | // Allow the server side of a pipe restricted to the "chrome.nacl." |
| 2442 | // namespace so that it cannot impersonate other system or other chrome |
| 2443 | // service pipes. |
| 2444 | sandbox::ResultCode result = policy->AddRule( |
| 2445 | sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, |
| 2446 | sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, |
| 2447 | L"\\\\.\\pipe\\chrome.nacl.*"); |
| 2448 | if (result != sandbox::SBOX_ALL_OK) { |
| 2449 | *success = false; |
| 2450 | return; |
| 2451 | } |
| 2452 | |
| 2453 | // Renderers need to send named pipe handles and shared memory |
| 2454 | // segment handles to NaCl loader processes. |
| 2455 | result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
| 2456 | sandbox::TargetPolicy::HANDLES_DUP_ANY, |
| 2457 | L"File"); |
| 2458 | if (result != sandbox::SBOX_ALL_OK) { |
| 2459 | *success = false; |
| 2460 | return; |
| 2461 | } |
| 2462 | } |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 2463 | #endif |
| 2464 | |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 2465 | #if defined(USE_NSS) |
| 2466 | crypto::CryptoModuleBlockingPasswordDelegate* |
| 2467 | ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 2468 | const GURL& url) { |
[email protected] | 6246ac5 | 2012-09-24 01:55:29 | [diff] [blame] | 2469 | return chrome::NewCryptoModuleBlockingDialogDelegate( |
| 2470 | chrome::kCryptoModulePasswordKeygen, url.host()); |
[email protected] | 37a72af | 2011-06-13 05:42:01 | [diff] [blame] | 2471 | } |
| 2472 | #endif |
| 2473 | |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 2474 | } // namespace chrome |