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