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