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