[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 | |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 7 | #include <map> |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 8 | #include <set> |
[email protected] | 1033acd | 2012-02-08 08:46:27 | [diff] [blame] | 9 | #include <utility> |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
brettw | f195891 | 2015-10-07 19:43:12 | [diff] [blame] | 12 | #include "base/base_switches.h" |
[email protected] | 317c58f0 | 2011-11-09 02:15:03 | [diff] [blame] | 13 | #include "base/bind.h" |
estark | 3ba1113 | 2015-04-10 01:38:33 | [diff] [blame] | 14 | #include "base/bind_helpers.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 15 | #include "base/command_line.h" |
morrita | d95714f | 2014-10-01 02:37:24 | [diff] [blame] | 16 | #include "base/files/scoped_file.h" |
Marc Treib | ad33cf94 | 2017-08-24 11:19:00 | [diff] [blame] | 17 | #include "base/i18n/base_i18n_switches.h" |
jinsukkim | 79df88a | 2017-01-04 06:26:15 | [diff] [blame] | 18 | #include "base/i18n/character_encoding.h" |
Ken Rockot | 341089f | 2019-01-11 23:11:58 | [diff] [blame] | 19 | #include "base/macros.h" |
Tarun Bansal | 73d67f0 | 2018-01-17 05:56:25 | [diff] [blame] | 20 | #include "base/metrics/field_trial_params.h" |
lazyboy | 5d5fede0 | 2016-03-10 04:10:14 | [diff] [blame] | 21 | #include "base/metrics/histogram_macros.h" |
Lei Zhang | 2cfceac | 2018-11-14 19:36:33 | [diff] [blame] | 22 | #include "base/no_destructor.h" |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 23 | #include "base/path_service.h" |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 24 | #include "base/stl_util.h" |
[email protected] | e746341 | 2013-06-10 22:53:46 | [diff] [blame] | 25 | #include "base/strings/string_number_conversions.h" |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 26 | #include "base/strings/string_split.h" |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 27 | #include "base/strings/string_util.h" |
| 28 | #include "base/strings/stringprintf.h" |
[email protected] | 135cb80 | 2013-06-09 16:44:20 | [diff] [blame] | 29 | #include "base/strings/utf_string_conversions.h" |
Sebastien Marchand | 75a7cdf | 2018-11-13 23:47:03 | [diff] [blame] | 30 | #include "base/system/sys_info.h" |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 31 | #include "base/task/post_task.h" |
Wojciech Dzierżanowski | 4538080 | 2019-04-29 14:50:32 | [diff] [blame] | 32 | #include "base/threading/sequenced_task_runner_handle.h" |
gab | b15e1907 | 2016-05-11 20:45:41 | [diff] [blame] | 33 | #include "base/threading/thread_task_runner_handle.h" |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 34 | #include "build/build_config.h" |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 35 | #include "chrome/app/builtin_service_manifests.h" |
Ken Rockot | 341089f | 2019-01-11 23:11:58 | [diff] [blame] | 36 | #include "chrome/app/chrome_content_browser_overlay_manifest.h" |
| 37 | #include "chrome/app/chrome_content_gpu_overlay_manifest.h" |
| 38 | #include "chrome/app/chrome_content_renderer_overlay_manifest.h" |
| 39 | #include "chrome/app/chrome_content_utility_overlay_manifest.h" |
Ken Rockot | 341089f | 2019-01-11 23:11:58 | [diff] [blame] | 40 | #include "chrome/app/chrome_renderer_manifest.h" |
Dominic Mazzoni | 21fb028 | 2019-02-13 18:32:47 | [diff] [blame] | 41 | #include "chrome/browser/accessibility/accessibility_labels_service.h" |
| 42 | #include "chrome/browser/accessibility/accessibility_labels_service_factory.h" |
michaeln | 96f887e2 | 2015-04-13 23:58:31 | [diff] [blame] | 43 | #include "chrome/browser/after_startup_task_utils.h" |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 44 | #include "chrome/browser/browser_about_handler.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 45 | #include "chrome/browser/browser_process.h" |
[email protected] | b0cb5e8 | 2012-07-19 19:22:47 | [diff] [blame] | 46 | #include "chrome/browser/browsing_data/browsing_data_helper.h" |
msramek | 1c2b3ca | 2017-03-14 17:57:56 | [diff] [blame] | 47 | #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
nigeltao | beff0a10 | 2017-04-29 09:30:37 | [diff] [blame] | 48 | #include "chrome/browser/cache_stats_recorder.h" |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 49 | #include "chrome/browser/chrome_content_browser_client_parts.h" |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 50 | #include "chrome/browser/chrome_quota_permission_context.h" |
droger | b171697 | 2015-06-30 09:04:09 | [diff] [blame] | 51 | #include "chrome/browser/content_settings/cookie_settings_factory.h" |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 52 | #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 53 | #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
Robbie McElrath | 1294d24 | 2019-05-31 20:46:22 | [diff] [blame] | 54 | #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 55 | #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
Zhuoyu Qian | cb197638 | 2018-12-13 02:18:30 | [diff] [blame] | 56 | #include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings.h" |
| 57 | #include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings_factory.h" |
rajendrant | feea859 | 2018-10-19 18:26:06 | [diff] [blame] | 58 | #include "chrome/browser/data_use_measurement/chrome_data_use_measurement.h" |
[email protected] | 9d06d88d | 2012-02-23 22:37:08 | [diff] [blame] | 59 | #include "chrome/browser/defaults.h" |
[email protected] | b1d9727 | 2013-08-17 13:38:49 | [diff] [blame] | 60 | #include "chrome/browser/download/download_prefs.h" |
Maks Orlovich | 710d5e3 | 2019-07-09 20:16:45 | [diff] [blame] | 61 | #include "chrome/browser/extensions/chrome_extension_cookies.h" |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 62 | #include "chrome/browser/external_protocol/external_protocol_handler.h" |
[email protected] | 354de9e | 2014-08-07 03:27:19 | [diff] [blame] | 63 | #include "chrome/browser/font_family_cache.h" |
Matt Reynolds | 93616f9b | 2019-06-07 01:28:52 | [diff] [blame] | 64 | #include "chrome/browser/hid/chrome_hid_delegate.h" |
Anthony Vallee-Dubois | e2432137a | 2019-01-17 20:06:01 | [diff] [blame] | 65 | #include "chrome/browser/language/translate_frame_binder.h" |
Avi Drissman | d3092734 | 2018-05-22 15:04:27 | [diff] [blame] | 66 | #include "chrome/browser/lifetime/browser_shutdown.h" |
Joe DeBlasio | 6e8409a | 2019-02-20 23:08:27 | [diff] [blame] | 67 | #include "chrome/browser/lookalikes/lookalike_url_navigation_throttle.h" |
thakis | 678822e | 2017-04-20 17:20:34 | [diff] [blame] | 68 | #include "chrome/browser/media/router/media_router_feature.h" |
Derek Cheng | eb64b19a | 2018-01-02 20:20:42 | [diff] [blame] | 69 | #include "chrome/browser/media/router/presentation/presentation_service_delegate_impl.h" |
| 70 | #include "chrome/browser/media/router/presentation/receiver_presentation_service_delegate_impl.h" |
Patrik Höglund | b564859b | 2018-05-17 11:17:16 | [diff] [blame] | 71 | #include "chrome/browser/media/webrtc/audio_debug_recordings_handler.h" |
mcasas | a2023ab | 2016-09-08 01:06:36 | [diff] [blame] | 72 | #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
Patrik Höglund | b564859b | 2018-05-17 11:17:16 | [diff] [blame] | 73 | #include "chrome/browser/media/webrtc/webrtc_logging_handler_host.h" |
[email protected] | 95132f5 | 2013-04-12 02:19:04 | [diff] [blame] | 74 | #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 75 | #include "chrome/browser/metrics/chrome_feature_list_creator.h" |
[email protected] | a2b4c5c | 2013-10-18 02:06:07 | [diff] [blame] | 76 | #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" |
Lu Chen | 5bec7a30 | 2018-06-26 18:52:32 | [diff] [blame] | 77 | #include "chrome/browser/navigation_predictor/navigation_predictor.h" |
John Abd-El-Malek | 7577f26 | 2019-06-10 21:23:23 | [diff] [blame] | 78 | #include "chrome/browser/net/chrome_network_delegate.h" |
Matt Menke | ae4fdb1 | 2018-06-02 06:32:54 | [diff] [blame] | 79 | #include "chrome/browser/net/system_network_context_manager.h" |
dvallet | 233f57ab | 2016-12-21 03:17:10 | [diff] [blame] | 80 | #include "chrome/browser/net_benchmarking.h" |
Richard Knoll | d0eae96 | 2019-04-04 12:34:02 | [diff] [blame] | 81 | #include "chrome/browser/notifications/platform_notification_service_factory.h" |
peter | c26c6c6 | 2014-12-10 14:13:59 | [diff] [blame] | 82 | #include "chrome/browser/notifications/platform_notification_service_impl.h" |
csharrison | 4bd8a19 | 2016-08-02 18:03:15 | [diff] [blame] | 83 | #include "chrome/browser/page_load_metrics/metrics_navigation_throttle.h" |
Charlie Harrison | 650e1142 | 2018-12-04 00:37:26 | [diff] [blame] | 84 | #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
Matt Falkenhagen | 8479b20 | 2017-07-14 04:35:31 | [diff] [blame] | 85 | #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
leon.han | 952ea325 | 2016-04-13 02:44:56 | [diff] [blame] | 86 | #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
Anthony Vallee-Dubois | 8f5e7e1 | 2018-01-12 16:14:06 | [diff] [blame] | 87 | #include "chrome/browser/payments/payment_request_display_manager_factory.h" |
Sigurdur Asgeirsson | 54b7270 | 2019-04-12 14:18:54 | [diff] [blame] | 88 | #include "chrome/browser/performance_manager/chrome_browser_main_extra_parts_performance_manager.h" |
Sigurdur Asgeirsson | 7069667 | 2019-02-08 16:14:51 | [diff] [blame] | 89 | #include "chrome/browser/performance_manager/chrome_content_browser_client_performance_manager_part.h" |
Adam Langley | 85339f6 | 2018-02-12 22:03:56 | [diff] [blame] | 90 | #include "chrome/browser/permissions/attestation_permission_request.h" |
jyasskin | c993ce8d | 2016-03-31 00:38:34 | [diff] [blame] | 91 | #include "chrome/browser/permissions/permission_context_base.h" |
Adam Langley | 85339f6 | 2018-02-12 22:03:56 | [diff] [blame] | 92 | #include "chrome/browser/permissions/permission_request_manager.h" |
[email protected] | 0609b17f | 2011-05-31 20:13:42 | [diff] [blame] | 93 | #include "chrome/browser/platform_util.h" |
Amber Won | 94afd811 | 2017-08-23 17:30:11 | [diff] [blame] | 94 | #include "chrome/browser/plugins/pdf_iframe_navigation_throttle.h" |
Ehsan Karamad | 91413d7 | 2019-03-22 16:37:48 | [diff] [blame] | 95 | #include "chrome/browser/plugins/plugin_utils.h" |
Alexandr Ilin | 4909ec8 | 2018-06-06 10:22:48 | [diff] [blame] | 96 | #include "chrome/browser/predictors/loading_predictor.h" |
| 97 | #include "chrome/browser/predictors/loading_predictor_factory.h" |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 98 | #include "chrome/browser/prerender/prerender_final_status.h" |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 99 | #include "chrome/browser/prerender/prerender_manager.h" |
[email protected] | 3085c50 | 2011-10-05 17:50:50 | [diff] [blame] | 100 | #include "chrome/browser/prerender/prerender_manager_factory.h" |
[email protected] | 2736c03 | 2012-05-11 18:06:07 | [diff] [blame] | 101 | #include "chrome/browser/prerender/prerender_message_filter.h" |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 102 | #include "chrome/browser/prerender/prerender_util.h" |
Ryan Sturm | cc5071be | 2019-02-16 02:15:19 | [diff] [blame] | 103 | #include "chrome/browser/previews/previews_content_util.h" |
Robert Ogden | afd250b | 2018-07-25 22:21:03 | [diff] [blame] | 104 | #include "chrome/browser/previews/previews_lite_page_decider.h" |
Robert Ogden | e7fdca9 | 2018-10-12 17:53:06 | [diff] [blame] | 105 | #include "chrome/browser/previews/previews_lite_page_navigation_throttle.h" |
Ryan Sturm | af52374 | 2019-01-16 00:15:45 | [diff] [blame] | 106 | #include "chrome/browser/previews/previews_lite_page_url_loader_interceptor.h" |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 107 | #include "chrome/browser/previews/previews_service.h" |
| 108 | #include "chrome/browser/previews/previews_service_factory.h" |
| 109 | #include "chrome/browser/previews/previews_ui_tab_helper.h" |
[email protected] | 7e75e4a | 2013-05-17 17:20:03 | [diff] [blame] | 110 | #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 111 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 8093a54 | 2011-05-13 07:29:32 | [diff] [blame] | 112 | #include "chrome/browser/profiles/profile_io_data.h" |
John Abd-El-Malek | 1f7fc91 | 2018-07-26 02:48:06 | [diff] [blame] | 113 | #include "chrome/browser/profiles/renderer_updater.h" |
| 114 | #include "chrome/browser/profiles/renderer_updater_factory.h" |
Erik Chen | 49bbfa2 | 2017-08-18 08:49:56 | [diff] [blame] | 115 | #include "chrome/browser/profiling_host/chrome_browser_main_extra_parts_profiling.h" |
| 116 | #include "chrome/browser/profiling_host/profiling_process_host.h" |
clamy | 1e5574e | 2016-09-29 16:48:44 | [diff] [blame] | 117 | #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h" |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 118 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 119 | #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" |
Kenichi Ishibashi | 4632987 | 2018-07-17 09:43:40 | [diff] [blame] | 120 | #include "chrome/browser/renderer_preferences_util.h" |
zhenw | 6edd49c | 2017-07-12 05:49:45 | [diff] [blame] | 121 | #include "chrome/browser/resource_coordinator/background_tab_navigation_throttle.h" |
meacer | f43117a | 2016-12-27 21:02:31 | [diff] [blame] | 122 | #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
| 123 | #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" |
Carlos IL | 4ee307e | 2018-12-22 03:19:00 | [diff] [blame] | 124 | #include "chrome/browser/safe_browsing/safe_browsing_navigation_throttle.h" |
yzshen | 2d8fb42 | 2017-06-01 20:29:40 | [diff] [blame] | 125 | #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 126 | #include "chrome/browser/safe_browsing/ui_manager.h" |
| 127 | #include "chrome/browser/safe_browsing/url_checker_delegate_impl.h" |
[email protected] | a7b8e43d | 2013-03-18 18:52:43 | [diff] [blame] | 128 | #include "chrome/browser/search/search.h" |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 129 | #include "chrome/browser/sessions/session_tab_helper.h" |
Reilly Grant | cc22e60 | 2018-09-07 15:25:20 | [diff] [blame] | 130 | #include "chrome/browser/signin/chrome_signin_proxying_url_loader_factory.h" |
Reilly Grant | 3787780 | 2018-08-18 00:58:35 | [diff] [blame] | 131 | #include "chrome/browser/signin/chrome_signin_url_loader_throttle.h" |
Reilly Grant | 24bf833 | 2018-08-27 21:55:01 | [diff] [blame] | 132 | #include "chrome/browser/signin/header_modification_delegate_impl.h" |
Lukasz Anforowicz | fd30af3 | 2019-03-28 17:33:28 | [diff] [blame] | 133 | #include "chrome/browser/site_isolation/site_isolation_policy.h" |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 134 | #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
Katie D | 840d953 | 2018-11-27 06:20:48 | [diff] [blame] | 135 | #include "chrome/browser/speech/tts_controller_delegate_impl.h" |
[email protected] | 7a06d28 | 2013-05-03 04:39:33 | [diff] [blame] | 136 | #include "chrome/browser/speech/tts_message_filter.h" |
Eric Lawrence | d0acf2a7c | 2017-07-20 18:02:48 | [diff] [blame] | 137 | #include "chrome/browser/ssl/insecure_sensitive_input_driver_factory.h" |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 138 | #include "chrome/browser/ssl/ssl_blocking_page.h" |
estark | 3ba1113 | 2015-04-10 01:38:33 | [diff] [blame] | 139 | #include "chrome/browser/ssl/ssl_cert_reporter.h" |
Joe DeBlasio | 9b99629 | 2019-01-31 05:09:32 | [diff] [blame] | 140 | #include "chrome/browser/ssl/ssl_client_auth_metrics.h" |
[email protected] | 25af6ec | 2014-06-06 19:35:07 | [diff] [blame] | 141 | #include "chrome/browser/ssl/ssl_client_certificate_selector.h" |
meacer | 4ef065e | 2015-01-09 03:21:35 | [diff] [blame] | 142 | #include "chrome/browser/ssl/ssl_error_handler.h" |
Lucas Garron | 94b1605 | 2017-11-11 01:58:12 | [diff] [blame] | 143 | #include "chrome/browser/ssl/ssl_error_navigation_throttle.h" |
Christopher Thompson | 4137cec | 2017-12-19 05:34:23 | [diff] [blame] | 144 | #include "chrome/browser/ssl/typed_navigation_timing_throttle.h" |
csharrison | 77bf834 | 2017-05-04 18:23:10 | [diff] [blame] | 145 | #include "chrome/browser/subresource_filter/chrome_subresource_filter_client.h" |
meacer | 4ef065e | 2015-01-09 03:21:35 | [diff] [blame] | 146 | #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 147 | #include "chrome/browser/tab_contents/tab_util.h" |
oysteine | c563c58 | 2015-02-13 19:19:52 | [diff] [blame] | 148 | #include "chrome/browser/tracing/chrome_tracing_delegate.h" |
Dave Tapuska | c6627e1 | 2018-08-30 15:07:19 | [diff] [blame] | 149 | #include "chrome/browser/translate/translate_service.h" |
[email protected] | 916615b | 2013-09-11 18:19:44 | [diff] [blame] | 150 | #include "chrome/browser/ui/blocked_content/blocked_window_params.h" |
Charlie Harrison | 804659a | 2018-10-16 16:43:38 | [diff] [blame] | 151 | #include "chrome/browser/ui/blocked_content/popup_blocker.h" |
Charles Harrison | 6dd11d28 | 2017-10-03 06:14:51 | [diff] [blame] | 152 | #include "chrome/browser/ui/blocked_content/tab_under_navigation_throttle.h" |
thestig | e8082124 | 2015-09-30 23:46:08 | [diff] [blame] | 153 | #include "chrome/browser/ui/browser_navigator.h" |
| 154 | #include "chrome/browser/ui/browser_navigator_params.h" |
[email protected] | a28e330 | 2013-02-03 03:50:43 | [diff] [blame] | 155 | #include "chrome/browser/ui/chrome_select_file_policy.h" |
Jun Cai | bc561f41 | 2018-02-28 18:41:39 | [diff] [blame] | 156 | #include "chrome/browser/ui/login/login_handler.h" |
Makoto Shimazu | c750293 | 2018-08-15 02:12:56 | [diff] [blame] | 157 | #include "chrome/browser/ui/prefs/pref_watcher.h" |
[email protected] | 329ac97 | 2013-06-21 15:24:25 | [diff] [blame] | 158 | #include "chrome/browser/ui/sync/sync_promo_ui.h" |
[email protected] | b5d7342 | 2012-06-02 23:46:44 | [diff] [blame] | 159 | #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
Dan Beam | f0a7e11 | 2019-06-07 18:40:58 | [diff] [blame] | 160 | #include "chrome/browser/ui/ui_features.h" |
[email protected] | 863f70a | 2012-01-27 02:05:50 | [diff] [blame] | 161 | #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
dbeam | baee5bd | 2015-09-26 03:07:01 | [diff] [blame] | 162 | #include "chrome/browser/ui/webui/log_web_ui_url.h" |
reillyg | 3ff4532 | 2015-10-23 21:16:25 | [diff] [blame] | 163 | #include "chrome/browser/usb/usb_tab_helper.h" |
Ian Vollick | 6243dfe0 | 2018-03-08 01:08:53 | [diff] [blame] | 164 | #include "chrome/browser/vr/vr_tab_helper.h" |
Giovanni Ortuño Urquidi | dcd3885 | 2019-03-07 08:08:25 | [diff] [blame] | 165 | #include "chrome/browser/web_applications/components/app_registrar.h" |
| 166 | #include "chrome/browser/web_applications/web_app_provider.h" |
Balazs Engedy | 5b108876 | 2018-06-05 09:30:46 | [diff] [blame] | 167 | #include "chrome/browser/webauthn/authenticator_request_scheduler.h" |
Balazs Engedy | a7ff7098 | 2018-06-04 18:14:47 | [diff] [blame] | 168 | #include "chrome/browser/webauthn/chrome_authenticator_request_delegate.h" |
Scott Violet | 6200d33 | 2018-02-23 21:29:23 | [diff] [blame] | 169 | #include "chrome/common/buildflags.h" |
sdefresne | 9fb6769 | 2015-08-03 18:48:22 | [diff] [blame] | 170 | #include "chrome/common/channel_info.h" |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 171 | #include "chrome/common/chrome_constants.h" |
chrisha | 927d8fe | 2017-01-18 23:09:51 | [diff] [blame] | 172 | #include "chrome/common/chrome_features.h" |
[email protected] | a7944aa | 2012-10-15 10:12:14 | [diff] [blame] | 173 | #include "chrome/common/chrome_paths.h" |
Mythri Alle | 0b8de0d | 2018-10-22 11:06:22 | [diff] [blame] | 174 | #include "chrome/common/chrome_paths_internal.h" |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 175 | #include "chrome/common/chrome_switches.h" |
Ben Goodger | e25ef85 | 2017-08-11 00:17:50 | [diff] [blame] | 176 | #include "chrome/common/constants.mojom.h" |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 177 | #include "chrome/common/env_vars.h" |
John Abd-El-Malek | 9fb6049 | 2018-08-02 04:28:50 | [diff] [blame] | 178 | #include "chrome/common/google_url_loader_throttle.h" |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 179 | #include "chrome/common/logging_chrome.h" |
[email protected] | 9d45049 | 2013-06-13 23:08:37 | [diff] [blame] | 180 | #include "chrome/common/pepper_permission_util.h" |
[email protected] | 763ec4ca | 2011-04-29 15:48:12 | [diff] [blame] | 181 | #include "chrome/common/pref_names.h" |
John Abd-El-Malek | d237798 | 2018-01-08 22:23:12 | [diff] [blame] | 182 | #include "chrome/common/prerender_url_loader_throttle.h" |
Egor Pasko | d52474c3 | 2018-06-19 12:03:22 | [diff] [blame] | 183 | #include "chrome/common/prerender_util.h" |
[email protected] | 3e69bc8 | 2011-05-26 23:22:38 | [diff] [blame] | 184 | #include "chrome/common/render_messages.h" |
nigeltao | 7cd8d558 | 2016-12-12 06:05:28 | [diff] [blame] | 185 | #include "chrome/common/renderer_configuration.mojom.h" |
falken | ad18509 | 2016-06-16 06:10:02 | [diff] [blame] | 186 | #include "chrome/common/secure_origin_whitelist.h" |
wittman | 832321f5 | 2016-10-10 18:18:38 | [diff] [blame] | 187 | #include "chrome/common/stack_sampling_configuration.h" |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 188 | #include "chrome/common/url_constants.h" |
ben | c70c0e3 | 2016-09-22 03:50:37 | [diff] [blame] | 189 | #include "chrome/grit/browser_resources.h" |
[email protected] | af39f00 | 2014-08-22 10:18:18 | [diff] [blame] | 190 | #include "chrome/grit/generated_resources.h" |
[email protected] | 264c0acac | 2013-10-01 13:33:30 | [diff] [blame] | 191 | #include "chrome/installer/util/google_update_settings.h" |
leon.han | 04b276e | 2016-06-01 01:34:16 | [diff] [blame] | 192 | #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
brettw | f195891 | 2015-10-07 19:43:12 | [diff] [blame] | 193 | #include "components/autofill/core/common/autofill_switches.h" |
msramek | 1c8e19d | 2017-01-04 20:04:53 | [diff] [blame] | 194 | #include "components/browsing_data/core/browsing_data_utils.h" |
[email protected] | 649b5727 | 2014-05-09 14:54:44 | [diff] [blame] | 195 | #include "components/cdm/browser/cdm_message_filter_android.h" |
Pavol Marko | b211ab2 | 2019-01-23 20:03:04 | [diff] [blame] | 196 | #include "components/certificate_matching/certificate_principal_pattern.h" |
[email protected] | 09cff7878 | 2014-04-20 22:04:48 | [diff] [blame] | 197 | #include "components/cloud_devices/common/cloud_devices_switches.h" |
Tao Bai | 02ab4dd4 | 2019-03-06 00:30:37 | [diff] [blame] | 198 | #include "components/content_capture/browser/content_capture_receiver_manager.h" |
mukai | 8eaec82 | 2014-10-25 17:53:16 | [diff] [blame] | 199 | #include "components/content_settings/core/browser/content_settings_utils.h" |
droger | b171697 | 2015-06-30 09:04:09 | [diff] [blame] | 200 | #include "components/content_settings/core/browser/cookie_settings.h" |
mukai | 8eaec82 | 2014-10-25 17:53:16 | [diff] [blame] | 201 | #include "components/content_settings/core/browser/host_content_settings_map.h" |
mukai | 077089f | 2014-09-11 18:41:52 | [diff] [blame] | 202 | #include "components/content_settings/core/common/content_settings.h" |
jyasskin | 98bdd399 | 2016-02-26 20:25:45 | [diff] [blame] | 203 | #include "components/content_settings/core/common/content_settings_types.h" |
tbansal | 08a0e3e | 2017-06-30 21:30:08 | [diff] [blame] | 204 | #include "components/content_settings/core/common/content_settings_utils.h" |
Daniel Vogelheim | 976f1c2 | 2017-11-22 16:26:03 | [diff] [blame] | 205 | #include "components/content_settings/core/common/pref_names.h" |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 206 | #include "components/data_reduction_proxy/content/common/data_reduction_proxy_url_loader_throttle.h" |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 207 | #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h" |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 208 | #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" |
Clark DuVall | 68eb997f | 2019-06-28 05:42:28 | [diff] [blame] | 209 | #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" |
rajendrant | 4319407 | 2019-04-15 22:13:43 | [diff] [blame] | 210 | #include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h" |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 211 | #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" |
Wojciech Dzierżanowski | 4538080 | 2019-04-29 14:50:32 | [diff] [blame] | 212 | #include "components/data_reduction_proxy/core/common/data_reduction_proxy_throttle_manager.h" |
wychen | e5568734 | 2015-11-13 20:17:03 | [diff] [blame] | 213 | #include "components/dom_distiller/core/dom_distiller_switches.h" |
[email protected] | 474a5a3 | 2014-07-28 18:23:24 | [diff] [blame] | 214 | #include "components/dom_distiller/core/url_constants.h" |
blundell | a5e3240a | 2016-01-05 11:30:43 | [diff] [blame] | 215 | #include "components/error_page/common/error_page_switches.h" |
khushalsagar | c5447db2 | 2017-08-22 17:53:01 | [diff] [blame] | 216 | #include "components/feature_engagement/public/feature_constants.h" |
| 217 | #include "components/feature_engagement/public/feature_list.h" |
John Abd-El-Malek | 9cf3d7f0 | 2018-07-27 02:40:39 | [diff] [blame] | 218 | #include "components/google/core/common/google_util.h" |
Alexandre Frechette | 572755b | 2019-02-13 22:30:20 | [diff] [blame] | 219 | #include "components/language/core/browser/pref_names.h" |
wittman | e16da278 | 2016-09-21 16:43:04 | [diff] [blame] | 220 | #include "components/metrics/call_stack_profile_collector.h" |
[email protected] | 8e885de | 2014-07-22 23:36:53 | [diff] [blame] | 221 | #include "components/metrics/client_info.h" |
Xiangjun Zhang | 4547484 | 2018-08-17 21:07:59 | [diff] [blame] | 222 | #include "components/mirroring/mojom/constants.mojom.h" |
| 223 | #include "components/mirroring/service/features.h" |
Scott Violet | 9ae8289 | 2018-03-01 18:38:12 | [diff] [blame] | 224 | #include "components/nacl/common/buildflags.h" |
sammc | 2b0375b | 2016-12-22 01:26:17 | [diff] [blame] | 225 | #include "components/nacl/common/nacl_constants.h" |
droger | c690e880 | 2015-09-21 14:29:16 | [diff] [blame] | 226 | #include "components/net_log/chrome_net_log.h" |
leon.han | 97e8f75 | 2016-09-06 06:13:20 | [diff] [blame] | 227 | #include "components/password_manager/content/browser/content_password_manager_driver_factory.h" |
Anthony Vallee-Dubois | 8f5e7e1 | 2018-01-12 16:14:06 | [diff] [blame] | 228 | #include "components/payments/content/payment_request_display_manager.h" |
Doug Turner | 9dcaf596 | 2017-12-21 04:38:53 | [diff] [blame] | 229 | #include "components/policy/content/policy_blacklist_navigation_throttle.h" |
Michael Giuffrida | 01d7b5d | 2018-08-21 07:55:54 | [diff] [blame] | 230 | #include "components/policy/content/policy_blacklist_service.h" |
John Abd-El-Malek | 27b3ebd2 | 2019-02-12 18:59:18 | [diff] [blame] | 231 | #include "components/policy/core/common/policy_service.h" |
| 232 | #include "components/policy/policy_constants.h" |
[email protected] | f0c8c499 | 2014-05-15 17:37:26 | [diff] [blame] | 233 | #include "components/pref_registry/pref_registry_syncable.h" |
Chris Palmer | ac7d7564 | 2017-11-22 20:12:54 | [diff] [blame] | 234 | #include "components/prefs/pref_registry_simple.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 235 | #include "components/prefs/pref_service.h" |
| 236 | #include "components/prefs/scoped_user_pref_update.h" |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 237 | #include "components/previews/content/previews_decider_impl.h" |
| 238 | #include "components/previews/content/previews_ui_service.h" |
| 239 | #include "components/previews/content/previews_user_data.h" |
| 240 | #include "components/previews/core/previews_decider.h" |
| 241 | #include "components/previews/core/previews_experiments.h" |
Ryan Sturm | af52374 | 2019-01-16 00:15:45 | [diff] [blame] | 242 | #include "components/previews/core/previews_features.h" |
Robert Ogden | 01770b36 | 2019-05-22 17:36:43 | [diff] [blame] | 243 | #include "components/previews/core/previews_switches.h" |
nzolghadr | d87a308d | 2016-12-07 15:45:56 | [diff] [blame] | 244 | #include "components/rappor/public/rappor_utils.h" |
nigeltao | 2f67376 | 2016-10-14 03:27:28 | [diff] [blame] | 245 | #include "components/rappor/rappor_recorder_impl.h" |
nzolghadr | d87a308d | 2016-12-07 15:45:56 | [diff] [blame] | 246 | #include "components/rappor/rappor_service_impl.h" |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 247 | #include "components/safe_browsing/browser/browser_url_loader_throttle.h" |
| 248 | #include "components/safe_browsing/browser/mojo_safe_browsing_impl.h" |
| 249 | #include "components/safe_browsing/browser/url_checker_delegate.h" |
timvolodine | 89cf1171 | 2017-05-15 18:05:07 | [diff] [blame] | 250 | #include "components/safe_browsing/common/safe_browsing_prefs.h" |
Tim Volodine | e4593847 | 2017-09-21 10:08:22 | [diff] [blame] | 251 | #include "components/safe_browsing/db/database_manager.h" |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 252 | #include "components/safe_browsing/features.h" |
Jialiu Lin | bdbb81d | 2017-10-11 21:29:09 | [diff] [blame] | 253 | #include "components/safe_browsing/password_protection/password_protection_navigation_throttle.h" |
Daniel Vogelheim | 6008f57 | 2018-09-24 14:35:14 | [diff] [blame] | 254 | #include "components/security_interstitials/content/origin_policy_ui.h" |
Alexei Filippov | 65c08b9 | 2019-02-02 03:41:00 | [diff] [blame] | 255 | #include "components/services/heap_profiling/heap_profiling_service.h" |
| 256 | #include "components/services/heap_profiling/public/cpp/settings.h" |
erikchen | 0d4a601 | 2018-04-03 16:06:33 | [diff] [blame] | 257 | #include "components/services/heap_profiling/public/mojom/constants.mojom.h" |
Sergey Kuznetsov | ae59440 | 2019-04-19 16:08:05 | [diff] [blame] | 258 | #include "components/services/patch/public/interfaces/constants.mojom.h" |
Alexander Woolf | ed183c51 | 2019-05-17 01:18:03 | [diff] [blame] | 259 | #include "components/services/quarantine/public/mojom/quarantine.mojom.h" |
| 260 | #include "components/services/quarantine/quarantine_service.h" |
Colin Blundell | 6a897c7 | 2018-03-16 11:14:14 | [diff] [blame] | 261 | #include "components/services/unzip/public/interfaces/constants.mojom.h" |
Colin Blundell | 3517170e | 2019-07-11 08:16:34 | [diff] [blame] | 262 | #include "components/signin/public/base/account_consistency_method.h" |
| 263 | #include "components/signin/public/base/signin_pref_names.h" |
Scott Violet | d7983c5 | 2018-03-03 00:24:41 | [diff] [blame] | 264 | #include "components/spellcheck/spellcheck_buildflags.h" |
csharrison | e985ebc | 2017-04-04 17:05:03 | [diff] [blame] | 265 | #include "components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.h" |
[email protected] | eba93c9 | 2014-01-07 17:34:17 | [diff] [blame] | 266 | #include "components/translate/core/common/translate_switches.h" |
rsleevi | 24f64dc2 | 2015-08-07 21:39:21 | [diff] [blame] | 267 | #include "components/url_formatter/url_fixer.h" |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 268 | #include "components/variations/variations_associated_data.h" |
Jun Cai | 0e56863 | 2018-08-09 02:05:33 | [diff] [blame] | 269 | #include "components/variations/variations_http_header_provider.h" |
Kyle Milka | b5c048e | 2017-07-07 02:38:46 | [diff] [blame] | 270 | #include "components/variations/variations_switches.h" |
sdefresne | 9fb6769 | 2015-08-03 18:48:22 | [diff] [blame] | 271 | #include "components/version_info/version_info.h" |
[email protected] | e0ada9c | 2012-03-20 03:54:43 | [diff] [blame] | 272 | #include "content/public/browser/browser_child_process_host.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 273 | #include "content/public/browser/browser_main_parts.h" |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 274 | #include "content/public/browser/browser_ppapi_host.h" |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 275 | #include "content/public/browser/browser_task_traits.h" |
[email protected] | 30a306f4 | 2013-06-10 03:09:03 | [diff] [blame] | 276 | #include "content/public/browser/browser_thread.h" |
[email protected] | 825b166 | 2012-03-12 19:07:31 | [diff] [blame] | 277 | #include "content/public/browser/browser_url_handler.h" |
msramek | e169ccb | 2017-04-26 05:21:41 | [diff] [blame] | 278 | #include "content/public/browser/browsing_data_remover.h" |
Lucas Garron | b9539b73 | 2017-10-31 00:22:09 | [diff] [blame] | 279 | #include "content/public/browser/certificate_request_result_type.h" |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 280 | #include "content/public/browser/child_process_data.h" |
[email protected] | b953542 | 2012-02-09 01:47:59 | [diff] [blame] | 281 | #include "content/public/browser/child_process_security_policy.h" |
davidben | 3b8455ae7 | 2015-03-11 19:42:19 | [diff] [blame] | 282 | #include "content/public/browser/client_certificate_delegate.h" |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 283 | #include "content/public/browser/file_url_loader.h" |
Mohsen Izadi | 6a6476b7 | 2018-12-07 04:34:35 | [diff] [blame] | 284 | #include "content/public/browser/gpu_data_manager.h" |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 285 | #include "content/public/browser/navigation_handle.h" |
| 286 | #include "content/public/browser/navigation_throttle.h" |
Jennifer Apacible | 4f854a8 | 2018-04-06 22:22:11 | [diff] [blame] | 287 | #include "content/public/browser/overlay_window.h" |
[email protected] | 094c877 | 2013-12-21 17:54:50 | [diff] [blame] | 288 | #include "content/public/browser/render_frame_host.h" |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 289 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 290 | #include "content/public/browser/render_view_host.h" |
[email protected] | ce96786 | 2012-02-09 22:47:05 | [diff] [blame] | 291 | #include "content/public/browser/resource_context.h" |
jam | 608f299 | 2016-03-31 16:35:34 | [diff] [blame] | 292 | #include "content/public/browser/storage_partition.h" |
Katie D | 840d953 | 2018-11-27 06:20:48 | [diff] [blame] | 293 | #include "content/public/browser/tts_controller.h" |
Katie D | 4713ee4 | 2018-11-30 01:48:27 | [diff] [blame] | 294 | #include "content/public/browser/tts_platform.h" |
Jian Li | de7b4379 | 2018-06-01 23:22:13 | [diff] [blame] | 295 | #include "content/public/browser/url_loader_request_interceptor.h" |
adrian.belgun | 5b341c7 | 2016-06-22 22:24:08 | [diff] [blame] | 296 | #include "content/public/browser/vpn_service_proxy.h" |
[email protected] | 91ee368 | 2012-01-19 15:02:19 | [diff] [blame] | 297 | #include "content/public/browser/web_contents.h" |
Ryan Sturm | da2a0e0 | 2018-10-25 01:52:21 | [diff] [blame] | 298 | #include "content/public/browser/web_contents_delegate.h" |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 299 | #include "content/public/browser/web_ui_url_loader_factory.h" |
[email protected] | e0ada9c | 2012-03-20 03:54:43 | [diff] [blame] | 300 | #include "content/public/common/child_process_host.h" |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 301 | #include "content/public/common/content_descriptors.h" |
juncai | 1bf9f7c | 2016-03-22 20:46:56 | [diff] [blame] | 302 | #include "content/public/common/content_features.h" |
brettw | 90e9260 | 2015-10-10 00:12:40 | [diff] [blame] | 303 | #include "content/public/common/content_switches.h" |
John Abd-El-Malek | 27b3ebd2 | 2019-02-12 18:59:18 | [diff] [blame] | 304 | #include "content/public/common/network_service_util.h" |
ben | d32292b | 2016-10-07 00:21:58 | [diff] [blame] | 305 | #include "content/public/common/service_manager_connection.h" |
ben | 51bb6c6 | 2016-11-17 20:15:57 | [diff] [blame] | 306 | #include "content/public/common/service_names.mojom.h" |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 307 | #include "content/public/common/url_constants.h" |
yzshen | efcb7c7 | 2017-06-16 23:12:30 | [diff] [blame] | 308 | #include "content/public/common/url_loader_throttle.h" |
[email protected] | 22aa4f8 | 2013-09-24 17:01:44 | [diff] [blame] | 309 | #include "content/public/common/url_utils.h" |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 310 | #include "content/public/common/user_agent.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 311 | #include "content/public/common/web_preferences.h" |
Takuto Ikuta | aa3b796c | 2019-02-06 02:54:56 | [diff] [blame] | 312 | #include "content/public/common/window_container_type.mojom-shared.h" |
Bill Orr | eb42922 | 2018-08-08 21:14:43 | [diff] [blame] | 313 | #include "device/vr/buildflags/buildflags.h" |
Scott Violet | c8240b0 | 2018-03-08 22:03:59 | [diff] [blame] | 314 | #include "extensions/buildflags/buildflags.h" |
Alex Moshchuk | d252c19 | 2017-07-17 22:03:48 | [diff] [blame] | 315 | #include "google_apis/gaia/gaia_urls.h" |
Andrew Moylan | 17329fc | 2017-09-25 07:43:30 | [diff] [blame] | 316 | #include "google_apis/google_api_keys.h" |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 317 | #include "gpu/config/gpu_switches.h" |
grunell | 086a411 | 2017-03-02 09:23:04 | [diff] [blame] | 318 | #include "media/audio/audio_manager.h" |
François Beaufort | 8c08979fc | 2018-03-05 13:06:31 | [diff] [blame] | 319 | #include "media/base/media_switches.h" |
Scott Violet | a35f9a4 | 2018-03-22 22:00:44 | [diff] [blame] | 320 | #include "media/media_buildflags.h" |
| 321 | #include "media/mojo/buildflags.h" |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 322 | #include "mojo/public/cpp/bindings/binding_set.h" |
Ken Rockot | 40a1df79 | 2019-05-08 22:15:52 | [diff] [blame] | 323 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
| 324 | #include "mojo/public/cpp/bindings/pending_remote.h" |
Ken Rockot | 0adc1e4 | 2019-05-24 08:20:08 | [diff] [blame] | 325 | #include "mojo/public/cpp/bindings/remote.h" |
engedy | afef048 | 2017-07-06 15:40:53 | [diff] [blame] | 326 | #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
Bence Béky | 6b44abf | 2018-04-11 10:32:51 | [diff] [blame] | 327 | #include "net/base/load_flags.h" |
[email protected] | 3b45550 | 2012-12-11 18:22:58 | [diff] [blame] | 328 | #include "net/base/mime_util.h" |
[email protected] | 5b9bc35 | 2012-07-18 13:13:34 | [diff] [blame] | 329 | #include "net/cookies/canonical_cookie.h" |
[email protected] | aa84a7e | 2012-03-15 21:29:06 | [diff] [blame] | 330 | #include "net/cookies/cookie_options.h" |
John Abd-El-Malek | 7577f26 | 2019-06-10 21:23:23 | [diff] [blame] | 331 | #include "net/http/http_util.h" |
Jun Cai | 9409ded | 2018-01-30 00:19:46 | [diff] [blame] | 332 | #include "net/ssl/client_cert_store.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 333 | #include "net/ssl/ssl_cert_request_info.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 334 | #include "ppapi/buildflags/buildflags.h" |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 335 | #include "ppapi/host/ppapi_host.h" |
Scott Violet | 318a55f | 2018-03-30 19:08:19 | [diff] [blame] | 336 | #include "printing/buildflags/buildflags.h" |
Andrew Moylan | 8ed9d83c8 | 2019-01-29 20:23:52 | [diff] [blame] | 337 | #include "services/image_annotation/public/mojom/constants.mojom.h" |
| 338 | #include "services/image_annotation/public/mojom/image_annotation.mojom.h" |
Lukasz Anforowicz | 60d1253d | 2019-05-08 16:31:37 | [diff] [blame] | 339 | #include "services/network/public/cpp/is_potentially_trustworthy.h" |
Lukasz Anforowicz | 9527fd4 | 2019-03-13 19:08:50 | [diff] [blame] | 340 | #include "services/network/public/cpp/network_switches.h" |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 341 | #include "services/network/public/cpp/resource_request.h" |
Sam McNally | e36abbc | 2017-07-20 01:04:28 | [diff] [blame] | 342 | #include "services/preferences/public/cpp/in_process_service_factory.h" |
Ken Rockot | f7f533e | 2018-02-11 02:21:33 | [diff] [blame] | 343 | #include "services/preferences/public/mojom/preferences.mojom.h" |
Ken Rockot | 26cf474 | 2018-02-11 04:10:40 | [diff] [blame] | 344 | #include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h" |
Jay Civelli | 668c097f | 2018-05-16 20:44:13 | [diff] [blame] | 345 | #include "services/service_manager/embedder/switches.h" |
erikchen | a9db3a7 | 2018-04-12 16:24:00 | [diff] [blame] | 346 | #include "services/service_manager/public/cpp/connector.h" |
Ken Rockot | 543f5e3 | 2018-02-04 02:13:50 | [diff] [blame] | 347 | #include "services/service_manager/public/mojom/connector.mojom.h" |
Tom Sepez | 15d4e520 | 2017-09-27 23:59:05 | [diff] [blame] | 348 | #include "services/service_manager/sandbox/sandbox_type.h" |
Andrew Comminos | 6605767 | 2019-05-01 00:03:34 | [diff] [blame] | 349 | #include "services/service_manager/sandbox/switches.h" |
Ken Rockot | cebdf9c8 | 2019-05-28 20:33:03 | [diff] [blame] | 350 | #include "services/strings/grit/services_strings.h" |
Mohsen Izadi | 6a6476b7 | 2018-12-07 04:34:35 | [diff] [blame] | 351 | #include "services/viz/public/interfaces/constants.mojom.h" |
pilgrim | e92c5fcd | 2014-09-10 23:31:23 | [diff] [blame] | 352 | #include "storage/browser/fileapi/external_mount_points.h" |
John Delaney | ac24e57 | 2019-04-30 19:47:02 | [diff] [blame] | 353 | #include "third_party/blink/public/common/features.h" |
Julie Jeongeun Kim | d3d00a1 | 2019-03-25 01:46:25 | [diff] [blame] | 354 | #include "third_party/blink/public/mojom/installedapp/installed_app_provider.mojom.h" |
Leon Han | c819dc6 | 2019-01-28 04:30:19 | [diff] [blame] | 355 | #include "third_party/blink/public/mojom/renderer_preferences.mojom.h" |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 356 | #include "third_party/blink/public/mojom/user_agent/user_agent_metadata.mojom.h" |
Eric Willigers | 3eeae17c | 2019-03-13 17:32:10 | [diff] [blame] | 357 | #include "third_party/blink/public/mojom/webshare/webshare.mojom.h" |
Evan Liu | 7cdbf887 | 2019-06-19 16:47:21 | [diff] [blame] | 358 | #include "third_party/skia/include/core/SkColor.h" |
Xiaohan Wang | f170c73 | 2018-09-27 05:45:26 | [diff] [blame] | 359 | #include "third_party/widevine/cdm/buildflags.h" |
Scott Violet | b72577d | 2019-01-09 22:18:18 | [diff] [blame] | 360 | #include "ui/base/buildflags.h" |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 361 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 362 | #include "ui/base/resource/resource_bundle.h" |
Scott Violet | 8ff9c30 | 2018-02-22 22:28:35 | [diff] [blame] | 363 | #include "ui/base/ui_base_features.h" |
Evan Liu | 7cdbf887 | 2019-06-19 16:47:21 | [diff] [blame] | 364 | #include "ui/base/ui_base_switches.h" |
| 365 | #include "ui/gfx/color_utils.h" |
Elly Fong-Jones | f9289739 | 2019-01-24 16:05:49 | [diff] [blame] | 366 | #include "ui/native_theme/caption_style.h" |
| 367 | #include "ui/native_theme/native_theme.h" |
[email protected] | b47dc49 | 2014-08-17 07:05:57 | [diff] [blame] | 368 | #include "ui/resources/grit/ui_resources.h" |
jyasskin | 98bdd399 | 2016-02-26 20:25:45 | [diff] [blame] | 369 | #include "url/gurl.h" |
| 370 | #include "url/origin.h" |
[email protected] | d977f9c | 2011-03-14 16:10:26 | [diff] [blame] | 371 | |
Ken Rockot | 69aade0 | 2019-01-23 21:19:51 | [diff] [blame] | 372 | #if BUILDFLAG(ENABLE_NACL) |
| 373 | #include "components/nacl/loader/nacl_loader_manifest.h" |
| 374 | #if defined(OS_WIN) && defined(ARCH_CPU_X86) |
| 375 | #include "components/nacl/broker/nacl_broker_manifest.h" |
| 376 | #endif |
| 377 | #endif |
| 378 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 379 | #if defined(OS_WIN) |
wfh | c91e967 | 2016-01-27 00:14:20 | [diff] [blame] | 380 | #include "base/strings/string_tokenizer.h" |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 381 | #include "chrome/browser/chrome_browser_main_win.h" |
Patrick Monette | bb54394 | 2019-05-17 17:45:32 | [diff] [blame] | 382 | #include "chrome/browser/win/conflicts/module_database.h" |
| 383 | #include "chrome/browser/win/conflicts/module_event_sink_impl.h" |
Jerry Lin | a0de7ce | 2018-06-22 15:18:36 | [diff] [blame] | 384 | #include "chrome/install_static/install_util.h" |
Ken Rockot | c74e379 | 2018-02-10 16:31:30 | [diff] [blame] | 385 | #include "chrome/services/util_win/public/mojom/constants.mojom.h" |
Ken Rockot | fba9e74 | 2018-02-10 16:36:20 | [diff] [blame] | 386 | #include "chrome/services/wifi_util_win/public/mojom/constants.mojom.h" |
Ken Rockot | 7c16850 | 2019-05-30 07:58:46 | [diff] [blame] | 387 | #include "components/services/quarantine/public/cpp/quarantine_features_win.h" |
[email protected] | 34f4868 | 2013-03-20 00:30:18 | [diff] [blame] | 388 | #include "sandbox/win/src/sandbox_policy.h" |
[email protected] | 199fc7a | 2011-09-28 22:45:38 | [diff] [blame] | 389 | #elif defined(OS_MACOSX) |
| 390 | #include "chrome/browser/chrome_browser_main_mac.h" |
Guido Urdaneta | 1a291743 | 2018-05-10 18:32:32 | [diff] [blame] | 391 | #include "services/audio/public/mojom/constants.mojom.h" |
Guido Urdaneta | 191635e | 2018-05-09 16:00:53 | [diff] [blame] | 392 | #include "services/video_capture/public/mojom/constants.mojom.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 393 | #elif defined(OS_CHROMEOS) |
Scott Violet | 776edf8 | 2017-09-29 02:03:01 | [diff] [blame] | 394 | #include "ash/public/interfaces/constants.mojom.h" |
Scott Violet | 47f00e5 | 2018-05-04 22:50:31 | [diff] [blame] | 395 | #include "chrome/browser/ash_service_registry.h" |
hashimoto | a53e7e8 | 2016-10-26 06:30:47 | [diff] [blame] | 396 | #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_backend_delegate.h" |
nya | f5df1e3 | 2016-12-14 04:36:17 | [diff] [blame] | 397 | #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_backend_delegate.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 398 | #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
Ahmed Fakhry | d70bf37b | 2018-04-04 17:07:24 | [diff] [blame] | 399 | #include "chrome/browser/chromeos/chrome_content_browser_client_chromeos_part.h" |
Scott Violet | ef765b9 | 2017-06-09 21:26:36 | [diff] [blame] | 400 | #include "chrome/browser/chromeos/chrome_service_name.h" |
Sam McNally | d8b7d82 | 2018-08-21 03:18:18 | [diff] [blame] | 401 | #include "chrome/browser/chromeos/drive/fileapi/drivefs_file_system_backend_delegate.h" |
[email protected] | 07fe275 | 2014-01-29 11:21:55 | [diff] [blame] | 402 | #include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h" |
[email protected] | 5bc61cad | 2014-07-08 05:05:08 | [diff] [blame] | 403 | #include "chrome/browser/chromeos/file_manager/app_id.h" |
[email protected] | 43420a1 | 2014-04-21 03:20:48 | [diff] [blame] | 404 | #include "chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.h" |
Robbie McElrath | 6a45ea6 | 2018-12-05 06:53:41 | [diff] [blame] | 405 | #include "chrome/browser/chromeos/fileapi/external_file_url_loader_factory.h" |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 406 | #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
[email protected] | bee0df31 | 2014-04-28 06:59:58 | [diff] [blame] | 407 | #include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h" |
clamy | 4967831 | 2015-10-22 21:59:00 | [diff] [blame] | 408 | #include "chrome/browser/chromeos/login/signin/merge_session_navigation_throttle.h" |
| 409 | #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 410 | #include "chrome/browser/chromeos/login/signin_partition_manager.h" |
[email protected] | 5c91525 | 2013-05-07 13:15:39 | [diff] [blame] | 411 | #include "chrome/browser/chromeos/login/startup_utils.h" |
edwardjung | 7db1c9e | 2015-03-25 15:44:31 | [diff] [blame] | 412 | #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
John Abd-El-Malek | 21bca7c | 2018-10-26 22:13:33 | [diff] [blame] | 413 | #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
Luum Habtemariam | ce0d1a9 | 2019-06-21 03:26:52 | [diff] [blame] | 414 | #include "chrome/browser/chromeos/printing/cups_proxy_service_delegate_impl.h" |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 415 | #include "chrome/browser/chromeos/profiles/profile_helper.h" |
[email protected] | c94ac69 | 2013-07-27 00:50:10 | [diff] [blame] | 416 | #include "chrome/browser/chromeos/system/input_device_settings.h" |
Katie D | b2d0709 | 2018-12-04 18:59:36 | [diff] [blame] | 417 | #include "chrome/browser/speech/tts_chromeos.h" |
Steven Bennetts | 81d07be | 2018-01-08 20:45:27 | [diff] [blame] | 418 | #include "chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.h" |
Huanzhong Huang | afa9809 | 2019-06-24 12:01:24 | [diff] [blame] | 419 | #include "chrome/browser/ui/ash/tablet_mode_client.h" |
djacobo | 21e56e0 | 2016-07-02 01:14:31 | [diff] [blame] | 420 | #include "chrome/browser/ui/browser_dialogs.h" |
Luum Habtemariam | c295b4ea | 2019-04-24 20:18:51 | [diff] [blame] | 421 | #include "chrome/services/cups_proxy/cups_proxy_service.h" |
| 422 | #include "chrome/services/cups_proxy/public/mojom/constants.mojom.h" |
Steven Bennetts | 38e9bde2 | 2019-01-03 17:31:10 | [diff] [blame] | 423 | #include "chromeos/constants/chromeos_constants.h" |
Kyle Horimoto | 1d6a679f | 2019-04-16 23:24:21 | [diff] [blame] | 424 | #include "chromeos/constants/chromeos_features.h" |
Steven Bennetts | 38e9bde2 | 2019-01-03 17:31:10 | [diff] [blame] | 425 | #include "chromeos/constants/chromeos_switches.h" |
Kyle Horimoto | 1d6a679f | 2019-04-16 23:24:21 | [diff] [blame] | 426 | #include "chromeos/services/cellular_setup/cellular_setup_service.h" |
| 427 | #include "chromeos/services/cellular_setup/public/mojom/cellular_setup.mojom.h" |
| 428 | #include "chromeos/services/cellular_setup/public/mojom/constants.mojom.h" |
Leo Zhang | 84ce09e9 | 2018-08-25 01:55:36 | [diff] [blame] | 429 | #include "chromeos/services/ime/public/mojom/constants.mojom.h" |
Steven Bennetts | 0c565d5b | 2019-04-24 23:52:45 | [diff] [blame] | 430 | #include "chromeos/services/network_config/network_config_service.h" |
| 431 | #include "chromeos/services/network_config/public/mojom/constants.mojom.h" |
Ryan Hansberry | 9a08623c | 2018-06-14 21:28:05 | [diff] [blame] | 432 | #include "chromeos/services/secure_channel/public/mojom/constants.mojom.h" |
| 433 | #include "chromeos/services/secure_channel/secure_channel_service.h" |
Ian Barkley-Yeung | 550aae05 | 2019-07-11 00:11:11 | [diff] [blame] | 434 | #include "components/crash/content/app/breakpad_linux.h" |
[email protected] | 4d39078 | 2014-08-15 09:22:58 | [diff] [blame] | 435 | #include "components/user_manager/user_manager.h" |
Ken Rockot | 543f5e3 | 2018-02-04 02:13:50 | [diff] [blame] | 436 | #include "services/service_manager/public/mojom/interface_provider_spec.mojom.h" |
[email protected] | 81ce2c4 | 2012-03-24 01:43:26 | [diff] [blame] | 437 | #elif defined(OS_LINUX) |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 438 | #include "chrome/browser/chrome_browser_main_linux.h" |
[email protected] | 81054f81 | 2012-08-30 00:47:09 | [diff] [blame] | 439 | #elif defined(OS_ANDROID) |
Bo Liu | 4ade6b1b2 | 2017-11-28 02:26:35 | [diff] [blame] | 440 | #include "base/android/application_status_listener.h" |
zqzhang | 93e959d1 | 2017-03-16 13:10:20 | [diff] [blame] | 441 | #include "chrome/browser/android/app_hooks.h" |
Scott Violet | ef765b9 | 2017-06-09 21:26:36 | [diff] [blame] | 442 | #include "chrome/browser/android/chrome_context_util.h" |
| 443 | #include "chrome/browser/android/devtools_manager_delegate_android.h" |
Dan Harrington | 964d48c | 2018-08-03 15:52:24 | [diff] [blame] | 444 | #include "chrome/browser/android/download/available_offline_content_provider.h" |
Min Qin | 0ab0e16 | 2017-11-14 21:57:19 | [diff] [blame] | 445 | #include "chrome/browser/android/download/intercept_oma_download_navigation_throttle.h" |
Scott Violet | ef765b9 | 2017-06-09 21:26:36 | [diff] [blame] | 446 | #include "chrome/browser/android/ntp/new_tab_page_url_handler.h" |
| 447 | #include "chrome/browser/android/service_tab_launcher.h" |
| 448 | #include "chrome/browser/android/tab_android.h" |
Jinsuk Kim | a3d393ce | 2019-05-27 00:57:42 | [diff] [blame] | 449 | #include "chrome/browser/android/tab_web_contents_delegate_android.h" |
Scott Violet | ef765b9 | 2017-06-09 21:26:36 | [diff] [blame] | 450 | #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" |
[email protected] | 81054f81 | 2012-08-30 00:47:09 | [diff] [blame] | 451 | #include "chrome/browser/chrome_browser_main_android.h" |
Dan Harrington | 954c882 | 2019-01-09 18:40:48 | [diff] [blame] | 452 | #include "chrome/browser/offline_pages/android/offline_page_auto_fetcher.h" |
Jinsuk Kim | 6f9253c | 2019-03-11 02:45:07 | [diff] [blame] | 453 | #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
James Cook | 01e3e5ef | 2019-04-09 14:44:38 | [diff] [blame] | 454 | #include "chrome/common/chrome_descriptors.h" |
Xing Liu | 302e065 | 2018-04-27 18:23:08 | [diff] [blame] | 455 | #include "chrome/services/media_gallery_util/public/mojom/constants.mojom.h" |
Joshua Peraza | 934e559 | 2018-07-18 23:43:11 | [diff] [blame] | 456 | #include "components/crash/content/browser/child_exit_observer_android.h" |
Yuzu Saijo | 2d12ef9 | 2018-08-21 04:52:07 | [diff] [blame] | 457 | #include "components/crash/content/browser/crash_memory_metrics_collector_android.h" |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 458 | #include "components/navigation_interception/intercept_navigation_delegate.h" |
Scott Violet | ef765b9 | 2017-06-09 21:26:36 | [diff] [blame] | 459 | #include "content/public/browser/android/java_interfaces.h" |
Jay Civelli | 2df2464 | 2017-10-09 20:22:28 | [diff] [blame] | 460 | #include "services/proxy_resolver/proxy_resolver_service.h" |
mfomitchev | 220b856 | 2017-07-13 23:08:54 | [diff] [blame] | 461 | #include "services/service_manager/public/cpp/interface_provider.h" |
Han Leon | abbe7c90 | 2018-08-30 02:08:10 | [diff] [blame] | 462 | #include "third_party/blink/public/mojom/payments/payment_request.mojom.h" |
Julie Jeongeun Kim | b6a0a1f | 2019-03-21 05:08:26 | [diff] [blame] | 463 | #include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h" |
agrieve | 05398f5 | 2015-06-24 18:59:00 | [diff] [blame] | 464 | #include "ui/base/resource/resource_bundle_android.h" |
Scott Violet | ef765b9 | 2017-06-09 21:26:36 | [diff] [blame] | 465 | #include "ui/base/ui_base_paths.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 466 | #elif defined(OS_POSIX) |
| 467 | #include "chrome/browser/chrome_browser_main_posix.h" |
| 468 | #endif |
| 469 | |
tmartino | fb34188 | 2017-02-10 19:36:53 | [diff] [blame] | 470 | #if !defined(OS_ANDROID) |
Jay Harris | 1ddcffa | 2019-07-09 03:07:40 | [diff] [blame] | 471 | #include "chrome/browser/badging/badge_manager.h" |
Scott Violet | ef765b9 | 2017-06-09 21:26:36 | [diff] [blame] | 472 | #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" |
Dmitry Gozman | 57b92ce | 2017-12-28 22:24:54 | [diff] [blame] | 473 | #include "chrome/browser/devtools/devtools_window.h" |
Becca Hughes | 7d2bbb8 | 2018-08-07 22:56:59 | [diff] [blame] | 474 | #include "chrome/browser/media/unified_autoplay_config.h" |
mathp | f709499d | 2017-01-09 20:48:36 | [diff] [blame] | 475 | #include "chrome/browser/payments/payment_request_factory.h" |
Marc Treib | 7895941d | 2017-11-28 12:37:02 | [diff] [blame] | 476 | #include "chrome/browser/search/instant_service.h" |
| 477 | #include "chrome/browser/search/instant_service_factory.h" |
Reilly Grant | 2814fb7 | 2019-03-19 17:04:46 | [diff] [blame] | 478 | #include "chrome/browser/serial/chrome_serial_delegate.h" |
Collin Baker | 8a21755 | 2019-05-29 19:47:51 | [diff] [blame] | 479 | #include "chrome/browser/ui/browser.h" |
| 480 | #include "chrome/browser/ui/browser_finder.h" |
| 481 | #include "chrome/browser/ui/browser_list.h" |
| 482 | #include "chrome/browser/ui/browser_window.h" |
jdoerrie | 4f9376f | 2018-12-12 18:26:20 | [diff] [blame] | 483 | #include "chrome/browser/ui/passwords/google_password_manager_navigation_throttle.h" |
Conley Owens | aafcf12 | 2018-02-26 18:53:51 | [diff] [blame] | 484 | #include "chrome/browser/ui/search/new_tab_page_navigation_throttle.h" |
Jay Civelli | 4d53be9b | 2017-08-31 22:01:43 | [diff] [blame] | 485 | #include "chrome/common/importer/profile_import.mojom.h" |
Austin Orion | e250d01 | 2019-05-29 02:56:27 | [diff] [blame] | 486 | #include "chrome/grit/chrome_unscaled_resources.h" |
Maggie Cai | a2f03f5 | 2019-04-02 02:13:28 | [diff] [blame] | 487 | #endif // !defined(OS_ANDROID) |
mathp | f709499d | 2017-01-09 20:48:36 | [diff] [blame] | 488 | |
Nicolas Ouellet-Payeur | bdcab009 | 2018-10-22 14:50:33 | [diff] [blame] | 489 | #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 490 | (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
Nicolas Ouellet-Payeur | 4b840a9 | 2018-09-18 14:46:52 | [diff] [blame] | 491 | #include "chrome/browser/browser_switcher/browser_switcher_navigation_throttle.h" |
| 492 | #endif |
| 493 | |
[email protected] | a220b593 | 2013-09-21 03:47:44 | [diff] [blame] | 494 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
Joshua Peraza | f890e4b | 2019-01-03 19:19:02 | [diff] [blame] | 495 | #if !defined(OS_ANDROID) |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 496 | #include "base/debug/leak_annotations.h" |
sdefresne | 8ba0b88c | 2015-09-18 10:33:13 | [diff] [blame] | 497 | #include "components/crash/content/app/breakpad_linux.h" |
Joshua Peraza | f890e4b | 2019-01-03 19:19:02 | [diff] [blame] | 498 | #endif // !defined(OS_ANDROID) |
sdefresne | 8ba0b88c | 2015-09-18 10:33:13 | [diff] [blame] | 499 | #include "components/crash/content/browser/crash_handler_host_linux.h" |
[email protected] | 1fd5302c | 2011-05-28 04:06:43 | [diff] [blame] | 500 | #endif |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 501 | |
Maggie Cai | a2f03f5 | 2019-04-02 02:13:28 | [diff] [blame] | 502 | // TODO(crbug.com/939205): Once the upcoming App Service is available, use a |
| 503 | // single navigation throttle to display the intent picker on all platforms. |
| 504 | #if !defined(OS_ANDROID) |
| 505 | #if defined(OS_CHROMEOS) |
| 506 | #include "chrome/browser/chromeos/apps/intent_helper/chromeos_apps_navigation_throttle.h" |
| 507 | #else |
| 508 | #include "chrome/browser/apps/intent_helper/apps_navigation_throttle.h" |
| 509 | #endif |
| 510 | #endif |
| 511 | |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 512 | #if defined(TOOLKIT_VIEWS) |
| 513 | #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" |
| 514 | #endif |
| 515 | |
estade | d3aa0e8 | 2016-02-17 22:55:21 | [diff] [blame] | 516 | #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
Maksim Sisov | 1f2f2e6 | 2019-05-08 07:56:22 | [diff] [blame] | 517 | #if defined(USE_X11) |
| 518 | #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views_linux_x11.h" |
| 519 | #else |
estade | d3aa0e8 | 2016-02-17 22:55:21 | [diff] [blame] | 520 | #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views_linux.h" |
Maksim Sisov | 1f2f2e6 | 2019-05-08 07:56:22 | [diff] [blame] | 521 | #endif // USE_X11 |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 522 | #endif |
| 523 | |
Mohsen Izadi | f1958f2 | 2019-01-18 20:29:31 | [diff] [blame] | 524 | #if defined(USE_OZONE) |
| 525 | #include "ui/ozone/public/ozone_platform.h" |
| 526 | #endif |
| 527 | |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 528 | #if defined(USE_X11) |
| 529 | #include "chrome/browser/chrome_browser_main_extra_parts_x11.h" |
| 530 | #endif |
| 531 | |
brettw | ab78fef | 2016-10-12 02:56:05 | [diff] [blame] | 532 | #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
[email protected] | 7a2a6d80 | 2014-06-06 13:39:19 | [diff] [blame] | 533 | #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 534 | #endif |
| 535 | |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 536 | #if BUILDFLAG(ENABLE_NACL) |
[email protected] | a56f832 | 2014-07-16 21:13:55 | [diff] [blame] | 537 | #include "components/nacl/browser/nacl_browser.h" |
| 538 | #include "components/nacl/browser/nacl_host_message_filter.h" |
| 539 | #include "components/nacl/browser/nacl_process_host.h" |
| 540 | #include "components/nacl/common/nacl_process_type.h" |
| 541 | #include "components/nacl/common/nacl_switches.h" |
| 542 | #endif |
| 543 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 544 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
je_julie.kim | 7fbb5a1a | 2015-02-09 17:26:05 | [diff] [blame] | 545 | #include "chrome/browser/accessibility/animation_policy_prefs.h" |
Dominick Ng | 6ff5105 | 2018-07-06 05:30:20 | [diff] [blame] | 546 | #include "chrome/browser/apps/platform_apps/platform_app_navigation_redirector.h" |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 547 | #include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h" |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 548 | #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
Clark DuVall | 2cf99249e | 2018-09-19 19:11:51 | [diff] [blame] | 549 | #include "chrome/browser/extensions/user_script_listener.h" |
| 550 | #include "chrome/browser/media/cast_transport_host_filter.h" |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 551 | #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
Giovanni Ortuño Urquidi | d231ca3 | 2018-05-14 04:20:53 | [diff] [blame] | 552 | #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h" |
Ken Rockot | 551f748 | 2018-02-10 11:18:46 | [diff] [blame] | 553 | #include "chrome/services/media_gallery_util/public/mojom/constants.mojom.h" |
Ken Rockot | 2ad4db3 | 2018-02-10 16:24:10 | [diff] [blame] | 554 | #include "chrome/services/removable_storage_writer/public/mojom/constants.mojom.h" |
fsamuel | 8dfa19a | 2015-05-05 01:00:39 | [diff] [blame] | 555 | #include "components/guest_view/browser/guest_view_base.h" |
| 556 | #include "components/guest_view/browser/guest_view_manager.h" |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 557 | #include "extensions/browser/api/web_request/web_request_api.h" |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 558 | #include "extensions/browser/extension_host.h" |
nasko | b9164c4 | 2016-06-07 01:21:35 | [diff] [blame] | 559 | #include "extensions/browser/extension_navigation_throttle.h" |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 560 | #include "extensions/browser/extension_protocols.h" |
reillyg | a3acbc1 | 2014-11-11 23:17:12 | [diff] [blame] | 561 | #include "extensions/browser/extension_registry.h" |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 562 | #include "extensions/browser/extension_system.h" |
tfarina | 01710e3 | 2015-07-13 21:53:22 | [diff] [blame] | 563 | #include "extensions/browser/extension_util.h" |
hanxi | 0d0a1e9 | 2014-08-26 18:39:48 | [diff] [blame] | 564 | #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 565 | #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" |
| 566 | #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 567 | #include "extensions/browser/process_manager.h" |
Dan Beam | 836c02a | 2019-06-15 01:58:27 | [diff] [blame] | 568 | #include "extensions/common/constants.h" |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 569 | #include "extensions/common/extension.h" |
| 570 | #include "extensions/common/extension_set.h" |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 571 | #include "extensions/common/manifest_handlers/background_info.h" |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 572 | #include "extensions/common/manifest_handlers/shared_module_info.h" |
Clark DuVall | bf7722f | 2018-08-03 18:03:33 | [diff] [blame] | 573 | #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 574 | #include "extensions/common/permissions/permissions_data.h" |
| 575 | #include "extensions/common/permissions/socket_permission.h" |
| 576 | #include "extensions/common/switches.h" |
thakis | 678822e | 2017-04-20 17:20:34 | [diff] [blame] | 577 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
merkin | db10455e | 2017-02-28 13:16:25 | [diff] [blame] | 578 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 579 | #if BUILDFLAG(ENABLE_PLUGINS) |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 580 | #include "chrome/browser/plugins/chrome_content_browser_client_plugins_part.h" |
trizzofo | 8ddaeb7 | 2016-09-01 23:18:27 | [diff] [blame] | 581 | #include "chrome/browser/plugins/flash_download_interception.h" |
John Abd-El-Malek | ecc6f5f | 2018-03-02 18:47:39 | [diff] [blame] | 582 | #include "chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.h" |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 583 | #endif |
| 584 | |
bauerb | 8f9c3774 | 2017-03-30 15:04:12 | [diff] [blame] | 585 | #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 586 | #include "chrome/browser/supervised_user/supervised_user_google_auth_navigation_throttle.h" |
| 587 | #endif |
| 588 | |
thakis | 678822e | 2017-04-20 17:20:34 | [diff] [blame] | 589 | #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
miu | 54dca6c | 2016-11-17 10:59:38 | [diff] [blame] | 590 | #include "chrome/browser/media/cast_remoting_connector.h" |
haibinlu | 9e605a9 | 2015-06-06 03:45:09 | [diff] [blame] | 591 | #endif |
| 592 | |
weili | fabbf757 | 2017-05-22 19:05:16 | [diff] [blame] | 593 | #if BUILDFLAG(ENABLE_PRINTING) |
Lei Zhang | a2fa14c | 2018-05-15 00:05:21 | [diff] [blame] | 594 | #include "chrome/browser/printing/printing_message_filter.h" |
Colin Blundell | 00b00a8 | 2018-05-24 10:22:16 | [diff] [blame] | 595 | #include "components/services/pdf_compositor/public/interfaces/pdf_compositor.mojom.h" |
weili | fabbf757 | 2017-05-22 19:05:16 | [diff] [blame] | 596 | #endif |
Lei Zhang | a2fa14c | 2018-05-15 00:05:21 | [diff] [blame] | 597 | |
| 598 | #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ |
| 599 | (BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)) |
Ken Rockot | ed7f41b | 2018-02-10 16:19:10 | [diff] [blame] | 600 | #include "chrome/services/printing/public/mojom/constants.mojom.h" |
Jay Civelli | 9237eac | 2017-09-21 16:10:21 | [diff] [blame] | 601 | #endif |
weili | fabbf757 | 2017-05-22 19:05:16 | [diff] [blame] | 602 | |
Xiaohan Wang | a4e4184 | 2018-06-26 18:45:10 | [diff] [blame] | 603 | #if BUILDFLAG(ENABLE_LIBRARY_CDMS) |
xhwang | c86d76e4 | 2016-03-14 23:38:49 | [diff] [blame] | 604 | #include "chrome/browser/media/output_protection_impl.h" |
Xiaohan Wang | a4e4184 | 2018-06-26 18:45:10 | [diff] [blame] | 605 | #include "chrome/browser/media/platform_verification_impl.h" |
Xiaohan Wang | f170c73 | 2018-09-27 05:45:26 | [diff] [blame] | 606 | #if defined(OS_WIN) && BUILDFLAG(ENABLE_WIDEVINE) |
Xiaohan Wang | a4e4184 | 2018-06-26 18:45:10 | [diff] [blame] | 607 | #include "chrome/browser/media/widevine_hardware_caps_win.h" |
| 608 | #include "third_party/widevine/cdm/widevine_cdm_common.h" |
| 609 | #endif |
| 610 | #endif |
| 611 | |
xhwang | db24d60 | 2017-05-20 06:32:24 | [diff] [blame] | 612 | #if BUILDFLAG(ENABLE_MOJO_CDM) && defined(OS_ANDROID) |
xhwang | 116acb9 | 2017-04-03 18:27:20 | [diff] [blame] | 613 | #include "chrome/browser/media/android/cdm/media_drm_storage_factory.h" |
| 614 | #endif |
xhwang | c86d76e4 | 2016-03-14 23:38:49 | [diff] [blame] | 615 | |
xhwang | db24d60 | 2017-05-20 06:32:24 | [diff] [blame] | 616 | #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
Xiaohan Wang | 3fcfc15 | 2017-07-06 00:51:55 | [diff] [blame] | 617 | #include "media/mojo/interfaces/constants.mojom.h" // nogncheck |
xhwang | b1d65fd | 2016-10-19 20:55:52 | [diff] [blame] | 618 | #include "media/mojo/services/media_service_factory.h" // nogncheck |
alokp | 6ecb238 | 2016-01-27 00:40:00 | [diff] [blame] | 619 | #endif |
| 620 | |
mmenke | db2637ff | 2017-03-30 23:59:42 | [diff] [blame] | 621 | #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 622 | #include "chrome/browser/supervised_user/supervised_user_navigation_throttle.h" |
| 623 | #endif |
| 624 | |
Luum Habtemariam | 7f7c6175 | 2018-07-18 00:41:18 | [diff] [blame] | 625 | #if BUILDFLAG(ENABLE_PRINTING) && defined(OS_CHROMEOS) |
Luum Habtemariam | c295b4ea | 2019-04-24 20:18:51 | [diff] [blame] | 626 | // TODO(crbug.com/948800): Doesn't match BUILD.gn of use_cups && is_chromeos. |
Luum Habtemariam | 9d99993 | 2018-10-15 23:04:12 | [diff] [blame] | 627 | #include "chrome/services/cups_ipp_parser/public/mojom/constants.mojom.h" |
Luum Habtemariam | 7f7c6175 | 2018-07-18 00:41:18 | [diff] [blame] | 628 | #endif |
| 629 | |
Daniel Rubery | a1611e3 | 2019-04-24 21:38:35 | [diff] [blame] | 630 | #if defined(FULL_SAFE_BROWSING) |
| 631 | #include "chrome/browser/safe_browsing/chrome_password_protection_service.h" |
| 632 | #endif |
| 633 | |
Jay Civelli | d5b61433 | 2017-11-10 03:37:05 | [diff] [blame] | 634 | #if defined(FULL_SAFE_BROWSING) || defined(OS_CHROMEOS) |
Ken Rockot | 3d36668 | 2018-02-10 11:13:26 | [diff] [blame] | 635 | #include "chrome/services/file_util/public/mojom/constants.mojom.h" |
Jay Civelli | d5b61433 | 2017-11-10 03:37:05 | [diff] [blame] | 636 | #endif |
| 637 | |
Jian Li | de7b4379 | 2018-06-01 23:22:13 | [diff] [blame] | 638 | #if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 639 | #include "chrome/browser/offline_pages/offline_page_tab_helper.h" |
Jian Li | de7b4379 | 2018-06-01 23:22:13 | [diff] [blame] | 640 | #include "chrome/browser/offline_pages/offline_page_url_loader_request_interceptor.h" |
| 641 | #endif |
| 642 | |
Ken Rockot | 80b08e9 | 2018-08-15 04:22:02 | [diff] [blame] | 643 | #if BUILDFLAG(ENABLE_SIMPLE_BROWSER_SERVICE_IN_PROCESS) |
| 644 | #include "services/content/simple_browser/public/mojom/constants.mojom.h" |
| 645 | #include "services/content/simple_browser/simple_browser_service.h" |
| 646 | #endif |
| 647 | |
| 648 | #if BUILDFLAG(ENABLE_SIMPLE_BROWSER_SERVICE_OUT_OF_PROCESS) |
Ken Rockot | 99c5bc74 | 2018-07-12 15:36:56 | [diff] [blame] | 649 | #include "services/content/simple_browser/public/mojom/constants.mojom.h" |
| 650 | #endif |
| 651 | |
Will Cassella | 40837ba | 2019-07-01 21:32:00 | [diff] [blame] | 652 | #if BUILDFLAG(ENABLE_VR) && !defined(OS_ANDROID) |
Bill Orr | eb42922 | 2018-08-08 21:14:43 | [diff] [blame] | 653 | #include "device/vr/public/mojom/isolated_xr_service.mojom.h" |
| 654 | #endif |
| 655 | |
Michael Thiessen | 909ba03 | 2019-03-26 23:47:43 | [diff] [blame] | 656 | #if defined(BROWSER_MEDIA_CONTROLS_MENU) |
| 657 | #include "third_party/blink/public/mojom/media_controls/touchless/media_controls.mojom.h" |
| 658 | #endif |
| 659 | |
Michael Thiessen | 07c444c | 2019-04-26 03:53:11 | [diff] [blame] | 660 | #if defined(ENABLE_SPATIAL_NAVIGATION_HOST) |
| 661 | #include "third_party/blink/public/mojom/page/spatial_navigation.mojom.h" |
| 662 | #endif |
| 663 | |
[email protected] | c7abd42 | 2012-09-25 00:20:08 | [diff] [blame] | 664 | using base::FileDescriptor; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 665 | using content::BrowserThread; |
[email protected] | 825b166 | 2012-03-12 19:07:31 | [diff] [blame] | 666 | using content::BrowserURLHandler; |
msramek | a3c7cfd | 2017-02-03 13:34:13 | [diff] [blame] | 667 | using content::BrowsingDataFilterBuilder; |
[email protected] | b953542 | 2012-02-09 01:47:59 | [diff] [blame] | 668 | using content::ChildProcessSecurityPolicy; |
[email protected] | 9f9749a | 2012-03-02 19:37:00 | [diff] [blame] | 669 | using content::QuotaPermissionContext; |
[email protected] | 2626d14 | 2014-04-22 17:24:02 | [diff] [blame] | 670 | using content::RenderFrameHost; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 671 | using content::RenderViewHost; |
[email protected] | 7491ad0 | 2014-07-05 19:10:07 | [diff] [blame] | 672 | using content::ResourceType; |
[email protected] | b658359 | 2012-01-25 19:52:33 | [diff] [blame] | 673 | using content::SiteInstance; |
[email protected] | 83ff91c | 2012-01-05 20:54:13 | [diff] [blame] | 674 | using content::WebContents; |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 675 | using content::WebPreferences; |
[email protected] | 593d2a7 | 2013-07-26 08:48:38 | [diff] [blame] | 676 | using message_center::NotifierId; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 677 | |
[email protected] | 0daaebfe | 2014-03-15 00:09:05 | [diff] [blame] | 678 | #if defined(OS_POSIX) |
brettw | 3c98c7d3 | 2017-07-25 01:44:20 | [diff] [blame] | 679 | using content::PosixFileDescriptorInfo; |
[email protected] | 0daaebfe | 2014-03-15 00:09:05 | [diff] [blame] | 680 | #endif |
| 681 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 682 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 683 | using extensions::APIPermission; |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 684 | using extensions::ChromeContentBrowserClientExtensionsPart; |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 685 | using extensions::Extension; |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 686 | using extensions::Manifest; |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 687 | #endif |
| 688 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 689 | #if BUILDFLAG(ENABLE_PLUGINS) |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 690 | using plugins::ChromeContentBrowserClientPluginsPart; |
| 691 | #endif |
| 692 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 693 | namespace { |
| 694 | |
michaeln | 10e5fc35 | 2017-02-07 02:07:58 | [diff] [blame] | 695 | const storage::QuotaSettings* g_default_quota_settings; |
| 696 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 697 | #if BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | aec5ed5 | 2014-06-20 07:51:42 | [diff] [blame] | 698 | // TODO(teravest): Add renderer-side API-specific checking for these APIs so |
| 699 | // that blanket permission isn't granted to all dev channel APIs for these. |
| 700 | // http://crbug.com/386743 |
| 701 | const char* const kPredefinedAllowedDevChannelOrigins[] = { |
| 702 | "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/383937 |
| 703 | "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/383937 |
| 704 | }; |
| 705 | |
[email protected] | 9de4da5 | 2014-05-24 12:26:50 | [diff] [blame] | 706 | const char* const kPredefinedAllowedFileHandleOrigins[] = { |
[email protected] | 10c3922 | 2013-11-13 20:09:25 | [diff] [blame] | 707 | "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/234789 |
| 708 | "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/234789 |
| 709 | }; |
| 710 | |
[email protected] | 9de4da5 | 2014-05-24 12:26:50 | [diff] [blame] | 711 | const char* const kPredefinedAllowedSocketOrigins[] = { |
Mike Frysinger | a9864c6a | 2017-12-18 22:12:31 | [diff] [blame] | 712 | "okddffdblfhhnmhodogpojmfkjmhinfp", // Secure Shell App (dev) |
| 713 | "pnhechapfaindjhompbnflcldabbghjo", // Secure Shell App (stable) |
| 714 | "algkcnfjnajfhgimadimbjhmpaeohhln", // Secure Shell Extension (dev) |
| 715 | "iodihamcpbpeioajjeobimgagajmlibd", // Secure Shell Extension (stable) |
[email protected] | 9913268 | 2012-04-24 19:00:45 | [diff] [blame] | 716 | "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126 |
| 717 | "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop |
| 718 | "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop |
| 719 | "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop |
[email protected] | a450b6be | 2012-05-22 19:30:35 | [diff] [blame] | 720 | "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary |
[email protected] | 9040a0c2 | 2012-06-22 19:06:54 | [diff] [blame] | 721 | "cbkkbcmdlboombapidmoeolnmdacpkch", // see crbug.com/129089 |
| 722 | "hhnbmknkdabfoieppbbljkhkfjcmcbjh", // see crbug.com/134099 |
| 723 | "mablfbjkhmhkmefkjjacnbaikjkipphg", // see crbug.com/134099 |
| 724 | "pdeelgamlgannhelgoegilelnnojegoh", // see crbug.com/134099 |
| 725 | "cabapfdbkniadpollkckdnedaanlciaj", // see crbug.com/134099 |
| 726 | "mapljbgnjledlpdmlchihnmeclmefbba", // see crbug.com/134099 |
[email protected] | 4dc30b8 | 2012-08-15 00:24:38 | [diff] [blame] | 727 | "ghbfeebgmiidnnmeobbbaiamklmpbpii", // see crbug.com/134099 |
[email protected] | 45db05f | 2012-12-10 21:52:58 | [diff] [blame] | 728 | "jdfhpkjeckflbbleddjlpimecpbjdeep", // see crbug.com/142514 |
[email protected] | b7131323 | 2013-05-06 06:16:29 | [diff] [blame] | 729 | "iabmpiboiopbgfabjmgeedhcmjenhbla", // see crbug.com/165080 |
[email protected] | 3f6fca2 | 2013-08-12 23:13:42 | [diff] [blame] | 730 | "B7CF8A292249681AF81771650BA4CEEAF19A4560", // see crbug.com/165080 |
[email protected] | 3f6fca2 | 2013-08-12 23:13:42 | [diff] [blame] | 731 | "7525AF4F66763A70A883C4700529F647B470E4D2", // see crbug.com/238084 |
| 732 | "0B549507088E1564D672F7942EB87CA4DAD73972", // see crbug.com/238084 |
| 733 | "864288364E239573E777D3E0E36864E590E95C74" // see crbug.com/238084 |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 734 | }; |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 735 | #endif |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 736 | |
lazyboy | 5d5fede0 | 2016-03-10 04:10:14 | [diff] [blame] | 737 | enum AppLoadedInTabSource { |
nick | b6ae0bd3 | 2017-04-18 20:53:53 | [diff] [blame] | 738 | // A platform app page tried to load one of its own URLs in a tab. |
lazyboy | 5d5fede0 | 2016-03-10 04:10:14 | [diff] [blame] | 739 | APP_LOADED_IN_TAB_SOURCE_APP = 0, |
nick | b6ae0bd3 | 2017-04-18 20:53:53 | [diff] [blame] | 740 | |
| 741 | // A platform app background page tried to load one of its own URLs in a tab. |
lazyboy | 5d5fede0 | 2016-03-10 04:10:14 | [diff] [blame] | 742 | APP_LOADED_IN_TAB_SOURCE_BACKGROUND_PAGE, |
nick | b6ae0bd3 | 2017-04-18 20:53:53 | [diff] [blame] | 743 | |
| 744 | // An extension or app tried to load a resource of a different platform app in |
| 745 | // a tab. |
| 746 | APP_LOADED_IN_TAB_SOURCE_OTHER_EXTENSION, |
| 747 | |
| 748 | // A non-app and non-extension page tried to load a platform app in a tab. |
| 749 | APP_LOADED_IN_TAB_SOURCE_OTHER, |
| 750 | |
lazyboy | 5d5fede0 | 2016-03-10 04:10:14 | [diff] [blame] | 751 | APP_LOADED_IN_TAB_SOURCE_MAX |
| 752 | }; |
| 753 | |
Lei Zhang | 2cfceac | 2018-11-14 19:36:33 | [diff] [blame] | 754 | // Cached version of the locale so we can return the locale on the I/O |
| 755 | // thread. |
| 756 | std::string& GetIOThreadApplicationLocale() { |
| 757 | static base::NoDestructor<std::string> s; |
| 758 | return *s; |
| 759 | } |
| 760 | |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 761 | // Returns a copy of the given url with its host set to given host and path set |
| 762 | // to given path. Other parts of the url will be the same. |
| 763 | GURL ReplaceURLHostAndPath(const GURL& url, |
| 764 | const std::string& host, |
| 765 | const std::string& path) { |
[email protected] | b4533450 | 2014-04-30 19:44:05 | [diff] [blame] | 766 | url::Replacements<char> replacements; |
| 767 | replacements.SetHost(host.c_str(), url::Component(0, host.length())); |
| 768 | replacements.SetPath(path.c_str(), url::Component(0, path.length())); |
[email protected] | f8f93eb | 2012-09-25 03:06:24 | [diff] [blame] | 769 | return url.ReplaceComponents(replacements); |
| 770 | } |
| 771 | |
mad | fbd1085 | 2017-01-20 03:15:33 | [diff] [blame] | 772 | // Handles the rewriting of the new tab page URL based on group policy. |
| 773 | bool HandleNewTabPageLocationOverride( |
| 774 | GURL* url, |
| 775 | content::BrowserContext* browser_context) { |
| 776 | if (!url->SchemeIs(content::kChromeUIScheme) || |
| 777 | url->host() != chrome::kChromeUINewTabHost) |
| 778 | return false; |
| 779 | |
| 780 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 781 | std::string ntp_location = |
| 782 | profile->GetPrefs()->GetString(prefs::kNewTabPageLocationOverride); |
| 783 | if (ntp_location.empty()) |
| 784 | return false; |
| 785 | |
| 786 | *url = GURL(ntp_location); |
| 787 | return true; |
| 788 | } |
| 789 | |
Becca Hughes | fe8c32c | 2018-03-21 13:36:56 | [diff] [blame] | 790 | #if !defined(OS_ANDROID) |
| 791 | // Check if the current url is whitelisted based on a list of whitelisted urls. |
| 792 | bool IsURLWhitelisted(const GURL& current_url, |
| 793 | const base::Value::ListStorage& whitelisted_urls) { |
| 794 | // Only check on HTTP and HTTPS pages. |
| 795 | if (!current_url.SchemeIsHTTPOrHTTPS()) |
| 796 | return false; |
| 797 | |
| 798 | for (auto const& value : whitelisted_urls) { |
| 799 | ContentSettingsPattern pattern = |
| 800 | ContentSettingsPattern::FromString(value.GetString()); |
| 801 | if (pattern == ContentSettingsPattern::Wildcard() || !pattern.IsValid()) |
| 802 | continue; |
| 803 | if (pattern.Matches(current_url)) |
| 804 | return true; |
| 805 | } |
| 806 | |
| 807 | return false; |
| 808 | } |
| 809 | |
| 810 | // Check if autoplay is allowed by policy configuration. |
| 811 | bool IsAutoplayAllowedByPolicy(content::WebContents* contents, |
| 812 | PrefService* prefs) { |
| 813 | DCHECK(prefs); |
| 814 | |
| 815 | // Check if we have globally allowed autoplay by policy. |
| 816 | if (prefs->GetBoolean(prefs::kAutoplayAllowed) && |
| 817 | prefs->IsManagedPreference(prefs::kAutoplayAllowed)) { |
| 818 | return true; |
| 819 | } |
| 820 | |
| 821 | if (!contents) |
| 822 | return false; |
| 823 | |
| 824 | // Check if the current URL matches a URL pattern on the whitelist. |
| 825 | const base::ListValue* autoplay_whitelist = |
| 826 | prefs->GetList(prefs::kAutoplayWhitelist); |
| 827 | return autoplay_whitelist && |
| 828 | prefs->IsManagedPreference(prefs::kAutoplayWhitelist) && |
| 829 | IsURLWhitelisted(contents->GetURL(), autoplay_whitelist->GetList()); |
| 830 | } |
| 831 | #endif |
| 832 | |
Joshua Peraza | f890e4b | 2019-01-03 19:19:02 | [diff] [blame] | 833 | #if defined(OS_ANDROID) |
| 834 | int GetCrashSignalFD(const base::CommandLine& command_line) { |
| 835 | return crashpad::CrashHandlerHost::Get()->GetDeathSignalSocket(); |
| 836 | } |
| 837 | #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | 0b818f7 | 2013-10-22 00:11:03 | [diff] [blame] | 838 | breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( |
| 839 | const std::string& process_type) { |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 840 | base::FilePath dumps_path; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 841 | base::PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 842 | { |
| 843 | ANNOTATE_SCOPED_MEMORY_LEAK; |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 844 | bool upload = !getenv(env_vars::kHeadless); |
[email protected] | 0b818f7 | 2013-10-22 00:11:03 | [diff] [blame] | 845 | breakpad::CrashHandlerHostLinux* crash_handler = |
[email protected] | 9de4da5 | 2014-05-24 12:26:50 | [diff] [blame] | 846 | new breakpad::CrashHandlerHostLinux(process_type, dumps_path, upload); |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 847 | crash_handler->StartUploaderThread(); |
| 848 | return crash_handler; |
| 849 | } |
| 850 | } |
| 851 | |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 852 | int GetCrashSignalFD(const base::CommandLine& command_line) { |
[email protected] | 9de4da5 | 2014-05-24 12:26:50 | [diff] [blame] | 853 | // Extensions have the same process type as renderers. |
[email protected] | cd0f7af | 2014-01-16 23:50:39 | [diff] [blame] | 854 | if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) { |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 855 | static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 856 | if (!crash_handler) |
| 857 | crash_handler = CreateCrashHandlerHost("extension"); |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 858 | return crash_handler->GetDeathSignalSocket(); |
| 859 | } |
| 860 | |
James Cook | 783fdeb | 2018-05-24 22:28:46 | [diff] [blame] | 861 | #if defined(OS_CHROMEOS) |
| 862 | // Mash services are utility processes, but crashes are reported using the |
| 863 | // service name as the process type to make the crash console easier to read. |
| 864 | if (command_line.HasSwitch(switches::kMashServiceName)) { |
| 865 | static base::NoDestructor< |
| 866 | std::map<std::string, breakpad::CrashHandlerHostLinux*>> |
| 867 | crash_handlers; |
| 868 | std::string service_name = |
| 869 | command_line.GetSwitchValueASCII(switches::kMashServiceName); |
| 870 | auto it = crash_handlers->find(service_name); |
| 871 | if (it == crash_handlers->end()) { |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 872 | auto insert_result = crash_handlers->insert( |
James Cook | 783fdeb | 2018-05-24 22:28:46 | [diff] [blame] | 873 | std::make_pair(service_name, CreateCrashHandlerHost(service_name))); |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 874 | it = insert_result.first; |
James Cook | 783fdeb | 2018-05-24 22:28:46 | [diff] [blame] | 875 | } |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 876 | return it->second->GetDeathSignalSocket(); |
James Cook | 783fdeb | 2018-05-24 22:28:46 | [diff] [blame] | 877 | } |
| 878 | #endif // defined(OS_CHROMEOS) |
| 879 | |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 880 | std::string process_type = |
| 881 | command_line.GetSwitchValueASCII(switches::kProcessType); |
| 882 | |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 883 | if (process_type == switches::kRendererProcess) { |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 884 | static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 885 | if (!crash_handler) |
| 886 | crash_handler = CreateCrashHandlerHost(process_type); |
| 887 | return crash_handler->GetDeathSignalSocket(); |
| 888 | } |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 889 | |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 890 | if (process_type == switches::kPpapiPluginProcess) { |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 891 | static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 892 | if (!crash_handler) |
| 893 | crash_handler = CreateCrashHandlerHost(process_type); |
| 894 | return crash_handler->GetDeathSignalSocket(); |
| 895 | } |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 896 | |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 897 | if (process_type == switches::kGpuProcess) { |
Lei Zhang | 74f3dd3f | 2019-04-10 00:16:31 | [diff] [blame] | 898 | static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; |
[email protected] | 779dd28 | 2013-10-19 15:57:02 | [diff] [blame] | 899 | if (!crash_handler) |
| 900 | crash_handler = CreateCrashHandlerHost(process_type); |
| 901 | return crash_handler->GetDeathSignalSocket(); |
| 902 | } |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 903 | |
James Cook | 9207cc1 | 2017-10-19 17:08:39 | [diff] [blame] | 904 | if (process_type == switches::kUtilityProcess) { |
| 905 | static breakpad::CrashHandlerHostLinux* crash_handler = nullptr; |
| 906 | if (!crash_handler) |
| 907 | crash_handler = CreateCrashHandlerHost(process_type); |
| 908 | return crash_handler->GetDeathSignalSocket(); |
| 909 | } |
| 910 | |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 911 | return -1; |
| 912 | } |
Joshua Peraza | f890e4b | 2019-01-03 19:19:02 | [diff] [blame] | 913 | #endif // defined(OS_ANDROID) |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 914 | |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 915 | void SetApplicationLocaleOnIOThread(const std::string& locale) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 916 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
Lei Zhang | 2cfceac | 2018-11-14 19:36:33 | [diff] [blame] | 917 | GetIOThreadApplicationLocale() = locale; |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 918 | } |
| 919 | |
estark | 3ba1113 | 2015-04-10 01:38:33 | [diff] [blame] | 920 | // An implementation of the SSLCertReporter interface used by |
meacer | f43117a | 2016-12-27 21:02:31 | [diff] [blame] | 921 | // SSLErrorHandler. Uses CertificateReportingService to send reports. The |
| 922 | // service handles queueing and re-sending of failed reports. Each certificate |
| 923 | // error creates a new instance of this class. |
| 924 | class CertificateReportingServiceCertReporter : public SSLCertReporter { |
estark | 3ba1113 | 2015-04-10 01:38:33 | [diff] [blame] | 925 | public: |
meacer | f43117a | 2016-12-27 21:02:31 | [diff] [blame] | 926 | explicit CertificateReportingServiceCertReporter( |
Lucas Garron | 94b1605 | 2017-11-11 01:58:12 | [diff] [blame] | 927 | content::WebContents* web_contents) |
| 928 | : service_(CertificateReportingServiceFactory::GetForBrowserContext( |
| 929 | web_contents->GetBrowserContext())) {} |
meacer | f43117a | 2016-12-27 21:02:31 | [diff] [blame] | 930 | ~CertificateReportingServiceCertReporter() override {} |
estark | 3ba1113 | 2015-04-10 01:38:33 | [diff] [blame] | 931 | |
| 932 | // SSLCertReporter implementation |
estark | 4282f117 | 2015-05-13 22:01:55 | [diff] [blame] | 933 | void ReportInvalidCertificateChain( |
| 934 | const std::string& serialized_report) override { |
meacer | f43117a | 2016-12-27 21:02:31 | [diff] [blame] | 935 | service_->Send(serialized_report); |
estark | 3ba1113 | 2015-04-10 01:38:33 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | private: |
meacer | f43117a | 2016-12-27 21:02:31 | [diff] [blame] | 939 | CertificateReportingService* service_; |
| 940 | |
| 941 | DISALLOW_COPY_AND_ASSIGN(CertificateReportingServiceCertReporter); |
estark | 3ba1113 | 2015-04-10 01:38:33 | [diff] [blame] | 942 | }; |
| 943 | |
bshe | 4f53ce4 | 2015-11-30 16:56:31 | [diff] [blame] | 944 | #if defined(OS_ANDROID) |
[email protected] | ded00dc | 2013-11-01 00:37:05 | [diff] [blame] | 945 | float GetDeviceScaleAdjustment() { |
[email protected] | b255a8e0e8 | 2013-10-22 04:03:59 | [diff] [blame] | 946 | static const float kMinFSM = 1.05f; |
| 947 | static const int kWidthForMinFSM = 320; |
| 948 | static const float kMaxFSM = 1.3f; |
| 949 | static const int kWidthForMaxFSM = 800; |
| 950 | |
boliu | 21c5afa | 2017-01-11 19:34:23 | [diff] [blame] | 951 | int minWidth = chrome::android::ChromeContextUtil::GetSmallestDIPWidth(); |
[email protected] | b255a8e0e8 | 2013-10-22 04:03:59 | [diff] [blame] | 952 | |
| 953 | if (minWidth <= kWidthForMinFSM) |
| 954 | return kMinFSM; |
| 955 | if (minWidth >= kWidthForMaxFSM) |
| 956 | return kMaxFSM; |
| 957 | |
| 958 | // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. |
| 959 | float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / |
| 960 | (kWidthForMaxFSM - kWidthForMinFSM); |
| 961 | return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
| 962 | } |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 963 | |
[email protected] | 916615b | 2013-09-11 18:19:44 | [diff] [blame] | 964 | #endif // defined(OS_ANDROID) |
| 965 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 966 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
nick | b6ae0bd3 | 2017-04-18 20:53:53 | [diff] [blame] | 967 | |
| 968 | AppLoadedInTabSource ClassifyAppLoadedInTabSource( |
| 969 | const GURL& opener_url, |
| 970 | const extensions::Extension* target_platform_app) { |
| 971 | if (opener_url.SchemeIs(extensions::kExtensionScheme)) { |
| 972 | if (opener_url.host_piece() == target_platform_app->id()) { |
| 973 | // This platform app was trying to window.open() one of its own URLs. |
| 974 | if (opener_url == |
| 975 | extensions::BackgroundInfo::GetBackgroundURL(target_platform_app)) { |
| 976 | // Source was the background page. |
| 977 | return APP_LOADED_IN_TAB_SOURCE_BACKGROUND_PAGE; |
| 978 | } else { |
| 979 | // Source was a different page inside the app. |
| 980 | return APP_LOADED_IN_TAB_SOURCE_APP; |
| 981 | } |
| 982 | } |
| 983 | // The forbidden app URL was being opened by a different app or extension. |
| 984 | return APP_LOADED_IN_TAB_SOURCE_OTHER_EXTENSION; |
| 985 | } |
| 986 | // The forbidden app URL was being opened by a non-extension page (e.g. http). |
| 987 | return APP_LOADED_IN_TAB_SOURCE_OTHER; |
| 988 | } |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 989 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | 9c765638 | 2014-08-08 21:02:30 | [diff] [blame] | 990 | |
Ken Rockot | 42dfa78 | 2018-06-28 21:08:41 | [diff] [blame] | 991 | WebContents* GetWebContentsFromProcessAndFrameId(int render_process_id, |
| 992 | int render_frame_id) { |
Clark DuVall | c57280be | 2018-06-19 03:46:23 | [diff] [blame] | 993 | if (render_process_id) { |
| 994 | RenderFrameHost* rfh = |
| 995 | RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 996 | return WebContents::FromRenderFrameHost(rfh); |
| 997 | } |
| 998 | return WebContents::FromFrameTreeNodeId(render_frame_id); |
jam | 092d3be | 2016-09-27 15:56:36 | [diff] [blame] | 999 | } |
| 1000 | |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 1001 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Charles Harrison | 34f6786 | 2017-08-22 01:04:17 | [diff] [blame] | 1002 | // Returns true if there is is an extension matching |url| in |
| 1003 | // |opener_render_process_id| with APIPermission::kBackground. |
| 1004 | // |
| 1005 | // Note that GetExtensionOrAppByURL requires a full URL in order to match with a |
| 1006 | // hosted app, even though normal extensions just use the host. |
| 1007 | bool URLHasExtensionBackgroundPermission( |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 1008 | extensions::ProcessMap* process_map, |
| 1009 | extensions::ExtensionRegistry* registry, |
Charles Harrison | 34f6786 | 2017-08-22 01:04:17 | [diff] [blame] | 1010 | const GURL& url, |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 1011 | int opener_render_process_id) { |
| 1012 | // Note: includes web URLs that are part of an extension's web extent. |
| 1013 | const Extension* extension = |
Charles Harrison | 34f6786 | 2017-08-22 01:04:17 | [diff] [blame] | 1014 | registry->enabled_extensions().GetExtensionOrAppByURL(url); |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 1015 | return extension && |
| 1016 | extension->permissions_data()->HasAPIPermission( |
| 1017 | APIPermission::kBackground) && |
| 1018 | process_map->Contains(extension->id(), opener_render_process_id); |
| 1019 | } |
Kevin Marshall | 32f99d7e | 2017-07-11 23:17:46 | [diff] [blame] | 1020 | |
| 1021 | void InvokeCallbackOnThread( |
| 1022 | scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 1023 | base::Callback<void(bool)> callback, |
| 1024 | bool result) { |
tzik | df81f14 | 2018-10-26 00:23:34 | [diff] [blame] | 1025 | task_runner->PostTask(FROM_HERE, base::BindOnce(std::move(callback), result)); |
Kevin Marshall | 32f99d7e | 2017-07-11 23:17:46 | [diff] [blame] | 1026 | } |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 1027 | #endif |
| 1028 | |
John Abd-El-Malek | d237798 | 2018-01-08 22:23:12 | [diff] [blame] | 1029 | chrome::mojom::PrerenderCanceler* GetPrerenderCanceller( |
| 1030 | const base::Callback<content::WebContents*()>& wc_getter) { |
| 1031 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 1032 | auto* web_contents = wc_getter.Run(); |
| 1033 | if (!web_contents) |
| 1034 | return nullptr; |
| 1035 | |
| 1036 | return prerender::PrerenderContents::FromWebContents(web_contents); |
| 1037 | } |
| 1038 | |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 1039 | void LaunchURL( |
| 1040 | const GURL& url, |
| 1041 | const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 1042 | ui::PageTransition page_transition, |
| 1043 | bool has_user_gesture) { |
| 1044 | // If there is no longer a WebContents, the request may have raced with tab |
| 1045 | // closing. Don't fire the external request. (It may have been a prerender.) |
| 1046 | content::WebContents* web_contents = web_contents_getter.Run(); |
| 1047 | if (!web_contents) |
| 1048 | return; |
| 1049 | |
| 1050 | // Do not launch external requests attached to unswapped prerenders. |
| 1051 | prerender::PrerenderContents* prerender_contents = |
| 1052 | prerender::PrerenderContents::FromWebContents(web_contents); |
| 1053 | if (prerender_contents) { |
| 1054 | prerender_contents->Destroy(prerender::FINAL_STATUS_UNSUPPORTED_SCHEME); |
| 1055 | prerender::ReportPrerenderExternalURL(); |
| 1056 | return; |
| 1057 | } |
| 1058 | |
Robbie McElrath | 1294d24 | 2019-05-31 20:46:22 | [diff] [blame] | 1059 | // Do not launch external requests for schemes that have a handler registered. |
| 1060 | ProtocolHandlerRegistry* protocol_handler_registry = |
| 1061 | ProtocolHandlerRegistryFactory::GetForBrowserContext( |
| 1062 | web_contents->GetBrowserContext()); |
| 1063 | if (protocol_handler_registry && |
| 1064 | protocol_handler_registry->IsHandledProtocol(url.scheme())) |
| 1065 | return; |
| 1066 | |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 1067 | bool is_whitelisted = false; |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 1068 | PolicyBlacklistService* service = |
Oleg Davydov | 5cfe7ab | 2019-02-01 12:27:19 | [diff] [blame] | 1069 | PolicyBlacklistFactory::GetForBrowserContext( |
| 1070 | web_contents->GetBrowserContext()); |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 1071 | if (service) { |
| 1072 | const policy::URLBlacklist::URLBlacklistState url_state = |
| 1073 | service->GetURLBlacklistState(url); |
| 1074 | is_whitelisted = |
| 1075 | url_state == policy::URLBlacklist::URLBlacklistState::URL_IN_WHITELIST; |
| 1076 | } |
| 1077 | |
| 1078 | // If the URL is in whitelist, we launch it without asking the user and |
| 1079 | // without any additional security checks. Since the URL is whitelisted, |
| 1080 | // we assume it can be executed. |
| 1081 | if (is_whitelisted) { |
| 1082 | ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(url, web_contents); |
| 1083 | } else { |
| 1084 | ExternalProtocolHandler::LaunchUrl( |
| 1085 | url, web_contents->GetRenderViewHost()->GetProcess()->GetID(), |
| 1086 | web_contents->GetRenderViewHost()->GetRoutingID(), page_transition, |
| 1087 | has_user_gesture); |
| 1088 | } |
| 1089 | } |
| 1090 | |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 1091 | std::string GetProduct() { |
| 1092 | return version_info::GetProductNameAndVersionForUserAgent(); |
| 1093 | } |
| 1094 | |
Lukasz Anforowicz | 60d1253d | 2019-05-08 16:31:37 | [diff] [blame] | 1095 | void MaybeAppendSecureOriginsAllowlistSwitch(base::CommandLine* cmdline) { |
| 1096 | // |allowlist| combines pref/policy + cmdline switch in the browser process. |
| 1097 | // For renderer and utility (e.g. NetworkService) processes the switch is the |
| 1098 | // only available source, so below the combined (pref/policy + cmdline) |
| 1099 | // allowlist of secure origins is injected into |cmdline| for these other |
| 1100 | // processes. |
| 1101 | std::vector<std::string> allowlist = |
| 1102 | network::SecureOriginAllowlist::GetInstance().GetCurrentAllowlist(); |
| 1103 | if (!allowlist.empty()) { |
| 1104 | cmdline->AppendSwitchASCII( |
| 1105 | network::switches::kUnsafelyTreatInsecureOriginAsSecure, |
| 1106 | base::JoinString(allowlist, ",")); |
| 1107 | } |
| 1108 | } |
| 1109 | |
[email protected] | 9dbfff1 | 2011-07-01 19:37:07 | [diff] [blame] | 1110 | } // namespace |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 1111 | |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 1112 | std::string GetUserAgent() { |
| 1113 | base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1114 | if (command_line->HasSwitch(switches::kUserAgent)) { |
| 1115 | std::string ua = command_line->GetSwitchValueASCII(switches::kUserAgent); |
| 1116 | if (net::HttpUtil::IsValidHeaderValue(ua)) |
| 1117 | return ua; |
| 1118 | LOG(WARNING) << "Ignored invalid value for flag --" << switches::kUserAgent; |
| 1119 | } |
| 1120 | |
John Delaney | ac24e57 | 2019-04-30 19:47:02 | [diff] [blame] | 1121 | if (base::FeatureList::IsEnabled(blink::features::kFreezeUserAgent)) { |
| 1122 | return content::GetFrozenUserAgent( |
| 1123 | command_line->HasSwitch(switches::kUseMobileUserAgent)) |
| 1124 | .as_string(); |
| 1125 | } |
| 1126 | |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 1127 | std::string product = GetProduct(); |
| 1128 | #if defined(OS_ANDROID) |
| 1129 | if (command_line->HasSwitch(switches::kUseMobileUserAgent)) |
| 1130 | product += " Mobile"; |
| 1131 | #endif |
| 1132 | return content::BuildUserAgentFromProduct(product); |
| 1133 | } |
| 1134 | |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 1135 | blink::UserAgentMetadata GetUserAgentMetadata() { |
| 1136 | blink::UserAgentMetadata metadata; |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 1137 | metadata.brand = version_info::GetProductName(); |
Mike West | e555be86 | 2019-02-20 16:17:30 | [diff] [blame] | 1138 | metadata.full_version = version_info::GetVersionNumber(); |
| 1139 | metadata.major_version = version_info::GetMajorVersionNumber(); |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 1140 | metadata.platform = version_info::GetOSType(); |
| 1141 | |
| 1142 | // TODO(mkwst): Poke at BuildUserAgentFromProduct to split out these pieces. |
| 1143 | metadata.architecture = ""; |
| 1144 | metadata.model = ""; |
| 1145 | |
| 1146 | return metadata; |
| 1147 | } |
| 1148 | |
Ran Ji | a96d43d4 | 2018-05-02 17:14:53 | [diff] [blame] | 1149 | ChromeContentBrowserClient::ChromeContentBrowserClient( |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 1150 | StartupData* startup_data) |
Wojciech Dzierżanowski | 4538080 | 2019-04-29 14:50:32 | [diff] [blame] | 1151 | : data_reduction_proxy_throttle_manager_( |
| 1152 | nullptr, |
| 1153 | base::OnTaskRunnerDeleter(nullptr)), |
| 1154 | startup_data_(startup_data), |
| 1155 | weak_factory_(this) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 1156 | #if BUILDFLAG(ENABLE_PLUGINS) |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 1157 | for (size_t i = 0; i < base::size(kPredefinedAllowedDevChannelOrigins); ++i) |
[email protected] | aec5ed5 | 2014-06-20 07:51:42 | [diff] [blame] | 1158 | allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 1159 | for (size_t i = 0; i < base::size(kPredefinedAllowedFileHandleOrigins); ++i) |
[email protected] | 10c3922 | 2013-11-13 20:09:25 | [diff] [blame] | 1160 | allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 1161 | for (size_t i = 0; i < base::size(kPredefinedAllowedSocketOrigins); ++i) |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 1162 | allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 1163 | |
| 1164 | extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart); |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 1165 | #endif |
[email protected] | 1deace2 | 2013-05-22 06:14:46 | [diff] [blame] | 1166 | |
Ahmed Fakhry | d70bf37b | 2018-04-04 17:07:24 | [diff] [blame] | 1167 | #if defined(OS_CHROMEOS) |
| 1168 | extra_parts_.push_back(new ChromeContentBrowserClientChromeOsPart); |
| 1169 | #endif // defined(OS_CHROMEOS) |
| 1170 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1171 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1172 | extra_parts_.push_back(new ChromeContentBrowserClientExtensionsPart); |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1173 | #endif |
ben | a06f7d6 | 2017-04-04 20:48:52 | [diff] [blame] | 1174 | |
Sigurdur Asgeirsson | 7069667 | 2019-02-08 16:14:51 | [diff] [blame] | 1175 | extra_parts_.push_back(new ChromeContentBrowserClientPerformanceManagerPart); |
Sigurdur Asgeirsson | 50945f9 | 2019-01-25 20:26:01 | [diff] [blame] | 1176 | |
ben | a06f7d6 | 2017-04-04 20:48:52 | [diff] [blame] | 1177 | gpu_binder_registry_.AddInterface( |
Mike Wittman | 16fa536 | 2018-09-04 17:27:30 | [diff] [blame] | 1178 | base::Bind(&metrics::CallStackProfileCollector::Create)); |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | ChromeContentBrowserClient::~ChromeContentBrowserClient() { |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 1182 | for (int i = static_cast<int>(extra_parts_.size()) - 1; i >= 0; --i) |
| 1183 | delete extra_parts_[i]; |
| 1184 | extra_parts_.clear(); |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 1185 | } |
| 1186 | |
[email protected] | bca1838 | 2012-06-25 19:15:23 | [diff] [blame] | 1187 | // static |
Chris Palmer | ac7d7564 | 2017-11-22 20:12:54 | [diff] [blame] | 1188 | void ChromeContentBrowserClient::RegisterLocalStatePrefs( |
| 1189 | PrefRegistrySimple* registry) { |
| 1190 | registry->RegisterStringPref(prefs::kIsolateOrigins, std::string()); |
| 1191 | registry->RegisterBooleanPref(prefs::kSitePerProcess, false); |
Chris Hamilton | 8206aad | 2018-07-18 01:00:03 | [diff] [blame] | 1192 | registry->RegisterBooleanPref(prefs::kTabLifecyclesEnabled, true); |
Julian Pastarmov | fac2800 | 2018-02-01 11:17:45 | [diff] [blame] | 1193 | registry->RegisterBooleanPref(prefs::kWebDriverOverridesIncompatiblePolicies, |
| 1194 | false); |
Chris Palmer | ac7d7564 | 2017-11-22 20:12:54 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | // static |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 1198 | void ChromeContentBrowserClient::RegisterProfilePrefs( |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 1199 | user_prefs::PrefRegistrySyncable* registry) { |
raymes | aa60872 | 2015-04-27 03:00:25 | [diff] [blame] | 1200 | registry->RegisterBooleanPref(prefs::kDisable3DAPIs, false); |
| 1201 | registry->RegisterBooleanPref(prefs::kEnableHyperlinkAuditing, true); |
| 1202 | registry->RegisterListPref(prefs::kEnableDeprecatedWebPlatformFeatures); |
Pavol Marko | 6adbea7f | 2018-02-20 16:35:28 | [diff] [blame] | 1203 | // Register user prefs for mapping SitePerProcess and IsolateOrigins in |
| 1204 | // user policy in addition to the same named ones in Local State (which are |
| 1205 | // used for mapping the command-line flags). |
| 1206 | registry->RegisterStringPref(prefs::kIsolateOrigins, std::string()); |
| 1207 | registry->RegisterBooleanPref(prefs::kSitePerProcess, false); |
Alex Moshchuk | e256d56 | 2019-04-26 21:43:57 | [diff] [blame] | 1208 | registry->RegisterListPref(prefs::kUserTriggeredIsolatedOrigins); |
Rayan Kanso | 411e84e | 2019-02-13 15:27:40 | [diff] [blame] | 1209 | registry->RegisterDictionaryPref( |
| 1210 | prefs::kDevToolsBackgroundServicesExpirationDict); |
Kunihiko Sakamoto | f586da6 | 2019-03-28 03:03:04 | [diff] [blame] | 1211 | registry->RegisterBooleanPref(prefs::kSignedHTTPExchangeEnabled, true); |
François Beaufort | 4f8107d | 2018-03-05 12:12:10 | [diff] [blame] | 1212 | #if !defined(OS_ANDROID) |
| 1213 | registry->RegisterBooleanPref(prefs::kAutoplayAllowed, false); |
Becca Hughes | fe8c32c | 2018-03-21 13:36:56 | [diff] [blame] | 1214 | registry->RegisterListPref(prefs::kAutoplayWhitelist); |
François Beaufort | 4f8107d | 2018-03-05 12:12:10 | [diff] [blame] | 1215 | #endif |
[email protected] | bca1838 | 2012-06-25 19:15:23 | [diff] [blame] | 1216 | } |
| 1217 | |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 1218 | // static |
| 1219 | void ChromeContentBrowserClient::SetApplicationLocale( |
| 1220 | const std::string& locale) { |
Scott Violet | 875789e | 2018-02-02 07:46:48 | [diff] [blame] | 1221 | // The common case is that this function is called early in Chrome startup |
| 1222 | // before any threads are created or registered. When there are no threads, |
| 1223 | // we can just set the string without worrying about threadsafety. |
Gabriel Charette | 192b8c9 | 2018-03-21 21:16:00 | [diff] [blame] | 1224 | if (!BrowserThread::IsThreadInitialized(BrowserThread::IO)) { |
Lei Zhang | 2cfceac | 2018-11-14 19:36:33 | [diff] [blame] | 1225 | GetIOThreadApplicationLocale() = locale; |
Scott Violet | 875789e | 2018-02-02 07:46:48 | [diff] [blame] | 1226 | return; |
| 1227 | } |
| 1228 | |
| 1229 | // Otherwise we're being called to change the locale. In this case set it on |
| 1230 | // the IO thread. |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 1231 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 1232 | |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 1233 | base::PostTaskWithTraits( |
| 1234 | FROM_HERE, {BrowserThread::IO}, |
Scott Violet | 875789e | 2018-02-02 07:46:48 | [diff] [blame] | 1235 | base::BindOnce(&SetApplicationLocaleOnIOThread, locale)); |
[email protected] | eabbfb1 | 2013-04-05 23:28:35 | [diff] [blame] | 1236 | } |
| 1237 | |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1238 | std::unique_ptr<content::BrowserMainParts> |
| 1239 | ChromeContentBrowserClient::CreateBrowserMainParts( |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 1240 | const content::MainFunctionParams& parameters) { |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1241 | std::unique_ptr<ChromeBrowserMainParts> main_parts; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 1242 | // Construct the Main browser parts based on the OS type. |
| 1243 | #if defined(OS_WIN) |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 1244 | main_parts = |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1245 | std::make_unique<ChromeBrowserMainPartsWin>(parameters, startup_data_); |
| 1246 | #elif defined(OS_MACOSX) |
| 1247 | main_parts = |
| 1248 | std::make_unique<ChromeBrowserMainPartsMac>(parameters, startup_data_); |
| 1249 | #elif defined(OS_CHROMEOS) |
| 1250 | main_parts = std::make_unique<chromeos::ChromeBrowserMainPartsChromeos>( |
| 1251 | parameters, startup_data_); |
[email protected] | 81ce2c4 | 2012-03-24 01:43:26 | [diff] [blame] | 1252 | #elif defined(OS_LINUX) |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1253 | main_parts = |
| 1254 | std::make_unique<ChromeBrowserMainPartsLinux>(parameters, startup_data_); |
[email protected] | 6e677a34 | 2012-02-11 01:21:14 | [diff] [blame] | 1255 | #elif defined(OS_ANDROID) |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1256 | main_parts = std::make_unique<ChromeBrowserMainPartsAndroid>(parameters, |
| 1257 | startup_data_); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 1258 | #elif defined(OS_POSIX) |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1259 | main_parts = |
| 1260 | std::make_unique<ChromeBrowserMainPartsPosix>(parameters, startup_data_); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 1261 | #else |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 1262 | NOTREACHED(); |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1263 | main_parts = |
| 1264 | std::make_unique<ChromeBrowserMainParts>(parameters, startup_data_); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 1265 | #endif |
| 1266 | |
Xi Han | 9fd4400 | 2019-04-30 17:39:36 | [diff] [blame] | 1267 | bool add_profiles_extra_parts = true; |
| 1268 | #if defined(OS_ANDROID) |
| 1269 | if (startup_data_->HasBuiltProfilePrefService()) |
| 1270 | add_profiles_extra_parts = false; |
| 1271 | #endif |
| 1272 | if (add_profiles_extra_parts) |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1273 | chrome::AddProfilesExtraParts(main_parts.get()); |
[email protected] | 7e75e4a | 2013-05-17 17:20:03 | [diff] [blame] | 1274 | |
Xi Han | 9fd4400 | 2019-04-30 17:39:36 | [diff] [blame] | 1275 | // Construct additional browser parts. Stages are called in the order in |
| 1276 | // which they are added. |
[email protected] | c748094 | 2011-11-08 19:18:27 | [diff] [blame] | 1277 | #if defined(TOOLKIT_VIEWS) |
Maksim Sisov | 1f2f2e6 | 2019-05-08 07:56:22 | [diff] [blame] | 1278 | #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1279 | #if defined(USE_X11) |
| 1280 | main_parts->AddParts(new ChromeBrowserMainExtraPartsViewsLinuxX11()); |
| 1281 | #else |
estade | d3aa0e8 | 2016-02-17 22:55:21 | [diff] [blame] | 1282 | main_parts->AddParts(new ChromeBrowserMainExtraPartsViewsLinux()); |
Maksim Sisov | 1f2f2e6 | 2019-05-08 07:56:22 | [diff] [blame] | 1283 | #endif // USE_X11 |
estade | d3aa0e8 | 2016-02-17 22:55:21 | [diff] [blame] | 1284 | #else |
riajiang | 7d6ec5c | 2017-01-25 16:40:33 | [diff] [blame] | 1285 | main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); |
James Cook | f9d34d2 | 2017-10-04 16:39:35 | [diff] [blame] | 1286 | #endif |
| 1287 | #endif |
| 1288 | |
| 1289 | #if defined(OS_CHROMEOS) |
| 1290 | // TODO(jamescook): Combine with ChromeBrowserMainPartsChromeos. |
riajiang | 7d6ec5c | 2017-01-25 16:40:33 | [diff] [blame] | 1291 | main_parts->AddParts(new ChromeBrowserMainExtraPartsAsh()); |
sky | cea631e | 2016-12-16 21:52:22 | [diff] [blame] | 1292 | #endif |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 1293 | |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 1294 | #if defined(USE_X11) |
| 1295 | main_parts->AddParts(new ChromeBrowserMainExtraPartsX11()); |
[email protected] | e050ef14 | 2012-03-21 01:04:24 | [diff] [blame] | 1296 | #endif |
| 1297 | |
Sigurdur Asgeirsson | 54b7270 | 2019-04-12 14:18:54 | [diff] [blame] | 1298 | main_parts->AddParts(new ChromeBrowserMainExtraPartsPerformanceManager); |
Etienne Bergeron | 05d6253 | 2017-10-13 18:24:00 | [diff] [blame] | 1299 | |
Albert J. Wong | 59d85acb | 2017-08-10 00:50:57 | [diff] [blame] | 1300 | main_parts->AddParts(new ChromeBrowserMainExtraPartsProfiling); |
Albert J. Wong | 59d85acb | 2017-08-10 00:50:57 | [diff] [blame] | 1301 | |
Patrick Monette | 61dfef9 | 2019-05-30 23:06:27 | [diff] [blame] | 1302 | chrome::AddMetricsExtraParts(main_parts.get()); |
[email protected] | 95132f5 | 2013-04-12 02:19:04 | [diff] [blame] | 1303 | |
Ben Goodger | 1633130 | 2018-01-23 00:43:21 | [diff] [blame] | 1304 | main_parts->AddParts(ChromeService::GetInstance()->CreateExtraParts()); |
| 1305 | |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 1306 | return main_parts; |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 1307 | } |
| 1308 | |
michaeln | 96f887e2 | 2015-04-13 23:58:31 | [diff] [blame] | 1309 | void ChromeContentBrowserClient::PostAfterStartupTask( |
Brett Wilson | e1a7042 | 2017-09-12 05:10:09 | [diff] [blame] | 1310 | const base::Location& from_here, |
michaeln | 96f887e2 | 2015-04-13 23:58:31 | [diff] [blame] | 1311 | const scoped_refptr<base::TaskRunner>& task_runner, |
tzik | 6e42784 | 2017-04-05 10:13:21 | [diff] [blame] | 1312 | base::OnceClosure task) { |
tzik | 070c8ffb | 2017-03-29 05:28:12 | [diff] [blame] | 1313 | AfterStartupTaskUtils::PostTask(from_here, task_runner, std::move(task)); |
michaeln | 96f887e2 | 2015-04-13 23:58:31 | [diff] [blame] | 1314 | } |
| 1315 | |
falken | b09d443f | 2016-04-07 12:36:12 | [diff] [blame] | 1316 | bool ChromeContentBrowserClient::IsBrowserStartupComplete() { |
| 1317 | return AfterStartupTaskUtils::IsBrowserStartupComplete(); |
| 1318 | } |
| 1319 | |
Gabriel Charette | c8cca99 | 2017-08-10 18:21:49 | [diff] [blame] | 1320 | void ChromeContentBrowserClient::SetBrowserStartupIsCompleteForTesting() { |
| 1321 | AfterStartupTaskUtils::SetBrowserStartupIsCompleteForTesting(); |
| 1322 | } |
| 1323 | |
John Abd-El-Malek | 9d57f9c | 2019-02-20 18:50:04 | [diff] [blame] | 1324 | bool ChromeContentBrowserClient::IsShuttingDown() { |
| 1325 | return browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID; |
| 1326 | } |
| 1327 | |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 1328 | std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 1329 | content::BrowserContext* browser_context, |
[email protected] | e94bbcb | 2012-09-07 05:33:57 | [diff] [blame] | 1330 | const GURL& site) { |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1331 | std::string partition_id; |
| 1332 | |
| 1333 | // The partition ID for webview guest processes is the string value of its |
| 1334 | // SiteInstance URL - "chrome-guest://app_id/persist?partition". |
rogerta | 5f5bb82 | 2015-12-17 03:24:45 | [diff] [blame] | 1335 | if (site.SchemeIs(content::kGuestScheme)) |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1336 | partition_id = site.spec(); |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1337 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
blundell | f650ea0 | 2016-02-08 11:50:50 | [diff] [blame] | 1338 | // The partition ID for extensions with isolated storage is treated similarly |
| 1339 | // to the above. |
| 1340 | else if (site.SchemeIs(extensions::kExtensionScheme) && |
| 1341 | extensions::util::SiteHasIsolatedStorage(site, browser_context)) |
| 1342 | partition_id = site.spec(); |
| 1343 | #endif |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1344 | |
[email protected] | 056efdc | 2013-04-06 00:14:53 | [diff] [blame] | 1345 | DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1346 | return partition_id; |
| 1347 | } |
| 1348 | |
| 1349 | bool ChromeContentBrowserClient::IsValidStoragePartitionId( |
| 1350 | content::BrowserContext* browser_context, |
| 1351 | const std::string& partition_id) { |
| 1352 | // The default ID is empty and is always valid. |
| 1353 | if (partition_id.empty()) |
| 1354 | return true; |
| 1355 | |
| 1356 | return GURL(partition_id).is_valid(); |
| 1357 | } |
| 1358 | |
| 1359 | void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( |
| 1360 | content::BrowserContext* browser_context, |
| 1361 | const GURL& site, |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 1362 | bool can_be_default, |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1363 | std::string* partition_domain, |
| 1364 | std::string* partition_name, |
| 1365 | bool* in_memory) { |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 1366 | // Default to the browser-wide storage partition and override based on |site| |
| 1367 | // below. |
| 1368 | partition_domain->clear(); |
| 1369 | partition_name->clear(); |
| 1370 | *in_memory = false; |
| 1371 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1372 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
rogerta | 5f5bb82 | 2015-12-17 03:24:45 | [diff] [blame] | 1373 | bool success = extensions::WebViewGuest::GetGuestPartitionConfigForSite( |
[email protected] | 3f24f97c | 2013-11-17 21:53:33 | [diff] [blame] | 1374 | site, partition_domain, partition_name, in_memory); |
| 1375 | |
| 1376 | if (!success && site.SchemeIs(extensions::kExtensionScheme)) { |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 1377 | // If |can_be_default| is false, the caller is stating that the |site| |
| 1378 | // should be parsed as if it had isolated storage. In particular it is |
| 1379 | // important to NOT check ExtensionService for the is_storage_isolated() |
| 1380 | // attribute because this code path is run during Extension uninstall |
| 1381 | // to do cleanup after the Extension has already been unloaded from the |
| 1382 | // ExtensionService. |
| 1383 | bool is_isolated = !can_be_default; |
| 1384 | if (can_be_default) { |
[email protected] | ca033634 | 2014-03-21 12:58:34 | [diff] [blame] | 1385 | if (extensions::util::SiteHasIsolatedStorage(site, browser_context)) |
| 1386 | is_isolated = true; |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 1387 | } |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1388 | |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 1389 | if (is_isolated) { |
| 1390 | CHECK(site.has_host()); |
| 1391 | // For extensions with isolated storage, the the host of the |site| is |
| 1392 | // the |partition_domain|. The |in_memory| and |partition_name| are only |
| 1393 | // used in guest schemes so they are cleared here. |
| 1394 | *partition_domain = site.host(); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1395 | *in_memory = false; |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 1396 | partition_name->clear(); |
[email protected] | 1bc2831 | 2012-11-08 08:31:53 | [diff] [blame] | 1397 | } |
[email protected] | 1df3d97 | 2014-06-11 04:55:18 | [diff] [blame] | 1398 | success = true; |
| 1399 | } |
| 1400 | #endif |
| 1401 | |
[email protected] | 14acc64 | 2012-11-17 12:20:10 | [diff] [blame] | 1402 | // Assert that if |can_be_default| is false, the code above must have found a |
| 1403 | // non-default partition. If this fails, the caller has a serious logic |
| 1404 | // error about which StoragePartition they expect to be in and it is not |
| 1405 | // safe to continue. |
| 1406 | CHECK(can_be_default || !partition_domain->empty()); |
[email protected] | d7c7c98a | 2012-07-12 21:27:44 | [diff] [blame] | 1407 | } |
| 1408 | |
[email protected] | 38b098f | 2012-03-14 21:11:57 | [diff] [blame] | 1409 | content::WebContentsViewDelegate* |
| 1410 | ChromeContentBrowserClient::GetWebContentsViewDelegate( |
| 1411 | content::WebContents* web_contents) { |
cm.sanchi | 2db24a8 | 2017-11-16 07:22:10 | [diff] [blame] | 1412 | return CreateWebContentsViewDelegate(web_contents); |
[email protected] | 74313b4 | 2011-08-24 16:51:32 | [diff] [blame] | 1413 | } |
| 1414 | |
Bo Liu | 4ade6b1b2 | 2017-11-28 02:26:35 | [diff] [blame] | 1415 | bool ChromeContentBrowserClient::AllowGpuLaunchRetryOnIOThread() { |
| 1416 | #if defined(OS_ANDROID) |
| 1417 | const base::android::ApplicationState app_state = |
| 1418 | base::android::ApplicationStatusListener::GetState(); |
| 1419 | return base::android::APPLICATION_STATE_UNKNOWN == app_state || |
| 1420 | base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES == app_state || |
| 1421 | base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES == app_state; |
| 1422 | #else |
| 1423 | return true; |
| 1424 | #endif |
| 1425 | } |
| 1426 | |
[email protected] | 6f286274 | 2013-12-20 07:53:19 | [diff] [blame] | 1427 | void ChromeContentBrowserClient::RenderProcessWillLaunch( |
Ben Goodger | 1633130 | 2018-01-23 00:43:21 | [diff] [blame] | 1428 | content::RenderProcessHost* host, |
| 1429 | service_manager::mojom::ServiceRequest* service_request) { |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1430 | int id = host->GetID(); |
| 1431 | Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
horo | 062ef535 | 2017-03-29 08:16:07 | [diff] [blame] | 1432 | host->AddFilter(new ChromeRenderMessageFilter(id, profile)); |
thakis | 678822e | 2017-04-20 17:20:34 | [diff] [blame] | 1433 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
John Abd-El-Malek | b79dd6ba | 2018-12-07 01:20:49 | [diff] [blame] | 1434 | host->AddFilter(new cast::CastTransportHostFilter()); |
thestig | 73f4cdc | 2015-01-15 01:51:06 | [diff] [blame] | 1435 | #endif |
Brett Wilson | 65f951c | 2016-11-03 22:06:12 | [diff] [blame] | 1436 | #if BUILDFLAG(ENABLE_PRINTING) |
[email protected] | 168b7799 | 2014-08-20 11:48:40 | [diff] [blame] | 1437 | host->AddFilter(new printing::PrintingMessageFilter(id, profile)); |
[email protected] | 058e573 | 2012-03-01 22:48:03 | [diff] [blame] | 1438 | #endif |
[email protected] | ba780c1 | 2013-10-01 17:07:06 | [diff] [blame] | 1439 | host->AddFilter(new prerender::PrerenderMessageFilter(id, profile)); |
thestig | 397accd | 2015-04-04 00:03:04 | [diff] [blame] | 1440 | host->AddFilter(new TtsMessageFilter(host->GetBrowserContext())); |
[email protected] | 10e5c5e5 | 2013-10-03 18:44:06 | [diff] [blame] | 1441 | WebRtcLoggingHandlerHost* webrtc_logging_handler_host = |
grunell | 34f2e5e | 2016-04-08 12:54:59 | [diff] [blame] | 1442 | new WebRtcLoggingHandlerHost(id, profile, |
| 1443 | g_browser_process->webrtc_log_uploader()); |
[email protected] | 10e5c5e5 | 2013-10-03 18:44:06 | [diff] [blame] | 1444 | host->AddFilter(webrtc_logging_handler_host); |
avi | 284ec61 | 2017-05-03 01:52:23 | [diff] [blame] | 1445 | host->SetUserData( |
| 1446 | WebRtcLoggingHandlerHost::kWebRtcLoggingHandlerHostKey, |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 1447 | std::make_unique<base::UserDataAdapter<WebRtcLoggingHandlerHost>>( |
avi | 284ec61 | 2017-05-03 01:52:23 | [diff] [blame] | 1448 | webrtc_logging_handler_host)); |
terelius | fa159cc | 2016-04-13 15:13:02 | [diff] [blame] | 1449 | |
grunell | 086a411 | 2017-03-02 09:23:04 | [diff] [blame] | 1450 | // The audio manager outlives the host, so it's safe to hand a raw pointer to |
| 1451 | // it to the AudioDebugRecordingsHandler, which is owned by the host. |
terelius | fa159cc | 2016-04-13 15:13:02 | [diff] [blame] | 1452 | AudioDebugRecordingsHandler* audio_debug_recordings_handler = |
Marina Ciocea | 741a4fb1 | 2018-01-27 09:55:12 | [diff] [blame] | 1453 | new AudioDebugRecordingsHandler(profile); |
terelius | fa159cc | 2016-04-13 15:13:02 | [diff] [blame] | 1454 | host->SetUserData( |
| 1455 | AudioDebugRecordingsHandler::kAudioDebugRecordingsHandlerKey, |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 1456 | std::make_unique<base::UserDataAdapter<AudioDebugRecordingsHandler>>( |
terelius | fa159cc | 2016-04-13 15:13:02 | [diff] [blame] | 1457 | audio_debug_recordings_handler)); |
| 1458 | |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 1459 | #if BUILDFLAG(ENABLE_NACL) |
Helen Li | 8897b02 | 2018-05-03 13:29:03 | [diff] [blame] | 1460 | host->AddFilter(new nacl::NaClHostMessageFilter(id, profile->IsOffTheRecord(), |
| 1461 | profile->GetPath())); |
[email protected] | 01e5975 | 2013-06-18 00:17:35 | [diff] [blame] | 1462 | #endif |
jeremyim | 364ac118 | 2015-03-03 18:49:43 | [diff] [blame] | 1463 | |
Xiaohan Wang | 9b34281b | 2017-09-08 23:48:33 | [diff] [blame] | 1464 | #if defined(OS_ANDROID) |
| 1465 | // Data cannot be persisted if the profile is off the record. |
| 1466 | host->AddFilter( |
John Abd-El-Malek | 1f7fc91 | 2018-07-26 02:48:06 | [diff] [blame] | 1467 | new cdm::CdmMessageFilterAndroid(!profile->IsOffTheRecord(), false)); |
Yuzu Saijo | 2d12ef9 | 2018-08-21 04:52:07 | [diff] [blame] | 1468 | |
| 1469 | // Register CrashMemoryMetricsCollector to report oom related metrics. |
| 1470 | host->SetUserData( |
| 1471 | CrashMemoryMetricsCollector::kCrashMemoryMetricsCollectorKey, |
| 1472 | std::make_unique<CrashMemoryMetricsCollector>(host)); |
Xiaohan Wang | 9b34281b | 2017-09-08 23:48:33 | [diff] [blame] | 1473 | #endif |
| 1474 | |
Jun Cai | db3f93cc | 2018-07-09 21:54:55 | [diff] [blame] | 1475 | Profile* original_profile = profile->GetOriginalProfile(); |
John Abd-El-Malek | 1f7fc91 | 2018-07-26 02:48:06 | [diff] [blame] | 1476 | RendererUpdaterFactory::GetForProfile(original_profile) |
| 1477 | ->InitializeRenderer(host); |
[email protected] | 39a5b53 | 2011-10-22 01:47:07 | [diff] [blame] | 1478 | |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 1479 | for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 1480 | extra_parts_[i]->RenderProcessWillLaunch(host); |
[email protected] | edece21 | 2011-11-16 11:56:56 | [diff] [blame] | 1481 | |
Ken Rockot | 40a1df79 | 2019-05-08 22:15:52 | [diff] [blame] | 1482 | mojo::PendingRemote<service_manager::mojom::Service> service; |
| 1483 | *service_request = service.InitWithNewPipeAndPassReceiver(); |
Ben Goodger | 1633130 | 2018-01-23 00:43:21 | [diff] [blame] | 1484 | service_manager::Identity renderer_identity = host->GetChildIdentity(); |
Ken Rockot | 0adc1e4 | 2019-05-24 08:20:08 | [diff] [blame] | 1485 | mojo::Remote<service_manager::mojom::ProcessMetadata> metadata; |
Ken Rockot | a86fa54 | 2018-11-13 21:47:13 | [diff] [blame] | 1486 | ChromeService::GetInstance()->connector()->RegisterServiceInstance( |
Ben Goodger | 1633130 | 2018-01-23 00:43:21 | [diff] [blame] | 1487 | service_manager::Identity(chrome::mojom::kRendererServiceName, |
Ken Rockot | d2ed25a | 2018-11-06 22:25:37 | [diff] [blame] | 1488 | renderer_identity.instance_group(), |
Ken Rockot | a86fa54 | 2018-11-13 21:47:13 | [diff] [blame] | 1489 | renderer_identity.instance_id(), |
| 1490 | base::Token::CreateRandom()), |
Ken Rockot | 0adc1e4 | 2019-05-24 08:20:08 | [diff] [blame] | 1491 | std::move(service), metadata.BindNewPipeAndPassReceiver()); |
[email protected] | 05fcf98 | 2011-04-19 00:44:14 | [diff] [blame] | 1492 | } |
| 1493 | |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1494 | GURL ChromeContentBrowserClient::GetEffectiveURL( |
Alex Moshchuk | bb99a33 | 2017-11-22 04:49:57 | [diff] [blame] | 1495 | content::BrowserContext* browser_context, |
Alex Moshchuk | a31c788 | 2018-01-17 00:57:30 | [diff] [blame] | 1496 | const GURL& url) { |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1497 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1498 | if (!profile) |
| 1499 | return url; |
| 1500 | |
Marc Treib | 7d467b79 | 2017-12-04 13:31:03 | [diff] [blame] | 1501 | #if !defined(OS_ANDROID) |
[email protected] | b3cb3a3 | 2013-07-31 01:32:29 | [diff] [blame] | 1502 | // If the input |url| should be assigned to the Instant renderer, make its |
| 1503 | // effective URL distinct from other URLs on the search provider's domain. |
Alex Moshchuk | ca17137 | 2017-11-28 16:11:31 | [diff] [blame] | 1504 | // This needs to happen even if |url| corresponds to an isolated origin; see |
| 1505 | // https://crbug.com/755595. |
sdefresne | 51bbec7b | 2015-08-03 14:18:13 | [diff] [blame] | 1506 | if (search::ShouldAssignURLToInstantRenderer(url, profile)) |
| 1507 | return search::GetEffectiveURLForInstant(url, profile); |
Marc Treib | 7d467b79 | 2017-12-04 13:31:03 | [diff] [blame] | 1508 | #endif |
[email protected] | b3cb3a3 | 2013-07-31 01:32:29 | [diff] [blame] | 1509 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1510 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Alex Moshchuk | a31c788 | 2018-01-17 00:57:30 | [diff] [blame] | 1511 | return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL(profile, |
| 1512 | url); |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1513 | #else |
| 1514 | return url; |
| 1515 | #endif |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 1516 | } |
| 1517 | |
Alexander Yashkin | 6aedc6e | 2018-08-15 08:58:45 | [diff] [blame] | 1518 | bool ChromeContentBrowserClient:: |
| 1519 | ShouldCompareEffectiveURLsForSiteInstanceSelection( |
| 1520 | content::BrowserContext* browser_context, |
| 1521 | content::SiteInstance* candidate_site_instance, |
| 1522 | bool is_main_frame, |
| 1523 | const GURL& candidate_url, |
| 1524 | const GURL& destination_url) { |
| 1525 | DCHECK(browser_context); |
| 1526 | DCHECK(candidate_site_instance); |
| 1527 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1528 | return ChromeContentBrowserClientExtensionsPart:: |
| 1529 | ShouldCompareEffectiveURLsForSiteInstanceSelection( |
| 1530 | browser_context, candidate_site_instance, is_main_frame, |
| 1531 | candidate_url, destination_url); |
| 1532 | #else |
| 1533 | return true; |
| 1534 | #endif |
| 1535 | } |
| 1536 | |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 1537 | bool ChromeContentBrowserClient::ShouldUseMobileFlingCurve() { |
Ahmed Fakhry | e6a2c64 | 2018-06-20 02:58:41 | [diff] [blame] | 1538 | #if defined(OS_ANDROID) |
| 1539 | return true; |
| 1540 | #elif defined(OS_CHROMEOS) |
Huanzhong Huang | afa9809 | 2019-06-24 12:01:24 | [diff] [blame] | 1541 | return TabletModeClient::Get() && |
| 1542 | TabletModeClient::Get()->tablet_mode_enabled(); |
Ahmed Fakhry | e6a2c64 | 2018-06-20 02:58:41 | [diff] [blame] | 1543 | #else |
| 1544 | return false; |
| 1545 | #endif // defined(OS_ANDROID) |
| 1546 | } |
| 1547 | |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 1548 | bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 1549 | content::BrowserContext* browser_context, const GURL& effective_url) { |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1550 | // Non-extension, non-Instant URLs should generally use |
| 1551 | // process-per-site-instance. Because we expect to use the effective URL, |
| 1552 | // URLs for hosted apps (apart from bookmark apps) should have an extension |
| 1553 | // scheme by now. |
| 1554 | |
| 1555 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 1556 | if (!profile) |
| 1557 | return false; |
| 1558 | |
Marc Treib | 7d467b79 | 2017-12-04 13:31:03 | [diff] [blame] | 1559 | #if !defined(OS_ANDROID) |
sdefresne | 51bbec7b | 2015-08-03 14:18:13 | [diff] [blame] | 1560 | if (search::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1561 | return true; |
Marc Treib | 7d467b79 | 2017-12-04 13:31:03 | [diff] [blame] | 1562 | #endif |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1563 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1564 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1565 | return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite( |
| 1566 | profile, effective_url); |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1567 | #else |
| 1568 | return false; |
| 1569 | #endif |
[email protected] | 056ad2a | 2011-07-12 02:13:55 | [diff] [blame] | 1570 | } |
| 1571 | |
Lukasz Anforowicz | 32d2712 | 2018-04-09 21:48:33 | [diff] [blame] | 1572 | bool ChromeContentBrowserClient::ShouldUseSpareRenderProcessHost( |
| 1573 | content::BrowserContext* browser_context, |
| 1574 | const GURL& site_url) { |
| 1575 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 1576 | if (!profile) |
| 1577 | return false; |
| 1578 | |
| 1579 | #if !defined(OS_ANDROID) |
| 1580 | // Instant renderers should not use a spare process, because they require |
| 1581 | // passing switches::kInstantProcess to the renderer process when it |
| 1582 | // launches. A spare process is launched earlier, before it is known which |
| 1583 | // navigation will use it, so it lacks this flag. |
| 1584 | if (search::ShouldAssignURLToInstantRenderer(site_url, profile)) |
| 1585 | return false; |
| 1586 | #endif |
| 1587 | |
| 1588 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1589 | return ChromeContentBrowserClientExtensionsPart:: |
| 1590 | ShouldUseSpareRenderProcessHost(profile, site_url); |
| 1591 | #else |
| 1592 | return true; |
| 1593 | #endif |
| 1594 | } |
| 1595 | |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1596 | bool ChromeContentBrowserClient::DoesSiteRequireDedicatedProcess( |
Lukasz Anforowicz | 4aff3b8 | 2019-04-04 16:00:33 | [diff] [blame] | 1597 | content::BrowserOrResourceContext browser_or_resource_context, |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1598 | const GURL& effective_site_url) { |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1599 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1600 | if (ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess( |
Lukasz Anforowicz | 4aff3b8 | 2019-04-04 16:00:33 | [diff] [blame] | 1601 | browser_or_resource_context, effective_site_url)) { |
nick | cc0d914 | 2015-10-14 16:27:10 | [diff] [blame] | 1602 | return true; |
| 1603 | } |
| 1604 | #endif |
| 1605 | return false; |
| 1606 | } |
| 1607 | |
nick | 7d0984c | 2015-08-29 00:13:46 | [diff] [blame] | 1608 | // TODO(creis, nick): https://crbug.com/160576 describes a weakness in our |
| 1609 | // origin-lock enforcement, where we don't have a way to efficiently know |
| 1610 | // effective URLs on the IO thread, and wind up killing processes that e.g. |
| 1611 | // request cookies for their actual URL. This whole function (and its |
| 1612 | // ExtensionsPart) should be removed once we add that ability to the IO thread. |
| 1613 | bool ChromeContentBrowserClient::ShouldLockToOrigin( |
| 1614 | content::BrowserContext* browser_context, |
| 1615 | const GURL& effective_site_url) { |
| 1616 | // Origin lock to the search scheme would kill processes upon legitimate |
| 1617 | // requests for cookies from the search engine's domain. |
| 1618 | if (effective_site_url.SchemeIs(chrome::kChromeSearchScheme)) |
| 1619 | return false; |
| 1620 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1621 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
nick | 7d0984c | 2015-08-29 00:13:46 | [diff] [blame] | 1622 | if (!ChromeContentBrowserClientExtensionsPart::ShouldLockToOrigin( |
| 1623 | browser_context, effective_site_url)) { |
| 1624 | return false; |
| 1625 | } |
| 1626 | #endif |
| 1627 | return true; |
creis | e5d6d173 | 2015-08-25 19:47:06 | [diff] [blame] | 1628 | } |
| 1629 | |
Lukasz Anforowicz | 05f356e | 2018-03-13 20:26:11 | [diff] [blame] | 1630 | const char* |
Lukasz Anforowicz | ce869f0b | 2018-08-06 18:33:37 | [diff] [blame] | 1631 | ChromeContentBrowserClient::GetInitiatorSchemeBypassingDocumentBlocking() { |
Charles Reis | 358baf47 | 2017-12-06 05:30:43 | [diff] [blame] | 1632 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Lukasz Anforowicz | 05f356e | 2018-03-13 20:26:11 | [diff] [blame] | 1633 | // Don't block responses for extension processes or for content scripts. |
| 1634 | // TODO(creis): When every extension fetch (including content scripts) has |
| 1635 | // been made to go through an extension-specific URLLoaderFactory, this |
| 1636 | // mechanism ought to work by enumerating the host permissions from the |
| 1637 | // extension manifest, and forwarding them on to the network service while |
| 1638 | // brokering the URLLoaderFactory. |
| 1639 | return extensions::kExtensionScheme; |
| 1640 | #else |
| 1641 | return nullptr; |
Charles Reis | 358baf47 | 2017-12-06 05:30:43 | [diff] [blame] | 1642 | #endif |
Charles Reis | 358baf47 | 2017-12-06 05:30:43 | [diff] [blame] | 1643 | } |
| 1644 | |
Lukasz Anforowicz | 2f81016 | 2018-10-03 21:38:07 | [diff] [blame] | 1645 | network::mojom::URLLoaderFactoryPtrInfo |
| 1646 | ChromeContentBrowserClient::CreateURLLoaderFactoryForNetworkRequests( |
| 1647 | content::RenderProcessHost* process, |
| 1648 | network::mojom::NetworkContext* network_context, |
Clark DuVall | a5e25b75 | 2018-11-27 22:08:16 | [diff] [blame] | 1649 | network::mojom::TrustedURLLoaderHeaderClientPtrInfo* header_client, |
Lukasz Anforowicz | 2f81016 | 2018-10-03 21:38:07 | [diff] [blame] | 1650 | const url::Origin& request_initiator) { |
| 1651 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1652 | return ChromeContentBrowserClientExtensionsPart:: |
Clark DuVall | a5e25b75 | 2018-11-27 22:08:16 | [diff] [blame] | 1653 | CreateURLLoaderFactoryForNetworkRequests( |
| 1654 | process, network_context, header_client, request_initiator); |
Lukasz Anforowicz | 2f81016 | 2018-10-03 21:38:07 | [diff] [blame] | 1655 | #else |
| 1656 | return network::mojom::URLLoaderFactoryPtrInfo(); |
| 1657 | #endif |
| 1658 | } |
| 1659 | |
[email protected] | 73b718f | 2014-01-27 02:59:46 | [diff] [blame] | 1660 | // These are treated as WebUI schemes but do not get WebUI bindings. Also, |
| 1661 | // view-source is allowed for these schemes. |
[email protected] | 8f89dd41 | 2013-04-17 02:35:41 | [diff] [blame] | 1662 | void ChromeContentBrowserClient::GetAdditionalWebUISchemes( |
| 1663 | std::vector<std::string>* additional_schemes) { |
| 1664 | additional_schemes->push_back(chrome::kChromeSearchScheme); |
[email protected] | 474a5a3 | 2014-07-28 18:23:24 | [diff] [blame] | 1665 | additional_schemes->push_back(dom_distiller::kDomDistillerScheme); |
Andrey Kosyakov | 031e9e3 | 2017-08-18 21:00:35 | [diff] [blame] | 1666 | additional_schemes->push_back(content::kChromeDevToolsScheme); |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 1667 | } |
| 1668 | |
alexmos | 94875b3b | 2017-03-16 22:19:01 | [diff] [blame] | 1669 | void ChromeContentBrowserClient::GetAdditionalViewSourceSchemes( |
| 1670 | std::vector<std::string>* additional_schemes) { |
| 1671 | GetAdditionalWebUISchemes(additional_schemes); |
| 1672 | |
| 1673 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1674 | additional_schemes->push_back(extensions::kExtensionScheme); |
| 1675 | #endif |
| 1676 | } |
| 1677 | |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 1678 | bool ChromeContentBrowserClient::LogWebUIUrl(const GURL& web_ui_url) { |
dbeam | baee5bd | 2015-09-26 03:07:01 | [diff] [blame] | 1679 | return webui::LogWebUIUrl(web_ui_url); |
| 1680 | } |
| 1681 | |
John Abd-El-Malek | 04bfa853 | 2018-07-12 05:28:22 | [diff] [blame] | 1682 | bool ChromeContentBrowserClient::IsWebUIAllowedToMakeNetworkRequests( |
| 1683 | const url::Origin& origin) { |
| 1684 | return ChromeWebUIControllerFactory::IsWebUIAllowedToMakeNetworkRequests( |
| 1685 | origin); |
| 1686 | } |
| 1687 | |
[email protected] | 46fb944 | 2011-12-09 17:57:47 | [diff] [blame] | 1688 | bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { |
| 1689 | return ProfileIOData::IsHandledURL(url); |
| 1690 | } |
| 1691 | |
[email protected] | c4365fa4 | 2013-05-14 01:08:24 | [diff] [blame] | 1692 | bool ChromeContentBrowserClient::CanCommitURL( |
| 1693 | content::RenderProcessHost* process_host, |
| 1694 | const GURL& url) { |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1695 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1696 | return ChromeContentBrowserClientExtensionsPart::CanCommitURL( |
| 1697 | process_host, url); |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1698 | #else |
| 1699 | return true; |
| 1700 | #endif |
[email protected] | c4365fa4 | 2013-05-14 01:08:24 | [diff] [blame] | 1701 | } |
| 1702 | |
[email protected] | 9a60d160 | 2013-09-11 04:09:12 | [diff] [blame] | 1703 | bool ChromeContentBrowserClient::ShouldAllowOpenURL( |
| 1704 | content::SiteInstance* site_instance, const GURL& url) { |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1705 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1706 | bool result; |
| 1707 | if (ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL( |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 1708 | site_instance, url, &result)) |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1709 | return result; |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1710 | #endif |
[email protected] | 879816a9 | 2014-04-29 00:53:54 | [diff] [blame] | 1711 | |
| 1712 | // Do not allow chrome://chrome-signin navigate to other chrome:// URLs, since |
| 1713 | // the signin page may host untrusted web content. |
alexmos | 1c3da4f | 2016-11-03 06:06:11 | [diff] [blame] | 1714 | GURL from_url = site_instance->GetSiteURL(); |
[email protected] | 879816a9 | 2014-04-29 00:53:54 | [diff] [blame] | 1715 | if (from_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL && |
| 1716 | url.SchemeIs(content::kChromeUIScheme) && |
brettw | b65cd5c | 2016-01-23 00:46:38 | [diff] [blame] | 1717 | url.host_piece() != chrome::kChromeUIChromeSigninHost) { |
[email protected] | 879816a9 | 2014-04-29 00:53:54 | [diff] [blame] | 1718 | VLOG(1) << "Blocked navigation to " << url.spec() << " from " |
| 1719 | << chrome::kChromeUIChromeSigninURL; |
| 1720 | return false; |
| 1721 | } |
| 1722 | |
[email protected] | 9a60d160 | 2013-09-11 04:09:12 | [diff] [blame] | 1723 | return true; |
| 1724 | } |
| 1725 | |
avi | 7595a1bc | 2016-11-17 20:24:01 | [diff] [blame] | 1726 | namespace { |
| 1727 | |
| 1728 | // Returns whether a SiteInstance holds a NTP. TODO(mastiz): This |
| 1729 | // really really really needs to be moved to a shared place where all the code |
| 1730 | // that needs to know this can access it. See http://crbug.com/624410. |
| 1731 | bool IsNTPSiteInstance(SiteInstance* site_instance) { |
| 1732 | // While using SiteInstance::GetSiteURL() is unreliable and the wrong thing to |
| 1733 | // use for making security decisions 99.44% of the time, for detecting the NTP |
| 1734 | // it is reliable and the correct way. Again, see http://crbug.com/624410. |
| 1735 | return site_instance && |
| 1736 | site_instance->GetSiteURL().SchemeIs(chrome::kChromeSearchScheme) && |
| 1737 | (site_instance->GetSiteURL().host_piece() == |
| 1738 | chrome::kChromeSearchRemoteNtpHost || |
| 1739 | site_instance->GetSiteURL().host_piece() == |
| 1740 | chrome::kChromeSearchLocalNtpHost); |
| 1741 | } |
| 1742 | |
| 1743 | } // namespace |
| 1744 | |
rdevlin.cronin | a32a090 | 2016-11-09 15:50:20 | [diff] [blame] | 1745 | void ChromeContentBrowserClient::OverrideNavigationParams( |
| 1746 | SiteInstance* site_instance, |
| 1747 | ui::PageTransition* transition, |
| 1748 | bool* is_renderer_initiated, |
Lukasz Anforowicz | 63f3b943 | 2019-05-30 05:42:58 | [diff] [blame] | 1749 | content::Referrer* referrer, |
| 1750 | base::Optional<url::Origin>* initiator_origin) { |
rdevlin.cronin | a32a090 | 2016-11-09 15:50:20 | [diff] [blame] | 1751 | DCHECK(transition); |
| 1752 | DCHECK(is_renderer_initiated); |
| 1753 | DCHECK(referrer); |
mastiz | a77db699 | 2016-06-30 09:48:42 | [diff] [blame] | 1754 | // TODO(crbug.com/624410): Factor the predicate to identify a URL as an NTP |
| 1755 | // to a shared library. |
avi | 7595a1bc | 2016-11-17 20:24:01 | [diff] [blame] | 1756 | if (IsNTPSiteInstance(site_instance) && |
rdevlin.cronin | a32a090 | 2016-11-09 15:50:20 | [diff] [blame] | 1757 | ui::PageTransitionCoreTypeIs(*transition, ui::PAGE_TRANSITION_LINK)) { |
Lukasz Anforowicz | 63f3b943 | 2019-05-30 05:42:58 | [diff] [blame] | 1758 | // Clicks on tiles of the new tab page should be treated as if a user |
| 1759 | // clicked on a bookmark. This is consistent with native implementations |
| 1760 | // like Android's. This also helps ensure that security features (like |
| 1761 | // Sec-Fetch-Site and SameSite-cookies) will treat the navigation as |
| 1762 | // browser-initiated. |
rdevlin.cronin | a32a090 | 2016-11-09 15:50:20 | [diff] [blame] | 1763 | *transition = ui::PAGE_TRANSITION_AUTO_BOOKMARK; |
| 1764 | *is_renderer_initiated = false; |
| 1765 | *referrer = content::Referrer(); |
Lukasz Anforowicz | 63f3b943 | 2019-05-30 05:42:58 | [diff] [blame] | 1766 | *initiator_origin = base::nullopt; |
mastiz | a77db699 | 2016-06-30 09:48:42 | [diff] [blame] | 1767 | } |
rdevlin.cronin | a32a090 | 2016-11-09 15:50:20 | [diff] [blame] | 1768 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1769 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
rdevlin.cronin | a32a090 | 2016-11-09 15:50:20 | [diff] [blame] | 1770 | ChromeContentBrowserClientExtensionsPart::OverrideNavigationParams( |
Lukasz Anforowicz | 63f3b943 | 2019-05-30 05:42:58 | [diff] [blame] | 1771 | site_instance, transition, is_renderer_initiated, referrer, |
| 1772 | initiator_origin); |
rdevlin.cronin | a32a090 | 2016-11-09 15:50:20 | [diff] [blame] | 1773 | #endif |
mastiz | a77db699 | 2016-06-30 09:48:42 | [diff] [blame] | 1774 | } |
| 1775 | |
Charles Reis | 29e9dd1 | 2017-09-28 00:59:15 | [diff] [blame] | 1776 | bool ChromeContentBrowserClient::ShouldStayInParentProcessForNTP( |
| 1777 | const GURL& url, |
| 1778 | SiteInstance* parent_site_instance) { |
| 1779 | return url.SchemeIs(chrome::kChromeSearchScheme) && |
| 1780 | IsNTPSiteInstance(parent_site_instance); |
| 1781 | } |
| 1782 | |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1783 | bool ChromeContentBrowserClient::IsSuitableHost( |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1784 | content::RenderProcessHost* process_host, |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1785 | const GURL& site_url) { |
| 1786 | Profile* profile = |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 1787 | Profile::FromBrowserContext(process_host->GetBrowserContext()); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1788 | // This may be NULL during tests. In that case, just assume any site can |
| 1789 | // share any host. |
| 1790 | if (!profile) |
| 1791 | return true; |
| 1792 | |
Marc Treib | 7895941d | 2017-11-28 12:37:02 | [diff] [blame] | 1793 | #if !defined(OS_ANDROID) |
[email protected] | d43f99fe | 2013-04-03 00:20:14 | [diff] [blame] | 1794 | // Instant URLs should only be in the instant process and instant process |
| 1795 | // should only have Instant URLs. |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1796 | InstantService* instant_service = |
| 1797 | InstantServiceFactory::GetForProfile(profile); |
[email protected] | d43f99fe | 2013-04-03 00:20:14 | [diff] [blame] | 1798 | if (instant_service) { |
| 1799 | bool is_instant_process = instant_service->IsInstantProcess( |
| 1800 | process_host->GetID()); |
| 1801 | bool should_be_in_instant_process = |
sdefresne | 51bbec7b | 2015-08-03 14:18:13 | [diff] [blame] | 1802 | search::ShouldAssignURLToInstantRenderer(site_url, profile); |
[email protected] | d43f99fe | 2013-04-03 00:20:14 | [diff] [blame] | 1803 | if (is_instant_process || should_be_in_instant_process) |
| 1804 | return is_instant_process && should_be_in_instant_process; |
| 1805 | } |
Marc Treib | 7895941d | 2017-11-28 12:37:02 | [diff] [blame] | 1806 | #endif |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1807 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1808 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1809 | return ChromeContentBrowserClientExtensionsPart::IsSuitableHost( |
| 1810 | profile, process_host, site_url); |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1811 | #else |
| 1812 | return true; |
| 1813 | #endif |
[email protected] | 2a5221b | 2011-09-27 23:07:31 | [diff] [blame] | 1814 | } |
| 1815 | |
[email protected] | 28c5d0b7 | 2014-05-13 08:19:59 | [diff] [blame] | 1816 | bool ChromeContentBrowserClient::MayReuseHost( |
| 1817 | content::RenderProcessHost* process_host) { |
| 1818 | // If there is currently a prerender in progress for the host provided, |
| 1819 | // it may not be shared. We require prerenders to be by themselves in a |
davidben | 879199c | 2015-03-06 00:55:04 | [diff] [blame] | 1820 | // separate process so that we can monitor their resource usage. |
[email protected] | 28c5d0b7 | 2014-05-13 08:19:59 | [diff] [blame] | 1821 | prerender::PrerenderManager* prerender_manager = |
droger | c154315 | 2016-09-20 13:03:37 | [diff] [blame] | 1822 | prerender::PrerenderManagerFactory::GetForBrowserContext( |
| 1823 | process_host->GetBrowserContext()); |
[email protected] | 28c5d0b7 | 2014-05-13 08:19:59 | [diff] [blame] | 1824 | if (prerender_manager && |
[email protected] | 2290af2 | 2014-05-26 15:44:49 | [diff] [blame] | 1825 | !prerender_manager->MayReuseProcessHost(process_host)) { |
[email protected] | 28c5d0b7 | 2014-05-13 08:19:59 | [diff] [blame] | 1826 | return false; |
| 1827 | } |
| 1828 | |
| 1829 | return true; |
| 1830 | } |
| 1831 | |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1832 | bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( |
| 1833 | content::BrowserContext* browser_context, const GURL& url) { |
| 1834 | // It has to be a valid URL for us to check for an extension. |
| 1835 | if (!url.is_valid()) |
| 1836 | return false; |
| 1837 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1838 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1839 | Profile* profile = Profile::FromBrowserContext(browser_context); |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1840 | return ChromeContentBrowserClientExtensionsPart:: |
| 1841 | ShouldTryToUseExistingProcessHost( |
| 1842 | profile, url); |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1843 | #else |
| 1844 | return false; |
| 1845 | #endif |
[email protected] | 76411f41 | 2012-02-22 18:56:06 | [diff] [blame] | 1846 | } |
| 1847 | |
Alex Moshchuk | 9c9e388 | 2018-11-02 19:57:03 | [diff] [blame] | 1848 | bool ChromeContentBrowserClient::ShouldSubframesTryToReuseExistingProcess( |
| 1849 | content::RenderFrameHost* main_frame) { |
| 1850 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 1851 | return ChromeContentBrowserClientExtensionsPart:: |
| 1852 | ShouldSubframesTryToReuseExistingProcess(main_frame); |
| 1853 | #else |
| 1854 | return true; |
| 1855 | #endif |
| 1856 | } |
| 1857 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1858 | void ChromeContentBrowserClient::SiteInstanceGotProcess( |
| 1859 | SiteInstance* site_instance) { |
| 1860 | CHECK(site_instance->HasProcess()); |
| 1861 | |
| 1862 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 72daaa9 | 2012-01-18 13:39:02 | [diff] [blame] | 1863 | site_instance->GetBrowserContext()); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1864 | if (!profile) |
| 1865 | return; |
| 1866 | |
Marc Treib | 7895941d | 2017-11-28 12:37:02 | [diff] [blame] | 1867 | #if !defined(OS_ANDROID) |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1868 | // Remember the ID of the Instant process to signal the renderer process |
| 1869 | // on startup in |AppendExtraCommandLineSwitches| below. |
sdefresne | 51bbec7b | 2015-08-03 14:18:13 | [diff] [blame] | 1870 | if (search::ShouldAssignURLToInstantRenderer(site_instance->GetSiteURL(), |
| 1871 | profile)) { |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1872 | InstantService* instant_service = |
| 1873 | InstantServiceFactory::GetForProfile(profile); |
| 1874 | if (instant_service) |
| 1875 | instant_service->AddInstantProcess(site_instance->GetProcess()->GetID()); |
| 1876 | } |
Marc Treib | 7895941d | 2017-11-28 12:37:02 | [diff] [blame] | 1877 | #endif |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1878 | |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 1879 | for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 1880 | extra_parts_[i]->SiteInstanceGotProcess(site_instance); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | void ChromeContentBrowserClient::SiteInstanceDeleting( |
| 1884 | SiteInstance* site_instance) { |
| 1885 | if (!site_instance->HasProcess()) |
| 1886 | return; |
| 1887 | |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 1888 | for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 1889 | extra_parts_[i]->SiteInstanceDeleting(site_instance); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 1890 | } |
| 1891 | |
[email protected] | 453f543 | 2013-11-26 19:43:00 | [diff] [blame] | 1892 | bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation( |
[email protected] | e9841fbd | 2013-02-22 23:12:14 | [diff] [blame] | 1893 | SiteInstance* site_instance, |
[email protected] | e3daf3c | 2011-10-05 21:17:08 | [diff] [blame] | 1894 | const GURL& current_url, |
| 1895 | const GURL& new_url) { |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 1896 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f7daaa3 | 2014-08-02 07:58:13 | [diff] [blame] | 1897 | return ChromeContentBrowserClientExtensionsPart:: |
| 1898 | ShouldSwapBrowsingInstancesForNavigation( |
| 1899 | site_instance, current_url, new_url); |
[email protected] | d5a74be | 2014-08-08 01:01:27 | [diff] [blame] | 1900 | #else |
| 1901 | return false; |
| 1902 | #endif |
[email protected] | e3daf3c | 2011-10-05 21:17:08 | [diff] [blame] | 1903 | } |
| 1904 | |
Nasko Oskov | d83b571 | 2018-05-04 04:50:57 | [diff] [blame] | 1905 | bool ChromeContentBrowserClient::ShouldIsolateErrorPage(bool in_main_frame) { |
| 1906 | // TODO(nasko): Consider supporting error page isolation in subframes if |
| 1907 | // Site Isolation is enabled. |
Nasko Oskov | 55d21e15 | 2018-06-27 23:59:38 | [diff] [blame] | 1908 | return in_main_frame; |
Nasko Oskov | d83b571 | 2018-05-04 04:50:57 | [diff] [blame] | 1909 | } |
| 1910 | |
[email protected] | 3d83199 | 2013-07-04 01:13:29 | [diff] [blame] | 1911 | bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { |
| 1912 | return !url.SchemeIs(chrome::kChromeNativeScheme); |
| 1913 | } |
| 1914 | |
Alex Moshchuk | d252c19 | 2017-07-17 22:03:48 | [diff] [blame] | 1915 | std::vector<url::Origin> |
| 1916 | ChromeContentBrowserClient::GetOriginsRequiringDedicatedProcess() { |
| 1917 | std::vector<url::Origin> isolated_origin_list; |
| 1918 | |
Alex Moshchuk | 89352a7 | 2017-10-25 20:25:59 | [diff] [blame] | 1919 | // Sign-in process isolation is not needed on Android, see |
| 1920 | // https://crbug.com/739418. |
| 1921 | #if !defined(OS_ANDROID) |
Alex Moshchuk | 36417aa | 2018-06-13 18:01:12 | [diff] [blame] | 1922 | isolated_origin_list.emplace_back( |
| 1923 | url::Origin::Create(GaiaUrls::GetInstance()->gaia_url())); |
Alex Moshchuk | 89352a7 | 2017-10-25 20:25:59 | [diff] [blame] | 1924 | #endif |
Alex Moshchuk | d252c19 | 2017-07-17 22:03:48 | [diff] [blame] | 1925 | |
| 1926 | return isolated_origin_list; |
| 1927 | } |
| 1928 | |
Lukasz Anforowicz | 5e201abd | 2018-03-24 00:41:06 | [diff] [blame] | 1929 | bool ChromeContentBrowserClient::ShouldEnableStrictSiteIsolation() { |
Aaron Colwell | 25617f7 | 2018-11-27 20:56:34 | [diff] [blame] | 1930 | return base::FeatureList::IsEnabled(features::kSitePerProcess); |
| 1931 | } |
| 1932 | |
| 1933 | bool ChromeContentBrowserClient::ShouldDisableSiteIsolation() { |
Lukasz Anforowicz | 0711a0f | 2019-03-28 18:15:31 | [diff] [blame] | 1934 | // Using 1077 rather than 1024 because 1) it helps ensure that devices with |
| 1935 | // exactly 1GB of RAM won't get included because of inaccuracies or off-by-one |
| 1936 | // errors and 2) this is the bucket boundary in Memory.Stats.Win.TotalPhys2. |
| 1937 | // See also https://crbug.com/844118. |
| 1938 | constexpr int kDefaultMemoryThresholdMb = 1077; |
Aaron Colwell | 25617f7 | 2018-11-27 20:56:34 | [diff] [blame] | 1939 | |
| 1940 | // TODO(acolwell): Rename feature since it now affects more than just the |
| 1941 | // site-per-process case. |
Lukasz Anforowicz | 46275d9 | 2018-04-12 14:57:38 | [diff] [blame] | 1942 | if (base::FeatureList::IsEnabled( |
| 1943 | features::kSitePerProcessOnlyForHighMemoryClients)) { |
Lukasz Anforowicz | 46275d9 | 2018-04-12 14:57:38 | [diff] [blame] | 1944 | int memory_threshold_mb = base::GetFieldTrialParamByFeatureAsInt( |
| 1945 | features::kSitePerProcessOnlyForHighMemoryClients, |
| 1946 | features::kSitePerProcessOnlyForHighMemoryClientsParamName, |
| 1947 | kDefaultMemoryThresholdMb); |
Aaron Colwell | 25617f7 | 2018-11-27 20:56:34 | [diff] [blame] | 1948 | return base::SysInfo::AmountOfPhysicalMemoryMB() <= memory_threshold_mb; |
Lukasz Anforowicz | 46275d9 | 2018-04-12 14:57:38 | [diff] [blame] | 1949 | } |
| 1950 | |
Aaron Colwell | 25617f7 | 2018-11-27 20:56:34 | [diff] [blame] | 1951 | #if defined(OS_ANDROID) |
| 1952 | if (base::SysInfo::AmountOfPhysicalMemoryMB() <= kDefaultMemoryThresholdMb) { |
| 1953 | return true; |
| 1954 | } |
| 1955 | #endif |
| 1956 | |
| 1957 | return false; |
Lukasz Anforowicz | 5e201abd | 2018-03-24 00:41:06 | [diff] [blame] | 1958 | } |
| 1959 | |
Alex Moshchuk | 082b5f8 | 2019-03-14 01:34:16 | [diff] [blame] | 1960 | std::vector<std::string> |
| 1961 | ChromeContentBrowserClient::GetAdditionalSiteIsolationModes() { |
| 1962 | if (SiteIsolationPolicy::IsIsolationForPasswordSitesEnabled()) |
| 1963 | return {"Isolate Password Sites"}; |
| 1964 | else |
| 1965 | return {}; |
| 1966 | } |
| 1967 | |
Alex Moshchuk | e256d56 | 2019-04-26 21:43:57 | [diff] [blame] | 1968 | void ChromeContentBrowserClient::PersistIsolatedOrigin( |
| 1969 | content::BrowserContext* context, |
| 1970 | const url::Origin& origin) { |
| 1971 | DCHECK(!context->IsOffTheRecord()); |
| 1972 | Profile* profile = Profile::FromBrowserContext(context); |
| 1973 | ListPrefUpdate update(profile->GetPrefs(), |
| 1974 | prefs::kUserTriggeredIsolatedOrigins); |
| 1975 | base::ListValue* list = update.Get(); |
| 1976 | base::Value value(origin.Serialize()); |
Jan Wilken Dörrie | a8cb5630 | 2019-06-06 18:59:36 | [diff] [blame] | 1977 | if (!base::Contains(list->GetList(), value)) |
Alex Moshchuk | e256d56 | 2019-04-26 21:43:57 | [diff] [blame] | 1978 | list->GetList().push_back(std::move(value)); |
| 1979 | } |
| 1980 | |
Ken Rockot | 314714c | 2017-11-05 23:36:24 | [diff] [blame] | 1981 | bool ChromeContentBrowserClient::IsFileAccessAllowed( |
| 1982 | const base::FilePath& path, |
| 1983 | const base::FilePath& absolute_path, |
| 1984 | const base::FilePath& profile_path) { |
| 1985 | return ChromeNetworkDelegate::IsAccessAllowed(path, absolute_path, |
| 1986 | profile_path); |
| 1987 | } |
| 1988 | |
[email protected] | d2e1a0a | 2014-06-16 15:49:37 | [diff] [blame] | 1989 | namespace { |
| 1990 | |
| 1991 | bool IsAutoReloadEnabled() { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 1992 | const base::CommandLine& browser_command_line = |
| 1993 | *base::CommandLine::ForCurrentProcess(); |
Elly Fong-Jones | 5f13ee1 | 2019-05-10 19:20:35 | [diff] [blame] | 1994 | if (browser_command_line.HasSwitch(switches::kEnableAutoReload)) |
[email protected] | d2e1a0a | 2014-06-16 15:49:37 | [diff] [blame] | 1995 | return true; |
Elly Fong-Jones | 5f13ee1 | 2019-05-10 19:20:35 | [diff] [blame] | 1996 | if (browser_command_line.HasSwitch(switches::kDisableAutoReload)) |
[email protected] | d2e1a0a | 2014-06-16 15:49:37 | [diff] [blame] | 1997 | return false; |
[email protected] | 9ef49b4 | 2014-08-07 16:44:24 | [diff] [blame] | 1998 | return true; |
[email protected] | d2e1a0a | 2014-06-16 15:49:37 | [diff] [blame] | 1999 | } |
| 2000 | |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 2001 | void MaybeAppendBlinkSettingsSwitchForFieldTrial( |
| 2002 | const base::CommandLine& browser_command_line, |
| 2003 | base::CommandLine* command_line) { |
bmcquade | 9dd54cc | 2015-06-22 16:56:52 | [diff] [blame] | 2004 | // List of field trials that modify the blink-settings command line flag. No |
| 2005 | // two field trials in the list should specify the same keys, otherwise one |
| 2006 | // field trial may overwrite another. See Source/core/frame/Settings.in in |
| 2007 | // Blink for the list of valid keys. |
| 2008 | static const char* const kBlinkSettingsFieldTrials[] = { |
jkarlin | 3bddb7d | 2016-09-21 18:44:16 | [diff] [blame] | 2009 | // Keys: disallowFetchForDocWrittenScriptsInMainFrame |
| 2010 | // disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections |
| 2011 | // disallowFetchForDocWrittenScriptsInMainFrameIfEffectively2G |
| 2012 | "DisallowFetchForDocWrittenScriptsInMainFrame", |
bmcquade | 9dd54cc | 2015-06-22 16:56:52 | [diff] [blame] | 2013 | }; |
| 2014 | |
| 2015 | std::vector<std::string> blink_settings; |
| 2016 | for (const char* field_trial_name : kBlinkSettingsFieldTrials) { |
| 2017 | // Each blink-settings field trial should include a forcing_flag group, |
| 2018 | // to make sure that clients that specify the blink-settings flag on the |
| 2019 | // command line are excluded from the experiment groups. To make |
| 2020 | // sure we assign clients that specify this flag to the forcing_flag |
| 2021 | // group, we must call GetVariationParams for each field trial first |
| 2022 | // (for example, before checking HasSwitch() and returning), since |
| 2023 | // GetVariationParams has the side-effect of assigning the client to |
| 2024 | // a field trial group. |
| 2025 | std::map<std::string, std::string> params; |
| 2026 | if (variations::GetVariationParams(field_trial_name, ¶ms)) { |
| 2027 | for (const auto& param : params) { |
| 2028 | blink_settings.push_back(base::StringPrintf( |
| 2029 | "%s=%s", param.first.c_str(), param.second.c_str())); |
| 2030 | } |
| 2031 | } |
| 2032 | } |
pmeenan | 9ac66968 | 2015-08-17 14:57:03 | [diff] [blame] | 2033 | |
bmcquade | 9dd54cc | 2015-06-22 16:56:52 | [diff] [blame] | 2034 | if (blink_settings.empty()) { |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 2035 | return; |
| 2036 | } |
| 2037 | |
| 2038 | if (browser_command_line.HasSwitch(switches::kBlinkSettings) || |
| 2039 | command_line->HasSwitch(switches::kBlinkSettings)) { |
pmeenan | 9ac66968 | 2015-08-17 14:57:03 | [diff] [blame] | 2040 | // The field trials should be configured to force users that specify the |
bmcquade | 9dd54cc | 2015-06-22 16:56:52 | [diff] [blame] | 2041 | // blink-settings flag into a group with no params, and we return |
| 2042 | // above if no params were specified, so it's an error if we reach |
| 2043 | // this point. |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 2044 | LOG(WARNING) << "Received field trial params, " |
| 2045 | "but blink-settings switch already specified."; |
| 2046 | return; |
| 2047 | } |
| 2048 | |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 2049 | command_line->AppendSwitchASCII(switches::kBlinkSettings, |
brettw | d94a2214 | 2015-07-15 05:19:26 | [diff] [blame] | 2050 | base::JoinString(blink_settings, ",")); |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 2051 | } |
| 2052 | |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 2053 | #if defined(OS_ANDROID) |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 2054 | template <typename Interface> |
| 2055 | void ForwardToJavaFrameRegistry( |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 2056 | mojo::InterfaceRequest<Interface> request, |
| 2057 | content::RenderFrameHost* render_frame_host) { |
| 2058 | render_frame_host->GetJavaInterfaces()->GetInterface(std::move(request)); |
mgiuca | 3d9a196 | 2017-04-07 05:25:44 | [diff] [blame] | 2059 | } |
| 2060 | |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 2061 | template <typename Interface> |
| 2062 | void ForwardToJavaWebContentsRegistry( |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 2063 | mojo::InterfaceRequest<Interface> request, |
| 2064 | content::RenderFrameHost* render_frame_host) { |
| 2065 | content::WebContents* contents = |
| 2066 | content::WebContents::FromRenderFrameHost(render_frame_host); |
| 2067 | if (contents) |
| 2068 | contents->GetJavaInterfaces()->GetInterface(std::move(request)); |
sammc | 0285a44 | 2016-10-04 23:03:56 | [diff] [blame] | 2069 | } |
| 2070 | #endif |
| 2071 | |
[email protected] | d2e1a0a | 2014-06-16 15:49:37 | [diff] [blame] | 2072 | } // namespace |
| 2073 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2074 | void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 2075 | base::CommandLine* command_line, |
| 2076 | int child_process_id) { |
Mark Mentovai | c67fa64f | 2015-03-24 14:00:06 | [diff] [blame] | 2077 | #if defined(OS_MACOSX) |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 2078 | std::unique_ptr<metrics::ClientInfo> client_info = |
Mark Mentovai | c67fa64f | 2015-03-24 14:00:06 | [diff] [blame] | 2079 | GoogleUpdateSettings::LoadMetricsClientInfo(); |
| 2080 | if (client_info) { |
| 2081 | command_line->AppendSwitchASCII(switches::kMetricsClientID, |
| 2082 | client_info->client_id); |
| 2083 | } |
| 2084 | #elif defined(OS_POSIX) |
Joshua Peraza | f890e4b | 2019-01-03 19:19:02 | [diff] [blame] | 2085 | #if defined(OS_ANDROID) |
| 2086 | bool enable_crash_reporter = true; |
| 2087 | #else |
| 2088 | bool enable_crash_reporter = breakpad::IsCrashReporterEnabled(); |
| 2089 | #endif |
| 2090 | if (enable_crash_reporter) { |
thestig | cb7a59a | 2016-01-26 02:43:51 | [diff] [blame] | 2091 | std::string switch_value; |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 2092 | std::unique_ptr<metrics::ClientInfo> client_info = |
[email protected] | 8e885de | 2014-07-22 23:36:53 | [diff] [blame] | 2093 | GoogleUpdateSettings::LoadMetricsClientInfo(); |
thestig | cb7a59a | 2016-01-26 02:43:51 | [diff] [blame] | 2094 | if (client_info) |
| 2095 | switch_value = client_info->client_id; |
| 2096 | switch_value.push_back(','); |
Boris Vidolov | 8657801 | 2018-03-21 16:55:25 | [diff] [blame] | 2097 | switch_value.append(chrome::GetChannelName()); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2098 | command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
thestig | cb7a59a | 2016-01-26 02:43:51 | [diff] [blame] | 2099 | switch_value); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2100 | } |
Mark Mentovai | c67fa64f | 2015-03-24 14:00:06 | [diff] [blame] | 2101 | #endif |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2102 | |
[email protected] | f193379 | 2011-06-14 00:49:34 | [diff] [blame] | 2103 | if (logging::DialogsAreSuppressed()) |
| 2104 | command_line->AppendSwitch(switches::kNoErrorDialogs); |
| 2105 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2106 | std::string process_type = |
| 2107 | command_line->GetSwitchValueASCII(switches::kProcessType); |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 2108 | const base::CommandLine& browser_command_line = |
| 2109 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | 9206f2a0 | 2013-03-20 01:10:32 | [diff] [blame] | 2110 | |
[email protected] | 7c9b6f9 | 2013-09-10 18:11:35 | [diff] [blame] | 2111 | static const char* const kCommonSwitchNames[] = { |
[email protected] | aa05127 | 2014-03-10 05:56:56 | [diff] [blame] | 2112 | switches::kUserAgent, |
[email protected] | 7c9b6f9 | 2013-09-10 18:11:35 | [diff] [blame] | 2113 | switches::kUserDataDir, // Make logs go to the right file. |
| 2114 | }; |
| 2115 | command_line->CopySwitchesFrom(browser_command_line, kCommonSwitchNames, |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 2116 | base::size(kCommonSwitchNames)); |
[email protected] | 9206f2a0 | 2013-03-20 01:10:32 | [diff] [blame] | 2117 | |
fqj | 15ff3f7 | 2015-10-09 19:20:02 | [diff] [blame] | 2118 | static const char* const kDinosaurEasterEggSwitches[] = { |
blundell | a5e3240a | 2016-01-05 11:30:43 | [diff] [blame] | 2119 | error_page::switches::kDisableDinosaurEasterEgg, |
edwardjung | 7db1c9e | 2015-03-25 15:44:31 | [diff] [blame] | 2120 | }; |
fqj | 15ff3f7 | 2015-10-09 19:20:02 | [diff] [blame] | 2121 | command_line->CopySwitchesFrom(browser_command_line, |
| 2122 | kDinosaurEasterEggSwitches, |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 2123 | base::size(kDinosaurEasterEggSwitches)); |
edwardjung | 7db1c9e | 2015-03-25 15:44:31 | [diff] [blame] | 2124 | |
fqj | 15ff3f7 | 2015-10-09 19:20:02 | [diff] [blame] | 2125 | #if defined(OS_CHROMEOS) |
[email protected] | 6bdc5227 | 2014-05-27 00:12:33 | [diff] [blame] | 2126 | // On Chrome OS need to pass primary user homedir (in multi-profiles session). |
| 2127 | base::FilePath homedir; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 2128 | base::PathService::Get(base::DIR_HOME, &homedir); |
[email protected] | 6bdc5227 | 2014-05-27 00:12:33 | [diff] [blame] | 2129 | command_line->AppendSwitchASCII(chromeos::switches::kHomedir, |
| 2130 | homedir.value().c_str()); |
| 2131 | #endif |
| 2132 | |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 2133 | if (process_type == switches::kRendererProcess) { |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 2134 | content::RenderProcessHost* process = |
| 2135 | content::RenderProcessHost::FromID(child_process_id); |
| 2136 | Profile* profile = |
| 2137 | process ? Profile::FromBrowserContext(process->GetBrowserContext()) |
| 2138 | : NULL; |
| 2139 | for (size_t i = 0; i < extra_parts_.size(); ++i) { |
| 2140 | extra_parts_[i]->AppendExtraRendererCommandLineSwitches( |
| 2141 | command_line, process, profile); |
| 2142 | } |
| 2143 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2144 | #if defined(OS_CHROMEOS) |
| 2145 | const std::string& login_profile = |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 2146 | browser_command_line.GetSwitchValueASCII( |
| 2147 | chromeos::switches::kLoginProfile); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2148 | if (!login_profile.empty()) |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 2149 | command_line->AppendSwitchASCII( |
| 2150 | chromeos::switches::kLoginProfile, login_profile); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2151 | #endif |
| 2152 | |
[email protected] | 30335fdf0 | 2014-02-26 19:51:27 | [diff] [blame] | 2153 | MaybeCopyDisableWebRtcEncryptionSwitch(command_line, |
| 2154 | browser_command_line, |
sdefresne | 9fb6769 | 2015-08-03 18:48:22 | [diff] [blame] | 2155 | chrome::GetChannel()); |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 2156 | if (process) { |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 2157 | PrefService* prefs = profile->GetPrefs(); |
| 2158 | // Currently this pref is only registered if applied via a policy. |
| 2159 | if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && |
| 2160 | prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
| 2161 | // Turn this policy into a command line switch. |
| 2162 | command_line->AppendSwitch(switches::kDisable3DAPIs); |
| 2163 | } |
[email protected] | 718eab6 | 2011-10-05 21:16:52 | [diff] [blame] | 2164 | |
[email protected] | 1733b78 | 2014-06-19 18:51:55 | [diff] [blame] | 2165 | const base::ListValue* switches = |
| 2166 | prefs->GetList(prefs::kEnableDeprecatedWebPlatformFeatures); |
| 2167 | if (switches) { |
| 2168 | // Enable any deprecated features that have been re-enabled by policy. |
jdoerrie | 601c715 | 2018-10-02 23:43:11 | [diff] [blame] | 2169 | for (auto it = switches->begin(); it != switches->end(); ++it) { |
[email protected] | 1733b78 | 2014-06-19 18:51:55 | [diff] [blame] | 2170 | std::string switch_to_enable; |
jdoerrie | a5676c6 | 2017-04-11 18:09:14 | [diff] [blame] | 2171 | if (it->GetAsString(&switch_to_enable)) |
[email protected] | 1733b78 | 2014-06-19 18:51:55 | [diff] [blame] | 2172 | command_line->AppendSwitch(switch_to_enable); |
| 2173 | } |
| 2174 | } |
| 2175 | |
[email protected] | a8d851f8 | 2011-12-21 00:32:37 | [diff] [blame] | 2176 | // Disable client-side phishing detection in the renderer if it is |
| 2177 | // disabled in the Profile preferences or the browser process. |
| 2178 | if (!prefs->GetBoolean(prefs::kSafeBrowsingEnabled) || |
| 2179 | !g_browser_process->safe_browsing_detection_service()) { |
| 2180 | command_line->AppendSwitch( |
| 2181 | switches::kDisableClientSidePhishingDetection); |
| 2182 | } |
[email protected] | 0045b0f4 | 2012-07-26 11:52:08 | [diff] [blame] | 2183 | |
vitalybuka | a7ae505 | 2014-09-26 04:11:13 | [diff] [blame] | 2184 | if (prefs->GetBoolean(prefs::kPrintPreviewDisabled)) |
| 2185 | command_line->AppendSwitch(switches::kDisablePrintPreview); |
| 2186 | |
Marc Treib | 7895941d | 2017-11-28 12:37:02 | [diff] [blame] | 2187 | #if !defined(OS_ANDROID) |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 2188 | InstantService* instant_service = |
| 2189 | InstantServiceFactory::GetForProfile(profile); |
| 2190 | if (instant_service && |
Chris Palmer | ac7d7564 | 2017-11-22 20:12:54 | [diff] [blame] | 2191 | instant_service->IsInstantProcess(process->GetID())) { |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 2192 | command_line->AppendSwitch(switches::kInstantProcess); |
Chris Palmer | ac7d7564 | 2017-11-22 20:12:54 | [diff] [blame] | 2193 | } |
Marc Treib | 7895941d | 2017-11-28 12:37:02 | [diff] [blame] | 2194 | #endif |
fqj | ba8749c | 2015-10-29 15:33:07 | [diff] [blame] | 2195 | |
fqj | 38306f7b | 2015-11-02 16:59:06 | [diff] [blame] | 2196 | if (prefs->HasPrefPath(prefs::kAllowDinosaurEasterEgg) && |
Chris Palmer | ac7d7564 | 2017-11-22 20:12:54 | [diff] [blame] | 2197 | !prefs->GetBoolean(prefs::kAllowDinosaurEasterEgg)) { |
blundell | a5e3240a | 2016-01-05 11:30:43 | [diff] [blame] | 2198 | command_line->AppendSwitch( |
| 2199 | error_page::switches::kDisableDinosaurEasterEgg); |
Chris Palmer | ac7d7564 | 2017-11-22 20:12:54 | [diff] [blame] | 2200 | } |
Daniel Vogelheim | 976f1c2 | 2017-11-22 16:26:03 | [diff] [blame] | 2201 | |
Lukasz Anforowicz | 60d1253d | 2019-05-08 16:31:37 | [diff] [blame] | 2202 | MaybeAppendSecureOriginsAllowlistSwitch(command_line); |
| 2203 | |
Amr Aboelkher | b04cbf3 | 2019-04-29 15:17:10 | [diff] [blame] | 2204 | if (prefs->HasPrefPath(prefs::kAllowPopupsDuringPageUnload) && |
| 2205 | prefs->GetBoolean(prefs::kAllowPopupsDuringPageUnload)) { |
Avi Drissman | fb96126 | 2019-03-05 22:50:29 | [diff] [blame] | 2206 | command_line->AppendSwitch(switches::kAllowPopupsDuringPageUnload); |
Amr Aboelkher | b04cbf3 | 2019-04-29 15:17:10 | [diff] [blame] | 2207 | } |
[email protected] | 47c7ec8 | 2012-01-18 03:29:21 | [diff] [blame] | 2208 | } |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2209 | |
[email protected] | d2e1a0a | 2014-06-16 15:49:37 | [diff] [blame] | 2210 | if (IsAutoReloadEnabled()) |
Elly Fong-Jones | 5f13ee1 | 2019-05-10 19:20:35 | [diff] [blame] | 2211 | command_line->AppendSwitch(switches::kEnableAutoReload); |
[email protected] | 28ee4e7 | 2014-03-28 19:29:04 | [diff] [blame] | 2212 | |
bmcquade | 5d2d9cf3 | 2015-06-19 17:42:28 | [diff] [blame] | 2213 | MaybeAppendBlinkSettingsSwitchForFieldTrial( |
| 2214 | browser_command_line, command_line); |
| 2215 | |
mdjones | a6b9e17 | 2016-09-23 16:24:30 | [diff] [blame] | 2216 | #if defined(OS_ANDROID) |
| 2217 | // If the platform is Android, force the distillability service on. |
| 2218 | command_line->AppendSwitch(switches::kEnableDistillabilityService); |
| 2219 | #endif |
| 2220 | |
[email protected] | 47c7ec8 | 2012-01-18 03:29:21 | [diff] [blame] | 2221 | // Please keep this in alphabetical order. |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2222 | static const char* const kSwitchNames[] = { |
estade | 0ee9126 | 2014-10-23 19:29:19 | [diff] [blame] | 2223 | autofill::switches::kIgnoreAutocompleteOffForAutofill, |
kolos | ad36993 | 2017-02-23 13:29:41 | [diff] [blame] | 2224 | autofill::switches::kShowAutofillSignatures, |
Chris Mumford | 6b1696b | 2019-01-25 02:54:30 | [diff] [blame] | 2225 | #if defined(OS_CHROMEOS) |
| 2226 | switches::kShortMergeSessionTimeoutForTest, // For tests only. |
| 2227 | #endif |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 2228 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | 558878cc8 | 2013-11-09 01:25:51 | [diff] [blame] | 2229 | extensions::switches::kAllowHTTPBackgroundPage, |
[email protected] | 49d9b14 | 2013-07-19 08:50:27 | [diff] [blame] | 2230 | extensions::switches::kAllowLegacyExtensionManifests, |
Chris Mumford | 3f0eda9 | 2018-07-23 14:51:17 | [diff] [blame] | 2231 | extensions::switches::kDisableExtensionsHttpThrottling, |
[email protected] | c8d0299 | 2013-07-31 22:16:51 | [diff] [blame] | 2232 | extensions::switches::kEnableExperimentalExtensionApis, |
[email protected] | 49d9b14 | 2013-07-19 08:50:27 | [diff] [blame] | 2233 | extensions::switches::kExtensionsOnChromeURLs, |
Chris Mumford | 3f0eda9 | 2018-07-23 14:51:17 | [diff] [blame] | 2234 | extensions::switches::kSetExtensionThrottleTestParams, // For tests only. |
[email protected] | a612eb3 | 2014-03-31 22:09:17 | [diff] [blame] | 2235 | extensions::switches::kWhitelistedExtensionID, |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 2236 | #endif |
estark | 4b003b33 | 2015-02-14 01:07:05 | [diff] [blame] | 2237 | switches::kAllowInsecureLocalhost, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2238 | switches::kAppsGalleryURL, |
[email protected] | 09cff7878 | 2014-04-20 22:04:48 | [diff] [blame] | 2239 | switches::kCloudPrintURL, |
[email protected] | 6f5c141a | 2014-04-15 21:44:51 | [diff] [blame] | 2240 | switches::kCloudPrintXmppEndpoint, |
[email protected] | 382fb0d | 2012-02-25 00:19:50 | [diff] [blame] | 2241 | switches::kDisableBundledPpapiFlash, |
dslomov | a893e97 | 2014-12-05 09:39:57 | [diff] [blame] | 2242 | switches::kDisableJavaScriptHarmonyShipping, |
Kyle Milka | b5c048e | 2017-07-07 02:38:46 | [diff] [blame] | 2243 | variations::switches::kEnableBenchmarking, |
mdjones | a6b9e17 | 2016-09-23 16:24:30 | [diff] [blame] | 2244 | switches::kEnableDistillabilityService, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2245 | switches::kEnableNaCl, |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 2246 | #if BUILDFLAG(ENABLE_NACL) |
[email protected] | 1b4ec38 | 2014-03-07 02:32:24 | [diff] [blame] | 2247 | switches::kEnableNaClDebug, |
[email protected] | b2c73f4 | 2014-03-07 15:44:48 | [diff] [blame] | 2248 | switches::kEnableNaClNonSfiMode, |
[email protected] | a56f832 | 2014-07-16 21:13:55 | [diff] [blame] | 2249 | #endif |
[email protected] | ce304ce | 2013-02-22 21:54:45 | [diff] [blame] | 2250 | switches::kEnableNetBenchmarking, |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 2251 | #if BUILDFLAG(ENABLE_NACL) |
stichnot | 7040ac83 | 2016-02-24 23:40:59 | [diff] [blame] | 2252 | switches::kForcePNaClSubzero, |
| 2253 | #endif |
Marc Treib | ad33cf94 | 2017-08-24 11:19:00 | [diff] [blame] | 2254 | switches::kForceUIDirection, |
erikcorry | b251cb9 | 2014-09-25 23:48:51 | [diff] [blame] | 2255 | switches::kJavaScriptHarmony, |
iclelland | 79237e9 | 2016-06-23 12:03:51 | [diff] [blame] | 2256 | switches::kOriginTrialDisabledFeatures, |
chasej | dfec22ae | 2017-03-16 20:58:55 | [diff] [blame] | 2257 | switches::kOriginTrialDisabledTokens, |
iclelland | ee4f4a7 | 2016-04-26 18:59:02 | [diff] [blame] | 2258 | switches::kOriginTrialPublicKey, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2259 | switches::kPpapiFlashArgs, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2260 | switches::kPpapiFlashPath, |
| 2261 | switches::kPpapiFlashVersion, |
wychen | e5568734 | 2015-11-13 20:17:03 | [diff] [blame] | 2262 | switches::kReaderModeHeuristics, |
[email protected] | 499e7c5 | 2013-10-04 16:03:09 | [diff] [blame] | 2263 | translate::switches::kTranslateSecurityOrigin, |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2264 | }; |
| 2265 | |
| 2266 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 2267 | base::size(kSwitchNames)); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 2268 | } else if (process_type == switches::kUtilityProcess) { |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 2269 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | a446534d | 2012-02-09 00:07:38 | [diff] [blame] | 2270 | static const char* const kSwitchNames[] = { |
[email protected] | 558878cc8 | 2013-11-09 01:25:51 | [diff] [blame] | 2271 | extensions::switches::kAllowHTTPBackgroundPage, |
[email protected] | c8d0299 | 2013-07-31 22:16:51 | [diff] [blame] | 2272 | extensions::switches::kEnableExperimentalExtensionApis, |
[email protected] | 49d9b14 | 2013-07-19 08:50:27 | [diff] [blame] | 2273 | extensions::switches::kExtensionsOnChromeURLs, |
[email protected] | a612eb3 | 2014-03-31 22:09:17 | [diff] [blame] | 2274 | extensions::switches::kWhitelistedExtensionID, |
[email protected] | a446534d | 2012-02-09 00:07:38 | [diff] [blame] | 2275 | }; |
| 2276 | |
| 2277 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 2278 | base::size(kSwitchNames)); |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 2279 | #endif |
Lukasz Anforowicz | 60d1253d | 2019-05-08 16:31:37 | [diff] [blame] | 2280 | MaybeAppendSecureOriginsAllowlistSwitch(command_line); |
Jay Civelli | 668c097f | 2018-05-16 20:44:13 | [diff] [blame] | 2281 | } else if (process_type == service_manager::switches::kZygoteProcess) { |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2282 | static const char* const kSwitchNames[] = { |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2283 | // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox. |
[email protected] | 382fb0d | 2012-02-25 00:19:50 | [diff] [blame] | 2284 | switches::kDisableBundledPpapiFlash, |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 2285 | #if BUILDFLAG(ENABLE_NACL) |
rickyz | 3638a21 | 2014-10-29 23:50:24 | [diff] [blame] | 2286 | switches::kEnableNaClDebug, |
[email protected] | a9a8e2f | 2014-05-13 23:32:58 | [diff] [blame] | 2287 | switches::kEnableNaClNonSfiMode, |
stichnot | 7040ac83 | 2016-02-24 23:40:59 | [diff] [blame] | 2288 | switches::kForcePNaClSubzero, |
[email protected] | 0b47034 | 2014-04-15 12:59:41 | [diff] [blame] | 2289 | switches::kNaClDangerousNoSandboxNonSfi, |
[email protected] | a56f832 | 2014-07-16 21:13:55 | [diff] [blame] | 2290 | #endif |
[email protected] | 4287a3d | 2011-06-13 23:56:51 | [diff] [blame] | 2291 | switches::kPpapiFlashPath, |
| 2292 | switches::kPpapiFlashVersion, |
| 2293 | }; |
| 2294 | |
| 2295 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 2296 | base::size(kSwitchNames)); |
[email protected] | d56ecf92 | 2012-02-15 16:03:11 | [diff] [blame] | 2297 | } else if (process_type == switches::kGpuProcess) { |
| 2298 | // If --ignore-gpu-blacklist is passed in, don't send in crash reports |
| 2299 | // because GPU is expected to be unreliable. |
| 2300 | if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) && |
| 2301 | !command_line->HasSwitch(switches::kDisableBreakpad)) |
| 2302 | command_line->AppendSwitch(switches::kDisableBreakpad); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2303 | } |
[email protected] | 6f08af8 | 2011-09-15 01:19:03 | [diff] [blame] | 2304 | |
Ian Barkley-Yeung | 550aae05 | 2019-07-11 00:11:11 | [diff] [blame] | 2305 | #if defined(OS_CHROMEOS) |
| 2306 | if (breakpad::ShouldPassCrashLoopBefore(process_type)) { |
| 2307 | static const char* const kSwitchNames[] = { |
| 2308 | switches::kCrashLoopBefore, |
| 2309 | }; |
| 2310 | command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 2311 | base::size(kSwitchNames)); |
| 2312 | } |
| 2313 | #endif |
| 2314 | |
wittman | 832321f5 | 2016-10-10 18:18:38 | [diff] [blame] | 2315 | StackSamplingConfiguration::Get()->AppendCommandLineSwitchForChildProcess( |
| 2316 | process_type, |
| 2317 | command_line); |
Andrew Comminos | 6605767 | 2019-05-01 00:03:34 | [diff] [blame] | 2318 | |
| 2319 | #if defined(OS_LINUX) |
| 2320 | // Processes may only query perf_event_open with the BPF sandbox disabled. |
| 2321 | if (browser_command_line.HasSwitch(switches::kEnableThreadInstructionCount) && |
| 2322 | command_line->HasSwitch(service_manager::switches::kNoSandbox)) { |
| 2323 | command_line->AppendSwitch(switches::kEnableThreadInstructionCount); |
| 2324 | } |
| 2325 | #endif |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2326 | } |
| 2327 | |
Scott Violet | 776edf8 | 2017-09-29 02:03:01 | [diff] [blame] | 2328 | void ChromeContentBrowserClient::AdjustUtilityServiceProcessCommandLine( |
| 2329 | const service_manager::Identity& identity, |
| 2330 | base::CommandLine* command_line) { |
Scott Violet | 776edf8 | 2017-09-29 02:03:01 | [diff] [blame] | 2331 | #if defined(OS_CHROMEOS) |
Mohsen Izadi | f1958f2 | 2019-01-18 20:29:31 | [diff] [blame] | 2332 | if (identity.name() == viz::mojom::kVizServiceName) { |
Mohsen Izadi | f1958f2 | 2019-01-18 20:29:31 | [diff] [blame] | 2333 | if (ui::OzonePlatform::EnsureInstance()->GetMessageLoopTypeForGpu() == |
| 2334 | base::MessageLoop::TYPE_UI) { |
| 2335 | command_line->AppendSwitch(switches::kMessageLoopTypeUi); |
| 2336 | } |
Maggie Chen | 867b582 | 2019-05-16 02:03:14 | [diff] [blame] | 2337 | content::GpuDataManager::GetInstance()->AppendGpuCommandLine( |
| 2338 | command_line, content::GPU_PROCESS_KIND_SANDBOXED); |
Mohsen Izadi | f1958f2 | 2019-01-18 20:29:31 | [diff] [blame] | 2339 | } |
Scott Violet | 776edf8 | 2017-09-29 02:03:01 | [diff] [blame] | 2340 | #endif |
Guido Urdaneta | 191635e | 2018-05-09 16:00:53 | [diff] [blame] | 2341 | |
| 2342 | #if defined(OS_MACOSX) |
Guido Urdaneta | 1a291743 | 2018-05-10 18:32:32 | [diff] [blame] | 2343 | // On Mac, the video-capture and audio services require a CFRunLoop, provided |
| 2344 | // by a UI message loop, to run AVFoundation and CoreAudio code. |
| 2345 | // See https://crbug.com/834581 |
| 2346 | if (identity.name() == video_capture::mojom::kServiceName || |
| 2347 | identity.name() == audio::mojom::kServiceName) |
Guido Urdaneta | 191635e | 2018-05-09 16:00:53 | [diff] [blame] | 2348 | command_line->AppendSwitch(switches::kMessageLoopTypeUi); |
| 2349 | #endif |
Scott Violet | 776edf8 | 2017-09-29 02:03:01 | [diff] [blame] | 2350 | } |
| 2351 | |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2352 | std::string ChromeContentBrowserClient::GetApplicationLocale() { |
[email protected] | e9a32a5 | 2012-06-14 23:32:43 | [diff] [blame] | 2353 | if (BrowserThread::CurrentlyOn(BrowserThread::IO)) |
Lei Zhang | 2cfceac | 2018-11-14 19:36:33 | [diff] [blame] | 2354 | return GetIOThreadApplicationLocale(); |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 2355 | return g_browser_process->GetApplicationLocale(); |
| 2356 | } |
| 2357 | |
[email protected] | 597a867b | 2011-11-18 18:31:20 | [diff] [blame] | 2358 | std::string ChromeContentBrowserClient::GetAcceptLangs( |
| 2359 | content::BrowserContext* context) { |
| 2360 | Profile* profile = Profile::FromBrowserContext(context); |
Alexandre Frechette | 572755b | 2019-02-13 22:30:20 | [diff] [blame] | 2361 | return profile->GetPrefs()->GetString(language::prefs::kAcceptLanguages); |
[email protected] | b5cca98 | 2011-05-26 04:42:08 | [diff] [blame] | 2362 | } |
| 2363 | |
Dana Fried | 34d58000 | 2019-04-24 20:05:48 | [diff] [blame] | 2364 | gfx::ImageSkia ChromeContentBrowserClient::GetDefaultFavicon() { |
Lei Zhang | 7640d54 | 2017-10-03 16:26:49 | [diff] [blame] | 2365 | ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
Dana Fried | 34d58000 | 2019-04-24 20:05:48 | [diff] [blame] | 2366 | return rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).AsImageSkia(); |
[email protected] | ac55e29 | 2011-06-24 05:16:08 | [diff] [blame] | 2367 | } |
| 2368 | |
bengr | e8a146f | 2016-03-10 01:20:22 | [diff] [blame] | 2369 | bool ChromeContentBrowserClient::IsDataSaverEnabled( |
| 2370 | content::BrowserContext* browser_context) { |
Robert Ogden | c995d4fe | 2019-03-25 19:18:37 | [diff] [blame] | 2371 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 2372 | return profile && data_reduction_proxy::DataReductionProxySettings:: |
| 2373 | IsDataSaverEnabledByUser(profile->GetPrefs()); |
bengr | e8a146f | 2016-03-10 01:20:22 | [diff] [blame] | 2374 | } |
| 2375 | |
Kenichi Ishibashi | 4632987 | 2018-07-17 09:43:40 | [diff] [blame] | 2376 | void ChromeContentBrowserClient::UpdateRendererPreferencesForWorker( |
| 2377 | content::BrowserContext* browser_context, |
Leon Han | c819dc6 | 2019-01-28 04:30:19 | [diff] [blame] | 2378 | blink::mojom::RendererPreferences* out_prefs) { |
Kenichi Ishibashi | 4632987 | 2018-07-17 09:43:40 | [diff] [blame] | 2379 | DCHECK(browser_context); |
| 2380 | DCHECK(out_prefs); |
| 2381 | renderer_preferences_util::UpdateFromSystemSettings( |
| 2382 | out_prefs, Profile::FromBrowserContext(browser_context)); |
| 2383 | } |
| 2384 | |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 2385 | bool ChromeContentBrowserClient::AllowAppCache( |
[email protected] | 5b52ad4 | 2011-05-26 14:26:09 | [diff] [blame] | 2386 | const GURL& manifest_url, |
[email protected] | 0a60884 | 2011-09-08 10:55:19 | [diff] [blame] | 2387 | const GURL& first_party, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2388 | content::ResourceContext* context) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2389 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2390 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
falken | 7169140 | 2017-01-27 03:38:00 | [diff] [blame] | 2391 | return io_data->GetCookieSettings()->IsCookieAccessAllowed(manifest_url, |
| 2392 | first_party); |
[email protected] | a217679 | 2011-05-08 19:30:49 | [diff] [blame] | 2393 | } |
| 2394 | |
falken | 3dbc36e | 2014-10-10 16:48:07 | [diff] [blame] | 2395 | bool ChromeContentBrowserClient::AllowServiceWorker( |
| 2396 | const GURL& scope, |
| 2397 | const GURL& first_party_url, |
David Bertoni | 3b3597d8 | 2019-06-22 02:29:36 | [diff] [blame] | 2398 | const GURL& script_url, |
falken | 4a22dce | 2015-04-30 08:25:20 | [diff] [blame] | 2399 | content::ResourceContext* context, |
tzik | df81f14 | 2018-10-26 00:23:34 | [diff] [blame] | 2400 | base::RepeatingCallback<content::WebContents*()> wc_getter) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2401 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
rdevlin.cronin | f5863da | 2015-09-10 19:21:45 | [diff] [blame] | 2402 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 2403 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
rdevlin.cronin | f5863da | 2015-09-10 19:21:45 | [diff] [blame] | 2404 | // Check if this is an extension-related service worker, and, if so, if it's |
| 2405 | // allowed (this can return false if, e.g., the extension is disabled). |
| 2406 | // If it's not allowed, return immediately. We deliberately do *not* report |
| 2407 | // to the TabSpecificContentSettings, since the service worker is blocked |
| 2408 | // because of the extension, rather than because of the user's content |
| 2409 | // settings. |
| 2410 | if (!ChromeContentBrowserClientExtensionsPart::AllowServiceWorker( |
David Bertoni | 3b3597d8 | 2019-06-22 02:29:36 | [diff] [blame] | 2411 | scope, first_party_url, script_url, context)) { |
rdevlin.cronin | f5863da | 2015-09-10 19:21:45 | [diff] [blame] | 2412 | return false; |
| 2413 | } |
| 2414 | #endif |
| 2415 | |
falken | 3dbc36e | 2014-10-10 16:48:07 | [diff] [blame] | 2416 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
falken | 4a22dce | 2015-04-30 08:25:20 | [diff] [blame] | 2417 | |
shimazu | ce8af8812 | 2016-10-06 23:49:21 | [diff] [blame] | 2418 | // Check if JavaScript is allowed. |
| 2419 | content_settings::SettingInfo info; |
| 2420 | std::unique_ptr<base::Value> value = |
| 2421 | io_data->GetHostContentSettingsMap()->GetWebsiteSetting( |
| 2422 | first_party_url, first_party_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 2423 | std::string(), &info); |
| 2424 | ContentSetting setting = content_settings::ValueToContentSetting(value.get()); |
| 2425 | bool allow_javascript = (setting == CONTENT_SETTING_ALLOW); |
| 2426 | |
| 2427 | // Check if cookies are allowed. |
| 2428 | bool allow_serviceworker = |
falken | 7169140 | 2017-01-27 03:38:00 | [diff] [blame] | 2429 | io_data->GetCookieSettings()->IsCookieAccessAllowed(scope, |
| 2430 | first_party_url); |
falken | 4a22dce | 2015-04-30 08:25:20 | [diff] [blame] | 2431 | // Record access to database for potential display in UI. |
yzshen | bc36c97 | 2016-12-21 21:39:24 | [diff] [blame] | 2432 | // Only post the task if this is for a specific tab. |
| 2433 | if (!wc_getter.is_null()) { |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 2434 | base::PostTaskWithTraits( |
| 2435 | FROM_HERE, {BrowserThread::UI}, |
tzik | 29ea5c7 | 2017-04-20 02:16:51 | [diff] [blame] | 2436 | base::BindOnce(&TabSpecificContentSettings::ServiceWorkerAccessed, |
tzik | df81f14 | 2018-10-26 00:23:34 | [diff] [blame] | 2437 | std::move(wc_getter), scope, !allow_javascript, |
tzik | 29ea5c7 | 2017-04-20 02:16:51 | [diff] [blame] | 2438 | !allow_serviceworker)); |
rdevlin.cronin | f5863da | 2015-09-10 19:21:45 | [diff] [blame] | 2439 | } |
shimazu | ce8af8812 | 2016-10-06 23:49:21 | [diff] [blame] | 2440 | return allow_javascript && allow_serviceworker; |
falken | 3dbc36e | 2014-10-10 16:48:07 | [diff] [blame] | 2441 | } |
| 2442 | |
Jochen Eisinger | 0ff7645c | 2017-11-28 08:11:26 | [diff] [blame] | 2443 | bool ChromeContentBrowserClient::AllowSharedWorker( |
| 2444 | const GURL& worker_url, |
| 2445 | const GURL& main_frame_url, |
| 2446 | const std::string& name, |
Hiroki Nakagawa | 018bb6d | 2017-11-30 03:31:37 | [diff] [blame] | 2447 | const url::Origin& constructor_origin, |
Jochen Eisinger | 0ff7645c | 2017-11-28 08:11:26 | [diff] [blame] | 2448 | content::BrowserContext* context, |
| 2449 | int render_process_id, |
| 2450 | int render_frame_id) { |
| 2451 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2452 | |
| 2453 | // Check if cookies are allowed. |
| 2454 | bool allow = |
| 2455 | CookieSettingsFactory::GetForProfile(Profile::FromBrowserContext(context)) |
| 2456 | ->IsCookieAccessAllowed(worker_url, main_frame_url); |
| 2457 | |
| 2458 | TabSpecificContentSettings::SharedWorkerAccessed( |
Hiroki Nakagawa | 018bb6d | 2017-11-30 03:31:37 | [diff] [blame] | 2459 | render_process_id, render_frame_id, worker_url, name, constructor_origin, |
| 2460 | !allow); |
Jochen Eisinger | 0ff7645c | 2017-11-28 08:11:26 | [diff] [blame] | 2461 | return allow; |
| 2462 | } |
| 2463 | |
Kunihiko Sakamoto | f586da6 | 2019-03-28 03:03:04 | [diff] [blame] | 2464 | bool ChromeContentBrowserClient::AllowSignedExchange( |
| 2465 | content::ResourceContext* resource_context) { |
| 2466 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 2467 | // Null-check safe_browsing_service_ as in unit tests |resource_context| is a |
| 2468 | // MockResourceContext and the cast doesn't work. |
| 2469 | if (!safe_browsing_service_) |
| 2470 | return false; |
| 2471 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 2472 | return io_data->signed_exchange_enabled()->GetValue(); |
| 2473 | } |
| 2474 | |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 2475 | bool ChromeContentBrowserClient::AllowGetCookie( |
| 2476 | const GURL& url, |
| 2477 | const GURL& first_party, |
| 2478 | const net::CookieList& cookie_list, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2479 | content::ResourceContext* context, |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 2480 | int render_process_id, |
[email protected] | f3add92 | 2013-12-20 23:17:16 | [diff] [blame] | 2481 | int render_frame_id) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2482 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2483 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
falken | 7169140 | 2017-01-27 03:38:00 | [diff] [blame] | 2484 | bool allow = |
| 2485 | io_data->GetCookieSettings()->IsCookieAccessAllowed(url, first_party); |
Clark DuVall | c57280be | 2018-06-19 03:46:23 | [diff] [blame] | 2486 | OnCookiesRead(render_process_id, render_frame_id, url, first_party, |
| 2487 | cookie_list, !allow); |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 2488 | |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 2489 | return allow; |
| 2490 | } |
| 2491 | |
| 2492 | bool ChromeContentBrowserClient::AllowSetCookie( |
| 2493 | const GURL& url, |
| 2494 | const GURL& first_party, |
Victor Costan | 9ab2fe1 | 2017-11-16 20:53:37 | [diff] [blame] | 2495 | const net::CanonicalCookie& cookie, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2496 | content::ResourceContext* context, |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 2497 | int render_process_id, |
Clark DuVall | c57280be | 2018-06-19 03:46:23 | [diff] [blame] | 2498 | int render_frame_id) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2499 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2500 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
droger | b171697 | 2015-06-30 09:04:09 | [diff] [blame] | 2501 | content_settings::CookieSettings* cookie_settings = |
| 2502 | io_data->GetCookieSettings(); |
falken | 7169140 | 2017-01-27 03:38:00 | [diff] [blame] | 2503 | bool allow = cookie_settings->IsCookieAccessAllowed(url, first_party); |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 2504 | |
Clark DuVall | c57280be | 2018-06-19 03:46:23 | [diff] [blame] | 2505 | OnCookieChange(render_process_id, render_frame_id, url, first_party, cookie, |
| 2506 | !allow); |
| 2507 | return allow; |
| 2508 | } |
| 2509 | |
| 2510 | void ChromeContentBrowserClient::OnCookiesRead( |
| 2511 | int process_id, |
| 2512 | int routing_id, |
| 2513 | const GURL& url, |
| 2514 | const GURL& first_party_url, |
| 2515 | const net::CookieList& cookie_list, |
| 2516 | bool blocked_by_policy) { |
| 2517 | base::RepeatingCallback<content::WebContents*(void)> wc_getter = |
Ken Rockot | 42dfa78 | 2018-06-28 21:08:41 | [diff] [blame] | 2518 | base::BindRepeating(&GetWebContentsFromProcessAndFrameId, process_id, |
| 2519 | routing_id); |
Maks Orlovich | 2fd169e6 | 2019-06-21 17:10:38 | [diff] [blame] | 2520 | if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 2521 | // Internal calls from AllowGetCookie are on IO thread, so need to jump. |
| 2522 | base::PostTaskWithTraits( |
| 2523 | FROM_HERE, {BrowserThread::UI}, |
| 2524 | base::BindOnce(&TabSpecificContentSettings::CookiesRead, wc_getter, url, |
| 2525 | first_party_url, cookie_list, blocked_by_policy)); |
| 2526 | } else { |
| 2527 | TabSpecificContentSettings::CookiesRead(wc_getter, url, first_party_url, |
| 2528 | cookie_list, blocked_by_policy); |
| 2529 | } |
Clark DuVall | c57280be | 2018-06-19 03:46:23 | [diff] [blame] | 2530 | } |
| 2531 | |
| 2532 | void ChromeContentBrowserClient::OnCookieChange( |
| 2533 | int process_id, |
| 2534 | int routing_id, |
| 2535 | const GURL& url, |
| 2536 | const GURL& first_party_url, |
| 2537 | const net::CanonicalCookie& cookie, |
| 2538 | bool blocked_by_policy) { |
| 2539 | base::RepeatingCallback<content::WebContents*(void)> wc_getter = |
Ken Rockot | 42dfa78 | 2018-06-28 21:08:41 | [diff] [blame] | 2540 | base::BindRepeating(&GetWebContentsFromProcessAndFrameId, process_id, |
| 2541 | routing_id); |
Maks Orlovich | 2fd169e6 | 2019-06-21 17:10:38 | [diff] [blame] | 2542 | if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 2543 | // Internal calls from AllowSetCookie are on IO thread, so need to jump. |
| 2544 | base::PostTaskWithTraits( |
| 2545 | FROM_HERE, {BrowserThread::UI}, |
| 2546 | base::BindOnce(&TabSpecificContentSettings::CookieChanged, wc_getter, |
| 2547 | url, first_party_url, cookie, blocked_by_policy)); |
| 2548 | } else { |
| 2549 | TabSpecificContentSettings::CookieChanged(wc_getter, url, first_party_url, |
| 2550 | cookie, blocked_by_policy); |
| 2551 | } |
[email protected] | ed24fad | 2011-05-10 22:44:01 | [diff] [blame] | 2552 | } |
| 2553 | |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2554 | void ChromeContentBrowserClient::AllowWorkerFileSystem( |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 2555 | const GURL& url, |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2556 | content::ResourceContext* context, |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2557 | const std::vector<content::GlobalFrameRoutingId>& render_frames, |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2558 | base::Callback<void(bool)> callback) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2559 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | df02aca | 2012-02-09 21:03:20 | [diff] [blame] | 2560 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
droger | b171697 | 2015-06-30 09:04:09 | [diff] [blame] | 2561 | content_settings::CookieSettings* cookie_settings = |
| 2562 | io_data->GetCookieSettings(); |
falken | 7169140 | 2017-01-27 03:38:00 | [diff] [blame] | 2563 | bool allow = cookie_settings->IsCookieAccessAllowed(url, url); |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 2564 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 2565 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2566 | GuestPermissionRequestHelper(url, render_frames, callback, allow); |
| 2567 | #else |
| 2568 | FileSystemAccessed(url, render_frames, callback, allow); |
| 2569 | #endif |
| 2570 | } |
| 2571 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 2572 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2573 | void ChromeContentBrowserClient::GuestPermissionRequestHelper( |
| 2574 | const GURL& url, |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2575 | const std::vector<content::GlobalFrameRoutingId>& render_frames, |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2576 | base::Callback<void(bool)> callback, |
| 2577 | bool allow) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2578 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2579 | std::map<int, int> process_map; |
| 2580 | std::map<int, int>::const_iterator it; |
| 2581 | bool has_web_view_guest = false; |
| 2582 | // Record access to file system for potential display in UI. |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2583 | for (const auto& it : render_frames) { |
| 2584 | if (process_map.find(it.child_id) != process_map.end()) |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2585 | continue; |
| 2586 | |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2587 | process_map.insert(std::pair<int, int>(it.child_id, it.frame_routing_id)); |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2588 | |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2589 | if (extensions::WebViewRendererState::GetInstance()->IsGuest(it.child_id)) |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2590 | has_web_view_guest = true; |
| 2591 | } |
| 2592 | if (!has_web_view_guest) { |
| 2593 | FileSystemAccessed(url, render_frames, callback, allow); |
| 2594 | return; |
| 2595 | } |
[email protected] | dffb9fc | 2014-07-16 04:14:02 | [diff] [blame] | 2596 | DCHECK_EQ(1U, process_map.size()); |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2597 | it = process_map.begin(); |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 2598 | base::PostTaskWithTraits( |
| 2599 | FROM_HERE, {BrowserThread::UI}, |
tzik | 29ea5c7 | 2017-04-20 02:16:51 | [diff] [blame] | 2600 | base::BindOnce( |
| 2601 | &ChromeContentBrowserClient::RequestFileSystemPermissionOnUIThread, |
| 2602 | it->first, it->second, url, allow, |
Kevin Marshall | 32f99d7e | 2017-07-11 23:17:46 | [diff] [blame] | 2603 | base::Bind( |
| 2604 | &ChromeContentBrowserClient::FileSystemAccessed, |
| 2605 | weak_factory_.GetWeakPtr(), url, render_frames, |
| 2606 | base::Bind(&InvokeCallbackOnThread, |
| 2607 | base::SequencedTaskRunnerHandle::Get(), callback)))); |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2608 | } |
| 2609 | |
| 2610 | void ChromeContentBrowserClient::RequestFileSystemPermissionOnUIThread( |
| 2611 | int render_process_id, |
| 2612 | int render_frame_id, |
| 2613 | const GURL& url, |
| 2614 | bool allowed_by_default, |
| 2615 | const base::Callback<void(bool)>& callback) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2616 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 140d6cd9 | 2014-08-12 18:26:46 | [diff] [blame] | 2617 | extensions::WebViewPermissionHelper* web_view_permission_helper = |
| 2618 | extensions::WebViewPermissionHelper::FromFrameID( |
| 2619 | render_process_id, render_frame_id); |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2620 | web_view_permission_helper->RequestFileSystemPermission(url, |
| 2621 | allowed_by_default, |
| 2622 | callback); |
| 2623 | } |
| 2624 | #endif |
| 2625 | |
| 2626 | void ChromeContentBrowserClient::FileSystemAccessed( |
| 2627 | const GURL& url, |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2628 | const std::vector<content::GlobalFrameRoutingId>& render_frames, |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2629 | base::Callback<void(bool)> callback, |
| 2630 | bool allow) { |
[email protected] | 6215105 | 2012-02-01 18:40:48 | [diff] [blame] | 2631 | // Record access to file system for potential display in UI. |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2632 | for (const auto& it : render_frames) { |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 2633 | base::PostTaskWithTraits( |
| 2634 | FROM_HERE, {BrowserThread::UI}, |
tzik | 29ea5c7 | 2017-04-20 02:16:51 | [diff] [blame] | 2635 | base::BindOnce(&TabSpecificContentSettings::FileSystemAccessed, |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2636 | it.child_id, it.frame_routing_id, url, !allow)); |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 2637 | } |
[email protected] | f917df2 | 2014-07-10 07:45:49 | [diff] [blame] | 2638 | callback.Run(allow); |
[email protected] | 5c5a88e | 2011-11-12 00:45:35 | [diff] [blame] | 2639 | } |
| 2640 | |
[email protected] | 7c5ff9a | 2012-03-02 07:42:49 | [diff] [blame] | 2641 | bool ChromeContentBrowserClient::AllowWorkerIndexedDB( |
| 2642 | const GURL& url, |
[email protected] | 7c5ff9a | 2012-03-02 07:42:49 | [diff] [blame] | 2643 | content::ResourceContext* context, |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2644 | const std::vector<content::GlobalFrameRoutingId>& render_frames) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 2645 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | 7c5ff9a | 2012-03-02 07:42:49 | [diff] [blame] | 2646 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
droger | b171697 | 2015-06-30 09:04:09 | [diff] [blame] | 2647 | content_settings::CookieSettings* cookie_settings = |
| 2648 | io_data->GetCookieSettings(); |
falken | 7169140 | 2017-01-27 03:38:00 | [diff] [blame] | 2649 | bool allow = cookie_settings->IsCookieAccessAllowed(url, url); |
[email protected] | 7c5ff9a | 2012-03-02 07:42:49 | [diff] [blame] | 2650 | |
| 2651 | // Record access to IndexedDB for potential display in UI. |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2652 | for (const auto& it : render_frames) { |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 2653 | base::PostTaskWithTraits( |
| 2654 | FROM_HERE, {BrowserThread::UI}, |
Lukasz Anforowicz | 09060bdf7 | 2018-08-23 15:53:17 | [diff] [blame] | 2655 | base::BindOnce(&TabSpecificContentSettings::IndexedDBAccessed, |
Joshua Bell | 7cdaafca | 2018-10-31 06:27:11 | [diff] [blame] | 2656 | it.child_id, it.frame_routing_id, url, !allow)); |
[email protected] | 7c5ff9a | 2012-03-02 07:42:49 | [diff] [blame] | 2657 | } |
| 2658 | |
| 2659 | return allow; |
| 2660 | } |
| 2661 | |
Ben Kelly | 6b2e61c | 2019-03-14 16:06:29 | [diff] [blame] | 2662 | bool ChromeContentBrowserClient::AllowWorkerCacheStorage( |
| 2663 | const GURL& url, |
| 2664 | content::ResourceContext* context, |
| 2665 | const std::vector<content::GlobalFrameRoutingId>& render_frames) { |
| 2666 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 2667 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 2668 | content_settings::CookieSettings* cookie_settings = |
| 2669 | io_data->GetCookieSettings(); |
| 2670 | bool allow = cookie_settings->IsCookieAccessAllowed(url, url); |
| 2671 | |
| 2672 | // Record access to CacheStorage for potential display in UI. |
| 2673 | for (const auto& it : render_frames) { |
| 2674 | base::PostTaskWithTraits( |
| 2675 | FROM_HERE, {BrowserThread::UI}, |
| 2676 | base::BindOnce(&TabSpecificContentSettings::CacheStorageAccessed, |
| 2677 | it.child_id, it.frame_routing_id, url, !allow)); |
| 2678 | } |
| 2679 | |
| 2680 | return allow; |
| 2681 | } |
| 2682 | |
jyasskin | c993ce8d | 2016-03-31 00:38:34 | [diff] [blame] | 2683 | ChromeContentBrowserClient::AllowWebBluetoothResult |
| 2684 | ChromeContentBrowserClient::AllowWebBluetooth( |
jyasskin | 98bdd399 | 2016-02-26 20:25:45 | [diff] [blame] | 2685 | content::BrowserContext* browser_context, |
| 2686 | const url::Origin& requesting_origin, |
| 2687 | const url::Origin& embedding_origin) { |
jyasskin | c993ce8d | 2016-03-31 00:38:34 | [diff] [blame] | 2688 | // TODO(crbug.com/598890): Don't disable if |
| 2689 | // base::CommandLine::ForCurrentProcess()-> |
| 2690 | // HasSwitch(switches::kEnableWebBluetooth) is true. |
| 2691 | if (variations::GetVariationParamValue( |
| 2692 | PermissionContextBase::kPermissionsKillSwitchFieldStudy, |
| 2693 | "Bluetooth") == |
| 2694 | PermissionContextBase::kPermissionsKillSwitchBlockedValue) { |
| 2695 | // The kill switch is enabled for this permission. Block requests. |
| 2696 | return AllowWebBluetoothResult::BLOCK_GLOBALLY_DISABLED; |
| 2697 | } |
| 2698 | |
jyasskin | 98bdd399 | 2016-02-26 20:25:45 | [diff] [blame] | 2699 | const HostContentSettingsMap* const content_settings = |
| 2700 | HostContentSettingsMapFactory::GetForProfile( |
| 2701 | Profile::FromBrowserContext(browser_context)); |
| 2702 | |
csharrison | aec2c54 | 2016-10-12 19:40:36 | [diff] [blame] | 2703 | if (content_settings->GetContentSetting( |
| 2704 | requesting_origin.GetURL(), embedding_origin.GetURL(), |
| 2705 | CONTENT_SETTINGS_TYPE_BLUETOOTH_GUARD, |
| 2706 | std::string()) == CONTENT_SETTING_BLOCK) { |
jyasskin | c993ce8d | 2016-03-31 00:38:34 | [diff] [blame] | 2707 | return AllowWebBluetoothResult::BLOCK_POLICY; |
| 2708 | } |
| 2709 | return AllowWebBluetoothResult::ALLOW; |
jyasskin | 98bdd399 | 2016-02-26 20:25:45 | [diff] [blame] | 2710 | } |
| 2711 | |
beaufort.francois | 01135bf | 2016-11-23 14:37:36 | [diff] [blame] | 2712 | std::string ChromeContentBrowserClient::GetWebBluetoothBlocklist() { |
| 2713 | return variations::GetVariationParamValue("WebBluetoothBlocklist", |
| 2714 | "blocklist_additions"); |
scheib | 7425032 | 2016-04-07 03:32:21 | [diff] [blame] | 2715 | } |
| 2716 | |
John Abd-El-Malek | 21bca7c | 2018-10-26 22:13:33 | [diff] [blame] | 2717 | #if defined(OS_CHROMEOS) |
John Abd-El-Malek | a5b1a5d60 | 2018-11-05 19:20:52 | [diff] [blame] | 2718 | void ChromeContentBrowserClient::OnTrustAnchorUsed( |
John Abd-El-Malek | 21bca7c | 2018-10-26 22:13:33 | [diff] [blame] | 2719 | const std::string& username_hash) { |
| 2720 | policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(username_hash); |
| 2721 | } |
| 2722 | #endif |
| 2723 | |
Reilly Grant | 19aaccd | 2018-07-16 22:06:37 | [diff] [blame] | 2724 | scoped_refptr<network::SharedURLLoaderFactory> |
| 2725 | ChromeContentBrowserClient::GetSystemSharedURLLoaderFactory() { |
Min Qin | da0d55b | 2018-10-12 18:30:05 | [diff] [blame] | 2726 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 2727 | !BrowserThread::IsThreadInitialized(BrowserThread::UI)); |
| 2728 | |
| 2729 | if (!SystemNetworkContextManager::GetInstance()) |
Reilly Grant | 19aaccd | 2018-07-16 22:06:37 | [diff] [blame] | 2730 | return nullptr; |
| 2731 | |
Min Qin | da0d55b | 2018-10-12 18:30:05 | [diff] [blame] | 2732 | return SystemNetworkContextManager::GetInstance() |
Reilly Grant | 19aaccd | 2018-07-16 22:06:37 | [diff] [blame] | 2733 | ->GetSharedURLLoaderFactory(); |
Andrew Moylan | 8673dba | 2017-10-10 04:29:04 | [diff] [blame] | 2734 | } |
| 2735 | |
Sean Gilhuly | da1ee4b | 2018-11-13 21:56:09 | [diff] [blame] | 2736 | network::mojom::NetworkContext* |
| 2737 | ChromeContentBrowserClient::GetSystemNetworkContext() { |
| 2738 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2739 | DCHECK(g_browser_process->system_network_context_manager()); |
| 2740 | return g_browser_process->system_network_context_manager()->GetContext(); |
| 2741 | } |
| 2742 | |
Andrew Moylan | 17329fc | 2017-09-25 07:43:30 | [diff] [blame] | 2743 | std::string ChromeContentBrowserClient::GetGeolocationApiKey() { |
| 2744 | return google_apis::GetAPIKey(); |
| 2745 | } |
| 2746 | |
Ke He | 21ee87f | 2018-05-30 02:35:32 | [diff] [blame] | 2747 | #if defined(OS_ANDROID) |
| 2748 | bool ChromeContentBrowserClient::ShouldUseGmsCoreGeolocationProvider() { |
| 2749 | // Indicate that Chrome uses the GMS core location provider. |
| 2750 | return true; |
| 2751 | } |
| 2752 | #endif |
| 2753 | |
Yeol | f3dc22ca | 2019-04-18 17:25:32 | [diff] [blame] | 2754 | scoped_refptr<content::QuotaPermissionContext> |
[email protected] | 317f96c9 | 2011-05-31 06:53:41 | [diff] [blame] | 2755 | ChromeContentBrowserClient::CreateQuotaPermissionContext() { |
| 2756 | return new ChromeQuotaPermissionContext(); |
| 2757 | } |
| 2758 | |
michaeln | 10e5fc35 | 2017-02-07 02:07:58 | [diff] [blame] | 2759 | void ChromeContentBrowserClient::GetQuotaSettings( |
| 2760 | content::BrowserContext* context, |
| 2761 | content::StoragePartition* partition, |
tapted | e6d878e | 2017-06-24 01:53:45 | [diff] [blame] | 2762 | storage::OptionalQuotaSettingsCallback callback) { |
michaeln | 10e5fc35 | 2017-02-07 02:07:58 | [diff] [blame] | 2763 | if (g_default_quota_settings) { |
| 2764 | // For debugging tests harness can inject settings. |
tapted | e6d878e | 2017-06-24 01:53:45 | [diff] [blame] | 2765 | std::move(callback).Run(*g_default_quota_settings); |
michaeln | 10e5fc35 | 2017-02-07 02:07:58 | [diff] [blame] | 2766 | return; |
| 2767 | } |
tapted | e6d878e | 2017-06-24 01:53:45 | [diff] [blame] | 2768 | storage::GetNominalDynamicSettings( |
Jarryd | 451ab7b | 2019-02-12 06:39:06 | [diff] [blame] | 2769 | partition->GetPath(), context->IsOffTheRecord(), |
| 2770 | storage::GetDefaultDiskInfoHelper(), std::move(callback)); |
calamity | c96116b | 2015-11-03 04:30:51 | [diff] [blame] | 2771 | } |
| 2772 | |
Mythri Alle | 0b8de0d | 2018-10-22 11:06:22 | [diff] [blame] | 2773 | content::GeneratedCodeCacheSettings |
| 2774 | ChromeContentBrowserClient::GetGeneratedCodeCacheSettings( |
| 2775 | content::BrowserContext* context) { |
| 2776 | base::FilePath cache_path; |
| 2777 | chrome::GetUserCacheDirectory(context->GetPath(), &cache_path); |
| 2778 | // If we pass 0 for size, disk_cache will pick a default size using the |
| 2779 | // heuristics based on available disk size. These are implemented in |
| 2780 | // disk_cache::PreferredCacheSize in net/disk_cache/cache_util.cc. |
Mythri A | b248657 | 2019-06-13 14:48:16 | [diff] [blame] | 2781 | int64_t size_in_bytes = 0; |
| 2782 | PrefService* prefs = Profile::FromBrowserContext(context)->GetPrefs(); |
| 2783 | DCHECK(prefs); |
| 2784 | size_in_bytes = prefs->GetInteger(prefs::kDiskCacheSize); |
| 2785 | return content::GeneratedCodeCacheSettings(true, size_in_bytes, cache_path); |
Mythri Alle | 0b8de0d | 2018-10-22 11:06:22 | [diff] [blame] | 2786 | } |
| 2787 | |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 2788 | void ChromeContentBrowserClient::AllowCertificateError( |
clamy | 0d32d6d | 2015-11-24 11:16:26 | [diff] [blame] | 2789 | content::WebContents* web_contents, |
[email protected] | 4cf611e3 | 2012-02-13 16:06:17 | [diff] [blame] | 2790 | int cert_error, |
| 2791 | const net::SSLInfo& ssl_info, |
| 2792 | const GURL& request_url, |
John Abd-El-Malek | c5b8df91 | 2019-05-07 17:02:23 | [diff] [blame] | 2793 | bool is_main_frame_request, |
[email protected] | d9be4770 | 2012-05-16 03:41:22 | [diff] [blame] | 2794 | bool strict_enforcement, |
[email protected] | 83c13fe | 2014-08-15 04:49:10 | [diff] [blame] | 2795 | bool expired_previous_decision, |
estark | 719dde5 | 2016-08-09 03:14:27 | [diff] [blame] | 2796 | const base::Callback<void(content::CertificateRequestResultType)>& |
| 2797 | callback) { |
clamy | 0d32d6d | 2015-11-24 11:16:26 | [diff] [blame] | 2798 | DCHECK(web_contents); |
John Abd-El-Malek | c5b8df91 | 2019-05-07 17:02:23 | [diff] [blame] | 2799 | if (!is_main_frame_request) { |
irisu | 8452ddd6 | 2017-03-22 07:46:14 | [diff] [blame] | 2800 | // A sub-resource has a certificate error. The user doesn't really |
[email protected] | a2f7688 | 2013-02-25 21:36:02 | [diff] [blame] | 2801 | // have a context for making the right decision, so block the |
| 2802 | // request hard, without an info bar to allow showing the insecure |
| 2803 | // content. |
estark | 719dde5 | 2016-08-09 03:14:27 | [diff] [blame] | 2804 | if (!callback.is_null()) |
| 2805 | callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY); |
[email protected] | a2f7688 | 2013-02-25 21:36:02 | [diff] [blame] | 2806 | return; |
| 2807 | } |
| 2808 | |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 2809 | // If the tab is being prerendered, cancel the prerender and the request. |
[email protected] | 09667f0 | 2014-01-06 15:37:57 | [diff] [blame] | 2810 | prerender::PrerenderContents* prerender_contents = |
clamy | 0d32d6d | 2015-11-24 11:16:26 | [diff] [blame] | 2811 | prerender::PrerenderContents::FromWebContents(web_contents); |
[email protected] | 09667f0 | 2014-01-06 15:37:57 | [diff] [blame] | 2812 | if (prerender_contents) { |
| 2813 | prerender_contents->Destroy(prerender::FINAL_STATUS_SSL_ERROR); |
estark | 719dde5 | 2016-08-09 03:14:27 | [diff] [blame] | 2814 | if (!callback.is_null()) { |
| 2815 | callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL); |
| 2816 | } |
[email protected] | 09667f0 | 2014-01-06 15:37:57 | [diff] [blame] | 2817 | return; |
[email protected] | f9034cf | 2011-07-21 12:43:41 | [diff] [blame] | 2818 | } |
| 2819 | |
Carlos IL | 5a9e751 | 2019-06-13 22:35:28 | [diff] [blame] | 2820 | callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY); |
| 2821 | return; |
[email protected] | 848dd04 | 2011-06-04 18:24:03 | [diff] [blame] | 2822 | } |
| 2823 | |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2824 | namespace { |
| 2825 | |
Pavol Marko | b211ab2 | 2019-01-23 20:03:04 | [diff] [blame] | 2826 | certificate_matching::CertificatePrincipalPattern |
| 2827 | ParseCertificatePrincipalPattern(const base::Value* pattern) { |
| 2828 | return certificate_matching::CertificatePrincipalPattern:: |
| 2829 | ParseFromOptionalDict(pattern, "CN", "L", "O", "OU"); |
| 2830 | } |
| 2831 | |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2832 | // Attempts to auto-select a client certificate according to the value of |
| 2833 | // |CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE| content setting for |
| 2834 | // |requesting_url|. If no certificate was auto-selected, returns nullptr. |
| 2835 | std::unique_ptr<net::ClientCertIdentity> AutoSelectCertificate( |
| 2836 | Profile* profile, |
| 2837 | const GURL& requesting_url, |
| 2838 | net::ClientCertIdentityList& client_certs) { |
| 2839 | HostContentSettingsMap* host_content_settings_map = |
| 2840 | HostContentSettingsMapFactory::GetForProfile(profile); |
| 2841 | std::unique_ptr<base::Value> setting = |
| 2842 | host_content_settings_map->GetWebsiteSetting( |
| 2843 | requesting_url, requesting_url, |
| 2844 | CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), NULL); |
| 2845 | |
Pavol Marko | b211ab2 | 2019-01-23 20:03:04 | [diff] [blame] | 2846 | if (!setting || !setting->is_dict()) |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2847 | return nullptr; |
| 2848 | |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2849 | const base::Value* filters = |
Pavol Marko | b211ab2 | 2019-01-23 20:03:04 | [diff] [blame] | 2850 | setting->FindKeyOfType("filters", base::Value::Type::LIST); |
| 2851 | if (!filters) { |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2852 | // |setting_dict| has the wrong format (e.g. single filter instead of a |
| 2853 | // list of filters). This content setting is only provided by |
| 2854 | // the |PolicyProvider|, which should always set it to a valid format. |
| 2855 | // Therefore, delete the invalid value. |
| 2856 | host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2857 | requesting_url, requesting_url, |
| 2858 | CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, std::string(), nullptr); |
Pavol Marko | b211ab2 | 2019-01-23 20:03:04 | [diff] [blame] | 2859 | return nullptr; |
| 2860 | } |
| 2861 | |
| 2862 | for (const base::Value& filter : filters->GetList()) { |
| 2863 | DCHECK(filter.is_dict()); |
| 2864 | |
| 2865 | auto issuer_pattern = ParseCertificatePrincipalPattern( |
| 2866 | filter.FindKeyOfType("ISSUER", base::Value::Type::DICTIONARY)); |
| 2867 | auto subject_pattern = ParseCertificatePrincipalPattern( |
| 2868 | filter.FindKeyOfType("SUBJECT", base::Value::Type::DICTIONARY)); |
| 2869 | // Use the first certificate that is matched by the filter. |
| 2870 | for (auto& client_cert : client_certs) { |
| 2871 | if (issuer_pattern.Matches(client_cert->certificate()->issuer()) && |
| 2872 | subject_pattern.Matches(client_cert->certificate()->subject())) { |
| 2873 | return std::move(client_cert); |
| 2874 | } |
| 2875 | } |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2876 | } |
| 2877 | |
| 2878 | return nullptr; |
| 2879 | } |
| 2880 | |
Eric Roman | a00cf68 | 2018-11-01 20:09:11 | [diff] [blame] | 2881 | void AddDataReductionProxyBinding( |
| 2882 | content::ResourceContext* resource_context, |
| 2883 | data_reduction_proxy::mojom::DataReductionProxyRequest request) { |
| 2884 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 2885 | auto* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 2886 | if (io_data && io_data->data_reduction_proxy_io_data()) { |
| 2887 | io_data->data_reduction_proxy_io_data()->Clone(std::move(request)); |
| 2888 | } |
| 2889 | } |
| 2890 | |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2891 | } // namespace |
| 2892 | |
Daniel McArdle | 85735f5 | 2019-06-25 03:27:06 | [diff] [blame] | 2893 | base::OnceClosure ChromeContentBrowserClient::SelectClientCertificate( |
davidben | 3b8455ae7 | 2015-03-11 19:42:19 | [diff] [blame] | 2894 | content::WebContents* web_contents, |
[email protected] | 7a593db | 2012-02-13 21:19:40 | [diff] [blame] | 2895 | net::SSLCertRequestInfo* cert_request_info, |
mattm | 436ccfe | 2017-06-19 20:24:08 | [diff] [blame] | 2896 | net::ClientCertIdentityList client_certs, |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 2897 | std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
[email protected] | 294084d | 2014-01-06 22:22:02 | [diff] [blame] | 2898 | prerender::PrerenderContents* prerender_contents = |
davidben | 3b8455ae7 | 2015-03-11 19:42:19 | [diff] [blame] | 2899 | prerender::PrerenderContents::FromWebContents(web_contents); |
[email protected] | 294084d | 2014-01-06 22:22:02 | [diff] [blame] | 2900 | if (prerender_contents) { |
| 2901 | prerender_contents->Destroy( |
| 2902 | prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED); |
Daniel McArdle | 85735f5 | 2019-06-25 03:27:06 | [diff] [blame] | 2903 | return base::OnceClosure(); |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 2904 | } |
| 2905 | |
[email protected] | 791879c | 2013-12-17 07:22:41 | [diff] [blame] | 2906 | GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
| 2907 | DCHECK(requesting_url.is_valid()) |
| 2908 | << "Invalid URL string: https://" |
| 2909 | << cert_request_info->host_and_port.ToString(); |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 2910 | |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 2911 | bool may_show_cert_selection = true; |
| 2912 | |
davidben | 3b8455ae7 | 2015-03-11 19:42:19 | [diff] [blame] | 2913 | Profile* profile = |
| 2914 | Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 2915 | #if defined(OS_CHROMEOS) |
| 2916 | if (chromeos::ProfileHelper::IsSigninProfile(profile)) { |
| 2917 | // TODO(pmarko): crbug.com/723849: Set |may_show_cert_selection| to false |
| 2918 | // and remove the command-line flag after prototype phase when the |
| 2919 | // DeviceLoginScreenAutoSelectCertificateForUrls policy is live. |
| 2920 | may_show_cert_selection = |
| 2921 | chromeos::switches::IsSigninFrameClientCertUserSelectionEnabled(); |
| 2922 | |
| 2923 | content::StoragePartition* storage_partition = |
| 2924 | content::BrowserContext::GetStoragePartition( |
| 2925 | profile, web_contents->GetSiteInstance()); |
| 2926 | chromeos::login::SigninPartitionManager* signin_partition_manager = |
| 2927 | chromeos::login::SigninPartitionManager::Factory::GetForBrowserContext( |
| 2928 | profile); |
| 2929 | |
| 2930 | // On the sign-in profile, only allow client certs in the context of the |
| 2931 | // sign-in frame. |
| 2932 | if (!signin_partition_manager->IsCurrentSigninStoragePartition( |
| 2933 | storage_partition)) { |
| 2934 | LOG(WARNING) |
| 2935 | << "Client cert requested in sign-in profile in wrong context."; |
| 2936 | // Continue without client certificate. We do this to mimic the case of no |
| 2937 | // client certificate being present in the profile's certificate store. |
| 2938 | delegate->ContinueWithCertificate(nullptr, nullptr); |
Daniel McArdle | 85735f5 | 2019-06-25 03:27:06 | [diff] [blame] | 2939 | return base::OnceClosure(); |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 2940 | } |
| 2941 | VLOG(1) << "Client cert requested in sign-in profile."; |
| 2942 | } |
| 2943 | #endif // defined(OS_CHROMEOS) |
| 2944 | |
Alexander Hendrich | bcf2616e | 2018-05-18 08:21:10 | [diff] [blame] | 2945 | std::unique_ptr<net::ClientCertIdentity> auto_selected_identity = |
| 2946 | AutoSelectCertificate(profile, requesting_url, client_certs); |
| 2947 | if (auto_selected_identity) { |
| 2948 | // The callback will own |auto_selected_identity| and |delegate|, keeping |
| 2949 | // them alive until after ContinueWithCertificate is called. |
| 2950 | scoped_refptr<net::X509Certificate> cert = |
| 2951 | auto_selected_identity->certificate(); |
| 2952 | net::ClientCertIdentity::SelfOwningAcquirePrivateKey( |
| 2953 | std::move(auto_selected_identity), |
David Benjamin | 0cda204 | 2019-04-08 23:00:58 | [diff] [blame] | 2954 | base::BindOnce( |
| 2955 | &content::ClientCertificateDelegate::ContinueWithCertificate, |
| 2956 | std::move(delegate), std::move(cert))); |
Joe DeBlasio | 9b99629 | 2019-01-31 05:09:32 | [diff] [blame] | 2957 | LogClientAuthResult(ClientCertSelectionResult::kAutoSelect); |
Daniel McArdle | 85735f5 | 2019-06-25 03:27:06 | [diff] [blame] | 2958 | return base::OnceClosure(); |
[email protected] | 6786bf40 | 2011-12-03 15:19:45 | [diff] [blame] | 2959 | } |
| 2960 | |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 2961 | if (!may_show_cert_selection) { |
| 2962 | LOG(WARNING) << "No client cert matched by policy and user selection is " |
| 2963 | "not allowed."; |
Joe DeBlasio | 9b99629 | 2019-01-31 05:09:32 | [diff] [blame] | 2964 | LogClientAuthResult(ClientCertSelectionResult::kNoSelectionAllowed); |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 2965 | // Continue without client certificate. We do this to mimic the case of no |
| 2966 | // client certificate being present in the profile's certificate store. |
| 2967 | delegate->ContinueWithCertificate(nullptr, nullptr); |
Daniel McArdle | 85735f5 | 2019-06-25 03:27:06 | [diff] [blame] | 2968 | return base::OnceClosure(); |
Pavol Marko | 230ea2c9 | 2017-12-03 22:35:44 | [diff] [blame] | 2969 | } |
| 2970 | |
Daniel McArdle | 85735f5 | 2019-06-25 03:27:06 | [diff] [blame] | 2971 | return chrome::ShowSSLClientCertificateSelector( |
| 2972 | web_contents, cert_request_info, std::move(client_certs), |
| 2973 | std::move(delegate)); |
[email protected] | 8ec2647 | 2011-06-06 16:52:45 | [diff] [blame] | 2974 | } |
| 2975 | |
[email protected] | dc73a7b | 2012-03-25 15:27:18 | [diff] [blame] | 2976 | content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { |
[email protected] | 11158e2d | 2013-02-01 02:31:56 | [diff] [blame] | 2977 | return MediaCaptureDevicesDispatcher::GetInstance(); |
[email protected] | dc73a7b | 2012-03-25 15:27:18 | [diff] [blame] | 2978 | } |
| 2979 | |
peter | c26c6c6 | 2014-12-10 14:13:59 | [diff] [blame] | 2980 | content::PlatformNotificationService* |
Richard Knoll | d0eae96 | 2019-04-04 12:34:02 | [diff] [blame] | 2981 | ChromeContentBrowserClient::GetPlatformNotificationService( |
| 2982 | content::BrowserContext* browser_context) { |
| 2983 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2984 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 2985 | return PlatformNotificationServiceFactory::GetForProfile(profile); |
[email protected] | 941623e | 2011-06-07 23:06:04 | [diff] [blame] | 2986 | } |
| 2987 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 2988 | bool ChromeContentBrowserClient::CanCreateWindow( |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 2989 | RenderFrameHost* opener, |
[email protected] | 2b751a1 | 2012-03-06 03:00:35 | [diff] [blame] | 2990 | const GURL& opener_url, |
[email protected] | 931bc92 | 2013-09-11 21:42:57 | [diff] [blame] | 2991 | const GURL& opener_top_level_frame_url, |
Nasko Oskov | e9f1978 | 2019-01-04 18:32:35 | [diff] [blame] | 2992 | const url::Origin& source_origin, |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 2993 | content::mojom::WindowContainerType container_type, |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 2994 | const GURL& target_url, |
| 2995 | const content::Referrer& referrer, |
jochen | 67b271b | 2016-08-03 13:50:21 | [diff] [blame] | 2996 | const std::string& frame_name, |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 2997 | WindowOpenDisposition disposition, |
scottmg | 8e6c608 | 2017-02-13 23:15:48 | [diff] [blame] | 2998 | const blink::mojom::WindowFeatures& features, |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 2999 | bool user_gesture, |
| 3000 | bool opener_suppressed, |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 3001 | bool* no_javascript_access) { |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3002 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 3003 | DCHECK(opener); |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 3004 | |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3005 | content::WebContents* web_contents = |
| 3006 | content::WebContents::FromRenderFrameHost(opener); |
| 3007 | Profile* profile = |
| 3008 | Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 3009 | DCHECK(profile); |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 3010 | *no_javascript_access = false; |
| 3011 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 3012 | // If the opener is trying to create a background window but doesn't have |
| 3013 | // the appropriate permission, fail the attempt. |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 3014 | if (container_type == content::mojom::WindowContainerType::BACKGROUND) { |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 3015 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3016 | auto* process_map = extensions::ProcessMap::Get(profile); |
| 3017 | auto* registry = extensions::ExtensionRegistry::Get(profile); |
Charles Harrison | 34f6786 | 2017-08-22 01:04:17 | [diff] [blame] | 3018 | if (!URLHasExtensionBackgroundPermission(process_map, registry, opener_url, |
| 3019 | opener->GetProcess()->GetID())) { |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 3020 | return false; |
| 3021 | } |
| 3022 | |
[email protected] | 7b54ca0 | 2012-03-02 18:06:53 | [diff] [blame] | 3023 | // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may |
| 3024 | // return a recently installed Extension even if this CanCreateWindow call |
| 3025 | // 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] | 3026 | // because the permission check above would have caused an early return |
| 3027 | // already. We must use the full URL to find hosted apps, though, and not |
| 3028 | // just the origin. |
[email protected] | be9915fb | 2013-07-18 09:28:55 | [diff] [blame] | 3029 | const Extension* extension = |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3030 | registry->enabled_extensions().GetExtensionOrAppByURL(opener_url); |
[email protected] | 9367eabc | 2013-03-01 01:29:29 | [diff] [blame] | 3031 | if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) |
[email protected] | 03b6d55 | 2012-03-29 04:03:01 | [diff] [blame] | 3032 | *no_javascript_access = true; |
[email protected] | dffb9fc | 2014-07-16 04:14:02 | [diff] [blame] | 3033 | #endif |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 3034 | |
| 3035 | return true; |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 3036 | } |
[email protected] | 056efdc | 2013-04-06 00:14:53 | [diff] [blame] | 3037 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 3038 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | 140d6cd9 | 2014-08-12 18:26:46 | [diff] [blame] | 3039 | if (extensions::WebViewRendererState::GetInstance()->IsGuest( |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3040 | opener->GetProcess()->GetID())) { |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 3041 | return true; |
lazyboy | 04b75d3 | 2016-02-25 03:12:18 | [diff] [blame] | 3042 | } |
| 3043 | |
nick | 0fbc392 | 2016-12-16 20:52:07 | [diff] [blame] | 3044 | if (target_url.SchemeIs(extensions::kExtensionScheme)) { |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3045 | // Intentionally duplicating |registry| code from above because we want to |
| 3046 | // reduce calls to retrieve them as this function is a SYNC IPC handler. |
| 3047 | auto* registry = extensions::ExtensionRegistry::Get(profile); |
lazyboy | 04b75d3 | 2016-02-25 03:12:18 | [diff] [blame] | 3048 | const Extension* extension = |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3049 | registry->enabled_extensions().GetExtensionOrAppByURL(target_url); |
lazyboy | 5d5fede0 | 2016-03-10 04:10:14 | [diff] [blame] | 3050 | if (extension && extension->is_platform_app()) { |
nick | b6ae0bd3 | 2017-04-18 20:53:53 | [diff] [blame] | 3051 | UMA_HISTOGRAM_ENUMERATION( |
| 3052 | "Extensions.AppLoadedInTab", |
| 3053 | ClassifyAppLoadedInTabSource(opener_url, extension), |
| 3054 | APP_LOADED_IN_TAB_SOURCE_MAX); |
| 3055 | |
| 3056 | // window.open() may not be used to load v2 apps in a regular tab. |
lazyboy | 39585ed | 2016-12-06 19:30:16 | [diff] [blame] | 3057 | return false; |
lazyboy | 5d5fede0 | 2016-03-10 04:10:14 | [diff] [blame] | 3058 | } |
lazyboy | 04b75d3 | 2016-02-25 03:12:18 | [diff] [blame] | 3059 | } |
[email protected] | 5940b0d | 2014-07-01 00:18:26 | [diff] [blame] | 3060 | #endif |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 3061 | |
Charles Harrison | af2acd0 | 2017-08-18 22:46:02 | [diff] [blame] | 3062 | #if BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 3063 | HostContentSettingsMap* content_settings = |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3064 | HostContentSettingsMapFactory::GetForProfile(profile); |
tommycli | 61f6f0c | 2016-09-21 00:26:58 | [diff] [blame] | 3065 | if (FlashDownloadInterception::ShouldStopFlashDownloadAction( |
| 3066 | content_settings, opener_top_level_frame_url, target_url, |
| 3067 | user_gesture)) { |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3068 | FlashDownloadInterception::InterceptFlashDownloadNavigation( |
| 3069 | web_contents, opener_top_level_frame_url); |
tommycli | 61f6f0c | 2016-09-21 00:26:58 | [diff] [blame] | 3070 | return false; |
| 3071 | } |
| 3072 | #endif |
| 3073 | |
Charles Harrison | af2acd0 | 2017-08-18 22:46:02 | [diff] [blame] | 3074 | // Don't let prerenders open popups. |
| 3075 | if (auto* prerender_contents = |
| 3076 | prerender::PrerenderContents::FromWebContents(web_contents)) { |
| 3077 | prerender_contents->Destroy(prerender::FINAL_STATUS_CREATE_NEW_WINDOW); |
| 3078 | return false; |
| 3079 | } |
| 3080 | |
Nasko Oskov | e9f1978 | 2019-01-04 18:32:35 | [diff] [blame] | 3081 | BlockedWindowParams blocked_params(target_url, source_origin, referrer, |
| 3082 | frame_name, disposition, features, |
| 3083 | user_gesture, opener_suppressed); |
cm.sanchi | 2522bc9 | 2017-12-04 08:04:13 | [diff] [blame] | 3084 | NavigateParams nav_params = blocked_params.CreateNavigateParams(web_contents); |
Charlie Harrison | 804659a | 2018-10-16 16:43:38 | [diff] [blame] | 3085 | if (MaybeBlockPopup(web_contents, opener_top_level_frame_url, &nav_params, |
| 3086 | nullptr /*=open_url_params*/, |
| 3087 | blocked_params.features())) { |
Charles Harrison | af2acd0 | 2017-08-18 22:46:02 | [diff] [blame] | 3088 | return false; |
[email protected] | 916615b | 2013-09-11 18:19:44 | [diff] [blame] | 3089 | } |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 3090 | |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 3091 | #if defined(OS_ANDROID) |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 3092 | auto* single_tab_mode_helper = |
| 3093 | SingleTabModeTabHelper::FromWebContents(web_contents); |
Bo Liu | 3d5b8d69 | 2017-12-14 22:42:03 | [diff] [blame] | 3094 | if (single_tab_mode_helper && |
| 3095 | single_tab_mode_helper->block_all_new_windows()) { |
Jinsuk Kim | 6f9253c | 2019-03-11 02:45:07 | [diff] [blame] | 3096 | TabModelList::HandlePopupNavigation(&nav_params); |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 3097 | return false; |
| 3098 | } |
[email protected] | 916615b | 2013-09-11 18:19:44 | [diff] [blame] | 3099 | #endif |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 3100 | |
[email protected] | 9f3fba5 | 2011-06-08 20:37:19 | [diff] [blame] | 3101 | return true; |
| 3102 | } |
| 3103 | |
[email protected] | 9990736 | 2012-01-11 05:41:40 | [diff] [blame] | 3104 | void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 3105 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
yzshen | efcb7c7 | 2017-06-16 23:12:30 | [diff] [blame] | 3106 | |
John Abd-El-Malek | c098bc8 | 2019-05-31 19:33:55 | [diff] [blame] | 3107 | // TODO(jam): move this creation elsewhere so we can remove this method. |
yzshen | efcb7c7 | 2017-06-16 23:12:30 | [diff] [blame] | 3108 | safe_browsing_service_ = g_browser_process->safe_browsing_service(); |
[email protected] | 3cb054e6 | 2011-06-13 05:21:17 | [diff] [blame] | 3109 | } |
| 3110 | |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 3111 | content::SpeechRecognitionManagerDelegate* |
zork | b548de08 | 2014-11-14 21:40:47 | [diff] [blame] | 3112 | ChromeContentBrowserClient::CreateSpeechRecognitionManagerDelegate() { |
[email protected] | 855e18b | 2013-07-08 21:02:00 | [diff] [blame] | 3113 | return new speech::ChromeSpeechRecognitionManagerDelegate(); |
[email protected] | 66cfec6 | 2012-02-24 17:57:51 | [diff] [blame] | 3114 | } |
| 3115 | |
Katie D | 840d953 | 2018-11-27 06:20:48 | [diff] [blame] | 3116 | content::TtsControllerDelegate* |
| 3117 | ChromeContentBrowserClient::GetTtsControllerDelegate() { |
| 3118 | TtsControllerDelegateImpl* delegate = |
| 3119 | TtsControllerDelegateImpl::GetInstance(); |
| 3120 | #if !defined(OS_ANDROID) |
| 3121 | TtsExtensionEngine* tts_extension_engine = TtsExtensionEngine::GetInstance(); |
| 3122 | delegate->SetTtsEngineDelegate(tts_extension_engine); |
| 3123 | #endif |
| 3124 | return delegate; |
| 3125 | } |
| 3126 | |
Katie D | 4713ee4 | 2018-11-30 01:48:27 | [diff] [blame] | 3127 | content::TtsPlatform* ChromeContentBrowserClient::GetTtsPlatform() { |
| 3128 | #ifdef OS_CHROMEOS |
| 3129 | return TtsPlatformImplChromeOs::GetInstance(); |
Katie D | 4713ee4 | 2018-11-30 01:48:27 | [diff] [blame] | 3130 | #else |
| 3131 | return nullptr; |
| 3132 | #endif |
| 3133 | } |
| 3134 | |
Evan Liu | 7cdbf887 | 2019-06-19 16:47:21 | [diff] [blame] | 3135 | base::Optional<ui::CaptionStyle> GetCaptionStyleFromPrefs(PrefService* prefs) { |
| 3136 | if (!prefs) { |
| 3137 | return base::nullopt; |
| 3138 | } |
| 3139 | |
| 3140 | ui::CaptionStyle style; |
| 3141 | |
| 3142 | style.text_size = prefs->GetString(prefs::kAccessibilityCaptionsTextSize); |
| 3143 | style.font_family = prefs->GetString(prefs::kAccessibilityCaptionsTextFont); |
Evan Liu | f248d40 | 2019-06-26 22:57:10 | [diff] [blame] | 3144 | if (!prefs->GetString(prefs::kAccessibilityCaptionsTextColor).empty()) { |
| 3145 | style.text_color = base::StringPrintf( |
| 3146 | "rgba(%s,%s)", |
| 3147 | prefs->GetString(prefs::kAccessibilityCaptionsTextColor).c_str(), |
| 3148 | base::NumberToString( |
| 3149 | prefs->GetInteger(prefs::kAccessibilityCaptionsTextOpacity) / 100.0) |
| 3150 | .c_str()); |
| 3151 | } |
| 3152 | |
| 3153 | if (!prefs->GetString(prefs::kAccessibilityCaptionsBackgroundColor).empty()) { |
| 3154 | style.background_color = base::StringPrintf( |
| 3155 | "rgba(%s,%s)", |
| 3156 | prefs->GetString(prefs::kAccessibilityCaptionsBackgroundColor).c_str(), |
| 3157 | base::NumberToString( |
| 3158 | prefs->GetInteger(prefs::kAccessibilityCaptionsBackgroundOpacity) / |
| 3159 | 100.0) |
| 3160 | .c_str()); |
| 3161 | } |
| 3162 | |
Evan Liu | 7cdbf887 | 2019-06-19 16:47:21 | [diff] [blame] | 3163 | style.text_shadow = prefs->GetString(prefs::kAccessibilityCaptionsTextShadow); |
| 3164 | |
| 3165 | return style; |
| 3166 | } |
| 3167 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3168 | void ChromeContentBrowserClient::OverrideWebkitPrefs( |
creis | 7b2d3d1 | 2015-02-12 23:29:50 | [diff] [blame] | 3169 | RenderViewHost* rvh, WebPreferences* web_prefs) { |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3170 | Profile* profile = Profile::FromBrowserContext( |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 3171 | rvh->GetProcess()->GetBrowserContext()); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3172 | PrefService* prefs = profile->GetPrefs(); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3173 | |
aelias | 0df335a | 2017-03-02 23:43:51 | [diff] [blame] | 3174 | // Fill font preferences. These are not registered on Android |
| 3175 | // - http://crbug.com/308033, http://crbug.com/696364. |
[email protected] | 33b7954 | 2013-10-18 11:18:45 | [diff] [blame] | 3176 | #if !defined(OS_ANDROID) |
[email protected] | 354de9e | 2014-08-07 03:27:19 | [diff] [blame] | 3177 | FontFamilyCache::FillFontFamilyMap(profile, |
| 3178 | prefs::kWebKitStandardFontFamilyMap, |
| 3179 | &web_prefs->standard_font_family_map); |
| 3180 | FontFamilyCache::FillFontFamilyMap(profile, |
| 3181 | prefs::kWebKitFixedFontFamilyMap, |
| 3182 | &web_prefs->fixed_font_family_map); |
| 3183 | FontFamilyCache::FillFontFamilyMap(profile, |
| 3184 | prefs::kWebKitSerifFontFamilyMap, |
| 3185 | &web_prefs->serif_font_family_map); |
| 3186 | FontFamilyCache::FillFontFamilyMap(profile, |
| 3187 | prefs::kWebKitSansSerifFontFamilyMap, |
| 3188 | &web_prefs->sans_serif_font_family_map); |
| 3189 | FontFamilyCache::FillFontFamilyMap(profile, |
| 3190 | prefs::kWebKitCursiveFontFamilyMap, |
| 3191 | &web_prefs->cursive_font_family_map); |
| 3192 | FontFamilyCache::FillFontFamilyMap(profile, |
| 3193 | prefs::kWebKitFantasyFontFamilyMap, |
| 3194 | &web_prefs->fantasy_font_family_map); |
| 3195 | FontFamilyCache::FillFontFamilyMap(profile, |
| 3196 | prefs::kWebKitPictographFontFamilyMap, |
| 3197 | &web_prefs->pictograph_font_family_map); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3198 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3199 | web_prefs->default_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3200 | prefs->GetInteger(prefs::kWebKitDefaultFontSize); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3201 | web_prefs->default_fixed_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3202 | prefs->GetInteger(prefs::kWebKitDefaultFixedFontSize); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3203 | web_prefs->minimum_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3204 | prefs->GetInteger(prefs::kWebKitMinimumFontSize); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3205 | web_prefs->minimum_logical_font_size = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3206 | prefs->GetInteger(prefs::kWebKitMinimumLogicalFontSize); |
aelias | 0df335a | 2017-03-02 23:43:51 | [diff] [blame] | 3207 | #endif |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3208 | |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3209 | web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3210 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3211 | web_prefs->dom_paste_enabled = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3212 | prefs->GetBoolean(prefs::kWebKitDomPasteEnabled); |
Joel Hockey | 08a6c84c | 2018-04-11 10:09:21 | [diff] [blame] | 3213 | web_prefs->javascript_can_access_clipboard = |
| 3214 | prefs->GetBoolean(prefs::kWebKitJavascriptCanAccessClipboard); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3215 | web_prefs->tabs_to_links = prefs->GetBoolean(prefs::kWebkitTabsToLinks); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3216 | |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3217 | if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled)) |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3218 | web_prefs->javascript_enabled = false; |
mkwst | a1f7749b | 2015-12-28 09:28:57 | [diff] [blame] | 3219 | |
Avi Drissman | 1aa6cb9 | 2019-01-23 15:58:38 | [diff] [blame] | 3220 | if (!prefs->GetBoolean(prefs::kWebKitWebSecurityEnabled)) |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3221 | web_prefs->web_security_enabled = false; |
mkwst | a1f7749b | 2015-12-28 09:28:57 | [diff] [blame] | 3222 | |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3223 | if (!prefs->GetBoolean(prefs::kWebKitPluginsEnabled)) |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3224 | web_prefs->plugins_enabled = false; |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3225 | web_prefs->loads_images_automatically = |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3226 | prefs->GetBoolean(prefs::kWebKitLoadsImagesAutomatically); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3227 | |
Zhenyao Mo | a3fda997 | 2017-09-16 01:34:40 | [diff] [blame] | 3228 | if (prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
| 3229 | web_prefs->webgl1_enabled = false; |
| 3230 | web_prefs->webgl2_enabled = false; |
| 3231 | } |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3232 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3233 | web_prefs->allow_running_insecure_content = |
| 3234 | prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent); |
[email protected] | d3b935f | 2012-10-19 23:14:32 | [diff] [blame] | 3235 | #if defined(OS_ANDROID) |
[email protected] | ded00dc | 2013-11-01 00:37:05 | [diff] [blame] | 3236 | web_prefs->font_scale_factor = |
| 3237 | static_cast<float>(prefs->GetDouble(prefs::kWebKitFontScaleFactor)); |
| 3238 | web_prefs->device_scale_adjustment = GetDeviceScaleAdjustment(); |
[email protected] | d3b935f | 2012-10-19 23:14:32 | [diff] [blame] | 3239 | web_prefs->force_enable_zoom = |
| 3240 | prefs->GetBoolean(prefs::kWebKitForceEnableZoom); |
Becky Zhou | bbfbde3 | 2019-02-20 17:07:59 | [diff] [blame] | 3241 | web_prefs->force_dark_mode_enabled = |
| 3242 | prefs->GetBoolean(prefs::kWebKitForceDarkModeEnabled); |
[email protected] | d3b935f | 2012-10-19 23:14:32 | [diff] [blame] | 3243 | #endif |
[email protected] | 5c91525 | 2013-05-07 13:15:39 | [diff] [blame] | 3244 | |
[email protected] | af4256d5 | 2013-06-04 20:39:07 | [diff] [blame] | 3245 | #if defined(OS_ANDROID) |
| 3246 | web_prefs->password_echo_enabled = |
| 3247 | prefs->GetBoolean(prefs::kWebKitPasswordEchoEnabled); |
| 3248 | #else |
[email protected] | 9d06d88d | 2012-02-23 22:37:08 | [diff] [blame] | 3249 | web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled; |
[email protected] | af4256d5 | 2013-06-04 20:39:07 | [diff] [blame] | 3250 | #endif |
| 3251 | |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3252 | web_prefs->text_areas_are_resizable = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3253 | prefs->GetBoolean(prefs::kWebKitTextAreasAreResizable); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3254 | web_prefs->hyperlink_auditing_enabled = |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3255 | prefs->GetBoolean(prefs::kEnableHyperlinkAuditing); |
| 3256 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 3257 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
je_julie.kim | 7fbb5a1a | 2015-02-09 17:26:05 | [diff] [blame] | 3258 | std::string image_animation_policy = |
| 3259 | prefs->GetString(prefs::kAnimationPolicy); |
| 3260 | if (image_animation_policy == kAnimationPolicyOnce) |
| 3261 | web_prefs->animation_policy = |
| 3262 | content::IMAGE_ANIMATION_POLICY_ANIMATION_ONCE; |
| 3263 | else if (image_animation_policy == kAnimationPolicyNone) |
| 3264 | web_prefs->animation_policy = content::IMAGE_ANIMATION_POLICY_NO_ANIMATION; |
| 3265 | else |
| 3266 | web_prefs->animation_policy = content::IMAGE_ANIMATION_POLICY_ALLOWED; |
| 3267 | #endif |
| 3268 | |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3269 | // Make sure we will set the default_encoding with canonical encoding name. |
jinsukkim | 79df88a | 2017-01-04 06:26:15 | [diff] [blame] | 3270 | web_prefs->default_encoding = |
| 3271 | base::GetCanonicalEncodingNameByAliasName(web_prefs->default_encoding); |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3272 | if (web_prefs->default_encoding.empty()) { |
[email protected] | ddf7214 | 2012-05-22 04:52:40 | [diff] [blame] | 3273 | prefs->ClearPref(prefs::kDefaultCharset); |
| 3274 | web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3275 | } |
[email protected] | 64d69de4 | 2012-02-06 00:19:54 | [diff] [blame] | 3276 | DCHECK(!web_prefs->default_encoding.empty()); |
[email protected] | f3986f8 | 2012-01-03 20:00:06 | [diff] [blame] | 3277 | |
mkwst | 0554410 | 2015-01-10 20:26:16 | [diff] [blame] | 3278 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 3279 | switches::kEnablePotentiallyAnnoyingSecurityFeatures)) { |
mkwst | 772ce814 | 2015-01-16 13:28:07 | [diff] [blame] | 3280 | web_prefs->disable_reading_from_canvas = true; |
mkwst | 0554410 | 2015-01-10 20:26:16 | [diff] [blame] | 3281 | web_prefs->strict_mixed_content_checking = true; |
| 3282 | web_prefs->strict_powerful_feature_restrictions = true; |
| 3283 | } |
| 3284 | |
Robert Ogden | cf2872d | 2019-03-19 18:59:37 | [diff] [blame] | 3285 | web_prefs->data_saver_enabled = IsDataSaverEnabled(profile); |
Ben Greenstein | 49878f5 | 2015-12-18 19:13:21 | [diff] [blame] | 3286 | |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 3287 | web_prefs->data_saver_holdback_web_api_enabled = |
| 3288 | base::GetFieldTrialParamByFeatureAsBool(features::kDataSaverHoldback, |
| 3289 | "holdback_web", false); |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 3290 | |
Jinsuk Kim | a3d393ce | 2019-05-27 00:57:42 | [diff] [blame] | 3291 | auto* contents = content::WebContents::FromRenderViewHost(rvh); |
shaktisahu | f97f753 | 2017-02-24 22:46:13 | [diff] [blame] | 3292 | if (contents) { |
Ian Vollick | 6243dfe0 | 2018-03-08 01:08:53 | [diff] [blame] | 3293 | #if defined(OS_ANDROID) |
Jinsuk Kim | a3d393ce | 2019-05-27 00:57:42 | [diff] [blame] | 3294 | auto* delegate = TabAndroid::FromWebContents(contents) |
| 3295 | ? static_cast<android::TabWebContentsDelegateAndroid*>( |
| 3296 | contents->GetDelegate()) |
| 3297 | : nullptr; |
| 3298 | if (delegate) { |
shaktisahu | f97f753 | 2017-02-24 22:46:13 | [diff] [blame] | 3299 | web_prefs->embedded_media_experience_enabled = |
Jinsuk Kim | a3d393ce | 2019-05-27 00:57:42 | [diff] [blame] | 3300 | delegate->ShouldEnableEmbeddedMediaExperience(); |
shaktisahu | f97f753 | 2017-02-24 22:46:13 | [diff] [blame] | 3301 | |
Mounir Lamouri | 9c99a160 | 2018-07-05 15:01:44 | [diff] [blame] | 3302 | web_prefs->picture_in_picture_enabled = |
Jinsuk Kim | a3d393ce | 2019-05-27 00:57:42 | [diff] [blame] | 3303 | delegate->IsPictureInPictureEnabled(); |
Rune Lillesveen | 17e4832 | 2019-04-15 23:12:38 | [diff] [blame] | 3304 | |
| 3305 | web_prefs->preferred_color_scheme = |
Jinsuk Kim | a3d393ce | 2019-05-27 00:57:42 | [diff] [blame] | 3306 | delegate->IsNightModeEnabled() ? blink::PreferredColorScheme::kDark |
| 3307 | : blink::PreferredColorScheme::kLight; |
zqzhang | 183dc82 | 2017-02-15 17:04:11 | [diff] [blame] | 3308 | } |
Ian Vollick | 6243dfe0 | 2018-03-08 01:08:53 | [diff] [blame] | 3309 | #endif // defined(OS_ANDROID) |
Giovanni Ortuño Urquidi | d231ca3 | 2018-05-14 04:20:53 | [diff] [blame] | 3310 | |
Mounir Lamouri | 6926107f | 2019-01-31 18:17:43 | [diff] [blame] | 3311 | // web_app_scope value is platform specific. |
| 3312 | #if defined(OS_ANDROID) |
Jinsuk Kim | a3d393ce | 2019-05-27 00:57:42 | [diff] [blame] | 3313 | if (delegate) |
| 3314 | web_prefs->web_app_scope = delegate->GetManifestScope(); |
Mounir Lamouri | 6926107f | 2019-01-31 18:17:43 | [diff] [blame] | 3315 | #elif BUILDFLAG(ENABLE_EXTENSIONS) |
| 3316 | { |
Giovanni Ortuño Urquidi | dcd3885 | 2019-03-07 08:08:25 | [diff] [blame] | 3317 | web_prefs->web_app_scope = GURL(); |
| 3318 | // Set |web_app_scope| based on the app associated with the app window if |
| 3319 | // any. Note that the app associated with the window never changes, even |
| 3320 | // if the app navigates off scope. This is not a problem because we still |
| 3321 | // want to use the scope of the app associated with the window, not the |
| 3322 | // WebContents. |
Mounir Lamouri | 6926107f | 2019-01-31 18:17:43 | [diff] [blame] | 3323 | Browser* browser = chrome::FindBrowserWithWebContents(contents); |
Alan Cutter | d0bd5190 | 2019-05-22 04:15:23 | [diff] [blame] | 3324 | if (browser && browser->app_controller() && |
Eric Willigers | e339c1e | 2019-05-13 19:22:44 | [diff] [blame] | 3325 | browser->app_controller()->CreatedForInstalledPwa()) { |
Yining Wang | 234ad327 | 2019-04-08 18:47:27 | [diff] [blame] | 3326 | // PWAs should be hosted apps. |
Eric Willigers | e339c1e | 2019-05-13 19:22:44 | [diff] [blame] | 3327 | DCHECK(browser->app_controller()->IsHostedApp()); |
Giovanni Ortuño Urquidi | dcd3885 | 2019-03-07 08:08:25 | [diff] [blame] | 3328 | // HostedApps that are PWAs are always created through WebAppProvider |
| 3329 | // or BookmarkAppHelper for profiles that support them, so we should |
| 3330 | // always be able to retrieve a WebAppProvider from the Profile. |
| 3331 | // |
| 3332 | // Similarly, if a Hosted Apps is a PWA, it will always have a scope |
| 3333 | // so there is no need to test for HasScope(). |
| 3334 | web_prefs->web_app_scope = |
| 3335 | web_app::WebAppProvider::Get(profile) |
| 3336 | ->registrar() |
Eric Willigers | e339c1e | 2019-05-13 19:22:44 | [diff] [blame] | 3337 | .GetScopeUrlForApp(*browser->app_controller()->GetAppId()); |
Mounir Lamouri | 6926107f | 2019-01-31 18:17:43 | [diff] [blame] | 3338 | } |
Mounir Lamouri | 6926107f | 2019-01-31 18:17:43 | [diff] [blame] | 3339 | } |
| 3340 | #endif |
| 3341 | |
Giovanni Ortuño Urquidi | d231ca3 | 2018-05-14 04:20:53 | [diff] [blame] | 3342 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 3343 | Browser* browser = chrome::FindBrowserWithWebContents(contents); |
Eric Willigers | e339c1e | 2019-05-13 19:22:44 | [diff] [blame] | 3344 | if (browser && browser->app_controller() && |
| 3345 | browser->app_controller()->CreatedForInstalledPwa()) { |
Giovanni Ortuño Urquidi | d231ca3 | 2018-05-14 04:20:53 | [diff] [blame] | 3346 | web_prefs->strict_mixed_content_checking = true; |
| 3347 | } |
| 3348 | #endif |
| 3349 | |
Ian Vollick | 6243dfe0 | 2018-03-08 01:08:53 | [diff] [blame] | 3350 | web_prefs->immersive_mode_enabled = vr::VrTabHelper::IsInVr(contents); |
zqzhang | 183dc82 | 2017-02-15 17:04:11 | [diff] [blame] | 3351 | } |
zqzhang | 93e959d1 | 2017-03-16 13:10:20 | [diff] [blame] | 3352 | |
Ian Vollick | 6243dfe0 | 2018-03-08 01:08:53 | [diff] [blame] | 3353 | #if defined(OS_ANDROID) |
Ted Choc | 81c89fc5 | 2018-06-22 23:51:14 | [diff] [blame] | 3354 | web_prefs->video_fullscreen_detection_enabled = true; |
zqzhang | 183dc82 | 2017-02-15 17:04:11 | [diff] [blame] | 3355 | #endif // defined(OS_ANDROID) |
| 3356 | |
Tarun Bansal | 73d67f0 | 2018-01-17 05:56:25 | [diff] [blame] | 3357 | if (base::FeatureList::IsEnabled(features::kLowPriorityIframes)) { |
| 3358 | // Obtain the maximum effective connection type at which the feature is |
| 3359 | // enabled. |
| 3360 | std::string effective_connection_type_param = |
| 3361 | base::GetFieldTrialParamValueByFeature( |
| 3362 | features::kLowPriorityIframes, |
| 3363 | "max_effective_connection_type_threshold"); |
| 3364 | |
| 3365 | base::Optional<net::EffectiveConnectionType> effective_connection_type = |
| 3366 | net::GetEffectiveConnectionTypeForName(effective_connection_type_param); |
| 3367 | if (effective_connection_type) { |
| 3368 | web_prefs->low_priority_iframes_threshold = |
| 3369 | effective_connection_type.value(); |
| 3370 | } |
| 3371 | } |
| 3372 | |
rajendrant | e87ed71 | 2018-11-30 01:55:00 | [diff] [blame] | 3373 | web_prefs->lazy_load_enabled = |
| 3374 | (base::FeatureList::IsEnabled(features::kLazyFrameLoading) || |
| 3375 | base::FeatureList::IsEnabled(features::kLazyImageLoading)) && |
rajendrant | 413b993f | 2018-12-03 23:33:38 | [diff] [blame] | 3376 | (!contents || !contents->GetDelegate() || |
rajendrant | e87ed71 | 2018-11-30 01:55:00 | [diff] [blame] | 3377 | contents->GetDelegate()->ShouldAllowLazyLoad()); |
| 3378 | |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 3379 | if (base::FeatureList::IsEnabled(features::kLazyFrameLoading)) { |
| 3380 | const char* param_name = |
| 3381 | web_prefs->data_saver_enabled |
| 3382 | ? "lazy_frame_loading_distance_thresholds_px_by_ect" |
| 3383 | : "lazy_frame_loading_distance_thresholds_px_by_ect_with_data_" |
| 3384 | "saver_enabled"; |
| 3385 | |
| 3386 | base::StringPairs pairs; |
| 3387 | base::SplitStringIntoKeyValuePairs( |
| 3388 | base::GetFieldTrialParamValueByFeature(features::kLazyFrameLoading, |
| 3389 | param_name), |
| 3390 | ':', ',', &pairs); |
| 3391 | |
| 3392 | for (const auto& pair : pairs) { |
| 3393 | base::Optional<net::EffectiveConnectionType> effective_connection_type = |
| 3394 | net::GetEffectiveConnectionTypeForName(pair.first); |
| 3395 | int value = 0; |
| 3396 | if (effective_connection_type && base::StringToInt(pair.second, &value)) { |
| 3397 | web_prefs->lazy_frame_loading_distance_thresholds_px |
| 3398 | [effective_connection_type.value()] = value; |
| 3399 | } |
| 3400 | } |
| 3401 | } |
| 3402 | |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 3403 | if (base::FeatureList::IsEnabled(features::kLazyImageLoading)) { |
| 3404 | const char* param_name = |
| 3405 | web_prefs->data_saver_enabled |
| 3406 | ? "lazy_image_loading_distance_thresholds_px_by_ect" |
| 3407 | : "lazy_image_loading_distance_thresholds_px_by_ect_with_data_" |
| 3408 | "saver_enabled"; |
| 3409 | |
| 3410 | base::StringPairs pairs; |
| 3411 | base::SplitStringIntoKeyValuePairs( |
| 3412 | base::GetFieldTrialParamValueByFeature(features::kLazyImageLoading, |
| 3413 | param_name), |
| 3414 | ':', ',', &pairs); |
| 3415 | |
| 3416 | for (const auto& pair : pairs) { |
| 3417 | base::Optional<net::EffectiveConnectionType> effective_connection_type = |
| 3418 | net::GetEffectiveConnectionTypeForName(pair.first); |
| 3419 | int value = 0; |
| 3420 | if (effective_connection_type && base::StringToInt(pair.second, &value)) { |
| 3421 | web_prefs->lazy_image_loading_distance_thresholds_px |
| 3422 | [effective_connection_type.value()] = value; |
| 3423 | } |
| 3424 | } |
| 3425 | } |
| 3426 | |
Tarun Bansal | d10f17a0 | 2018-09-13 00:23:17 | [diff] [blame] | 3427 | if (base::FeatureList::IsEnabled( |
| 3428 | features::kNetworkQualityEstimatorWebHoldback)) { |
| 3429 | std::string effective_connection_type_param = |
| 3430 | base::GetFieldTrialParamValueByFeature( |
| 3431 | features::kNetworkQualityEstimatorWebHoldback, |
| 3432 | "web_effective_connection_type_override"); |
| 3433 | |
| 3434 | base::Optional<net::EffectiveConnectionType> effective_connection_type = |
| 3435 | net::GetEffectiveConnectionTypeForName(effective_connection_type_param); |
| 3436 | DCHECK(effective_connection_type_param.empty() || |
| 3437 | effective_connection_type); |
| 3438 | if (effective_connection_type) { |
| 3439 | DCHECK_NE(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, |
| 3440 | effective_connection_type.value()); |
| 3441 | web_prefs->network_quality_estimator_web_holdback = |
| 3442 | effective_connection_type.value(); |
| 3443 | } |
| 3444 | } |
| 3445 | |
Dan Beam | f0a7e11 | 2019-06-07 18:40:58 | [diff] [blame] | 3446 | auto* native_theme = GetWebTheme(); |
François Beaufort | 4f8107d | 2018-03-05 12:12:10 | [diff] [blame] | 3447 | #if !defined(OS_ANDROID) |
Becca Hughes | fe8c32c | 2018-03-21 13:36:56 | [diff] [blame] | 3448 | if (IsAutoplayAllowedByPolicy(contents, prefs)) { |
Becca Hughes | 7d2bbb8 | 2018-08-07 22:56:59 | [diff] [blame] | 3449 | // If autoplay is allowed by policy then force the no user gesture required |
| 3450 | // autoplay policy. |
François Beaufort | 4f8107d | 2018-03-05 12:12:10 | [diff] [blame] | 3451 | web_prefs->autoplay_policy = |
| 3452 | content::AutoplayPolicy::kNoUserGestureRequired; |
Mounir Lamouri | c2186808 | 2018-10-11 21:09:55 | [diff] [blame] | 3453 | } else if (base::FeatureList::IsEnabled(media::kAutoplayDisableSettings) && |
Becca Hughes | 7d2bbb8 | 2018-08-07 22:56:59 | [diff] [blame] | 3454 | web_prefs->autoplay_policy == |
| 3455 | content::AutoplayPolicy::kDocumentUserActivationRequired) { |
Mounir Lamouri | c2186808 | 2018-10-11 21:09:55 | [diff] [blame] | 3456 | // If the autoplay disable settings feature is enabled and the autoplay |
| 3457 | // policy is set to using the unified policy then set the default autoplay |
| 3458 | // policy based on user preference. |
Becca Hughes | 7d2bbb8 | 2018-08-07 22:56:59 | [diff] [blame] | 3459 | web_prefs->autoplay_policy = |
| 3460 | UnifiedAutoplayConfig::ShouldBlockAutoplay(profile) |
| 3461 | ? content::AutoplayPolicy::kDocumentUserActivationRequired |
| 3462 | : content::AutoplayPolicy::kNoUserGestureRequired; |
François Beaufort | 4f8107d | 2018-03-05 12:12:10 | [diff] [blame] | 3463 | } |
Alison Maher | be15c07 | 2019-07-08 18:12:39 | [diff] [blame] | 3464 | web_prefs->forced_colors = native_theme->UsesHighContrastColors() |
| 3465 | ? blink::ForcedColors::kActive |
| 3466 | : blink::ForcedColors::kNone; |
Rune Lillesveen | 5d8c4998 | 2019-04-24 19:07:30 | [diff] [blame] | 3467 | web_prefs->preferred_color_scheme = native_theme->SystemDarkModeEnabled() |
| 3468 | ? blink::PreferredColorScheme::kDark |
| 3469 | : blink::PreferredColorScheme::kLight; |
François Beaufort | 4f8107d | 2018-03-05 12:12:10 | [diff] [blame] | 3470 | #endif // !defined(OS_ANDROID) |
| 3471 | |
Dave Tapuska | c6627e1 | 2018-08-30 15:07:19 | [diff] [blame] | 3472 | web_prefs->translate_service_available = TranslateService::IsAvailable(prefs); |
Elly Fong-Jones | f9289739 | 2019-01-24 16:05:49 | [diff] [blame] | 3473 | |
Dan Beam | 836c02a | 2019-06-15 01:58:27 | [diff] [blame] | 3474 | // Force a light preferred color scheme on certain URLs if kWebUIDarkMode is |
| 3475 | // disabled; some of the UI is not yet correctly themed. Note: the WebUI CSS |
| 3476 | // explicitly uses light (instead of not dark), which is why we don't reset |
| 3477 | // back to no-preference. https://crbug.com/965811 |
| 3478 | if (contents && !base::FeatureList::IsEnabled(features::kWebUIDarkMode)) { |
| 3479 | bool force_light = contents->GetURL().SchemeIs(content::kChromeUIScheme); |
| 3480 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 3481 | if (!force_light) { |
| 3482 | force_light = |
| 3483 | contents->GetURL().SchemeIs(extensions::kExtensionScheme) && |
| 3484 | contents->GetURL().host_piece() == extension_misc::kPdfExtensionId; |
| 3485 | } |
| 3486 | #endif |
| 3487 | if (force_light) |
| 3488 | web_prefs->preferred_color_scheme = blink::PreferredColorScheme::kLight; |
Dan Beam | f0a7e11 | 2019-06-07 18:40:58 | [diff] [blame] | 3489 | } |
| 3490 | |
Elly Fong-Jones | f9289739 | 2019-01-24 16:05:49 | [diff] [blame] | 3491 | // Apply native CaptionStyle parameters. |
Evan Liu | 7cdbf887 | 2019-06-19 16:47:21 | [diff] [blame] | 3492 | base::Optional<ui::CaptionStyle> style; |
| 3493 | |
| 3494 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 3495 | ::switches::kForceCaptionStyle)) { |
| 3496 | style = ui::CaptionStyle::FromSpec( |
| 3497 | base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 3498 | switches::kForceCaptionStyle)); |
| 3499 | } |
| 3500 | |
| 3501 | // Apply system caption style. |
| 3502 | if (!style) { |
| 3503 | style = native_theme->GetSystemCaptionStyle(); |
| 3504 | } |
| 3505 | |
| 3506 | // Apply caption style from preferences if system caption style is undefined. |
| 3507 | if (!style && base::FeatureList::IsEnabled(features::kCaptionSettings)) { |
| 3508 | style = GetCaptionStyleFromPrefs(prefs); |
| 3509 | } |
| 3510 | |
| 3511 | if (style) { |
| 3512 | web_prefs->text_track_background_color = style->background_color; |
| 3513 | web_prefs->text_track_text_color = style->text_color; |
| 3514 | web_prefs->text_track_text_size = style->text_size; |
| 3515 | web_prefs->text_track_text_shadow = style->text_shadow; |
| 3516 | web_prefs->text_track_font_family = style->font_family; |
| 3517 | web_prefs->text_track_font_variant = style->font_variant; |
| 3518 | } |
Elly Fong-Jones | f9289739 | 2019-01-24 16:05:49 | [diff] [blame] | 3519 | |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 3520 | for (size_t i = 0; i < extra_parts_.size(); ++i) |
creis | 7b2d3d1 | 2015-02-12 23:29:50 | [diff] [blame] | 3521 | extra_parts_[i]->OverrideWebkitPrefs(rvh, web_prefs); |
[email protected] | 181a95ee | 2011-07-12 19:26:36 | [diff] [blame] | 3522 | } |
| 3523 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 3524 | void ChromeContentBrowserClient::BrowserURLHandlerCreated( |
| 3525 | BrowserURLHandler* handler) { |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 3526 | for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 3527 | extra_parts_[i]->BrowserURLHandlerCreated(handler); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 3528 | |
[email protected] | b3adbd0 | 2011-11-30 22:23:27 | [diff] [blame] | 3529 | // about: handler. Must come before chrome: handler, since it will |
| 3530 | // rewrite about: urls to chrome: URLs and then expect chrome: to |
creis | 94a977f6 | 2015-02-18 23:51:05 | [diff] [blame] | 3531 | // actually handle them. Also relies on a preliminary fixup phase. |
| 3532 | handler->SetFixupHandler(&FixupBrowserAboutURL); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 3533 | handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 3534 | BrowserURLHandler::null_handler()); |
[email protected] | 231dba2 | 2013-07-25 23:53:03 | [diff] [blame] | 3535 | |
mad | fbd1085 | 2017-01-20 03:15:33 | [diff] [blame] | 3536 | // The group policy NTP URL handler must be registered before the other NTP |
| 3537 | // URL handlers below. |
| 3538 | handler->AddHandlerPair(&HandleNewTabPageLocationOverride, |
| 3539 | BrowserURLHandler::null_handler()); |
| 3540 | |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 3541 | #if defined(OS_ANDROID) |
[email protected] | 4bd78e9 | 2014-03-28 18:54:03 | [diff] [blame] | 3542 | // Handler to rewrite chrome://newtab on Android. |
ianwen | 465e17b | 2015-01-20 18:32:35 | [diff] [blame] | 3543 | handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, |
[email protected] | 4bd78e9 | 2014-03-28 18:54:03 | [diff] [blame] | 3544 | BrowserURLHandler::null_handler()); |
| 3545 | #else |
[email protected] | 231dba2 | 2013-07-25 23:53:03 | [diff] [blame] | 3546 | // Handler to rewrite chrome://newtab for InstantExtended. |
sdefresne | 51bbec7b | 2015-08-03 14:18:13 | [diff] [blame] | 3547 | handler->AddHandlerPair(&search::HandleNewTabURLRewrite, |
| 3548 | &search::HandleNewTabURLReverseRewrite); |
[email protected] | 4bd78e9 | 2014-03-28 18:54:03 | [diff] [blame] | 3549 | #endif |
[email protected] | 231dba2 | 2013-07-25 23:53:03 | [diff] [blame] | 3550 | |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 3551 | // chrome: & friends. |
dbeam | 25472e0c | 2017-06-23 19:02:31 | [diff] [blame] | 3552 | handler->AddHandlerPair(&ChromeContentBrowserClient::HandleWebUI, |
| 3553 | &ChromeContentBrowserClient::HandleWebUIReverse); |
Robert Ogden | e7fdca9 | 2018-10-12 17:53:06 | [diff] [blame] | 3554 | |
| 3555 | // Handler to rewrite Preview's Server Lite Page, to show the original URL to |
| 3556 | // the user. |
| 3557 | handler->AddHandlerPair(&HandlePreviewsLitePageURLRewrite, |
| 3558 | &HandlePreviewsLitePageURLRewriteReverse); |
[email protected] | b8148ac | 2011-07-13 22:03:25 | [diff] [blame] | 3559 | } |
| 3560 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 3561 | base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
[email protected] | b1d9727 | 2013-08-17 13:38:49 | [diff] [blame] | 3562 | return DownloadPrefs::GetDefaultDownloadDirectory(); |
[email protected] | e1d16eb9 | 2011-08-18 23:19:32 | [diff] [blame] | 3563 | } |
| 3564 | |
[email protected] | c9b6eb6 | 2011-10-18 20:49:39 | [diff] [blame] | 3565 | std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
| 3566 | return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
| 3567 | } |
| 3568 | |
Dominik Röttsches | 4734783 | 2019-03-12 17:45:01 | [diff] [blame] | 3569 | base::FilePath ChromeContentBrowserClient::GetFontLookupTableCacheDir() { |
| 3570 | base::FilePath user_data_dir; |
| 3571 | base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 3572 | DCHECK(!user_data_dir.empty()); |
| 3573 | return user_data_dir.Append(FILE_PATH_LITERAL("FontLookupTableCache")); |
| 3574 | } |
| 3575 | |
jmadill | 57b52d4 | 2015-08-21 18:16:13 | [diff] [blame] | 3576 | base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { |
| 3577 | base::FilePath user_data_dir; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 3578 | base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
jmadill | 57b52d4 | 2015-08-21 18:16:13 | [diff] [blame] | 3579 | DCHECK(!user_data_dir.empty()); |
| 3580 | return user_data_dir.Append(FILE_PATH_LITERAL("ShaderCache")); |
| 3581 | } |
| 3582 | |
Khushal | 7ca0b78 | 2018-07-20 05:53:27 | [diff] [blame] | 3583 | base::FilePath ChromeContentBrowserClient::GetGrShaderDiskCacheDirectory() { |
| 3584 | base::FilePath user_data_dir; |
| 3585 | base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 3586 | DCHECK(!user_data_dir.empty()); |
| 3587 | return user_data_dir.Append(FILE_PATH_LITERAL("GrShaderCache")); |
| 3588 | } |
| 3589 | |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 3590 | void ChromeContentBrowserClient::DidCreatePpapiPlugin( |
| 3591 | content::BrowserPpapiHost* browser_host) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 3592 | #if BUILDFLAG(ENABLE_PLUGINS) |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 3593 | ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin(browser_host); |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 3594 | #endif |
[email protected] | b7631cc | 2012-09-15 05:08:38 | [diff] [blame] | 3595 | } |
| 3596 | |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 3597 | content::BrowserPpapiHost* |
| 3598 | ChromeContentBrowserClient::GetExternalBrowserPpapiHost( |
| 3599 | int plugin_process_id) { |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 3600 | #if BUILDFLAG(ENABLE_NACL) |
[email protected] | a56f832 | 2014-07-16 21:13:55 | [diff] [blame] | 3601 | content::BrowserChildProcessHostIterator iter(PROCESS_TYPE_NACL_LOADER); |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 3602 | while (!iter.Done()) { |
[email protected] | 7c766e9 | 2013-11-22 20:44:02 | [diff] [blame] | 3603 | nacl::NaClProcessHost* host = static_cast<nacl::NaClProcessHost*>( |
| 3604 | iter.GetDelegate()); |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 3605 | if (host->process() && |
| 3606 | host->process()->GetData().id == plugin_process_id) { |
| 3607 | // Found the plugin. |
| 3608 | return host->browser_ppapi_host(); |
| 3609 | } |
| 3610 | ++iter; |
| 3611 | } |
[email protected] | a56f832 | 2014-07-16 21:13:55 | [diff] [blame] | 3612 | #endif |
[email protected] | 0c719374 | 2012-11-07 19:05:03 | [diff] [blame] | 3613 | return NULL; |
| 3614 | } |
| 3615 | |
[email protected] | 38cd8f7f | 2012-06-15 22:06:07 | [diff] [blame] | 3616 | bool ChromeContentBrowserClient::AllowPepperSocketAPI( |
[email protected] | 157cc90 | 2012-11-02 06:31:58 | [diff] [blame] | 3617 | content::BrowserContext* browser_context, |
| 3618 | const GURL& url, |
[email protected] | dda5482 | 2013-06-15 01:26:39 | [diff] [blame] | 3619 | bool private_api, |
[email protected] | 8b92ed18 | 2013-09-21 04:47:12 | [diff] [blame] | 3620 | const content::SocketPermissionRequest* params) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 3621 | #if BUILDFLAG(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 3622 | return ChromeContentBrowserClientPluginsPart::AllowPepperSocketAPI( |
| 3623 | browser_context, url, private_api, params, allowed_socket_origins_); |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 3624 | #else |
[email protected] | a658d45 | 2012-03-02 12:45:29 | [diff] [blame] | 3625 | return false; |
[email protected] | 93f7206 | 2013-05-29 20:29:40 | [diff] [blame] | 3626 | #endif |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 3627 | } |
| 3628 | |
adrian.belgun | d54465ba | 2016-05-18 10:03:58 | [diff] [blame] | 3629 | bool ChromeContentBrowserClient::IsPepperVpnProviderAPIAllowed( |
| 3630 | content::BrowserContext* browser_context, |
| 3631 | const GURL& url) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 3632 | #if BUILDFLAG(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
adrian.belgun | d54465ba | 2016-05-18 10:03:58 | [diff] [blame] | 3633 | return ChromeContentBrowserClientPluginsPart::IsPepperVpnProviderAPIAllowed( |
| 3634 | browser_context, url); |
| 3635 | #else |
| 3636 | return false; |
| 3637 | #endif |
| 3638 | } |
| 3639 | |
adrian.belgun | 5b341c7 | 2016-06-22 22:24:08 | [diff] [blame] | 3640 | std::unique_ptr<content::VpnServiceProxy> |
| 3641 | ChromeContentBrowserClient::GetVpnServiceProxy( |
| 3642 | content::BrowserContext* browser_context) { |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 3643 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
adrian.belgun | 5b341c7 | 2016-06-22 22:24:08 | [diff] [blame] | 3644 | return ChromeContentBrowserClientExtensionsPart::GetVpnServiceProxy( |
| 3645 | browser_context); |
| 3646 | #else |
| 3647 | return nullptr; |
| 3648 | #endif |
| 3649 | } |
| 3650 | |
Brett Wilson | 804e83c | 2017-08-18 22:57:33 | [diff] [blame] | 3651 | std::unique_ptr<ui::SelectFilePolicy> |
| 3652 | ChromeContentBrowserClient::CreateSelectFilePolicy(WebContents* web_contents) { |
| 3653 | return std::make_unique<ChromeSelectFilePolicy>(web_contents); |
[email protected] | a28e330 | 2013-02-03 03:50:43 | [diff] [blame] | 3654 | } |
| 3655 | |
[email protected] | 7d942470 | 2013-04-14 13:14:16 | [diff] [blame] | 3656 | void ChromeContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
| 3657 | std::vector<std::string>* additional_allowed_schemes) { |
| 3658 | ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( |
| 3659 | additional_allowed_schemes); |
[email protected] | b3690f7 | 2014-02-17 00:32:48 | [diff] [blame] | 3660 | additional_allowed_schemes->push_back(content::kChromeDevToolsScheme); |
[email protected] | 2d9748b2 | 2014-02-11 00:17:29 | [diff] [blame] | 3661 | additional_allowed_schemes->push_back(content::kChromeUIScheme); |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 3662 | for (size_t i = 0; i < extra_parts_.size(); ++i) { |
| 3663 | extra_parts_[i]->GetAdditionalAllowedSchemesForFileSystem( |
| 3664 | additional_allowed_schemes); |
| 3665 | } |
[email protected] | 7d942470 | 2013-04-14 13:14:16 | [diff] [blame] | 3666 | } |
| 3667 | |
falken | ad18509 | 2016-06-16 06:10:02 | [diff] [blame] | 3668 | void ChromeContentBrowserClient::GetSchemesBypassingSecureContextCheckWhitelist( |
| 3669 | std::set<std::string>* schemes) { |
Daniel Vogelheim | 11e59b7 | 2017-11-22 15:44:04 | [diff] [blame] | 3670 | *schemes = secure_origin_whitelist::GetSchemesBypassingSecureContextCheck(); |
falken | ad18509 | 2016-06-16 06:10:02 | [diff] [blame] | 3671 | } |
| 3672 | |
[email protected] | c79859b8 | 2014-03-20 22:43:55 | [diff] [blame] | 3673 | void ChromeContentBrowserClient::GetURLRequestAutoMountHandlers( |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 3674 | std::vector<storage::URLRequestAutoMountHandler>* handlers) { |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 3675 | for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 3676 | extra_parts_[i]->GetURLRequestAutoMountHandlers(handlers); |
[email protected] | c79859b8 | 2014-03-20 22:43:55 | [diff] [blame] | 3677 | } |
| 3678 | |
nzolghadr | d87a308d | 2016-12-07 15:45:56 | [diff] [blame] | 3679 | ::rappor::RapporService* ChromeContentBrowserClient::GetRapporService() { |
| 3680 | return g_browser_process->rappor_service(); |
| 3681 | } |
| 3682 | |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 3683 | void ChromeContentBrowserClient::GetAdditionalFileSystemBackends( |
[email protected] | 0ff5eb5 | 2013-07-10 20:35:31 | [diff] [blame] | 3684 | content::BrowserContext* browser_context, |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 3685 | const base::FilePath& storage_partition_path, |
avi | d6d88b91 | 2017-01-13 00:16:00 | [diff] [blame] | 3686 | std::vector<std::unique_ptr<storage::FileSystemBackend>>* |
| 3687 | additional_backends) { |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 3688 | #if defined(OS_CHROMEOS) |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 3689 | storage::ExternalMountPoints* external_mount_points = |
[email protected] | 0ff5eb5 | 2013-07-10 20:35:31 | [diff] [blame] | 3690 | content::BrowserContext::GetMountPoints(browser_context); |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 3691 | DCHECK(external_mount_points); |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 3692 | auto backend = std::make_unique<chromeos::FileSystemBackend>( |
| 3693 | std::make_unique<drive::FileSystemBackendDelegate>(), |
| 3694 | std::make_unique<chromeos::file_system_provider::BackendDelegate>(), |
| 3695 | std::make_unique<chromeos::MTPFileSystemBackendDelegate>( |
hashimoto | a53e7e8 | 2016-10-26 06:30:47 | [diff] [blame] | 3696 | storage_partition_path), |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 3697 | std::make_unique<arc::ArcContentFileSystemBackendDelegate>(), |
| 3698 | std::make_unique<arc::ArcDocumentsProviderBackendDelegate>(), |
Sam McNally | 47f2eac | 2018-08-28 06:45:05 | [diff] [blame] | 3699 | std::make_unique<drive::DriveFsFileSystemBackendDelegate>( |
| 3700 | Profile::FromBrowserContext(browser_context)), |
hashimoto | a53e7e8 | 2016-10-26 06:30:47 | [diff] [blame] | 3701 | external_mount_points, storage::ExternalMountPoints::GetSystemInstance()); |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 3702 | backend->AddSystemMountPoints(); |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 3703 | DCHECK(backend->CanHandleType(storage::kFileSystemTypeExternal)); |
avi | d6d88b91 | 2017-01-13 00:16:00 | [diff] [blame] | 3704 | additional_backends->push_back(std::move(backend)); |
[email protected] | b40015c | 2013-06-26 08:13:31 | [diff] [blame] | 3705 | #endif |
[email protected] | 445b7db | 2013-08-02 04:58:27 | [diff] [blame] | 3706 | |
[email protected] | a48ab711 | 2014-08-01 16:48:03 | [diff] [blame] | 3707 | for (size_t i = 0; i < extra_parts_.size(); ++i) { |
| 3708 | extra_parts_[i]->GetAdditionalFileSystemBackends( |
| 3709 | browser_context, storage_partition_path, additional_backends); |
| 3710 | } |
[email protected] | 0225095 | 2013-04-24 23:52:53 | [diff] [blame] | 3711 | } |
| 3712 | |
jcivelli | e6f55074 | 2017-01-06 19:29:12 | [diff] [blame] | 3713 | #if defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | a1733df | 2012-06-22 11:24:18 | [diff] [blame] | 3714 | void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 3715 | const base::CommandLine& command_line, |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 3716 | int child_process_id, |
brettw | 3c98c7d3 | 2017-07-25 01:44:20 | [diff] [blame] | 3717 | PosixFileDescriptorInfo* mappings) { |
Albert J. Wong | b694253 | 2017-07-13 22:49:30 | [diff] [blame] | 3718 | |
jcivelli | e6f55074 | 2017-01-06 19:29:12 | [diff] [blame] | 3719 | #if defined(OS_ANDROID) |
| 3720 | base::MemoryMappedFile::Region region; |
| 3721 | int fd = ui::GetMainAndroidPackFd(®ion); |
| 3722 | mappings->ShareWithRegion(kAndroidUIResourcesPakDescriptor, fd, region); |
agrieve | 05398f5 | 2015-06-24 18:59:00 | [diff] [blame] | 3723 | |
jcivelli | e6f55074 | 2017-01-06 19:29:12 | [diff] [blame] | 3724 | fd = ui::GetCommonResourcesPackFd(®ion); |
| 3725 | mappings->ShareWithRegion(kAndroidChrome100PercentPakDescriptor, fd, region); |
[email protected] | 29699c2 | 2012-10-03 23:57:39 | [diff] [blame] | 3726 | |
jcivelli | e6f55074 | 2017-01-06 19:29:12 | [diff] [blame] | 3727 | fd = ui::GetLocalePackFd(®ion); |
| 3728 | mappings->ShareWithRegion(kAndroidLocalePakDescriptor, fd, region); |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 3729 | |
zpeng | 368afac8 | 2017-07-17 18:47:45 | [diff] [blame] | 3730 | // Optional secondary locale .pak file. |
| 3731 | fd = ui::GetSecondaryLocalePackFd(®ion); |
| 3732 | if (fd != -1) { |
| 3733 | mappings->ShareWithRegion(kAndroidSecondaryLocalePakDescriptor, fd, region); |
| 3734 | } |
| 3735 | |
[email protected] | 09560f7f | 2014-06-10 18:40:28 | [diff] [blame] | 3736 | base::FilePath app_data_path; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 3737 | base::PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path); |
[email protected] | 09560f7f | 2014-06-10 18:40:28 | [diff] [blame] | 3738 | DCHECK(!app_data_path.empty()); |
Joshua Peraza | f890e4b | 2019-01-03 19:19:02 | [diff] [blame] | 3739 | #endif // defined(OS_ANDROID) |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 3740 | int crash_signal_fd = GetCrashSignalFD(command_line); |
| 3741 | if (crash_signal_fd >= 0) { |
Jay Civelli | 668c097f | 2018-05-16 20:44:13 | [diff] [blame] | 3742 | mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd); |
[email protected] | 40da3e0c | 2012-10-24 22:03:38 | [diff] [blame] | 3743 | } |
jcivelli | e6f55074 | 2017-01-06 19:29:12 | [diff] [blame] | 3744 | } |
| 3745 | #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
[email protected] | b80f6843 | 2011-05-02 17:22:30 | [diff] [blame] | 3746 | |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 3747 | #if defined(OS_WIN) |
wfh | 182da09c | 2015-06-24 19:23:03 | [diff] [blame] | 3748 | base::string16 ChromeContentBrowserClient::GetAppContainerSidForSandboxType( |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 3749 | int sandbox_type) { |
wfh | 182da09c | 2015-06-24 19:23:03 | [diff] [blame] | 3750 | // TODO(wfh): Add support for more process types here. crbug.com/499523 |
| 3751 | switch (sandbox_type) { |
Tom Sepez | 15d4e520 | 2017-09-27 23:59:05 | [diff] [blame] | 3752 | case service_manager::SANDBOX_TYPE_RENDERER: |
Jerry Lin | a0de7ce | 2018-06-22 15:18:36 | [diff] [blame] | 3753 | return base::string16(install_static::GetSandboxSidPrefix()) + |
| 3754 | L"129201922"; |
Tom Sepez | 15d4e520 | 2017-09-27 23:59:05 | [diff] [blame] | 3755 | case service_manager::SANDBOX_TYPE_UTILITY: |
wfh | 182da09c | 2015-06-24 19:23:03 | [diff] [blame] | 3756 | return base::string16(); |
Tom Sepez | 15d4e520 | 2017-09-27 23:59:05 | [diff] [blame] | 3757 | case service_manager::SANDBOX_TYPE_GPU: |
wfh | 182da09c | 2015-06-24 19:23:03 | [diff] [blame] | 3758 | return base::string16(); |
Tom Sepez | 15d4e520 | 2017-09-27 23:59:05 | [diff] [blame] | 3759 | case service_manager::SANDBOX_TYPE_PPAPI: |
Jerry Lin | a0de7ce | 2018-06-22 15:18:36 | [diff] [blame] | 3760 | return base::string16(install_static::GetSandboxSidPrefix()) + |
| 3761 | L"129201925"; |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 3762 | #if BUILDFLAG(ENABLE_NACL) |
wfh | 182da09c | 2015-06-24 19:23:03 | [diff] [blame] | 3763 | case PROCESS_TYPE_NACL_LOADER: |
| 3764 | return base::string16(); |
| 3765 | case PROCESS_TYPE_NACL_BROKER: |
| 3766 | return base::string16(); |
| 3767 | #endif |
| 3768 | } |
| 3769 | |
| 3770 | // Should never reach here. |
| 3771 | CHECK(0); |
| 3772 | return base::string16(); |
| 3773 | } |
| 3774 | |
rickyz | 5010931 | 2015-11-11 00:37:08 | [diff] [blame] | 3775 | bool ChromeContentBrowserClient::PreSpawnRenderer( |
| 3776 | sandbox::TargetPolicy* policy) { |
[email protected] | 34f4868 | 2013-03-20 00:30:18 | [diff] [blame] | 3777 | // This code is duplicated in nacl_exe_win_64.cc. |
| 3778 | // Allow the server side of a pipe restricted to the "chrome.nacl." |
| 3779 | // namespace so that it cannot impersonate other system or other chrome |
| 3780 | // service pipes. |
| 3781 | sandbox::ResultCode result = policy->AddRule( |
| 3782 | sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, |
| 3783 | sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, |
| 3784 | L"\\\\.\\pipe\\chrome.nacl.*"); |
rickyz | 5010931 | 2015-11-11 00:37:08 | [diff] [blame] | 3785 | if (result != sandbox::SBOX_ALL_OK) |
| 3786 | return false; |
rickyz | 5010931 | 2015-11-11 00:37:08 | [diff] [blame] | 3787 | return result == sandbox::SBOX_ALL_OK; |
[email protected] | 34f4868 | 2013-03-20 00:30:18 | [diff] [blame] | 3788 | } |
wfh | c91e967 | 2016-01-27 00:14:20 | [diff] [blame] | 3789 | #endif // defined(OS_WIN) |
[email protected] | 4a65826d | 2011-08-25 16:04:01 | [diff] [blame] | 3790 | |
ben | d1dd50f5 | 2016-06-26 22:10:48 | [diff] [blame] | 3791 | void ChromeContentBrowserClient::ExposeInterfacesToRenderer( |
ben | a06f7d6 | 2017-04-04 20:48:52 | [diff] [blame] | 3792 | service_manager::BinderRegistry* registry, |
Sam McNally | 52e5028 | 2017-11-29 00:54:02 | [diff] [blame] | 3793 | blink::AssociatedInterfaceRegistry* associated_registry, |
leon.han | 0b61879 | 2016-06-16 01:53:51 | [diff] [blame] | 3794 | content::RenderProcessHost* render_process_host) { |
nigeltao | beff0a10 | 2017-04-29 09:30:37 | [diff] [blame] | 3795 | // The CacheStatsRecorder is an associated binding, instead of a |
| 3796 | // non-associated one, because the sender (in the renderer process) posts the |
| 3797 | // message after a time delay, in order to rate limit. The association |
| 3798 | // protects against the render process host ID being recycled in that time |
| 3799 | // gap between the preparation and the execution of that IPC. |
| 3800 | associated_registry->AddInterface( |
| 3801 | base::Bind(&CacheStatsRecorder::Create, render_process_host->GetID())); |
| 3802 | |
ben | 5be0b913 | 2016-08-03 00:17:18 | [diff] [blame] | 3803 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner = |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 3804 | base::CreateSingleThreadTaskRunnerWithTraits( |
| 3805 | {content::BrowserThread::UI}); |
ben | d1dd50f5 | 2016-06-26 22:10:48 | [diff] [blame] | 3806 | registry->AddInterface( |
nigeltao | 2f67376 | 2016-10-14 03:27:28 | [diff] [blame] | 3807 | base::Bind(&rappor::RapporRecorderImpl::Create, |
| 3808 | g_browser_process->rappor_service()), |
| 3809 | ui_task_runner); |
Sadrul Habib Chowdhury | 16b3a16 | 2018-02-03 01:43:18 | [diff] [blame] | 3810 | registry->AddInterface( |
Mike Wittman | 16fa536 | 2018-09-04 17:27:30 | [diff] [blame] | 3811 | base::BindRepeating(&metrics::CallStackProfileCollector::Create)); |
Sadrul Habib Chowdhury | 16b3a16 | 2018-02-03 01:43:18 | [diff] [blame] | 3812 | |
dvallet | 233f57ab | 2016-12-21 03:17:10 | [diff] [blame] | 3813 | if (NetBenchmarking::CheckBenchmarkingEnabled()) { |
| 3814 | Profile* profile = |
| 3815 | Profile::FromBrowserContext(render_process_host->GetBrowserContext()); |
Alexandr Ilin | 4909ec8 | 2018-06-06 10:22:48 | [diff] [blame] | 3816 | auto* loading_predictor = |
| 3817 | predictors::LoadingPredictorFactory::GetForProfile(profile); |
Robbie McElrath | b0f248c | 2018-07-24 19:44:16 | [diff] [blame] | 3818 | registry->AddInterface( |
| 3819 | base::BindRepeating( |
| 3820 | &NetBenchmarking::Create, |
| 3821 | loading_predictor ? loading_predictor->GetWeakPtr() : nullptr, |
Robbie McElrath | b0f248c | 2018-07-24 19:44:16 | [diff] [blame] | 3822 | render_process_host->GetID()), |
| 3823 | ui_task_runner); |
dvallet | 233f57ab | 2016-12-21 03:17:10 | [diff] [blame] | 3824 | } |
yzshen | 2d8fb42 | 2017-06-01 20:29:40 | [diff] [blame] | 3825 | |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 3826 | #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
Adam Rice | 41b8959 | 2017-07-28 10:33:44 | [diff] [blame] | 3827 | if (safe_browsing_service_) { |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 3828 | content::ResourceContext* resource_context = |
| 3829 | render_process_host->GetBrowserContext()->GetResourceContext(); |
yzshen | 2d8fb42 | 2017-06-01 20:29:40 | [diff] [blame] | 3830 | registry->AddInterface( |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 3831 | base::Bind( |
| 3832 | &safe_browsing::MojoSafeBrowsingImpl::MaybeCreate, |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 3833 | render_process_host->GetID(), resource_context, |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 3834 | base::Bind( |
| 3835 | &ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate, |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 3836 | base::Unretained(this), resource_context)), |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 3837 | base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO})); |
yzshen | 2d8fb42 | 2017-06-01 20:29:40 | [diff] [blame] | 3838 | } |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 3839 | #endif // defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
yzshen | 2d8fb42 | 2017-06-01 20:29:40 | [diff] [blame] | 3840 | |
Eric Roman | a00cf68 | 2018-11-01 20:09:11 | [diff] [blame] | 3841 | if (data_reduction_proxy::params::IsEnabledWithNetworkService()) { |
| 3842 | registry->AddInterface(base::BindRepeating( |
| 3843 | &AddDataReductionProxyBinding, |
| 3844 | render_process_host->GetBrowserContext()->GetResourceContext())); |
| 3845 | } |
| 3846 | |
chrisha | 927d8fe | 2017-01-18 23:09:51 | [diff] [blame] | 3847 | #if defined(OS_WIN) |
Patrick Monette | 9a10ae2 | 2018-06-14 22:18:18 | [diff] [blame] | 3848 | // Add the ModuleEventSink interface. This is the interface used by renderer |
| 3849 | // processes to notify the browser of modules in their address space. The |
| 3850 | // process handle is not yet available at this point so pass in a callback |
| 3851 | // to allow to retrieve a duplicate at the time the interface is actually |
| 3852 | // created. It is safe to pass a raw pointer to |render_process_host|: the |
Patrick Monette | aa2ec56 | 2019-03-20 23:37:45 | [diff] [blame] | 3853 | // callback will be invoked during the Mojo initialization, which occurs while |
| 3854 | // the |render_process_host| is alive. |
Patrick Monette | 9a10ae2 | 2018-06-14 22:18:18 | [diff] [blame] | 3855 | auto get_process = base::BindRepeating( |
| 3856 | [](content::RenderProcessHost* host) -> base::Process { |
| 3857 | return host->GetProcess().Duplicate(); |
| 3858 | }, |
| 3859 | base::Unretained(render_process_host)); |
Patrick Monette | 9a10ae2 | 2018-06-14 22:18:18 | [diff] [blame] | 3860 | registry->AddInterface( |
Patrick Monette | aa2ec56 | 2019-03-20 23:37:45 | [diff] [blame] | 3861 | base::BindRepeating( |
| 3862 | &ModuleEventSinkImpl::Create, std::move(get_process), |
| 3863 | content::PROCESS_TYPE_RENDERER, |
| 3864 | base::BindRepeating(&ModuleDatabase::HandleModuleLoadEvent)), |
Patrick Monette | 9a10ae2 | 2018-06-14 22:18:18 | [diff] [blame] | 3865 | ui_task_runner); |
chrisha | 927d8fe | 2017-01-18 23:09:51 | [diff] [blame] | 3866 | #endif |
Dan Harrington | 964d48c | 2018-08-03 15:52:24 | [diff] [blame] | 3867 | #if defined(OS_ANDROID) |
Carlos Knippschild | 63b3f04 | 2018-11-20 22:55:04 | [diff] [blame] | 3868 | Profile* profile = |
| 3869 | Profile::FromBrowserContext(render_process_host->GetBrowserContext()); |
Dan Harrington | 964d48c | 2018-08-03 15:52:24 | [diff] [blame] | 3870 | registry->AddInterface( |
| 3871 | base::BindRepeating(&android::AvailableOfflineContentProvider::Create, |
Carlos Knippschild | 63b3f04 | 2018-11-20 22:55:04 | [diff] [blame] | 3872 | profile), |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 3873 | base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})); |
Dan Harrington | 964d48c | 2018-08-03 15:52:24 | [diff] [blame] | 3874 | #endif |
chrisha | 927d8fe | 2017-01-18 23:09:51 | [diff] [blame] | 3875 | |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 3876 | for (auto* ep : extra_parts_) { |
| 3877 | ep->ExposeInterfacesToRenderer(registry, associated_registry, |
| 3878 | render_process_host); |
| 3879 | } |
sammc | 33584452 | 2016-06-09 10:15:59 | [diff] [blame] | 3880 | } |
| 3881 | |
ben | dd157e1a | 2016-07-22 03:15:57 | [diff] [blame] | 3882 | void ChromeContentBrowserClient::ExposeInterfacesToMediaService( |
ben | 8408b13 | 2017-05-01 23:48:50 | [diff] [blame] | 3883 | service_manager::BinderRegistry* registry, |
xhwang | 9ab9648 | 2015-05-11 22:02:33 | [diff] [blame] | 3884 | content::RenderFrameHost* render_frame_host) { |
Xiaohan Wang | 15303d0c | 2017-10-06 05:22:44 | [diff] [blame] | 3885 | #if BUILDFLAG(ENABLE_LIBRARY_CDMS) |
| 3886 | registry->AddInterface( |
| 3887 | base::Bind(&OutputProtectionImpl::Create, render_frame_host)); |
ben | 155ecf8 | 2016-06-21 22:43:26 | [diff] [blame] | 3888 | registry->AddInterface( |
John Rummell | 1b5da610 | 2017-11-02 02:15:45 | [diff] [blame] | 3889 | base::Bind(&PlatformVerificationImpl::Create, render_frame_host)); |
Xiaohan Wang | 15303d0c | 2017-10-06 05:22:44 | [diff] [blame] | 3890 | #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) |
xhwang | c86d76e4 | 2016-03-14 23:38:49 | [diff] [blame] | 3891 | |
xhwang | db24d60 | 2017-05-20 06:32:24 | [diff] [blame] | 3892 | #if BUILDFLAG(ENABLE_MOJO_CDM) && defined(OS_ANDROID) |
cm.sanchi | ad3f42a6 | 2017-11-07 11:33:35 | [diff] [blame] | 3893 | registry->AddInterface(base::Bind(&CreateMediaDrmStorage, render_frame_host)); |
xhwang | 116acb9 | 2017-04-03 18:27:20 | [diff] [blame] | 3894 | #endif |
xhwang | 9ab9648 | 2015-05-11 22:02:33 | [diff] [blame] | 3895 | } |
| 3896 | |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 3897 | void ChromeContentBrowserClient::BindInterfaceRequestFromFrame( |
| 3898 | content::RenderFrameHost* render_frame_host, |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 3899 | const std::string& interface_name, |
| 3900 | mojo::ScopedMessagePipeHandle interface_pipe) { |
Sam McNally | faf9a40 | 2017-10-31 03:06:31 | [diff] [blame] | 3901 | if (!frame_interfaces_ && !frame_interfaces_parameterized_ && |
| 3902 | !worker_interfaces_parameterized_) { |
| 3903 | InitWebContextInterfaces(); |
| 3904 | } |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 3905 | |
Ben Goodger | 272e063 | 2017-07-19 23:27:00 | [diff] [blame] | 3906 | if (!frame_interfaces_parameterized_->TryBindInterface( |
| 3907 | interface_name, &interface_pipe, render_frame_host)) { |
| 3908 | frame_interfaces_->TryBindInterface(interface_name, &interface_pipe); |
juncai | 1bf9f7c | 2016-03-22 20:46:56 | [diff] [blame] | 3909 | } |
rockot | 0fa66a8 | 2015-06-11 17:25:45 | [diff] [blame] | 3910 | } |
| 3911 | |
Mario Sanchez Prada | 39dee4a | 2019-07-09 07:15:40 | [diff] [blame] | 3912 | void ChromeContentBrowserClient::BindCredentialManagerReceiver( |
Oksana Zhuravlova | 23ecbb40 | 2019-03-29 19:44:11 | [diff] [blame] | 3913 | content::RenderFrameHost* render_frame_host, |
Mario Sanchez Prada | 39dee4a | 2019-07-09 07:15:40 | [diff] [blame] | 3914 | mojo::PendingReceiver<blink::mojom::CredentialManager> receiver) { |
| 3915 | ChromePasswordManagerClient::BindCredentialManager(std::move(receiver), |
Oksana Zhuravlova | 23ecbb40 | 2019-03-29 19:44:11 | [diff] [blame] | 3916 | render_frame_host); |
| 3917 | } |
| 3918 | |
Ken Rockot | 0aad7ec | 2018-07-31 15:58:44 | [diff] [blame] | 3919 | bool ChromeContentBrowserClient::BindAssociatedInterfaceRequestFromFrame( |
| 3920 | content::RenderFrameHost* render_frame_host, |
| 3921 | const std::string& interface_name, |
| 3922 | mojo::ScopedInterfaceEndpointHandle* handle) { |
| 3923 | if (interface_name == autofill::mojom::AutofillDriver::Name_) { |
| 3924 | autofill::ContentAutofillDriverFactory::BindAutofillDriver( |
| 3925 | autofill::mojom::AutofillDriverAssociatedRequest(std::move(*handle)), |
| 3926 | render_frame_host); |
| 3927 | return true; |
Lei Zhang | 5b3f81f | 2019-04-10 00:54:58 | [diff] [blame] | 3928 | } |
| 3929 | if (interface_name == autofill::mojom::PasswordManagerDriver::Name_) { |
Dominic Battre | 97d5edf | 2019-03-26 13:41:38 | [diff] [blame] | 3930 | password_manager::ContentPasswordManagerDriverFactory::BindAutofillDriver( |
| 3931 | autofill::mojom::PasswordManagerDriverAssociatedRequest( |
| 3932 | std::move(*handle)), |
| 3933 | render_frame_host); |
| 3934 | return true; |
Lei Zhang | 5b3f81f | 2019-04-10 00:54:58 | [diff] [blame] | 3935 | } |
| 3936 | if (interface_name == content_capture::mojom::ContentCaptureReceiver::Name_) { |
Tao Bai | 02ab4dd4 | 2019-03-06 00:30:37 | [diff] [blame] | 3937 | content_capture::ContentCaptureReceiverManager::BindContentCaptureReceiver( |
| 3938 | content_capture::mojom::ContentCaptureReceiverAssociatedRequest( |
| 3939 | std::move(*handle)), |
| 3940 | render_frame_host); |
| 3941 | return true; |
Ken Rockot | 0aad7ec | 2018-07-31 15:58:44 | [diff] [blame] | 3942 | } |
| 3943 | |
| 3944 | return false; |
| 3945 | } |
| 3946 | |
Sam McNally | faf9a40 | 2017-10-31 03:06:31 | [diff] [blame] | 3947 | void ChromeContentBrowserClient::BindInterfaceRequestFromWorker( |
| 3948 | content::RenderProcessHost* render_process_host, |
| 3949 | const url::Origin& origin, |
| 3950 | const std::string& interface_name, |
| 3951 | mojo::ScopedMessagePipeHandle interface_pipe) { |
| 3952 | if (!frame_interfaces_ && !frame_interfaces_parameterized_ && |
| 3953 | !worker_interfaces_parameterized_) { |
| 3954 | InitWebContextInterfaces(); |
| 3955 | } |
| 3956 | |
| 3957 | worker_interfaces_parameterized_->BindInterface( |
| 3958 | interface_name, std::move(interface_pipe), render_process_host, origin); |
| 3959 | } |
| 3960 | |
ben | a06f7d6 | 2017-04-04 20:48:52 | [diff] [blame] | 3961 | void ChromeContentBrowserClient::BindInterfaceRequest( |
ben | 2c36828d | 2017-05-02 04:09:01 | [diff] [blame] | 3962 | const service_manager::BindSourceInfo& source_info, |
ben | a06f7d6 | 2017-04-04 20:48:52 | [diff] [blame] | 3963 | const std::string& interface_name, |
| 3964 | mojo::ScopedMessagePipeHandle* interface_pipe) { |
Ben Goodger | 272e063 | 2017-07-19 23:27:00 | [diff] [blame] | 3965 | if (source_info.identity.name() == content::mojom::kGpuServiceName) |
| 3966 | gpu_binder_registry_.TryBindInterface(interface_name, interface_pipe); |
wittman | 757af87 | 2016-08-16 00:13:46 | [diff] [blame] | 3967 | } |
| 3968 | |
Ken Rockot | fa5d5711 | 2019-05-29 20:57:14 | [diff] [blame] | 3969 | void ChromeContentBrowserClient::WillStartServiceManager() { |
John Abd-El-Malek | 27b3ebd2 | 2019-02-12 18:59:18 | [diff] [blame] | 3970 | #if defined(OS_WIN) |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 3971 | if (startup_data_) { |
| 3972 | auto* chrome_feature_list_creator = |
| 3973 | startup_data_->chrome_feature_list_creator(); |
John Abd-El-Malek | 27b3ebd2 | 2019-02-12 18:59:18 | [diff] [blame] | 3974 | // This has to run very early before ServiceManagerContext is created. |
| 3975 | const base::Value* force_network_in_process_value = |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 3976 | chrome_feature_list_creator->browser_policy_connector() |
John Abd-El-Malek | 27b3ebd2 | 2019-02-12 18:59:18 | [diff] [blame] | 3977 | ->GetPolicyService() |
| 3978 | ->GetPolicies(policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 3979 | std::string())) |
| 3980 | .GetValue(policy::key::kForceNetworkInProcess); |
| 3981 | bool force_network_in_process = false; |
| 3982 | if (force_network_in_process_value) |
| 3983 | force_network_in_process_value->GetAsBoolean(&force_network_in_process); |
| 3984 | if (force_network_in_process) |
| 3985 | content::ForceInProcessNetworkService(true); |
| 3986 | } |
| 3987 | #endif |
xhwang | 5e63046 | 2015-10-30 03:18:48 | [diff] [blame] | 3988 | } |
| 3989 | |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 3990 | void ChromeContentBrowserClient::RunServiceInstance( |
| 3991 | const service_manager::Identity& identity, |
| 3992 | mojo::PendingReceiver<service_manager::mojom::Service>* receiver) { |
| 3993 | const std::string& service_name = identity.name(); |
Ken Rockot | 0875052 | 2018-11-29 07:41:34 | [diff] [blame] | 3994 | if (service_name == prefs::mojom::kLocalStateServiceName) { |
| 3995 | if (!g_browser_process || !g_browser_process->pref_service_factory()) |
| 3996 | return; |
| 3997 | |
Ken Rockot | d80eb10 | 2018-11-29 14:55:16 | [diff] [blame] | 3998 | service_manager::Service::RunAsyncUntilTermination( |
Ken Rockot | 0875052 | 2018-11-29 07:41:34 | [diff] [blame] | 3999 | g_browser_process->pref_service_factory()->CreatePrefService( |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4000 | std::move(*receiver))); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4001 | return; |
Ken Rockot | 0875052 | 2018-11-29 07:41:34 | [diff] [blame] | 4002 | } |
| 4003 | |
Alexander Woolf | ed183c51 | 2019-05-17 01:18:03 | [diff] [blame] | 4004 | #if defined(OS_WIN) |
| 4005 | bool run_quarantine_service_in_process = |
| 4006 | !base::FeatureList::IsEnabled(quarantine::kOutOfProcessQuarantine); |
| 4007 | #else |
| 4008 | bool run_quarantine_service_in_process = true; |
| 4009 | #endif |
| 4010 | |
| 4011 | if (run_quarantine_service_in_process && |
| 4012 | service_name == quarantine::mojom::kServiceName) { |
| 4013 | service_manager::Service::RunAsyncUntilTermination( |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4014 | std::make_unique<quarantine::QuarantineService>(std::move(*receiver))); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4015 | return; |
Alexander Woolf | ed183c51 | 2019-05-17 01:18:03 | [diff] [blame] | 4016 | } |
| 4017 | |
Ken Rockot | 3d8be74 | 2018-11-22 08:59:38 | [diff] [blame] | 4018 | #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) |
| 4019 | if (service_name == media::mojom::kMediaServiceName) { |
Ken Rockot | d80eb10 | 2018-11-29 14:55:16 | [diff] [blame] | 4020 | service_manager::Service::RunAsyncUntilTermination( |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4021 | media::CreateMediaService(std::move(*receiver))); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4022 | return; |
Ken Rockot | 3d8be74 | 2018-11-22 08:59:38 | [diff] [blame] | 4023 | } |
| 4024 | #endif |
Ken Rockot | e116c20 | 2018-11-30 01:52:50 | [diff] [blame] | 4025 | |
Ken Rockot | c15f3499 | 2018-12-01 21:27:57 | [diff] [blame] | 4026 | #if BUILDFLAG(ENABLE_SIMPLE_BROWSER_SERVICE_IN_PROCESS) |
| 4027 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 4028 | switches::kLaunchInProcessSimpleBrowserSwitch) && |
| 4029 | service_name == simple_browser::mojom::kServiceName) { |
| 4030 | service_manager::Service::RunAsyncUntilTermination( |
| 4031 | std::make_unique<simple_browser::SimpleBrowserService>( |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4032 | std::move(*receiver), simple_browser::SimpleBrowserService:: |
| 4033 | UIInitializationMode::kUseEnvironmentUI)); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4034 | return; |
Ken Rockot | c15f3499 | 2018-12-01 21:27:57 | [diff] [blame] | 4035 | } |
| 4036 | #endif |
| 4037 | |
Ken Rockot | e116c20 | 2018-11-30 01:52:50 | [diff] [blame] | 4038 | #if defined(OS_CHROMEOS) |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4039 | if (base::FeatureList::IsEnabled( |
| 4040 | chromeos::features::kUpdatedCellularActivationUi) && |
| 4041 | service_name == chromeos::cellular_setup::mojom::kServiceName) { |
Kyle Horimoto | 1d6a679f | 2019-04-16 23:24:21 | [diff] [blame] | 4042 | service_manager::Service::RunAsyncUntilTermination( |
| 4043 | std::make_unique<chromeos::cellular_setup::CellularSetupService>( |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4044 | std::move(*receiver))); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4045 | return; |
Kyle Horimoto | 1d6a679f | 2019-04-16 23:24:21 | [diff] [blame] | 4046 | } |
| 4047 | |
Regan Hsu | 07912b7d | 2018-12-13 21:27:01 | [diff] [blame] | 4048 | if (service_name == chromeos::secure_channel::mojom::kServiceName) { |
Ken Rockot | c15f3499 | 2018-12-01 21:27:57 | [diff] [blame] | 4049 | service_manager::Service::RunAsyncUntilTermination( |
| 4050 | std::make_unique<chromeos::secure_channel::SecureChannelService>( |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4051 | std::move(*receiver))); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4052 | return; |
Ken Rockot | c15f3499 | 2018-12-01 21:27:57 | [diff] [blame] | 4053 | } |
| 4054 | |
Luum Habtemariam | c295b4ea | 2019-04-24 20:18:51 | [diff] [blame] | 4055 | if (service_name == chromeos::printing::mojom::kCupsProxyServiceName) { |
| 4056 | service_manager::Service::RunAsyncUntilTermination( |
| 4057 | std::make_unique<chromeos::printing::CupsProxyService>( |
Luum Habtemariam | ce0d1a9 | 2019-06-21 03:26:52 | [diff] [blame] | 4058 | std::move(*receiver), |
| 4059 | std::make_unique<chromeos::CupsProxyServiceDelegateImpl>())); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4060 | return; |
Luum Habtemariam | c295b4ea | 2019-04-24 20:18:51 | [diff] [blame] | 4061 | } |
| 4062 | |
Steven Bennetts | 0c565d5b | 2019-04-24 23:52:45 | [diff] [blame] | 4063 | if (service_name == chromeos::network_config::mojom::kServiceName) { |
| 4064 | service_manager::Service::RunAsyncUntilTermination( |
| 4065 | std::make_unique<chromeos::network_config::NetworkConfigService>( |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4066 | std::move(*receiver))); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4067 | return; |
Steven Bennetts | 0c565d5b | 2019-04-24 23:52:45 | [diff] [blame] | 4068 | } |
| 4069 | |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4070 | auto service = ash_service_registry::HandleServiceRequest( |
| 4071 | service_name, std::move(*receiver)); |
Ken Rockot | c15f3499 | 2018-12-01 21:27:57 | [diff] [blame] | 4072 | if (service) |
| 4073 | service_manager::Service::RunAsyncUntilTermination(std::move(service)); |
Lei Zhang | 194fcd3 | 2019-05-23 16:19:41 | [diff] [blame] | 4074 | #endif // defined(OS_CHROMEOS) |
Ken Rockot | 3d8be74 | 2018-11-22 08:59:38 | [diff] [blame] | 4075 | } |
| 4076 | |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4077 | void ChromeContentBrowserClient::RunServiceInstanceOnIOThread( |
| 4078 | const service_manager::Identity& identity, |
| 4079 | mojo::PendingReceiver<service_manager::mojom::Service>* receiver) { |
| 4080 | if (identity.name() == chrome::mojom::kServiceName) { |
| 4081 | ChromeService::GetInstance()->CreateChromeServiceRequestHandler().Run( |
| 4082 | std::move(*receiver)); |
| 4083 | return; |
| 4084 | } |
| 4085 | |
| 4086 | #if defined(OS_ANDROID) |
| 4087 | if (identity.name() == proxy_resolver::mojom::kProxyResolverServiceName) { |
| 4088 | service_manager::Service::RunAsyncUntilTermination( |
| 4089 | std::make_unique<proxy_resolver::ProxyResolverService>( |
| 4090 | std::move(*receiver))); |
| 4091 | return; |
| 4092 | } |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4093 | #endif |
| 4094 | |
| 4095 | if (identity.name() == heap_profiling::mojom::kServiceName) { |
| 4096 | heap_profiling::HeapProfilingService::GetServiceFactory().Run( |
| 4097 | std::move(*receiver)); |
| 4098 | return; |
| 4099 | } |
| 4100 | } |
| 4101 | |
Ken Rockot | 8f39a27 | 2018-12-21 23:38:35 | [diff] [blame] | 4102 | base::Optional<service_manager::Manifest> |
sammc | 2b0375b | 2016-12-22 01:26:17 | [diff] [blame] | 4103 | ChromeContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { |
Lei Zhang | 5b3f81f | 2019-04-10 00:54:58 | [diff] [blame] | 4104 | if (name == content::mojom::kBrowserServiceName) |
Ken Rockot | 341089f | 2019-01-11 23:11:58 | [diff] [blame] | 4105 | return GetChromeContentBrowserOverlayManifest(); |
Lei Zhang | 5b3f81f | 2019-04-10 00:54:58 | [diff] [blame] | 4106 | if (name == content::mojom::kGpuServiceName) |
Ken Rockot | 341089f | 2019-01-11 23:11:58 | [diff] [blame] | 4107 | return GetChromeContentGpuOverlayManifest(); |
Lei Zhang | 5b3f81f | 2019-04-10 00:54:58 | [diff] [blame] | 4108 | if (name == content::mojom::kRendererServiceName) |
| 4109 | return GetChromeContentRendererOverlayManifest(); |
| 4110 | if (name == content::mojom::kUtilityServiceName) |
| 4111 | return GetChromeContentUtilityOverlayManifest(); |
Ken Rockot | 341089f | 2019-01-11 23:11:58 | [diff] [blame] | 4112 | return base::nullopt; |
ben | c70c0e3 | 2016-09-22 03:50:37 | [diff] [blame] | 4113 | } |
| 4114 | |
Ken Rockot | 69aade0 | 2019-01-23 21:19:51 | [diff] [blame] | 4115 | std::vector<service_manager::Manifest> |
sammc | 2b0375b | 2016-12-22 01:26:17 | [diff] [blame] | 4116 | ChromeContentBrowserClient::GetExtraServiceManifests() { |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4117 | auto manifests = GetChromeBuiltinServiceManifests(); |
| 4118 | manifests.push_back(GetChromeRendererManifest()); |
| 4119 | |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 4120 | #if BUILDFLAG(ENABLE_NACL) |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4121 | manifests.push_back(GetNaClLoaderManifest()); |
Ken Rockot | 69aade0 | 2019-01-23 21:19:51 | [diff] [blame] | 4122 | #if defined(OS_WIN) && defined(ARCH_CPU_X86) |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4123 | manifests.push_back(GetNaClBrokerManifest()); |
sammc | 2b0375b | 2016-12-22 01:26:17 | [diff] [blame] | 4124 | #endif // defined(OS_WIN) |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 4125 | #endif // BUILDFLAG(ENABLE_NACL) |
Ken Rockot | 06fd283 | 2019-05-24 17:24:44 | [diff] [blame] | 4126 | |
| 4127 | return manifests; |
sammc | 2b0375b | 2016-12-22 01:26:17 | [diff] [blame] | 4128 | } |
| 4129 | |
peter | bbcccc1 | 2015-02-11 22:23:33 | [diff] [blame] | 4130 | void ChromeContentBrowserClient::OpenURL( |
Matt Falkenhagen | 18c5c5d | 2018-11-26 02:55:37 | [diff] [blame] | 4131 | content::SiteInstance* site_instance, |
peter | bbcccc1 | 2015-02-11 22:23:33 | [diff] [blame] | 4132 | const content::OpenURLParams& params, |
danakj | a9fe91c | 2019-05-01 19:02:29 | [diff] [blame] | 4133 | base::OnceCallback<void(content::WebContents*)> callback) { |
mlamouri | eb40d55 | 2015-02-05 00:57:08 | [diff] [blame] | 4134 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Matt Falkenhagen | 18c5c5d | 2018-11-26 02:55:37 | [diff] [blame] | 4135 | DCHECK(ShouldAllowOpenURL(site_instance, params.url)); |
| 4136 | |
| 4137 | content::BrowserContext* browser_context = site_instance->GetBrowserContext(); |
mlamouri | eb40d55 | 2015-02-05 00:57:08 | [diff] [blame] | 4138 | |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 4139 | #if defined(OS_ANDROID) |
pkotwicz | aa289f0 | 2016-07-05 22:26:22 | [diff] [blame] | 4140 | ServiceTabLauncher::GetInstance()->LaunchTab(browser_context, params, |
danakj | a9fe91c | 2019-05-01 19:02:29 | [diff] [blame] | 4141 | std::move(callback)); |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 4142 | #else |
cm.sanchi | 2522bc9 | 2017-12-04 08:04:13 | [diff] [blame] | 4143 | NavigateParams nav_params(Profile::FromBrowserContext(browser_context), |
| 4144 | params.url, params.transition); |
| 4145 | nav_params.FillNavigateParamsFromOpenURLParams(params); |
mlamouri | eb40d55 | 2015-02-05 00:57:08 | [diff] [blame] | 4146 | nav_params.user_gesture = params.user_gesture; |
| 4147 | |
| 4148 | Navigate(&nav_params); |
danakj | a9fe91c | 2019-05-01 19:02:29 | [diff] [blame] | 4149 | std::move(callback).Run(nav_params.navigated_or_inserted_contents); |
peter | bbcccc1 | 2015-02-11 22:23:33 | [diff] [blame] | 4150 | #endif |
mlamouri | eb40d55 | 2015-02-05 00:57:08 | [diff] [blame] | 4151 | } |
| 4152 | |
zhaobin | f3704f8 | 2017-01-12 07:19:36 | [diff] [blame] | 4153 | content::ControllerPresentationServiceDelegate* |
| 4154 | ChromeContentBrowserClient::GetControllerPresentationServiceDelegate( |
| 4155 | content::WebContents* web_contents) { |
mfoltz | 99bd44c | 2016-03-18 20:36:46 | [diff] [blame] | 4156 | if (media_router::MediaRouterEnabled(web_contents->GetBrowserContext())) { |
haibinlu | 9e605a9 | 2015-06-06 03:45:09 | [diff] [blame] | 4157 | return media_router::PresentationServiceDelegateImpl:: |
| 4158 | GetOrCreateForWebContents(web_contents); |
| 4159 | } |
haibinlu | 9e605a9 | 2015-06-06 03:45:09 | [diff] [blame] | 4160 | return nullptr; |
| 4161 | } |
| 4162 | |
zhaobin | f3704f8 | 2017-01-12 07:19:36 | [diff] [blame] | 4163 | content::ReceiverPresentationServiceDelegate* |
| 4164 | ChromeContentBrowserClient::GetReceiverPresentationServiceDelegate( |
| 4165 | content::WebContents* web_contents) { |
zhaobin | f3704f8 | 2017-01-12 07:19:36 | [diff] [blame] | 4166 | if (media_router::MediaRouterEnabled(web_contents->GetBrowserContext())) { |
| 4167 | // ReceiverPresentationServiceDelegateImpl exists only for WebContents |
| 4168 | // created for offscreen presentations. The WebContents must belong to |
| 4169 | // an incognito profile. |
| 4170 | if (auto* impl = media_router::ReceiverPresentationServiceDelegateImpl:: |
| 4171 | FromWebContents(web_contents)) { |
| 4172 | DCHECK(web_contents->GetBrowserContext()->IsOffTheRecord()); |
| 4173 | return impl; |
| 4174 | } |
| 4175 | } |
zhaobin | f3704f8 | 2017-01-12 07:19:36 | [diff] [blame] | 4176 | return nullptr; |
| 4177 | } |
| 4178 | |
horo | 48d4d3e | 2015-02-27 03:04:00 | [diff] [blame] | 4179 | void ChromeContentBrowserClient::RecordURLMetric(const std::string& metric, |
| 4180 | const GURL& url) { |
mathp | 46284f3 | 2015-03-11 13:06:41 | [diff] [blame] | 4181 | if (url.is_valid()) { |
| 4182 | rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), |
| 4183 | metric, url); |
| 4184 | } |
horo | 48d4d3e | 2015-02-27 03:04:00 | [diff] [blame] | 4185 | } |
| 4186 | |
Matt Falkenhagen | 8479b20 | 2017-07-14 04:35:31 | [diff] [blame] | 4187 | std::string ChromeContentBrowserClient::GetMetricSuffixForURL(const GURL& url) { |
| 4188 | // Don't change these returned strings. They are written (in hashed form) into |
| 4189 | // UMA logs. If you add more strings, you must update histograms.xml and get |
| 4190 | // histograms review. Only Google domains should be here for privacy purposes. |
| 4191 | // TODO(falken): Ideally Chrome would log the relevant UMA directly and this |
| 4192 | // function could be removed. |
Matt Falkenhagen | 2c98ee29a | 2017-07-20 16:43:19 | [diff] [blame] | 4193 | if (page_load_metrics::IsGoogleSearchResultUrl(url)) |
Matt Falkenhagen | 8479b20 | 2017-07-14 04:35:31 | [diff] [blame] | 4194 | return "search"; |
Matt Falkenhagen | 2c98ee29a | 2017-07-20 16:43:19 | [diff] [blame] | 4195 | if (url.host() == "docs.google.com") |
| 4196 | return "docs"; |
Matt Falkenhagen | 8479b20 | 2017-07-14 04:35:31 | [diff] [blame] | 4197 | return std::string(); |
| 4198 | } |
| 4199 | |
avi | d6d88b91 | 2017-01-13 00:16:00 | [diff] [blame] | 4200 | std::vector<std::unique_ptr<content::NavigationThrottle>> |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 4201 | ChromeContentBrowserClient::CreateThrottlesForNavigation( |
| 4202 | content::NavigationHandle* handle) { |
avi | d6d88b91 | 2017-01-13 00:16:00 | [diff] [blame] | 4203 | std::vector<std::unique_ptr<content::NavigationThrottle>> throttles; |
trizzofo | 8ddaeb7 | 2016-09-01 23:18:27 | [diff] [blame] | 4204 | |
bmcquade | b455655 | 2017-03-24 22:24:37 | [diff] [blame] | 4205 | // MetricsNavigationThrottle requires that it runs before NavigationThrottles |
| 4206 | // that may delay or cancel navigations, so only NavigationThrottles that |
| 4207 | // don't delay or cancel navigations (e.g. throttles that are only observing |
| 4208 | // callbacks without affecting navigation behavior) should be added before |
| 4209 | // MetricsNavigationThrottle. |
| 4210 | if (handle->IsInMainFrame()) { |
| 4211 | throttles.push_back( |
| 4212 | page_load_metrics::MetricsNavigationThrottle::Create(handle)); |
| 4213 | } |
| 4214 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 4215 | #if BUILDFLAG(ENABLE_PLUGINS) |
tommycli | ae590f160 | 2016-11-02 03:59:23 | [diff] [blame] | 4216 | std::unique_ptr<content::NavigationThrottle> flash_url_throttle = |
| 4217 | FlashDownloadInterception::MaybeCreateThrottleFor(handle); |
| 4218 | if (flash_url_throttle) |
| 4219 | throttles.push_back(std::move(flash_url_throttle)); |
trizzofo | 8ddaeb7 | 2016-09-01 23:18:27 | [diff] [blame] | 4220 | #endif |
| 4221 | |
mmenke | db2637ff | 2017-03-30 23:59:42 | [diff] [blame] | 4222 | #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 4223 | std::unique_ptr<content::NavigationThrottle> supervised_user_throttle = |
| 4224 | SupervisedUserNavigationThrottle::MaybeCreateThrottleFor(handle); |
| 4225 | if (supervised_user_throttle) |
| 4226 | throttles.push_back(std::move(supervised_user_throttle)); |
| 4227 | #endif |
| 4228 | |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 4229 | #if defined(OS_ANDROID) |
| 4230 | // TODO(davidben): This is insufficient to integrate with prerender properly. |
| 4231 | // https://crbug.com/370595 |
| 4232 | prerender::PrerenderContents* prerender_contents = |
| 4233 | prerender::PrerenderContents::FromWebContents(handle->GetWebContents()); |
| 4234 | if (!prerender_contents && handle->IsInMainFrame()) { |
| 4235 | throttles.push_back( |
| 4236 | navigation_interception::InterceptNavigationDelegate::CreateThrottleFor( |
Charlie Harrison | 3286ab7 | 2019-02-13 20:13:30 | [diff] [blame] | 4237 | handle, navigation_interception::SynchronyMode::kAsync)); |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 4238 | } |
Min Qin | 0ab0e16 | 2017-11-14 21:57:19 | [diff] [blame] | 4239 | throttles.push_back(InterceptOMADownloadNavigationThrottle::Create(handle)); |
Giovanni Ortuño Urquidi | 7ae7fb0 | 2017-10-09 01:49:57 | [diff] [blame] | 4240 | #elif BUILDFLAG(ENABLE_EXTENSIONS) |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 4241 | if (handle->IsInMainFrame()) { |
| 4242 | // Redirect some navigations to apps that have registered matching URL |
| 4243 | // handlers ('url_handlers' in the manifest). |
Giovanni Ortuño Urquidi | 7ae7fb0 | 2017-10-09 01:49:57 | [diff] [blame] | 4244 | auto url_to_app_throttle = |
| 4245 | PlatformAppNavigationRedirector::MaybeCreateThrottleFor(handle); |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 4246 | if (url_to_app_throttle) |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 4247 | throttles.push_back(std::move(url_to_app_throttle)); |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 4248 | } |
| 4249 | #endif |
clamy | 4967831 | 2015-10-22 21:59:00 | [diff] [blame] | 4250 | |
| 4251 | #if defined(OS_CHROMEOS) |
| 4252 | // Check if we need to add merge session throttle. This throttle will postpone |
| 4253 | // loading of main frames. |
| 4254 | if (handle->IsInMainFrame()) { |
| 4255 | // Add interstitial page while merge session process (cookie reconstruction |
| 4256 | // from OAuth2 refresh token in ChromeOS login) is still in progress while |
| 4257 | // we are attempting to load a google property. |
csharrison | dd06bab | 2016-07-22 14:15:02 | [diff] [blame] | 4258 | if (merge_session_throttling_utils::ShouldAttachNavigationThrottle() && |
| 4259 | !merge_session_throttling_utils::AreAllSessionMergedAlready() && |
clamy | 4967831 | 2015-10-22 21:59:00 | [diff] [blame] | 4260 | handle->GetURL().SchemeIsHTTPOrHTTPS()) { |
| 4261 | throttles.push_back(MergeSessionNavigationThrottle::Create(handle)); |
| 4262 | } |
Maggie Cai | a2f03f5 | 2019-04-02 02:13:28 | [diff] [blame] | 4263 | } |
| 4264 | #endif |
djacobo | 21e56e0 | 2016-07-02 01:14:31 | [diff] [blame] | 4265 | |
Maggie Cai | a2f03f5 | 2019-04-02 02:13:28 | [diff] [blame] | 4266 | #if !defined(OS_ANDROID) |
| 4267 | if (base::FeatureList::IsEnabled(features::kIntentPicker)) { |
Dominick Ng | 7c28994 | 2018-03-27 05:57:15 | [diff] [blame] | 4268 | auto url_to_apps_throttle = |
Maggie Cai | a2f03f5 | 2019-04-02 02:13:28 | [diff] [blame] | 4269 | #if defined(OS_CHROMEOS) |
| 4270 | chromeos::ChromeOsAppsNavigationThrottle::MaybeCreate(handle); |
| 4271 | #else |
| 4272 | apps::AppsNavigationThrottle::MaybeCreate(handle); |
| 4273 | #endif |
Dominick Ng | 7c28994 | 2018-03-27 05:57:15 | [diff] [blame] | 4274 | if (url_to_apps_throttle) |
| 4275 | throttles.push_back(std::move(url_to_apps_throttle)); |
clamy | 4967831 | 2015-10-22 21:59:00 | [diff] [blame] | 4276 | } |
| 4277 | #endif |
| 4278 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 4279 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
avi | d6d88b91 | 2017-01-13 00:16:00 | [diff] [blame] | 4280 | throttles.push_back( |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 4281 | std::make_unique<extensions::ExtensionNavigationThrottle>(handle)); |
Clark DuVall | 2cf99249e | 2018-09-19 19:11:51 | [diff] [blame] | 4282 | |
| 4283 | std::unique_ptr<content::NavigationThrottle> user_script_throttle = |
| 4284 | extensions::ExtensionsBrowserClient::Get() |
| 4285 | ->GetUserScriptListener() |
| 4286 | ->CreateNavigationThrottle(handle); |
| 4287 | if (user_script_throttle) |
| 4288 | throttles.push_back(std::move(user_script_throttle)); |
nasko | b9164c4 | 2016-06-07 01:21:35 | [diff] [blame] | 4289 | #endif |
| 4290 | |
bauerb | 8f9c3774 | 2017-03-30 15:04:12 | [diff] [blame] | 4291 | #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 4292 | std::unique_ptr<content::NavigationThrottle> supervised_user_nav_throttle = |
| 4293 | SupervisedUserGoogleAuthNavigationThrottle::MaybeCreate(handle); |
| 4294 | if (supervised_user_nav_throttle) |
| 4295 | throttles.push_back(std::move(supervised_user_nav_throttle)); |
| 4296 | #endif |
| 4297 | |
csharrison | e985ebc | 2017-04-04 17:05:03 | [diff] [blame] | 4298 | content::WebContents* web_contents = handle->GetWebContents(); |
csharrison | 77bf834 | 2017-05-04 18:23:10 | [diff] [blame] | 4299 | if (auto* subresource_filter_client = |
| 4300 | ChromeSubresourceFilterClient::FromWebContents(web_contents)) { |
| 4301 | subresource_filter_client->MaybeAppendNavigationThrottles(handle, |
| 4302 | &throttles); |
csharrison | e985ebc | 2017-04-04 17:05:03 | [diff] [blame] | 4303 | } |
| 4304 | |
zhenw | 6edd49c | 2017-07-12 05:49:45 | [diff] [blame] | 4305 | #if !defined(OS_ANDROID) |
| 4306 | // BackgroundTabNavigationThrottle is used by TabManager, which is only |
| 4307 | // enabled on non-Android platforms. |
| 4308 | std::unique_ptr<content::NavigationThrottle> |
| 4309 | background_tab_navigation_throttle = resource_coordinator:: |
| 4310 | BackgroundTabNavigationThrottle::MaybeCreateThrottleFor(handle); |
| 4311 | if (background_tab_navigation_throttle) |
| 4312 | throttles.push_back(std::move(background_tab_navigation_throttle)); |
| 4313 | #endif |
| 4314 | |
Michael Thiessen | 4c9e4a8 | 2019-03-08 04:39:44 | [diff] [blame] | 4315 | #if defined(FULL_SAFE_BROWSING) |
Jialiu Lin | bdbb81d | 2017-10-11 21:29:09 | [diff] [blame] | 4316 | std::unique_ptr<content::NavigationThrottle> |
| 4317 | password_protection_navigation_throttle = |
| 4318 | safe_browsing::MaybeCreateNavigationThrottle(handle); |
| 4319 | if (password_protection_navigation_throttle) { |
| 4320 | throttles.push_back(std::move(password_protection_navigation_throttle)); |
| 4321 | } |
| 4322 | #endif |
| 4323 | |
Joe DeBlasio | 6e8409a | 2019-02-20 23:08:27 | [diff] [blame] | 4324 | std::unique_ptr<content::NavigationThrottle> |
Mustafa Emre Acer | e14f626 | 2019-04-02 00:19:31 | [diff] [blame] | 4325 | lookalike_url_navigation_throttle = lookalikes:: |
Joe DeBlasio | 6e8409a | 2019-02-20 23:08:27 | [diff] [blame] | 4326 | LookalikeUrlNavigationThrottle::MaybeCreateNavigationThrottle(handle); |
| 4327 | if (lookalike_url_navigation_throttle) |
| 4328 | throttles.push_back(std::move(lookalike_url_navigation_throttle)); |
Joe DeBlasio | 6e8409a | 2019-02-20 23:08:27 | [diff] [blame] | 4329 | |
Amber Won | f56d8f4 | 2017-08-31 22:29:40 | [diff] [blame] | 4330 | std::unique_ptr<content::NavigationThrottle> pdf_iframe_throttle = |
| 4331 | PDFIFrameNavigationThrottle::MaybeCreateThrottleFor(handle); |
| 4332 | if (pdf_iframe_throttle) |
| 4333 | throttles.push_back(std::move(pdf_iframe_throttle)); |
Amber Won | 6b5edc75 | 2017-08-17 19:23:54 | [diff] [blame] | 4334 | |
Charles Harrison | 6dd11d28 | 2017-10-03 06:14:51 | [diff] [blame] | 4335 | std::unique_ptr<content::NavigationThrottle> tab_under_throttle = |
| 4336 | TabUnderNavigationThrottle::MaybeCreate(handle); |
| 4337 | if (tab_under_throttle) |
| 4338 | throttles.push_back(std::move(tab_under_throttle)); |
| 4339 | |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 4340 | throttles.push_back(std::make_unique<PolicyBlacklistNavigationThrottle>( |
Doug Turner | 9dcaf596 | 2017-12-21 04:38:53 | [diff] [blame] | 4341 | handle, handle->GetWebContents()->GetBrowserContext())); |
| 4342 | |
Carlos IL | 5a9e751 | 2019-06-13 22:35:28 | [diff] [blame] | 4343 | throttles.push_back(std::make_unique<SSLErrorNavigationThrottle>( |
| 4344 | handle, |
| 4345 | std::make_unique<CertificateReportingServiceCertReporter>(web_contents), |
| 4346 | base::Bind(&SSLErrorHandler::HandleSSLError))); |
Lucas Garron | 94b1605 | 2017-11-11 01:58:12 | [diff] [blame] | 4347 | |
Christopher Thompson | 4137cec | 2017-12-19 05:34:23 | [diff] [blame] | 4348 | std::unique_ptr<content::NavigationThrottle> https_upgrade_timing_throttle = |
| 4349 | TypedNavigationTimingThrottle::MaybeCreateThrottleFor(handle); |
| 4350 | if (https_upgrade_timing_throttle) |
| 4351 | throttles.push_back(std::move(https_upgrade_timing_throttle)); |
| 4352 | |
Dmitry Gozman | 57b92ce | 2017-12-28 22:24:54 | [diff] [blame] | 4353 | #if !defined(OS_ANDROID) |
| 4354 | std::unique_ptr<content::NavigationThrottle> devtools_throttle = |
| 4355 | DevToolsWindow::MaybeCreateNavigationThrottle(handle); |
| 4356 | if (devtools_throttle) |
| 4357 | throttles.push_back(std::move(devtools_throttle)); |
Conley Owens | aafcf12 | 2018-02-26 18:53:51 | [diff] [blame] | 4358 | |
| 4359 | std::unique_ptr<content::NavigationThrottle> new_tab_page_throttle = |
| 4360 | NewTabPageNavigationThrottle::MaybeCreateThrottleFor(handle); |
| 4361 | if (new_tab_page_throttle) |
| 4362 | throttles.push_back(std::move(new_tab_page_throttle)); |
jdoerrie | 4f9376f | 2018-12-12 18:26:20 | [diff] [blame] | 4363 | |
| 4364 | std::unique_ptr<content::NavigationThrottle> |
| 4365 | google_password_manager_throttle = |
| 4366 | GooglePasswordManagerNavigationThrottle::MaybeCreateThrottleFor( |
| 4367 | handle); |
| 4368 | if (google_password_manager_throttle) |
| 4369 | throttles.push_back(std::move(google_password_manager_throttle)); |
Dmitry Gozman | 57b92ce | 2017-12-28 22:24:54 | [diff] [blame] | 4370 | #endif |
| 4371 | |
Robert Ogden | afd250b | 2018-07-25 22:21:03 | [diff] [blame] | 4372 | std::unique_ptr<content::NavigationThrottle> previews_lite_page_throttle = |
| 4373 | PreviewsLitePageDecider::MaybeCreateThrottleFor(handle); |
| 4374 | if (previews_lite_page_throttle) |
| 4375 | throttles.push_back(std::move(previews_lite_page_throttle)); |
Carlos IL | 4ee307e | 2018-12-22 03:19:00 | [diff] [blame] | 4376 | if (base::FeatureList::IsEnabled(safe_browsing::kCommittedSBInterstitials)) { |
| 4377 | throttles.push_back( |
| 4378 | std::make_unique<safe_browsing::SafeBrowsingNavigationThrottle>( |
| 4379 | handle)); |
| 4380 | } |
Robert Ogden | afd250b | 2018-07-25 22:21:03 | [diff] [blame] | 4381 | |
Nicolas Ouellet-Payeur | bdcab009 | 2018-10-22 14:50:33 | [diff] [blame] | 4382 | #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 4383 | (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
Nicolas Ouellet-Payeur | 995e777 | 2018-09-13 16:02:13 | [diff] [blame] | 4384 | std::unique_ptr<content::NavigationThrottle> browser_switcher_throttle = |
| 4385 | browser_switcher::BrowserSwitcherNavigationThrottle :: |
| 4386 | MaybeCreateThrottleFor(handle); |
| 4387 | if (browser_switcher_throttle) |
| 4388 | throttles.push_back(std::move(browser_switcher_throttle)); |
| 4389 | #endif |
| 4390 | |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 4391 | return throttles; |
clamy | 40c9e14 | 2015-09-29 11:18:47 | [diff] [blame] | 4392 | } |
| 4393 | |
clamy | 1e5574e | 2016-09-29 16:48:44 | [diff] [blame] | 4394 | std::unique_ptr<content::NavigationUIData> |
| 4395 | ChromeContentBrowserClient::GetNavigationUIData( |
| 4396 | content::NavigationHandle* navigation_handle) { |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 4397 | return std::make_unique<ChromeNavigationUIData>(navigation_handle); |
clamy | 1e5574e | 2016-09-29 16:48:44 | [diff] [blame] | 4398 | } |
| 4399 | |
Xiaohan Wang | a4e4184 | 2018-06-26 18:45:10 | [diff] [blame] | 4400 | void ChromeContentBrowserClient::GetHardwareSecureDecryptionCaps( |
| 4401 | const std::string& key_system, |
| 4402 | const base::flat_set<media::CdmProxy::Protocol>& cdm_proxy_protocols, |
| 4403 | base::flat_set<media::VideoCodec>* video_codecs, |
| 4404 | base::flat_set<media::EncryptionMode>* encryption_schemes) { |
| 4405 | #if defined(OS_WIN) && BUILDFLAG(ENABLE_LIBRARY_CDMS) && \ |
Xiaohan Wang | f170c73 | 2018-09-27 05:45:26 | [diff] [blame] | 4406 | BUILDFLAG(ENABLE_WIDEVINE) |
Xiaohan Wang | a4e4184 | 2018-06-26 18:45:10 | [diff] [blame] | 4407 | if (key_system == kWidevineKeySystem) { |
| 4408 | GetWidevineHardwareCaps(cdm_proxy_protocols, video_codecs, |
| 4409 | encryption_schemes); |
| 4410 | } |
| 4411 | #endif |
| 4412 | } |
| 4413 | |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 4414 | content::DevToolsManagerDelegate* |
| 4415 | ChromeContentBrowserClient::GetDevToolsManagerDelegate() { |
Pavel Feldman | 43f56b7c | 2016-08-30 00:04:35 | [diff] [blame] | 4416 | #if defined(OS_ANDROID) |
| 4417 | return new DevToolsManagerDelegateAndroid(); |
| 4418 | #else |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 4419 | return new ChromeDevToolsManagerDelegate(); |
Pavel Feldman | 43f56b7c | 2016-08-30 00:04:35 | [diff] [blame] | 4420 | #endif |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 4421 | } |
| 4422 | |
Rayan Kanso | 411e84e | 2019-02-13 15:27:40 | [diff] [blame] | 4423 | void ChromeContentBrowserClient::UpdateDevToolsBackgroundServiceExpiration( |
| 4424 | content::BrowserContext* browser_context, |
| 4425 | int service, |
| 4426 | base::Time expiration_time) { |
| 4427 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 4428 | DCHECK(profile); |
| 4429 | |
| 4430 | auto* pref_service = profile->GetPrefs(); |
| 4431 | DCHECK(pref_service); |
| 4432 | |
| 4433 | DictionaryPrefUpdate pref_update( |
| 4434 | pref_service, prefs::kDevToolsBackgroundServicesExpirationDict); |
| 4435 | base::DictionaryValue* exp_dict = pref_update.Get(); |
| 4436 | |
| 4437 | // Convert |expiration_time| to minutes since that is the most granular |
| 4438 | // option that returns an int. base::Value does not accept int64. |
| 4439 | int expiration_time_minutes = |
| 4440 | expiration_time.ToDeltaSinceWindowsEpoch().InMinutes(); |
| 4441 | exp_dict->SetInteger(base::NumberToString(service), expiration_time_minutes); |
| 4442 | } |
| 4443 | |
| 4444 | base::flat_map<int, base::Time> |
| 4445 | ChromeContentBrowserClient::GetDevToolsBackgroundServiceExpirations( |
| 4446 | content::BrowserContext* browser_context) { |
| 4447 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 4448 | DCHECK(profile); |
| 4449 | |
| 4450 | auto* pref_service = profile->GetPrefs(); |
| 4451 | DCHECK(pref_service); |
| 4452 | |
| 4453 | auto* expiration_dict = pref_service->GetDictionary( |
| 4454 | prefs::kDevToolsBackgroundServicesExpirationDict); |
| 4455 | DCHECK(expiration_dict); |
| 4456 | |
| 4457 | base::flat_map<int, base::Time> expiration_times; |
| 4458 | for (const auto& it : *expiration_dict) { |
| 4459 | // key. |
| 4460 | int service = 0; |
| 4461 | bool did_convert = base::StringToInt(it.first, &service); |
| 4462 | DCHECK(did_convert); |
| 4463 | |
| 4464 | // value. |
| 4465 | DCHECK(it.second->is_int()); |
| 4466 | base::TimeDelta delta = base::TimeDelta::FromMinutes(it.second->GetInt()); |
| 4467 | base::Time expiration_time = base::Time::FromDeltaSinceWindowsEpoch(delta); |
| 4468 | |
| 4469 | expiration_times[service] = expiration_time; |
| 4470 | } |
| 4471 | |
| 4472 | return expiration_times; |
| 4473 | } |
| 4474 | |
oysteine | c563c58 | 2015-02-13 19:19:52 | [diff] [blame] | 4475 | content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() { |
oysteine | c563c58 | 2015-02-13 19:19:52 | [diff] [blame] | 4476 | return new ChromeTracingDelegate(); |
oysteine | c563c58 | 2015-02-13 19:19:52 | [diff] [blame] | 4477 | } |
| 4478 | |
[email protected] | a6868c2 | 2013-10-09 02:50:29 | [diff] [blame] | 4479 | bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
| 4480 | content::BrowserContext* browser_context, |
| 4481 | const GURL& url) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 4482 | #if BUILDFLAG(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 4483 | return ChromeContentBrowserClientPluginsPart:: |
| 4484 | IsPluginAllowedToCallRequestOSFileHandle(browser_context, url, |
| 4485 | allowed_file_handle_origins_); |
[email protected] | a6868c2 | 2013-10-09 02:50:29 | [diff] [blame] | 4486 | #else |
| 4487 | return false; |
| 4488 | #endif |
| 4489 | } |
| 4490 | |
[email protected] | aec5ed5 | 2014-06-20 07:51:42 | [diff] [blame] | 4491 | bool ChromeContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs( |
| 4492 | content::BrowserContext* browser_context, |
| 4493 | const GURL& url) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 4494 | #if BUILDFLAG(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
jitendra.ks | 42e889a | 2014-12-05 09:05:55 | [diff] [blame] | 4495 | return ChromeContentBrowserClientPluginsPart:: |
| 4496 | IsPluginAllowedToUseDevChannelAPIs(browser_context, url, |
| 4497 | allowed_dev_channel_origins_); |
[email protected] | 8ddc6b7c | 2013-12-12 20:42:06 | [diff] [blame] | 4498 | #else |
| 4499 | return false; |
| 4500 | #endif |
| 4501 | } |
| 4502 | |
mlamouri | f8c23a200 | 2015-01-27 13:10:10 | [diff] [blame] | 4503 | void ChromeContentBrowserClient::OverridePageVisibilityState( |
xzhan96 | cf0a3c54 | 2017-11-17 04:33:01 | [diff] [blame] | 4504 | RenderFrameHost* render_frame_host, |
danakj | 0018a29a | 2018-12-01 01:03:43 | [diff] [blame] | 4505 | content::PageVisibilityState* visibility_state) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 4506 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
mlamouri | f8c23a200 | 2015-01-27 13:10:10 | [diff] [blame] | 4507 | |
| 4508 | WebContents* web_contents = |
| 4509 | WebContents::FromRenderFrameHost(render_frame_host); |
| 4510 | DCHECK(web_contents); |
| 4511 | |
mlamouri | f8c23a200 | 2015-01-27 13:10:10 | [diff] [blame] | 4512 | prerender::PrerenderManager* prerender_manager = |
droger | c154315 | 2016-09-20 13:03:37 | [diff] [blame] | 4513 | prerender::PrerenderManagerFactory::GetForBrowserContext( |
| 4514 | web_contents->GetBrowserContext()); |
mlamouri | f8c23a200 | 2015-01-27 13:10:10 | [diff] [blame] | 4515 | if (prerender_manager && |
| 4516 | prerender_manager->IsWebContentsPrerendering(web_contents, nullptr)) { |
danakj | 0018a29a | 2018-12-01 01:03:43 | [diff] [blame] | 4517 | *visibility_state = content::PageVisibilityState::kPrerender; |
mlamouri | f8c23a200 | 2015-01-27 13:10:10 | [diff] [blame] | 4518 | } |
| 4519 | } |
| 4520 | |
Andrew Moylan | 8ed9d83c8 | 2019-01-29 20:23:52 | [diff] [blame] | 4521 | // Forward image Annotator requests to the image_annotation service. |
| 4522 | void BindImageAnnotator(image_annotation::mojom::AnnotatorRequest request, |
| 4523 | RenderFrameHost* const frame_host) { |
| 4524 | content::BrowserContext::GetConnectorFor( |
| 4525 | frame_host->GetProcess()->GetBrowserContext()) |
| 4526 | ->BindInterface(image_annotation::mojom::kServiceName, |
| 4527 | std::move(request)); |
| 4528 | } |
| 4529 | |
Sam McNally | faf9a40 | 2017-10-31 03:06:31 | [diff] [blame] | 4530 | void ChromeContentBrowserClient::InitWebContextInterfaces() { |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 4531 | frame_interfaces_ = std::make_unique<service_manager::BinderRegistry>(); |
| 4532 | frame_interfaces_parameterized_ = std::make_unique< |
Ben Goodger | 21ada1e | 2017-07-19 14:53:01 | [diff] [blame] | 4533 | service_manager::BinderRegistryWithArgs<content::RenderFrameHost*>>(); |
Sam McNally | faf9a40 | 2017-10-31 03:06:31 | [diff] [blame] | 4534 | worker_interfaces_parameterized_ = |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 4535 | std::make_unique<service_manager::BinderRegistryWithArgs< |
Sam McNally | faf9a40 | 2017-10-31 03:06:31 | [diff] [blame] | 4536 | content::RenderProcessHost*, const url::Origin&>>(); |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4537 | |
Michael Martis | 4a542f5 | 2017-07-28 01:51:44 | [diff] [blame] | 4538 | // Register mojo ContentTranslateDriver interface only for main frame. |
Anthony Vallee-Dubois | e2432137a | 2019-01-17 20:06:01 | [diff] [blame] | 4539 | frame_interfaces_parameterized_->AddInterface( |
| 4540 | base::BindRepeating(&language::BindContentTranslateDriver)); |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4541 | |
| 4542 | frame_interfaces_parameterized_->AddInterface( |
Eric Lawrence | d0acf2a7c | 2017-07-20 18:02:48 | [diff] [blame] | 4543 | base::Bind(&InsecureSensitiveInputDriverFactory::BindDriver)); |
Andrew Moylan | 8ed9d83c8 | 2019-01-29 20:23:52 | [diff] [blame] | 4544 | frame_interfaces_parameterized_->AddInterface( |
| 4545 | base::BindRepeating(&BindImageAnnotator)); |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4546 | |
| 4547 | #if defined(OS_ANDROID) |
| 4548 | frame_interfaces_parameterized_->AddInterface(base::Bind( |
Matt Giuca | ee4aefb | 2017-08-04 03:11:55 | [diff] [blame] | 4549 | &ForwardToJavaFrameRegistry<blink::mojom::InstalledAppProvider>)); |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4550 | frame_interfaces_parameterized_->AddInterface( |
| 4551 | base::Bind(&ForwardToJavaFrameRegistry<payments::mojom::PaymentRequest>)); |
Kim Paulhamus | 3d33e44 | 2018-03-29 23:04:14 | [diff] [blame] | 4552 | frame_interfaces_parameterized_->AddInterface( |
Amos Lim | dddb699 | 2018-07-19 22:14:32 | [diff] [blame] | 4553 | base::Bind(&ForwardToJavaFrameRegistry<blink::mojom::Authenticator>)); |
Michael Thiessen | 909ba03 | 2019-03-26 23:47:43 | [diff] [blame] | 4554 | #if defined(BROWSER_MEDIA_CONTROLS_MENU) |
| 4555 | frame_interfaces_parameterized_->AddInterface(base::Bind( |
| 4556 | &ForwardToJavaFrameRegistry<blink::mojom::MediaControlsMenuHost>)); |
| 4557 | #endif |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4558 | #else |
| 4559 | if (base::FeatureList::IsEnabled(features::kWebPayments)) { |
| 4560 | frame_interfaces_parameterized_->AddInterface( |
| 4561 | base::Bind(&payments::CreatePaymentRequest)); |
| 4562 | } |
| 4563 | #endif |
| 4564 | |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4565 | #if defined(OS_ANDROID) |
Matt Giuca | 00e99360 | 2017-06-23 05:17:54 | [diff] [blame] | 4566 | frame_interfaces_parameterized_->AddInterface(base::Bind( |
| 4567 | &ForwardToJavaWebContentsRegistry<blink::mojom::ShareService>)); |
Michael Thiessen | 07c444c | 2019-04-26 03:53:11 | [diff] [blame] | 4568 | #if defined(ENABLE_SPATIAL_NAVIGATION_HOST) |
| 4569 | frame_interfaces_parameterized_->AddInterface(base::Bind( |
| 4570 | &ForwardToJavaWebContentsRegistry<blink::mojom::SpatialNavigationHost>)); |
| 4571 | #endif |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4572 | #endif |
Reilly Grant | 8e5c85c | 2017-07-07 16:35:06 | [diff] [blame] | 4573 | |
Jay Harris | 5a42aa21b | 2018-11-28 01:23:55 | [diff] [blame] | 4574 | #if !defined(OS_ANDROID) |
Eric Stevenson | 1d074a97 | 2018-12-07 14:16:45 | [diff] [blame] | 4575 | frame_interfaces_parameterized_->AddInterface( |
Jay Harris | 1ddcffa | 2019-07-09 03:07:40 | [diff] [blame] | 4576 | base::BindRepeating(&badging::BadgeManager::BindRequest)); |
Eric Stevenson | c3b1805 | 2018-10-01 22:22:00 | [diff] [blame] | 4577 | #endif |
| 4578 | |
Reilly Grant | 8e5c85c | 2017-07-07 16:35:06 | [diff] [blame] | 4579 | frame_interfaces_parameterized_->AddInterface( |
Lu Chen | 5bec7a30 | 2018-06-26 18:52:32 | [diff] [blame] | 4580 | base::BindRepeating(&NavigationPredictor::Create)); |
Dan Harrington | bc87c06 | 2018-10-31 15:21:24 | [diff] [blame] | 4581 | |
| 4582 | #if defined(OS_ANDROID) |
| 4583 | frame_interfaces_parameterized_->AddInterface( |
| 4584 | base::BindRepeating(&offline_pages::OfflinePageAutoFetcher::Create), |
| 4585 | base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})); |
| 4586 | #endif |
Ben Goodger | 6a695c01 | 2017-06-20 20:21:20 | [diff] [blame] | 4587 | } |
| 4588 | |
[email protected] | 30335fdf0 | 2014-02-26 19:51:27 | [diff] [blame] | 4589 | void ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch( |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 4590 | base::CommandLine* to_command_line, |
| 4591 | const base::CommandLine& from_command_line, |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 4592 | version_info::Channel channel) { |
[email protected] | 30335fdf0 | 2014-02-26 19:51:27 | [diff] [blame] | 4593 | #if defined(OS_ANDROID) |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 4594 | const version_info::Channel kMaxDisableEncryptionChannel = |
| 4595 | version_info::Channel::BETA; |
[email protected] | 30335fdf0 | 2014-02-26 19:51:27 | [diff] [blame] | 4596 | #else |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 4597 | const version_info::Channel kMaxDisableEncryptionChannel = |
| 4598 | version_info::Channel::DEV; |
[email protected] | 30335fdf0 | 2014-02-26 19:51:27 | [diff] [blame] | 4599 | #endif |
| 4600 | if (channel <= kMaxDisableEncryptionChannel) { |
| 4601 | static const char* const kWebRtcDevSwitchNames[] = { |
| 4602 | switches::kDisableWebRtcEncryption, |
| 4603 | }; |
Avi Drissman | d251e91 | 2018-12-26 15:46:37 | [diff] [blame] | 4604 | to_command_line->CopySwitchesFrom(from_command_line, kWebRtcDevSwitchNames, |
| 4605 | base::size(kWebRtcDevSwitchNames)); |
[email protected] | 30335fdf0 | 2014-02-26 19:51:27 | [diff] [blame] | 4606 | } |
| 4607 | } |
bashi | 93362955 | 2016-10-13 23:32:40 | [diff] [blame] | 4608 | |
miu | 54dca6c | 2016-11-17 10:59:38 | [diff] [blame] | 4609 | #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 4610 | void ChromeContentBrowserClient::CreateMediaRemoter( |
| 4611 | content::RenderFrameHost* render_frame_host, |
| 4612 | media::mojom::RemotingSourcePtr source, |
| 4613 | media::mojom::RemoterRequest request) { |
miu | 54dca6c | 2016-11-17 10:59:38 | [diff] [blame] | 4614 | CastRemotingConnector::CreateMediaRemoter( |
| 4615 | render_frame_host, std::move(source), std::move(request)); |
miu | 54dca6c | 2016-11-17 10:59:38 | [diff] [blame] | 4616 | } |
| 4617 | #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) |
robliao | bf5a32e | 2016-12-09 03:35:46 | [diff] [blame] | 4618 | |
Michael Giuffrida | 6802ffe | 2017-09-29 03:40:25 | [diff] [blame] | 4619 | base::FilePath ChromeContentBrowserClient::GetLoggingFileName( |
| 4620 | const base::CommandLine& command_line) { |
| 4621 | return logging::GetLogFileName(command_line); |
kerrnel | a67fad5 | 2017-06-14 20:18:16 | [diff] [blame] | 4622 | } |
| 4623 | |
John Abd-El-Malek | 8efa11f | 2019-01-06 00:51:53 | [diff] [blame] | 4624 | namespace { |
| 4625 | // TODO(jam): move this to a separate file. |
Clark DuVall | 8512cee6 | 2019-06-26 01:14:21 | [diff] [blame] | 4626 | template <class HandlerRegistry> |
John Abd-El-Malek | 8efa11f | 2019-01-06 00:51:53 | [diff] [blame] | 4627 | class ProtocolHandlerThrottle : public content::URLLoaderThrottle { |
| 4628 | public: |
| 4629 | explicit ProtocolHandlerThrottle( |
Clark DuVall | 8512cee6 | 2019-06-26 01:14:21 | [diff] [blame] | 4630 | const HandlerRegistry& protocol_handler_registry) |
John Abd-El-Malek | 8efa11f | 2019-01-06 00:51:53 | [diff] [blame] | 4631 | : protocol_handler_registry_(protocol_handler_registry) {} |
| 4632 | ~ProtocolHandlerThrottle() override = default; |
| 4633 | |
| 4634 | void WillStartRequest(network::ResourceRequest* request, |
| 4635 | bool* defer) override { |
Robbie McElrath | 16aaed6c | 2019-06-04 00:50:29 | [diff] [blame] | 4636 | TranslateUrl(&request->url); |
John Abd-El-Malek | 8efa11f | 2019-01-06 00:51:53 | [diff] [blame] | 4637 | } |
| 4638 | |
| 4639 | void WillRedirectRequest(net::RedirectInfo* redirect_info, |
| 4640 | const network::ResourceResponseHead& response_head, |
| 4641 | bool* defer, |
| 4642 | std::vector<std::string>* to_be_removed_headers, |
| 4643 | net::HttpRequestHeaders* modified_headers) override { |
Robbie McElrath | 16aaed6c | 2019-06-04 00:50:29 | [diff] [blame] | 4644 | TranslateUrl(&redirect_info->new_url); |
John Abd-El-Malek | 8efa11f | 2019-01-06 00:51:53 | [diff] [blame] | 4645 | } |
| 4646 | |
| 4647 | private: |
Robbie McElrath | 16aaed6c | 2019-06-04 00:50:29 | [diff] [blame] | 4648 | void TranslateUrl(GURL* url) { |
| 4649 | if (!protocol_handler_registry_->IsHandledProtocol(url->scheme())) |
| 4650 | return; |
| 4651 | GURL translated_url = protocol_handler_registry_->Translate(*url); |
| 4652 | if (!translated_url.is_empty()) |
| 4653 | *url = translated_url; |
| 4654 | } |
| 4655 | |
Clark DuVall | 8512cee6 | 2019-06-26 01:14:21 | [diff] [blame] | 4656 | HandlerRegistry protocol_handler_registry_; |
John Abd-El-Malek | 8efa11f | 2019-01-06 00:51:53 | [diff] [blame] | 4657 | }; |
| 4658 | } // namespace |
| 4659 | |
yzshen | efcb7c7 | 2017-06-16 23:12:30 | [diff] [blame] | 4660 | std::vector<std::unique_ptr<content::URLLoaderThrottle>> |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 4661 | ChromeContentBrowserClient::CreateURLLoaderThrottlesOnIO( |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 4662 | const network::ResourceRequest& request, |
| 4663 | content::ResourceContext* resource_context, |
| 4664 | const base::RepeatingCallback<content::WebContents*()>& wc_getter, |
Yuzhu Shen | 9508fc7 | 2018-02-08 23:18:59 | [diff] [blame] | 4665 | content::NavigationUIData* navigation_ui_data, |
| 4666 | int frame_tree_node_id) { |
yzshen | efcb7c7 | 2017-06-16 23:12:30 | [diff] [blame] | 4667 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 4668 | DCHECK(!base::FeatureList::IsEnabled(features::kNavigationLoaderOnUI)); |
yzshen | efcb7c7 | 2017-06-16 23:12:30 | [diff] [blame] | 4669 | |
| 4670 | std::vector<std::unique_ptr<content::URLLoaderThrottle>> result; |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 4671 | |
Vasilii Sukhanov | 0163c514 | 2018-10-10 08:30:03 | [diff] [blame] | 4672 | ProfileIOData* io_data = nullptr; |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 4673 | // Only set |io_data| if needed, as in unit tests |resource_context| is a |
Clark DuVall | 6eee9cb | 2018-10-09 22:08:12 | [diff] [blame] | 4674 | // MockResourceContext and the cast doesn't work. |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 4675 | if (safe_browsing_service_ || |
| 4676 | data_reduction_proxy::params::IsEnabledWithNetworkService()) { |
Vasilii Sukhanov | 0163c514 | 2018-10-10 08:30:03 | [diff] [blame] | 4677 | io_data = ProfileIOData::FromResourceContext(resource_context); |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 4678 | } |
| 4679 | |
rajendrant | 4319407 | 2019-04-15 22:13:43 | [diff] [blame] | 4680 | ChromeNavigationUIData* chrome_navigation_ui_data = |
| 4681 | static_cast<ChromeNavigationUIData*>(navigation_ui_data); |
| 4682 | if (chrome_navigation_ui_data && io_data && |
| 4683 | io_data->data_reduction_proxy_io_data() && |
Clark DuVall | 05faba1 | 2018-10-29 19:34:48 | [diff] [blame] | 4684 | data_reduction_proxy::params::IsEnabledWithNetworkService()) { |
Wojciech Dzierżanowski | 4538080 | 2019-04-29 14:50:32 | [diff] [blame] | 4685 | if (!data_reduction_proxy_throttle_manager_) { |
| 4686 | data_reduction_proxy_throttle_manager_ = std::unique_ptr< |
| 4687 | data_reduction_proxy::DataReductionProxyThrottleManager, |
| 4688 | base::OnTaskRunnerDeleter>( |
| 4689 | new data_reduction_proxy::DataReductionProxyThrottleManager( |
| 4690 | io_data->data_reduction_proxy_io_data(), |
| 4691 | io_data->data_reduction_proxy_io_data()->CreateThrottleConfig()), |
| 4692 | base::OnTaskRunnerDeleter(base::SequencedTaskRunnerHandle::Get())); |
| 4693 | } |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 4694 | net::HttpRequestHeaders headers; |
| 4695 | data_reduction_proxy::DataReductionProxyRequestOptions* request_options = |
| 4696 | io_data->data_reduction_proxy_io_data()->request_options(); |
rajendrant | 4319407 | 2019-04-15 22:13:43 | [diff] [blame] | 4697 | uint64_t page_id = |
| 4698 | base::FeatureList::IsEnabled( |
| 4699 | data_reduction_proxy::features:: |
| 4700 | kDataReductionProxyPopulatePreviewsPageIDToPingback) |
| 4701 | ? chrome_navigation_ui_data->data_reduction_proxy_page_id() |
| 4702 | : request_options->GeneratePageId(); |
| 4703 | request_options->AddPageIDRequestHeader(&headers, page_id); |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 4704 | result.push_back(std::make_unique< |
| 4705 | data_reduction_proxy::DataReductionProxyURLLoaderThrottle>( |
Wojciech Dzierżanowski | 4538080 | 2019-04-29 14:50:32 | [diff] [blame] | 4706 | headers, data_reduction_proxy_throttle_manager_.get())); |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 4707 | } |
Vasilii Sukhanov | 0163c514 | 2018-10-10 08:30:03 | [diff] [blame] | 4708 | |
| 4709 | #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
Clark DuVall | 9233584 | 2018-10-10 16:49:09 | [diff] [blame] | 4710 | if (io_data && safe_browsing_service_) { |
John Abd-El-Malek | 9fb6049 | 2018-08-02 04:28:50 | [diff] [blame] | 4711 | bool matches_enterprise_whitelist = safe_browsing::IsURLWhitelistedByPolicy( |
| 4712 | request.url, io_data->safe_browsing_whitelist_domains()); |
John Abd-El-Malek | 7577f26 | 2019-06-10 21:23:23 | [diff] [blame] | 4713 | if (!matches_enterprise_whitelist) { |
John Abd-El-Malek | 39d5daaa | 2018-04-02 21:31:41 | [diff] [blame] | 4714 | auto* delegate = GetSafeBrowsingUrlCheckerDelegate(resource_context); |
| 4715 | if (delegate && !delegate->ShouldSkipRequestCheck( |
| 4716 | resource_context, request.url, frame_tree_node_id, |
| 4717 | -1 /* render_process_id */, -1 /* render_frame_id */, |
| 4718 | request.originated_from_service_worker)) { |
| 4719 | auto safe_browsing_throttle = |
| 4720 | safe_browsing::BrowserURLLoaderThrottle::MaybeCreate(delegate, |
| 4721 | wc_getter); |
| 4722 | if (safe_browsing_throttle) |
| 4723 | result.push_back(std::move(safe_browsing_throttle)); |
| 4724 | } |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 4725 | } |
| 4726 | } |
| 4727 | #endif // defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 4728 | |
Egor Pasko | 0f4403e | 2019-01-24 17:42:20 | [diff] [blame] | 4729 | if (chrome_navigation_ui_data && |
| 4730 | chrome_navigation_ui_data->prerender_mode() != prerender::NO_PRERENDER) { |
| 4731 | result.push_back(std::make_unique<prerender::PrerenderURLLoaderThrottle>( |
| 4732 | chrome_navigation_ui_data->prerender_mode(), |
| 4733 | chrome_navigation_ui_data->prerender_histogram_prefix(), |
| 4734 | base::BindOnce(GetPrerenderCanceller, wc_getter), |
| 4735 | base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI}))); |
John Abd-El-Malek | 9fb6049 | 2018-08-02 04:28:50 | [diff] [blame] | 4736 | } |
Jun Cai | 605ff0e7 | 2018-06-12 22:29:20 | [diff] [blame] | 4737 | |
John Abd-El-Malek | 9fb6049 | 2018-08-02 04:28:50 | [diff] [blame] | 4738 | if (io_data) { |
Jun Cai | 605ff0e7 | 2018-06-12 22:29:20 | [diff] [blame] | 4739 | bool is_off_the_record = io_data->IsOffTheRecord(); |
| 4740 | bool is_signed_in = |
| 4741 | !is_off_the_record && |
| 4742 | !io_data->google_services_account_id()->GetValue().empty(); |
| 4743 | |
Chris Mumford | 809d8fb | 2018-11-10 12:26:11 | [diff] [blame] | 4744 | chrome::mojom::DynamicParams dynamic_params = { |
| 4745 | io_data->force_google_safesearch()->GetValue(), |
John Abd-El-Malek | 9fb6049 | 2018-08-02 04:28:50 | [diff] [blame] | 4746 | io_data->force_youtube_restrict()->GetValue(), |
Chris Mumford | 809d8fb | 2018-11-10 12:26:11 | [diff] [blame] | 4747 | io_data->allowed_domains_for_apps()->GetValue(), |
| 4748 | variations::VariationsHttpHeaderProvider::GetInstance() |
| 4749 | ->GetClientDataHeader(is_signed_in)}; |
| 4750 | result.push_back(std::make_unique<GoogleURLLoaderThrottle>( |
| 4751 | is_off_the_record, std::move(dynamic_params))); |
John Abd-El-Malek | 8efa11f | 2019-01-06 00:51:53 | [diff] [blame] | 4752 | |
Clark DuVall | 8512cee6 | 2019-06-26 01:14:21 | [diff] [blame] | 4753 | result.push_back( |
| 4754 | std::make_unique<ProtocolHandlerThrottle< |
| 4755 | scoped_refptr<ProtocolHandlerRegistry::IOThreadDelegate>>>( |
| 4756 | io_data->protocol_handler_registry_io_thread_delegate())); |
John Abd-El-Malek | d237798 | 2018-01-08 22:23:12 | [diff] [blame] | 4757 | } |
| 4758 | |
John Abd-El-Malek | ecc6f5f | 2018-03-02 18:47:39 | [diff] [blame] | 4759 | #if BUILDFLAG(ENABLE_PLUGINS) |
Matt Falkenhagen | e75bdd45 | 2019-04-03 07:41:52 | [diff] [blame] | 4760 | result.push_back(std::make_unique<PluginResponseInterceptorURLLoaderThrottle>( |
| 4761 | resource_context, request.resource_type, frame_tree_node_id)); |
John Abd-El-Malek | ecc6f5f | 2018-03-02 18:47:39 | [diff] [blame] | 4762 | #endif |
Reilly Grant | 3787780 | 2018-08-18 00:58:35 | [diff] [blame] | 4763 | |
John Abd-El-Malek | 7577f26 | 2019-06-10 21:23:23 | [diff] [blame] | 4764 | auto delegate = std::make_unique<signin::HeaderModificationDelegateImpl>( |
| 4765 | resource_context); |
| 4766 | auto signin_throttle = signin::URLLoaderThrottle::MaybeCreate( |
| 4767 | std::move(delegate), navigation_ui_data, wc_getter); |
| 4768 | if (signin_throttle) |
| 4769 | result.push_back(std::move(signin_throttle)); |
| 4770 | |
yzshen | efcb7c7 | 2017-06-16 23:12:30 | [diff] [blame] | 4771 | return result; |
| 4772 | } |
| 4773 | |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 4774 | std::vector<std::unique_ptr<content::URLLoaderThrottle>> |
| 4775 | ChromeContentBrowserClient::CreateURLLoaderThrottles( |
| 4776 | const network::ResourceRequest& request, |
| 4777 | content::BrowserContext* browser_context, |
| 4778 | const base::RepeatingCallback<content::WebContents*()>& wc_getter, |
| 4779 | content::NavigationUIData* navigation_ui_data, |
| 4780 | int frame_tree_node_id) { |
| 4781 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 4782 | |
| 4783 | std::vector<std::unique_ptr<content::URLLoaderThrottle>> result; |
| 4784 | |
| 4785 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 4786 | |
| 4787 | ChromeNavigationUIData* chrome_navigation_ui_data = |
| 4788 | static_cast<ChromeNavigationUIData*>(navigation_ui_data); |
| 4789 | |
Clark DuVall | 68eb997f | 2019-06-28 05:42:28 | [diff] [blame] | 4790 | auto* drp_settings = |
| 4791 | DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 4792 | browser_context); |
| 4793 | if (chrome_navigation_ui_data && !profile->IsIncognitoProfile() && |
| 4794 | data_reduction_proxy::params::IsEnabledWithNetworkService() && |
| 4795 | drp_settings) { |
| 4796 | if (!data_reduction_proxy_throttle_manager_) { |
| 4797 | data_reduction_proxy_throttle_manager_ = std::unique_ptr< |
| 4798 | data_reduction_proxy::DataReductionProxyThrottleManager, |
| 4799 | base::OnTaskRunnerDeleter>( |
| 4800 | new data_reduction_proxy::DataReductionProxyThrottleManager( |
| 4801 | drp_settings->data_reduction_proxy_service(), |
| 4802 | data_reduction_proxy::DataReductionProxyThrottleManager:: |
| 4803 | CreateConfig(drp_settings->proxies_for_http())), |
| 4804 | base::OnTaskRunnerDeleter(base::SequencedTaskRunnerHandle::Get())); |
| 4805 | } |
| 4806 | net::HttpRequestHeaders headers; |
| 4807 | data_reduction_proxy::DataReductionProxyRequestOptions:: |
| 4808 | AddPageIDRequestHeader( |
| 4809 | &headers, |
| 4810 | chrome_navigation_ui_data->data_reduction_proxy_page_id()); |
| 4811 | result.push_back(std::make_unique< |
| 4812 | data_reduction_proxy::DataReductionProxyURLLoaderThrottle>( |
| 4813 | headers, data_reduction_proxy_throttle_manager_.get())); |
| 4814 | } |
| 4815 | |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 4816 | if (chrome_navigation_ui_data && |
| 4817 | chrome_navigation_ui_data->prerender_mode() != prerender::NO_PRERENDER) { |
| 4818 | result.push_back(std::make_unique<prerender::PrerenderURLLoaderThrottle>( |
| 4819 | chrome_navigation_ui_data->prerender_mode(), |
| 4820 | chrome_navigation_ui_data->prerender_histogram_prefix(), |
| 4821 | base::BindOnce(GetPrerenderCanceller, wc_getter), |
| 4822 | base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI}))); |
| 4823 | } |
| 4824 | |
| 4825 | bool is_off_the_record = profile->IsOffTheRecord(); |
| 4826 | bool is_signed_in = !is_off_the_record && |
| 4827 | !profile->GetPrefs() |
| 4828 | ->GetString(prefs::kGoogleServicesUserAccountId) |
| 4829 | .empty(); |
| 4830 | |
| 4831 | chrome::mojom::DynamicParams dynamic_params = { |
| 4832 | profile->GetPrefs()->GetBoolean(prefs::kForceGoogleSafeSearch), |
| 4833 | profile->GetPrefs()->GetInteger(prefs::kForceYouTubeRestrict), |
| 4834 | profile->GetPrefs()->GetString(prefs::kAllowedDomainsForApps), |
| 4835 | variations::VariationsHttpHeaderProvider::GetInstance() |
| 4836 | ->GetClientDataHeader(is_signed_in)}; |
| 4837 | result.push_back(std::make_unique<GoogleURLLoaderThrottle>( |
| 4838 | is_off_the_record, std::move(dynamic_params))); |
| 4839 | |
Clark DuVall | 8512cee6 | 2019-06-26 01:14:21 | [diff] [blame] | 4840 | result.push_back( |
| 4841 | std::make_unique<ProtocolHandlerThrottle<ProtocolHandlerRegistry*>>( |
| 4842 | ProtocolHandlerRegistryFactory::GetForBrowserContext( |
| 4843 | browser_context))); |
| 4844 | |
Clark DuVall | 39c2cfc | 2019-06-25 21:49:28 | [diff] [blame] | 4845 | #if BUILDFLAG(ENABLE_PLUGINS) |
| 4846 | result.push_back(std::make_unique<PluginResponseInterceptorURLLoaderThrottle>( |
| 4847 | browser_context, request.resource_type, frame_tree_node_id)); |
| 4848 | #endif |
| 4849 | |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 4850 | return result; |
| 4851 | } |
| 4852 | |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4853 | void ChromeContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories( |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 4854 | int frame_tree_node_id, |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4855 | NonNetworkURLLoaderFactoryMap* factories) { |
Robbie McElrath | 6a45ea6 | 2018-12-05 06:53:41 | [diff] [blame] | 4856 | #if BUILDFLAG(ENABLE_EXTENSIONS) || defined(OS_CHROMEOS) |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 4857 | content::WebContents* web_contents = |
| 4858 | content::WebContents::FromFrameTreeNodeId(frame_tree_node_id); |
Robbie McElrath | 6a45ea6 | 2018-12-05 06:53:41 | [diff] [blame] | 4859 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4860 | factories->emplace( |
| 4861 | extensions::kExtensionScheme, |
Chris Mumford | 8f81266 | 2018-02-22 00:27:57 | [diff] [blame] | 4862 | extensions::CreateExtensionNavigationURLLoaderFactory( |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 4863 | web_contents->GetBrowserContext(), |
| 4864 | !!extensions::WebViewGuest::FromWebContents(web_contents))); |
Robbie McElrath | 6a45ea6 | 2018-12-05 06:53:41 | [diff] [blame] | 4865 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 4866 | #if defined(OS_CHROMEOS) |
| 4867 | Profile* profile = |
| 4868 | Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
Robbie McElrath | 89cc933 | 2019-03-05 02:12:30 | [diff] [blame] | 4869 | factories->emplace(content::kExternalFileScheme, |
| 4870 | std::make_unique<chromeos::ExternalFileURLLoaderFactory>( |
| 4871 | profile, content::ChildProcessHost::kInvalidUniqueID)); |
Robbie McElrath | 6a45ea6 | 2018-12-05 06:53:41 | [diff] [blame] | 4872 | #endif // defined(OS_CHROMEOS) |
| 4873 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) || defined(OS_CHROMEOS) |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4874 | } |
| 4875 | |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 4876 | namespace { |
| 4877 | |
| 4878 | // The FileURLLoaderFactory provided to the extension background pages. |
| 4879 | // Checks with the ChildProcessSecurityPolicy to validate the file access. |
| 4880 | class FileURLLoaderFactory : public network::mojom::URLLoaderFactory { |
| 4881 | public: |
| 4882 | explicit FileURLLoaderFactory(int child_id) : child_id_(child_id) {} |
| 4883 | |
| 4884 | private: |
| 4885 | // network::mojom::URLLoaderFactory: |
| 4886 | void CreateLoaderAndStart(network::mojom::URLLoaderRequest loader, |
| 4887 | int32_t routing_id, |
| 4888 | int32_t request_id, |
| 4889 | uint32_t options, |
| 4890 | const network::ResourceRequest& request, |
| 4891 | network::mojom::URLLoaderClientPtr client, |
| 4892 | const net::MutableNetworkTrafficAnnotationTag& |
| 4893 | traffic_annotation) override { |
| 4894 | if (!content::ChildProcessSecurityPolicy::GetInstance()->CanRequestURL( |
| 4895 | child_id_, request.url)) { |
| 4896 | client->OnComplete( |
| 4897 | network::URLLoaderCompletionStatus(net::ERR_ACCESS_DENIED)); |
| 4898 | return; |
| 4899 | } |
| 4900 | content::CreateFileURLLoader(request, std::move(loader), std::move(client), |
John Abd-El-Malek | 916f2b8 | 2019-02-19 23:49:45 | [diff] [blame] | 4901 | /*observer=*/nullptr, |
| 4902 | /* allow_directory_listing */ true); |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 4903 | } |
| 4904 | |
| 4905 | void Clone(network::mojom::URLLoaderFactoryRequest loader) override { |
| 4906 | bindings_.AddBinding(this, std::move(loader)); |
| 4907 | } |
| 4908 | |
| 4909 | int child_id_; |
| 4910 | mojo::BindingSet<network::mojom::URLLoaderFactory> bindings_; |
| 4911 | DISALLOW_COPY_AND_ASSIGN(FileURLLoaderFactory); |
| 4912 | }; |
| 4913 | |
| 4914 | } // namespace |
| 4915 | |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4916 | void ChromeContentBrowserClient:: |
| 4917 | RegisterNonNetworkSubresourceURLLoaderFactories( |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 4918 | int render_process_id, |
| 4919 | int render_frame_id, |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4920 | NonNetworkURLLoaderFactoryMap* factories) { |
Robbie McElrath | 6a45ea6 | 2018-12-05 06:53:41 | [diff] [blame] | 4921 | #if defined(OS_CHROMEOS) || BUILDFLAG(ENABLE_EXTENSIONS) |
| 4922 | content::RenderFrameHost* frame_host = |
| 4923 | RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 4924 | WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); |
| 4925 | #endif // defined(OS_CHROMEOS) || BUILDFLAG(ENABLE_EXTENSIONS) |
| 4926 | |
| 4927 | #if defined(OS_CHROMEOS) |
| 4928 | if (web_contents) { |
| 4929 | Profile* profile = |
| 4930 | Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
Robbie McElrath | 89cc933 | 2019-03-05 02:12:30 | [diff] [blame] | 4931 | factories->emplace(content::kExternalFileScheme, |
| 4932 | std::make_unique<chromeos::ExternalFileURLLoaderFactory>( |
| 4933 | profile, render_process_id)); |
Robbie McElrath | 6a45ea6 | 2018-12-05 06:53:41 | [diff] [blame] | 4934 | } |
| 4935 | #endif // defined(OS_CHROMEOS) |
| 4936 | |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4937 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 4938 | auto factory = extensions::CreateExtensionURLLoaderFactory(render_process_id, |
| 4939 | render_frame_id); |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 4940 | if (factory) |
| 4941 | factories->emplace(extensions::kExtensionScheme, std::move(factory)); |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4942 | |
| 4943 | // This logic should match |
| 4944 | // ChromeExtensionWebContentsObserver::RenderFrameCreated. |
Jay Civelli | c9bbf72d | 2018-03-24 01:58:31 | [diff] [blame] | 4945 | if (!web_contents) |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4946 | return; |
Jay Civelli | c9bbf72d | 2018-03-24 01:58:31 | [diff] [blame] | 4947 | |
| 4948 | Profile* profile = |
| 4949 | Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 4950 | InstantService* instant_service = |
| 4951 | InstantServiceFactory::GetForProfile(profile); |
| 4952 | // The test below matches what's done by ShouldServiceRequestIOThread in |
| 4953 | // local_ntp_source.cc. |
John Abd-El-Malek | ea00630 | 2018-05-10 05:50:46 | [diff] [blame] | 4954 | if (instant_service->IsInstantProcess(render_process_id)) { |
Jay Civelli | c9bbf72d | 2018-03-24 01:58:31 | [diff] [blame] | 4955 | factories->emplace( |
| 4956 | chrome::kChromeSearchScheme, |
| 4957 | content::CreateWebUIURLLoader( |
| 4958 | frame_host, chrome::kChromeSearchScheme, |
| 4959 | /*allowed_webui_hosts=*/base::flat_set<std::string>())); |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4960 | } |
Jay Civelli | c9bbf72d | 2018-03-24 01:58:31 | [diff] [blame] | 4961 | |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4962 | extensions::ChromeExtensionWebContentsObserver* web_observer = |
| 4963 | extensions::ChromeExtensionWebContentsObserver::FromWebContents( |
| 4964 | web_contents); |
| 4965 | |
Karan Bhatia | 9192857 | 2018-03-06 01:18:07 | [diff] [blame] | 4966 | // There is nothing to do if no ChromeExtensionWebContentsObserver is attached |
| 4967 | // to the |web_contents|. |
| 4968 | if (!web_observer) |
| 4969 | return; |
| 4970 | |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4971 | const Extension* extension = |
| 4972 | web_observer->GetExtensionFromFrame(frame_host, false); |
| 4973 | if (!extension) |
| 4974 | return; |
| 4975 | |
Sam McNally | 7414eeb7 | 2018-09-03 04:05:30 | [diff] [blame] | 4976 | std::vector<std::string> allowed_webui_hosts; |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4977 | // Support for chrome:// scheme if appropriate. |
| 4978 | if ((extension->is_extension() || extension->is_platform_app()) && |
| 4979 | Manifest::IsComponentLocation(extension->location())) { |
| 4980 | // Components of chrome that are implemented as extensions or platform apps |
| 4981 | // are allowed to use chrome://resources/ and chrome://theme/ URLs. |
Sam McNally | 7414eeb7 | 2018-09-03 04:05:30 | [diff] [blame] | 4982 | allowed_webui_hosts.emplace_back(content::kChromeUIResourcesHost); |
| 4983 | allowed_webui_hosts.emplace_back(chrome::kChromeUIThemeHost); |
| 4984 | } |
| 4985 | if (extension->is_extension() || extension->is_legacy_packaged_app() || |
| 4986 | (extension->is_platform_app() && |
| 4987 | Manifest::IsComponentLocation(extension->location()))) { |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4988 | // Extensions, legacy packaged apps, and component platform apps are allowed |
Lucas Tenório | 3dd8092 | 2019-03-27 03:51:02 | [diff] [blame] | 4989 | // to use chrome://favicon/, chrome://extension-icon/ and chrome://app-icon |
| 4990 | // URLs. Hosted apps are not allowed because they are served via web servers |
| 4991 | // (and are generally never given access to Chrome APIs). |
Sam McNally | 7414eeb7 | 2018-09-03 04:05:30 | [diff] [blame] | 4992 | allowed_webui_hosts.emplace_back(chrome::kChromeUIExtensionIconHost); |
| 4993 | allowed_webui_hosts.emplace_back(chrome::kChromeUIFaviconHost); |
Lucas Tenório | 3dd8092 | 2019-03-27 03:51:02 | [diff] [blame] | 4994 | allowed_webui_hosts.emplace_back(chrome::kChromeUIAppIconHost); |
Sam McNally | 7414eeb7 | 2018-09-03 04:05:30 | [diff] [blame] | 4995 | } |
| 4996 | if (!allowed_webui_hosts.empty()) { |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 4997 | factories->emplace( |
| 4998 | content::kChromeUIScheme, |
| 4999 | content::CreateWebUIURLLoader(frame_host, content::kChromeUIScheme, |
| 5000 | std::move(allowed_webui_hosts))); |
| 5001 | } |
Jay Civelli | 2578ebe | 2018-06-05 18:44:31 | [diff] [blame] | 5002 | |
| 5003 | // Extension with a background page get file access that gets approval from |
| 5004 | // ChildProcessSecurityPolicy. |
| 5005 | extensions::ExtensionHost* host = |
| 5006 | extensions::ProcessManager::Get(web_contents->GetBrowserContext()) |
| 5007 | ->GetBackgroundHostForExtension(extension->id()); |
| 5008 | if (host) { |
| 5009 | factories->emplace(url::kFileScheme, std::make_unique<FileURLLoaderFactory>( |
| 5010 | render_process_id)); |
| 5011 | } |
Chris Mumford | bae8a74 | 2018-03-01 23:02:23 | [diff] [blame] | 5012 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
Ken Rockot | 6414c4d9 | 2017-11-08 19:58:32 | [diff] [blame] | 5013 | } |
| 5014 | |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5015 | bool ChromeContentBrowserClient::WillCreateURLLoaderFactory( |
Ken Rockot | 428b1d6 | 2018-06-06 17:12:21 | [diff] [blame] | 5016 | content::BrowserContext* browser_context, |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5017 | content::RenderFrameHost* frame, |
Kenichi Ishibashi | 09ee5e7 | 2018-11-27 07:12:38 | [diff] [blame] | 5018 | int render_process_id, |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5019 | bool is_navigation, |
Ken Rockot | 1726e18 | 2019-02-28 09:48:56 | [diff] [blame] | 5020 | bool is_download, |
Lukasz Anforowicz | 76273365 | 2018-09-28 14:48:26 | [diff] [blame] | 5021 | const url::Origin& request_initiator, |
Clark DuVall | 8dc4e50 | 2018-09-07 01:51:12 | [diff] [blame] | 5022 | network::mojom::URLLoaderFactoryRequest* factory_request, |
Clark DuVall | a5e25b75 | 2018-11-27 22:08:16 | [diff] [blame] | 5023 | network::mojom::TrustedURLLoaderHeaderClientPtrInfo* header_client, |
Clark DuVall | 8dc4e50 | 2018-09-07 01:51:12 | [diff] [blame] | 5024 | bool* bypass_redirect_checks) { |
Reilly Grant | 24bf833 | 2018-08-27 21:55:01 | [diff] [blame] | 5025 | bool use_proxy = false; |
| 5026 | |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5027 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5028 | auto* web_request_api = |
| 5029 | extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get( |
Ken Rockot | 428b1d6 | 2018-06-06 17:12:21 | [diff] [blame] | 5030 | browser_context); |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5031 | |
| 5032 | // NOTE: Some unit test environments do not initialize |
| 5033 | // BrowserContextKeyedAPI factories for e.g. WebRequest. |
Reilly Grant | 24bf833 | 2018-08-27 21:55:01 | [diff] [blame] | 5034 | if (web_request_api) { |
Clark DuVall | 8dc4e50 | 2018-09-07 01:51:12 | [diff] [blame] | 5035 | bool use_proxy_for_web_request = |
Kenichi Ishibashi | 09ee5e7 | 2018-11-27 07:12:38 | [diff] [blame] | 5036 | web_request_api->MaybeProxyURLLoaderFactory( |
| 5037 | browser_context, frame, render_process_id, is_navigation, |
Ken Rockot | 1726e18 | 2019-02-28 09:48:56 | [diff] [blame] | 5038 | is_download, factory_request, header_client); |
Clark DuVall | 8dc4e50 | 2018-09-07 01:51:12 | [diff] [blame] | 5039 | if (bypass_redirect_checks) |
| 5040 | *bypass_redirect_checks = use_proxy_for_web_request; |
| 5041 | use_proxy |= use_proxy_for_web_request; |
Reilly Grant | 24bf833 | 2018-08-27 21:55:01 | [diff] [blame] | 5042 | } |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5043 | #endif |
Reilly Grant | 24bf833 | 2018-08-27 21:55:01 | [diff] [blame] | 5044 | |
Reilly Grant | cc22e60 | 2018-09-07 15:25:20 | [diff] [blame] | 5045 | use_proxy |= signin::ProxyingURLLoaderFactory::MaybeProxyRequest( |
Lukasz Anforowicz | 76273365 | 2018-09-28 14:48:26 | [diff] [blame] | 5046 | frame, is_navigation, request_initiator, factory_request); |
Reilly Grant | 24bf833 | 2018-08-27 21:55:01 | [diff] [blame] | 5047 | |
| 5048 | return use_proxy; |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5049 | } |
| 5050 | |
Jian Li | de7b4379 | 2018-06-01 23:22:13 | [diff] [blame] | 5051 | std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>> |
| 5052 | ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( |
| 5053 | content::NavigationUIData* navigation_ui_data, |
Ryan Sturm | 27d93f41 | 2019-02-15 21:30:14 | [diff] [blame] | 5054 | int frame_tree_node_id, |
| 5055 | const scoped_refptr<network::SharedURLLoaderFactory>& |
| 5056 | network_loader_factory) { |
Jian Li | de7b4379 | 2018-06-01 23:22:13 | [diff] [blame] | 5057 | std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>> |
| 5058 | interceptors; |
| 5059 | #if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
John Abd-El-Malek | 7577f26 | 2019-06-10 21:23:23 | [diff] [blame] | 5060 | interceptors.push_back( |
| 5061 | std::make_unique<offline_pages::OfflinePageURLLoaderRequestInterceptor>( |
| 5062 | navigation_ui_data, frame_tree_node_id)); |
Jian Li | de7b4379 | 2018-06-01 23:22:13 | [diff] [blame] | 5063 | #endif |
Ryan Sturm | af52374 | 2019-01-16 00:15:45 | [diff] [blame] | 5064 | |
Robert Ogden | 3d5d5b4 | 2019-04-22 05:13:11 | [diff] [blame] | 5065 | ChromeNavigationUIData* chrome_navigation_ui_data = |
| 5066 | static_cast<ChromeNavigationUIData*>(navigation_ui_data); |
| 5067 | |
Ryan Sturm | 27d93f41 | 2019-02-15 21:30:14 | [diff] [blame] | 5068 | // TODO(ryansturm): Once this is on the UI thread, stop passing |
| 5069 | // |network_loader_factory| and have interceptors create one themselves. |
| 5070 | // https://crbug.com/931786 |
John Abd-El-Malek | 7577f26 | 2019-06-10 21:23:23 | [diff] [blame] | 5071 | if (base::FeatureList::IsEnabled( |
Ryan Sturm | af52374 | 2019-01-16 00:15:45 | [diff] [blame] | 5072 | previews::features::kHTTPSServerPreviewsUsingURLLoader)) { |
| 5073 | interceptors.push_back( |
| 5074 | std::make_unique<previews::PreviewsLitePageURLLoaderInterceptor>( |
Robert Ogden | 3d5d5b4 | 2019-04-22 05:13:11 | [diff] [blame] | 5075 | network_loader_factory, |
| 5076 | chrome_navigation_ui_data->data_reduction_proxy_page_id(), |
| 5077 | frame_tree_node_id)); |
Ryan Sturm | af52374 | 2019-01-16 00:15:45 | [diff] [blame] | 5078 | } |
| 5079 | |
Jian Li | de7b4379 | 2018-06-01 23:22:13 | [diff] [blame] | 5080 | return interceptors; |
| 5081 | } |
| 5082 | |
Yutaka Hirano | 8e0b4d43 | 2019-07-04 07:12:38 | [diff] [blame] | 5083 | bool ChromeContentBrowserClient::WillInterceptWebSocket( |
| 5084 | content::RenderFrameHost* frame) { |
Yutaka Hirano | 36c9495 | 2018-05-30 21:33:33 | [diff] [blame] | 5085 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Yutaka Hirano | 8e0b4d43 | 2019-07-04 07:12:38 | [diff] [blame] | 5086 | if (!frame) { |
| 5087 | return false; |
| 5088 | } |
| 5089 | const auto* web_request_api = |
Yutaka Hirano | 36c9495 | 2018-05-30 21:33:33 | [diff] [blame] | 5090 | extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get( |
| 5091 | frame->GetProcess()->GetBrowserContext()); |
| 5092 | |
| 5093 | // NOTE: Some unit test environments do not initialize |
| 5094 | // BrowserContextKeyedAPI factories for e.g. WebRequest. |
| 5095 | if (!web_request_api) |
Yutaka Hirano | 8e0b4d43 | 2019-07-04 07:12:38 | [diff] [blame] | 5096 | return false; |
Yutaka Hirano | 36c9495 | 2018-05-30 21:33:33 | [diff] [blame] | 5097 | |
Yutaka Hirano | 8e0b4d43 | 2019-07-04 07:12:38 | [diff] [blame] | 5098 | return web_request_api->MayHaveProxies(); |
| 5099 | #else |
| 5100 | return false; |
| 5101 | #endif |
| 5102 | } |
| 5103 | |
| 5104 | void ChromeContentBrowserClient::CreateWebSocket( |
| 5105 | content::RenderFrameHost* frame, |
| 5106 | WebSocketFactory factory, |
| 5107 | const GURL& url, |
| 5108 | const GURL& site_for_cookies, |
| 5109 | const base::Optional<std::string>& user_agent, |
| 5110 | network::mojom::WebSocketHandshakeClientPtr handshake_client) { |
| 5111 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5112 | if (!frame) { |
| 5113 | return; |
| 5114 | } |
| 5115 | auto* web_request_api = |
| 5116 | extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get( |
| 5117 | frame->GetProcess()->GetBrowserContext()); |
| 5118 | |
| 5119 | DCHECK(web_request_api); |
| 5120 | web_request_api->ProxyWebSocket(frame, std::move(factory), url, |
| 5121 | site_for_cookies, user_agent, |
| 5122 | std::move(handshake_client)); |
Yutaka Hirano | 36c9495 | 2018-05-30 21:33:33 | [diff] [blame] | 5123 | #endif |
| 5124 | } |
| 5125 | |
Maks Orlovich | 710d5e3 | 2019-07-09 20:16:45 | [diff] [blame] | 5126 | bool ChromeContentBrowserClient::WillCreateRestrictedCookieManager( |
| 5127 | content::BrowserContext* browser_context, |
| 5128 | const url::Origin& origin, |
| 5129 | bool is_service_worker, |
| 5130 | int process_id, |
| 5131 | int routing_id, |
| 5132 | network::mojom::RestrictedCookieManagerRequest* request) { |
| 5133 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 5134 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5135 | if (origin.scheme() == extensions::kExtensionScheme) { |
| 5136 | extensions::ChromeExtensionCookies::Get(browser_context) |
| 5137 | ->CreateRestrictedCookieManager(origin, std::move(*request)); |
| 5138 | return true; |
| 5139 | } |
| 5140 | #endif |
| 5141 | return false; |
| 5142 | } |
| 5143 | |
Matt Menke | ae4fdb1 | 2018-06-02 06:32:54 | [diff] [blame] | 5144 | void ChromeContentBrowserClient::OnNetworkServiceCreated( |
| 5145 | network::mojom::NetworkService* network_service) { |
Henrique Nakashima | 8941aad | 2018-11-29 23:01:53 | [diff] [blame] | 5146 | PrefService* local_state; |
| 5147 | if (g_browser_process) { |
| 5148 | DCHECK(g_browser_process->local_state()); |
| 5149 | local_state = g_browser_process->local_state(); |
| 5150 | } else { |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 5151 | DCHECK(startup_data_->chrome_feature_list_creator()->local_state()); |
| 5152 | local_state = startup_data_->chrome_feature_list_creator()->local_state(); |
Henrique Nakashima | 8941aad | 2018-11-29 23:01:53 | [diff] [blame] | 5153 | } |
| 5154 | |
| 5155 | if (!data_use_measurement::ChromeDataUseMeasurement::GetInstance()) |
| 5156 | data_use_measurement::ChromeDataUseMeasurement::CreateInstance(local_state); |
| 5157 | |
Henrique Nakashima | a3b1c5d | 2019-07-03 19:25:49 | [diff] [blame] | 5158 | // Create SystemNetworkContextManager if it has not been created yet. We need |
| 5159 | // to set up global NetworkService state before anything else uses it and this |
| 5160 | // is the first opportunity to initialize SystemNetworkContextManager with the |
| 5161 | // NetworkService. |
| 5162 | if (!SystemNetworkContextManager::HasInstance()) |
Henrique Nakashima | 8941aad | 2018-11-29 23:01:53 | [diff] [blame] | 5163 | SystemNetworkContextManager::CreateInstance(local_state); |
John Abd-El-Malek | 897374f4 | 2019-05-30 03:58:07 | [diff] [blame] | 5164 | |
Min Qin | 8caab1d | 2018-10-03 17:28:13 | [diff] [blame] | 5165 | SystemNetworkContextManager::GetInstance()->OnNetworkServiceCreated( |
Matt Menke | ae4fdb1 | 2018-06-02 06:32:54 | [diff] [blame] | 5166 | network_service); |
| 5167 | } |
| 5168 | |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5169 | network::mojom::NetworkContextPtr |
| 5170 | ChromeContentBrowserClient::CreateNetworkContext( |
| 5171 | content::BrowserContext* context, |
| 5172 | bool in_memory, |
| 5173 | const base::FilePath& relative_partition_path) { |
John Abd-El-Malek | cc0b2a6 | 2018-03-20 19:32:50 | [diff] [blame] | 5174 | Profile* profile = Profile::FromBrowserContext(context); |
Matt Menke | d38efd9 | 2018-08-14 20:39:45 | [diff] [blame] | 5175 | return profile->CreateNetworkContext(in_memory, relative_partition_path); |
Ken Rockot | a0dfaca1 | 2018-02-15 07:26:25 | [diff] [blame] | 5176 | } |
| 5177 | |
Robert Sesek | 34f68f31 | 2019-01-14 20:25:11 | [diff] [blame] | 5178 | std::vector<base::FilePath> |
| 5179 | ChromeContentBrowserClient::GetNetworkContextsParentDirectory() { |
| 5180 | base::FilePath user_data_dir; |
| 5181 | base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 5182 | DCHECK(!user_data_dir.empty()); |
| 5183 | |
| 5184 | base::FilePath cache_dir; |
| 5185 | chrome::GetUserCacheDirectory(user_data_dir, &cache_dir); |
| 5186 | DCHECK(!cache_dir.empty()); |
| 5187 | |
| 5188 | // On some platforms, the cache is a child of the user_data_dir so only |
| 5189 | // return the one path. |
| 5190 | if (user_data_dir.IsParent(cache_dir)) |
| 5191 | return {user_data_dir}; |
| 5192 | |
| 5193 | return {user_data_dir, cache_dir}; |
| 5194 | } |
| 5195 | |
Min Qin | 75ed6df | 2017-12-01 20:39:15 | [diff] [blame] | 5196 | bool ChromeContentBrowserClient::AllowRenderingMhtmlOverHttp( |
Min Qin | 30a78a1 | 2017-12-06 01:29:13 | [diff] [blame] | 5197 | content::NavigationUIData* navigation_ui_data) { |
Min Qin | 75ed6df | 2017-12-01 20:39:15 | [diff] [blame] | 5198 | #if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
| 5199 | // It is OK to load the saved offline copy, in MHTML format. |
| 5200 | ChromeNavigationUIData* chrome_navigation_ui_data = |
| 5201 | static_cast<ChromeNavigationUIData*>(navigation_ui_data); |
| 5202 | if (!chrome_navigation_ui_data) |
| 5203 | return false; |
| 5204 | offline_pages::OfflinePageNavigationUIData* offline_page_data = |
| 5205 | chrome_navigation_ui_data->GetOfflinePageNavigationUIData(); |
| 5206 | return offline_page_data && offline_page_data->is_offline_page(); |
| 5207 | #else |
| 5208 | return false; |
| 5209 | #endif |
| 5210 | } |
| 5211 | |
Min Qin | 30a78a1 | 2017-12-06 01:29:13 | [diff] [blame] | 5212 | bool ChromeContentBrowserClient::ShouldForceDownloadResource( |
| 5213 | const GURL& url, |
| 5214 | const std::string& mime_type) { |
| 5215 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5216 | // Special-case user scripts to get downloaded instead of viewed. |
| 5217 | return extensions::UserScript::IsURLUserScript(url, mime_type); |
| 5218 | #else |
| 5219 | return false; |
| 5220 | #endif |
| 5221 | } |
| 5222 | |
Donna Wu | 838ac36 | 2018-08-10 10:36:33 | [diff] [blame] | 5223 | void ChromeContentBrowserClient::CreateWebUsbService( |
Reilly Grant | c31b819 | 2017-12-15 19:54:34 | [diff] [blame] | 5224 | content::RenderFrameHost* render_frame_host, |
Donna Wu | 838ac36 | 2018-08-10 10:36:33 | [diff] [blame] | 5225 | mojo::InterfaceRequest<blink::mojom::WebUsbService> request) { |
Reilly Grant | c31b819 | 2017-12-15 19:54:34 | [diff] [blame] | 5226 | if (!base::FeatureList::IsEnabled(features::kWebUsb)) |
| 5227 | return; |
| 5228 | |
Reilly Grant | c31b819 | 2017-12-15 19:54:34 | [diff] [blame] | 5229 | WebContents* web_contents = |
| 5230 | WebContents::FromRenderFrameHost(render_frame_host); |
| 5231 | if (!web_contents) { |
| 5232 | NOTREACHED(); |
| 5233 | return; |
| 5234 | } |
| 5235 | |
| 5236 | UsbTabHelper* tab_helper = |
| 5237 | UsbTabHelper::GetOrCreateForWebContents(web_contents); |
Donna Wu | 838ac36 | 2018-08-10 10:36:33 | [diff] [blame] | 5238 | tab_helper->CreateWebUsbService(render_frame_host, std::move(request)); |
Reilly Grant | c31b819 | 2017-12-15 19:54:34 | [diff] [blame] | 5239 | } |
| 5240 | |
Reilly Grant | 0d28232 | 2019-01-29 02:42:58 | [diff] [blame] | 5241 | #if !defined(OS_ANDROID) |
| 5242 | content::SerialDelegate* ChromeContentBrowserClient::GetSerialDelegate() { |
| 5243 | if (!serial_delegate_) |
| 5244 | serial_delegate_ = std::make_unique<ChromeSerialDelegate>(); |
| 5245 | return serial_delegate_.get(); |
| 5246 | } |
Matt Reynolds | 93616f9b | 2019-06-07 01:28:52 | [diff] [blame] | 5247 | |
| 5248 | content::HidDelegate* ChromeContentBrowserClient::GetHidDelegate() { |
| 5249 | if (!hid_delegate_) |
| 5250 | hid_delegate_ = std::make_unique<ChromeHidDelegate>(); |
| 5251 | return hid_delegate_.get(); |
| 5252 | } |
Reilly Grant | 0d28232 | 2019-01-29 02:42:58 | [diff] [blame] | 5253 | #endif |
| 5254 | |
Balazs Engedy | a7ff7098 | 2018-06-04 18:14:47 | [diff] [blame] | 5255 | std::unique_ptr<content::AuthenticatorRequestClientDelegate> |
| 5256 | ChromeContentBrowserClient::GetWebAuthenticationRequestDelegate( |
Adam Langley | eeac87e | 2019-04-13 22:58:22 | [diff] [blame] | 5257 | content::RenderFrameHost* render_frame_host, |
| 5258 | const std::string& relying_party_id) { |
| 5259 | return AuthenticatorRequestScheduler::CreateRequestDelegate(render_frame_host, |
| 5260 | relying_party_id); |
Balazs Engedy | a7ff7098 | 2018-06-04 18:14:47 | [diff] [blame] | 5261 | } |
| 5262 | |
Martin Kreichgauer | bcfda9cf | 2018-08-02 00:47:07 | [diff] [blame] | 5263 | #if defined(OS_MACOSX) |
| 5264 | bool ChromeContentBrowserClient:: |
| 5265 | IsWebAuthenticationTouchIdAuthenticatorSupported() { |
| 5266 | return true; |
| 5267 | } |
| 5268 | #endif |
| 5269 | |
Jun Cai | 9409ded | 2018-01-30 00:19:46 | [diff] [blame] | 5270 | std::unique_ptr<net::ClientCertStore> |
| 5271 | ChromeContentBrowserClient::CreateClientCertStore( |
| 5272 | content::ResourceContext* resource_context) { |
| 5273 | if (!resource_context) |
| 5274 | return nullptr; |
| 5275 | return ProfileIOData::FromResourceContext(resource_context) |
| 5276 | ->CreateClientCertStore(); |
| 5277 | } |
| 5278 | |
David Benjamin | eced01fc | 2019-02-27 18:29:02 | [diff] [blame] | 5279 | std::unique_ptr<content::LoginDelegate> |
Jun Cai | bc561f41 | 2018-02-28 18:41:39 | [diff] [blame] | 5280 | ChromeContentBrowserClient::CreateLoginDelegate( |
Emily Stark | f2c9bbd | 2019-04-09 17:08:58 | [diff] [blame] | 5281 | const net::AuthChallengeInfo& auth_info, |
David Benjamin | eced01fc | 2019-02-27 18:29:02 | [diff] [blame] | 5282 | content::WebContents* web_contents, |
Ken Rockot | 5f734e3 | 2018-06-13 01:41:03 | [diff] [blame] | 5283 | const content::GlobalRequestID& request_id, |
Jun Cai | 8e165d2 | 2018-05-14 19:21:24 | [diff] [blame] | 5284 | bool is_request_for_main_frame, |
Jun Cai | bc561f41 | 2018-02-28 18:41:39 | [diff] [blame] | 5285 | const GURL& url, |
Ken Rockot | 5f734e3 | 2018-06-13 01:41:03 | [diff] [blame] | 5286 | scoped_refptr<net::HttpResponseHeaders> response_headers, |
Jun Cai | bc561f41 | 2018-02-28 18:41:39 | [diff] [blame] | 5287 | bool first_auth_attempt, |
Mark Pilgrim | 7cfcd11 | 2018-05-08 00:07:56 | [diff] [blame] | 5288 | LoginAuthRequiredCallback auth_required_callback) { |
Ken Rockot | 5f734e3 | 2018-06-13 01:41:03 | [diff] [blame] | 5289 | return CreateLoginPrompt( |
David Benjamin | eced01fc | 2019-02-27 18:29:02 | [diff] [blame] | 5290 | auth_info, web_contents, request_id, is_request_for_main_frame, url, |
Emily Stark | c5f1579 | 2019-05-19 17:24:20 | [diff] [blame] | 5291 | std::move(response_headers), LoginHandler::PRE_COMMIT, |
| 5292 | std::move(auth_required_callback)); |
Jun Cai | bc561f41 | 2018-02-28 18:41:39 | [diff] [blame] | 5293 | } |
| 5294 | |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 5295 | bool ChromeContentBrowserClient::HandleExternalProtocol( |
| 5296 | const GURL& url, |
| 5297 | content::ResourceRequestInfo::WebContentsGetter web_contents_getter, |
| 5298 | int child_id, |
| 5299 | content::NavigationUIData* navigation_data, |
| 5300 | bool is_main_frame, |
| 5301 | ui::PageTransition page_transition, |
Tim Volodine | b24393f3 | 2018-11-16 18:45:45 | [diff] [blame] | 5302 | bool has_user_gesture, |
Tim Volodine | fc21834 | 2019-03-08 15:34:38 | [diff] [blame] | 5303 | network::mojom::URLLoaderFactoryRequest* factory_request, |
| 5304 | network::mojom::URLLoaderFactory*& out_factory) { |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 5305 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5306 | // External protocols are disabled for guests. An exception is made for the |
| 5307 | // "mailto" protocol, so that pages that utilize it work properly in a |
| 5308 | // WebView. |
| 5309 | ChromeNavigationUIData* chrome_data = |
| 5310 | static_cast<ChromeNavigationUIData*>(navigation_data); |
| 5311 | if ((extensions::WebViewRendererState::GetInstance()->IsGuest(child_id) || |
| 5312 | (chrome_data && |
| 5313 | chrome_data->GetExtensionNavigationUIData()->is_web_view())) && |
| 5314 | !url.SchemeIs(url::kMailToScheme)) { |
| 5315 | return false; |
| 5316 | } |
| 5317 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 5318 | |
| 5319 | #if defined(OS_ANDROID) |
| 5320 | // Main frame external protocols are handled by |
| 5321 | // InterceptNavigationResourceThrottle. |
| 5322 | if (is_main_frame) |
| 5323 | return false; |
| 5324 | #endif // defined(ANDROID) |
| 5325 | |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 5326 | base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, |
| 5327 | base::BindOnce(&LaunchURL, url, web_contents_getter, |
| 5328 | page_transition, has_user_gesture)); |
John Abd-El-Malek | a67add8 | 2018-03-09 18:22:01 | [diff] [blame] | 5329 | return true; |
| 5330 | } |
| 5331 | |
Jennifer Apacible | 4f854a8 | 2018-04-06 22:22:11 | [diff] [blame] | 5332 | std::unique_ptr<content::OverlayWindow> |
Jennifer Apacible | 6010b023 | 2018-04-12 23:35:28 | [diff] [blame] | 5333 | ChromeContentBrowserClient::CreateWindowForPictureInPicture( |
| 5334 | content::PictureInPictureWindowController* controller) { |
Jennifer Apacible | 4f854a8 | 2018-04-06 22:22:11 | [diff] [blame] | 5335 | #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ |
| 5336 | defined(OS_CHROMEOS) |
| 5337 | // Note: content::OverlayWindow::Create() is defined by platform-specific |
| 5338 | // implementation in chrome/browser/ui/views. This layering hack, which goes |
| 5339 | // through //content and ContentBrowserClient, allows us to work around the |
| 5340 | // dependency constraints that disallow directly calling |
| 5341 | // chrome/browser/ui/views code either from here or from other code in |
| 5342 | // chrome/browser. |
Jennifer Apacible | 6010b023 | 2018-04-12 23:35:28 | [diff] [blame] | 5343 | return content::OverlayWindow::Create(controller); |
Jennifer Apacible | 4f854a8 | 2018-04-06 22:22:11 | [diff] [blame] | 5344 | #else |
| 5345 | return nullptr; |
| 5346 | #endif |
| 5347 | } |
| 5348 | |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 5349 | bool ChromeContentBrowserClient::IsSafeRedirectTargetOnIO( |
Clark DuVall | bf7722f | 2018-08-03 18:03:33 | [diff] [blame] | 5350 | const GURL& url, |
| 5351 | content::ResourceContext* context) { |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 5352 | DCHECK(!base::FeatureList::IsEnabled(features::kNavigationLoaderOnUI)); |
Clark DuVall | bf7722f | 2018-08-03 18:03:33 | [diff] [blame] | 5353 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5354 | if (url.SchemeIs(extensions::kExtensionScheme)) { |
| 5355 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 5356 | const Extension* extension = |
| 5357 | io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); |
| 5358 | if (!extension) |
| 5359 | return false; |
| 5360 | return extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible( |
| 5361 | extension, url.path()); |
| 5362 | } |
| 5363 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 5364 | return true; |
| 5365 | } |
| 5366 | |
Clark DuVall | fffa41e | 2019-06-25 20:27:19 | [diff] [blame] | 5367 | bool ChromeContentBrowserClient::IsSafeRedirectTarget( |
| 5368 | const GURL& url, |
| 5369 | content::BrowserContext* context) { |
| 5370 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5371 | if (url.SchemeIs(extensions::kExtensionScheme)) { |
| 5372 | const Extension* extension = extensions::ExtensionRegistry::Get(context) |
| 5373 | ->enabled_extensions() |
| 5374 | .GetByID(url.host()); |
| 5375 | if (!extension) |
| 5376 | return false; |
| 5377 | return extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible( |
| 5378 | extension, url.path()); |
| 5379 | } |
| 5380 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 5381 | return true; |
| 5382 | } |
| 5383 | |
Kunihiko Sakamoto | 19aa708 | 2019-02-25 03:14:43 | [diff] [blame] | 5384 | void ChromeContentBrowserClient::RegisterRendererPreferenceWatcher( |
Makoto Shimazu | c750293 | 2018-08-15 02:12:56 | [diff] [blame] | 5385 | content::BrowserContext* browser_context, |
Leon Han | f4003a16 | 2019-01-28 05:31:58 | [diff] [blame] | 5386 | blink::mojom::RendererPreferenceWatcherPtr watcher) { |
Makoto Shimazu | c750293 | 2018-08-15 02:12:56 | [diff] [blame] | 5387 | Profile* profile = Profile::FromBrowserContext(browser_context); |
Kunihiko Sakamoto | 19aa708 | 2019-02-25 03:14:43 | [diff] [blame] | 5388 | PrefWatcher::Get(profile)->RegisterRendererPreferenceWatcher( |
| 5389 | std::move(watcher)); |
Makoto Shimazu | c750293 | 2018-08-15 02:12:56 | [diff] [blame] | 5390 | } |
| 5391 | |
dbeam | 25472e0c | 2017-06-23 19:02:31 | [diff] [blame] | 5392 | // Static; handles rewriting Web UI URLs. |
| 5393 | bool ChromeContentBrowserClient::HandleWebUI( |
| 5394 | GURL* url, |
| 5395 | content::BrowserContext* browser_context) { |
| 5396 | // Rewrite chrome://help and chrome://chrome to chrome://settings/help. |
| 5397 | if (url->SchemeIs(content::kChromeUIScheme) && |
| 5398 | (url->host() == chrome::kChromeUIHelpHost || |
| 5399 | (url->host() == chrome::kChromeUIUberHost && |
| 5400 | (url->path().empty() || url->path() == "/")))) { |
| 5401 | *url = ReplaceURLHostAndPath(*url, chrome::kChromeUISettingsHost, |
| 5402 | chrome::kChromeUIHelpHost); |
| 5403 | return true; // Return true to update the displayed URL. |
| 5404 | } |
| 5405 | |
| 5406 | if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( |
| 5407 | browser_context, *url)) { |
| 5408 | return false; |
| 5409 | } |
| 5410 | |
| 5411 | #if defined(OS_CHROMEOS) |
| 5412 | // Special case : in ChromeOS in Guest mode bookmarks and history are |
| 5413 | // disabled for security reasons. New tab page explains the reasons, so |
| 5414 | // we redirect user to new tab page. |
| 5415 | if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) { |
| 5416 | if (url->SchemeIs(content::kChromeUIScheme) && |
| 5417 | (url->DomainIs(chrome::kChromeUIBookmarksHost) || |
| 5418 | url->DomainIs(chrome::kChromeUIHistoryHost))) { |
| 5419 | // Rewrite with new tab URL |
| 5420 | *url = GURL(chrome::kChromeUINewTabURL); |
| 5421 | } |
| 5422 | } |
| 5423 | #endif |
| 5424 | |
| 5425 | return true; |
| 5426 | } |
| 5427 | |
Anthony Vallee-Dubois | 8f5e7e1 | 2018-01-12 16:14:06 | [diff] [blame] | 5428 | bool ChromeContentBrowserClient::ShowPaymentHandlerWindow( |
| 5429 | content::BrowserContext* browser_context, |
| 5430 | const GURL& url, |
Anthony Vallee-Dubois | 98befeaa | 2018-01-18 16:31:32 | [diff] [blame] | 5431 | base::OnceCallback<void(bool, int, int)> callback) { |
Anthony Vallee-Dubois | 8f5e7e1 | 2018-01-12 16:14:06 | [diff] [blame] | 5432 | #if defined(OS_ANDROID) |
| 5433 | return false; |
| 5434 | #else |
| 5435 | payments::PaymentRequestDisplayManagerFactory::GetInstance() |
| 5436 | ->GetForBrowserContext(browser_context) |
| 5437 | ->ShowPaymentHandlerWindow(url, std::move(callback)); |
| 5438 | return true; |
| 5439 | #endif |
| 5440 | } |
| 5441 | |
dbeam | 25472e0c | 2017-06-23 19:02:31 | [diff] [blame] | 5442 | // Static; reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to |
| 5443 | // "chrome://foo/". |
| 5444 | bool ChromeContentBrowserClient::HandleWebUIReverse( |
| 5445 | GURL* url, |
| 5446 | content::BrowserContext* browser_context) { |
| 5447 | // No need to actually reverse-rewrite the URL, but return true to update the |
| 5448 | // displayed URL when rewriting chrome://help to chrome://settings/help. |
| 5449 | return url->SchemeIs(content::kChromeUIScheme) && |
| 5450 | url->host() == chrome::kChromeUISettingsHost; |
| 5451 | } |
| 5452 | |
Dan Beam | f0a7e11 | 2019-06-07 18:40:58 | [diff] [blame] | 5453 | const ui::NativeTheme* ChromeContentBrowserClient::GetWebTheme() const { |
| 5454 | return ui::NativeTheme::GetInstanceForWeb(); |
| 5455 | } |
| 5456 | |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 5457 | // static |
michaeln | 10e5fc35 | 2017-02-07 02:07:58 | [diff] [blame] | 5458 | void ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( |
| 5459 | const storage::QuotaSettings* settings) { |
| 5460 | g_default_quota_settings = settings; |
| 5461 | } |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 5462 | |
| 5463 | safe_browsing::UrlCheckerDelegate* |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 5464 | ChromeContentBrowserClient::GetSafeBrowsingUrlCheckerDelegate( |
| 5465 | content::ResourceContext* resource_context) { |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 5466 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 5467 | |
Yuzhu Shen | cb3011f6 | 2018-02-08 02:51:50 | [diff] [blame] | 5468 | ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 5469 | if (!io_data->safe_browsing_enabled()->GetValue()) |
| 5470 | return nullptr; |
| 5471 | |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 5472 | // |safe_browsing_service_| may be unavailable in tests. |
| 5473 | if (safe_browsing_service_ && !safe_browsing_url_checker_delegate_) { |
| 5474 | safe_browsing_url_checker_delegate_ = |
Jialiu Lin | 0de6756c | 2018-03-22 00:57:43 | [diff] [blame] | 5475 | base::MakeRefCounted<safe_browsing::UrlCheckerDelegateImpl>( |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 5476 | safe_browsing_service_->database_manager(), |
Jialiu Lin | 0de6756c | 2018-03-22 00:57:43 | [diff] [blame] | 5477 | safe_browsing_service_->ui_manager()); |
Yuzhu Shen | 44094e2 | 2017-07-18 22:52:35 | [diff] [blame] | 5478 | } |
| 5479 | |
| 5480 | return safe_browsing_url_checker_delegate_.get(); |
| 5481 | } |
Daniel Vogelheim | 6008f57 | 2018-09-24 14:35:14 | [diff] [blame] | 5482 | |
| 5483 | base::Optional<std::string> |
| 5484 | ChromeContentBrowserClient::GetOriginPolicyErrorPage( |
| 5485 | content::OriginPolicyErrorReason error_reason, |
Daniel Vogelheim | 7badd0d | 2019-02-04 14:42:18 | [diff] [blame] | 5486 | content::NavigationHandle* handle) { |
| 5487 | return security_interstitials::OriginPolicyUI::GetErrorPageAsHTML( |
| 5488 | error_reason, handle); |
Daniel Vogelheim | 6008f57 | 2018-09-24 14:35:14 | [diff] [blame] | 5489 | } |
Kunihiko Sakamoto | 73b803d | 2018-10-05 09:09:52 | [diff] [blame] | 5490 | |
| 5491 | bool ChromeContentBrowserClient::CanIgnoreCertificateErrorIfNeeded() { |
| 5492 | // We require --user-data-dir flag too so that no dangerous changes are made |
| 5493 | // in the user's regular profile. |
| 5494 | return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 5495 | switches::kUserDataDir); |
| 5496 | } |
rajendrant | feea859 | 2018-10-19 18:26:06 | [diff] [blame] | 5497 | |
| 5498 | void ChromeContentBrowserClient::OnNetworkServiceDataUseUpdate( |
| 5499 | int32_t network_traffic_annotation_id_hash, |
| 5500 | int64_t recv_bytes, |
| 5501 | int64_t sent_bytes) { |
Min Qin | cafb27b | 2018-10-30 18:02:03 | [diff] [blame] | 5502 | if (data_use_measurement::ChromeDataUseMeasurement::GetInstance()) { |
| 5503 | data_use_measurement::ChromeDataUseMeasurement::GetInstance() |
| 5504 | ->ReportNetworkServiceDataUse(network_traffic_annotation_id_hash, |
| 5505 | recv_bytes, sent_bytes); |
rajendrant | feea859 | 2018-10-19 18:26:06 | [diff] [blame] | 5506 | } |
| 5507 | } |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5508 | |
| 5509 | content::PreviewsState ChromeContentBrowserClient::DetermineAllowedPreviews( |
| 5510 | content::PreviewsState initial_state, |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5511 | content::NavigationHandle* navigation_handle, |
| 5512 | const GURL& current_navigation_url) { |
Robert Ogden | 30bbc9d | 2019-04-30 20:15:13 | [diff] [blame] | 5513 | content::PreviewsState state = DetermineAllowedPreviewsWithoutHoldback( |
| 5514 | initial_state, navigation_handle, current_navigation_url); |
| 5515 | |
| 5516 | return previews::MaybeCoinFlipHoldbackBeforeCommit(state, navigation_handle); |
| 5517 | } |
| 5518 | |
| 5519 | content::PreviewsState |
| 5520 | ChromeContentBrowserClient::DetermineAllowedPreviewsWithoutHoldback( |
| 5521 | content::PreviewsState initial_state, |
| 5522 | content::NavigationHandle* navigation_handle, |
| 5523 | const GURL& current_navigation_url) { |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5524 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
Tarun Bansal | b89c1d5 | 2019-01-16 06:56:29 | [diff] [blame] | 5525 | DCHECK(!navigation_handle->HasCommitted()); |
Ryan Sturm | da2a0e0 | 2018-10-25 01:52:21 | [diff] [blame] | 5526 | |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5527 | // If this is not a main frame, return the initial state. If there are no |
| 5528 | // previews in the state, return the state as is. |
| 5529 | if (!navigation_handle->IsInMainFrame() || |
| 5530 | navigation_handle->IsSameDocument()) { |
| 5531 | return initial_state; |
| 5532 | } |
| 5533 | |
Robert Ogden | a994eb4 | 2019-02-14 19:15:08 | [diff] [blame] | 5534 | if (!current_navigation_url.SchemeIsHTTPOrHTTPS()) |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5535 | return content::PREVIEWS_OFF; |
Robert Ogden | a994eb4 | 2019-02-14 19:15:08 | [diff] [blame] | 5536 | |
| 5537 | // Do not allow previews on POST navigations since the primary opt-out |
| 5538 | // mechanism is to reload the page. Because POST navigations are not |
| 5539 | // idempotent, we do not want to show a preview on a POST navigation where |
| 5540 | // opting out would cause another navigation, i.e.: a reload. |
| 5541 | if (navigation_handle->IsPost()) |
| 5542 | return content::PREVIEWS_OFF; |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5543 | |
| 5544 | content::WebContents* web_contents = navigation_handle->GetWebContents(); |
| 5545 | content::WebContentsDelegate* delegate = web_contents->GetDelegate(); |
| 5546 | |
Ryan Sturm | da2a0e0 | 2018-10-25 01:52:21 | [diff] [blame] | 5547 | auto* browser_context = web_contents->GetBrowserContext(); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5548 | |
| 5549 | PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile( |
| 5550 | Profile::FromBrowserContext(browser_context)); |
| 5551 | auto* data_reduction_proxy_settings = |
| 5552 | DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 5553 | browser_context); |
| 5554 | // If the profile does not support previews or Data Saver, do not turn on |
| 5555 | // Previews. |
| 5556 | if (!previews_service || !previews_service->previews_ui_service() || |
| 5557 | !data_reduction_proxy_settings) { |
| 5558 | return content::PREVIEWS_OFF; |
| 5559 | } |
| 5560 | |
| 5561 | PreviewsUITabHelper* ui_tab_helper = |
Ryan Sturm | da2a0e0 | 2018-10-25 01:52:21 | [diff] [blame] | 5562 | PreviewsUITabHelper::FromWebContents(web_contents); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5563 | // If this tab does not have a PreviewsUITabHelper, no preview should be |
| 5564 | // served. |
| 5565 | if (!ui_tab_helper) |
| 5566 | return content::PREVIEWS_OFF; |
| 5567 | |
| 5568 | DCHECK(!browser_context->IsOffTheRecord()); |
| 5569 | |
| 5570 | // Other previews objects should all exist and be initialized if we have made |
| 5571 | // it past earlier checks. |
| 5572 | previews::PreviewsDeciderImpl* previews_decider_impl = |
| 5573 | previews_service->previews_ui_service()->previews_decider_impl(); |
| 5574 | DCHECK(previews_decider_impl); |
| 5575 | |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5576 | // Start with an unspecified state. |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5577 | content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED; |
| 5578 | |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5579 | previews::PreviewsUserData* previews_data = |
| 5580 | ui_tab_helper->GetPreviewsUserData(navigation_handle); |
| 5581 | |
| 5582 | // Certain PreviewsStates are used within URLLoaders (Offline, server |
Sean | ac57e9b9 | 2019-04-29 19:19:31 | [diff] [blame] | 5583 | // previews) and cannot re-evaluate PreviewsState once previews triggering |
| 5584 | // logic has already been run, so they should not change. Assume that |
| 5585 | // previews triggering logic has run when PreviewsUserData already exists and |
| 5586 | // a Lite Page Redirect preview is not being attempted, since it may also |
| 5587 | // create a previews_data before this point. |
| 5588 | bool previews_triggering_logic_already_ran = false; |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5589 | if (previews_data) { |
Sean | ac57e9b9 | 2019-04-29 19:19:31 | [diff] [blame] | 5590 | previews_triggering_logic_already_ran = |
| 5591 | !previews_data->server_lite_page_info(); |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5592 | } else { |
| 5593 | previews_data = ui_tab_helper->CreatePreviewsUserDataForNavigationHandle( |
| 5594 | navigation_handle, previews_decider_impl->GeneratePageId()); |
| 5595 | } |
| 5596 | |
| 5597 | DCHECK(previews_data); |
| 5598 | |
Robert Ogden | 01770b36 | 2019-05-22 17:36:43 | [diff] [blame] | 5599 | if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 5600 | previews::switches::kForceEnablePreviews)) { |
| 5601 | previews_decider_impl->LoadPageHints(current_navigation_url); |
| 5602 | return content::ALL_SUPPORTED_PREVIEWS; |
| 5603 | } |
| 5604 | |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5605 | bool is_reload = |
| 5606 | navigation_handle->GetReloadType() != content::ReloadType::NONE; |
| 5607 | |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5608 | content::PreviewsState server_previews_enabled_state = |
Robert Ogden | 54bb4ff | 2019-06-19 01:31:51 | [diff] [blame] | 5609 | content::SERVER_LITE_PAGE_ON; |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5610 | |
| 5611 | // For now, treat server previews types as a single decision, and do not |
| 5612 | // re-evaluate upon redirect. Plumbing does not exist to modify the CPAT |
| 5613 | // header, nor does the plumbing exist to modify the PreviewsState within the |
| 5614 | // URLLoader. |
Sean | ac57e9b9 | 2019-04-29 19:19:31 | [diff] [blame] | 5615 | if (previews_triggering_logic_already_ran) { |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5616 | // Copy the server state that was used before the redirect for the initial |
| 5617 | // URL. |
Robert Ogden | 869986f | 2019-06-20 19:12:05 | [diff] [blame] | 5618 | previews_state |= |
| 5619 | (previews_data->AllowedPreviewsState() & server_previews_enabled_state); |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5620 | } else { |
Doug Arnett | a3dc7158 | 2018-11-08 00:25:10 | [diff] [blame] | 5621 | if (previews_decider_impl->ShouldAllowPreviewAtNavigationStart( |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5622 | previews_data, current_navigation_url, is_reload, |
Doug Arnett | d5a6003 | 2018-11-12 19:37:30 | [diff] [blame] | 5623 | previews::PreviewsType::LITE_PAGE)) { |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5624 | previews_state |= server_previews_enabled_state; |
| 5625 | } |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5626 | } |
| 5627 | |
Robert Ogden | 198d657 | 2019-06-26 15:15:33 | [diff] [blame] | 5628 | // Evaluate Offline, NoScript, and ResourceBlocking previews. |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5629 | previews_state |= previews::DetermineAllowedClientPreviewsState( |
Sean | ac57e9b9 | 2019-04-29 19:19:31 | [diff] [blame] | 5630 | previews_data, previews_triggering_logic_already_ran, |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5631 | data_reduction_proxy_settings->IsDataReductionProxyEnabled(), |
Ryan Sturm | 37b3069e | 2019-02-22 04:11:24 | [diff] [blame] | 5632 | previews_decider_impl, navigation_handle); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5633 | |
| 5634 | if (previews_state & content::PREVIEWS_OFF) { |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5635 | previews_data->set_allowed_previews_state(content::PREVIEWS_OFF); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5636 | return content::PREVIEWS_OFF; |
| 5637 | } |
| 5638 | |
| 5639 | if (previews_state & content::PREVIEWS_NO_TRANSFORM) { |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5640 | previews_data->set_allowed_previews_state(content::PREVIEWS_NO_TRANSFORM); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5641 | return content::PREVIEWS_NO_TRANSFORM; |
| 5642 | } |
| 5643 | |
| 5644 | // At this point, if no Preview is allowed, don't allow previews. |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5645 | if (previews_state == content::PREVIEWS_UNSPECIFIED) { |
| 5646 | previews_data->set_allowed_previews_state(content::PREVIEWS_OFF); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5647 | return content::PREVIEWS_OFF; |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5648 | } |
| 5649 | |
| 5650 | content::PreviewsState embedder_state = content::PREVIEWS_UNSPECIFIED; |
| 5651 | if (delegate) { |
| 5652 | delegate->AdjustPreviewsStateForNavigation(web_contents, &embedder_state); |
| 5653 | } |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5654 | |
| 5655 | // If the allowed previews are limited by the embedder, ensure previews honors |
| 5656 | // those limits. |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5657 | if (embedder_state != content::PREVIEWS_UNSPECIFIED) { |
| 5658 | previews_state = previews_state & embedder_state; |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5659 | // If no valid previews are left, set the state explicitly to PREVIEWS_OFF. |
| 5660 | if (previews_state == content::PREVIEWS_UNSPECIFIED) |
| 5661 | previews_state = content::PREVIEWS_OFF; |
| 5662 | } |
Ryan Sturm | 647d1d9 | 2018-11-07 15:41:39 | [diff] [blame] | 5663 | previews_data->set_allowed_previews_state(previews_state); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5664 | return previews_state; |
| 5665 | } |
| 5666 | |
| 5667 | // static |
| 5668 | content::PreviewsState |
| 5669 | ChromeContentBrowserClient::DetermineCommittedPreviewsForURL( |
| 5670 | const GURL& url, |
| 5671 | data_reduction_proxy::DataReductionProxyData* drp_data, |
| 5672 | previews::PreviewsUserData* previews_user_data, |
| 5673 | const previews::PreviewsDecider* previews_decider, |
Ryan Sturm | 737bd1d | 2019-02-28 01:38:05 | [diff] [blame] | 5674 | content::PreviewsState initial_state, |
| 5675 | content::NavigationHandle* navigation_handle) { |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5676 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 5677 | if (!previews::HasEnabledPreviews(initial_state)) |
| 5678 | return content::PREVIEWS_OFF; |
| 5679 | |
| 5680 | // Check if the server sent a preview directive. |
| 5681 | content::PreviewsState previews_state = |
Clark DuVall | 0ec5214 | 2019-06-06 19:53:55 | [diff] [blame] | 5682 | previews::DetermineCommittedServerPreviewsState(drp_data, initial_state); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5683 | |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5684 | // Check the various other client previews types. |
| 5685 | return previews::DetermineCommittedClientPreviewsState( |
Ryan Sturm | 737bd1d | 2019-02-28 01:38:05 | [diff] [blame] | 5686 | previews_user_data, url, previews_state, previews_decider, |
| 5687 | navigation_handle); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5688 | } |
| 5689 | |
| 5690 | content::PreviewsState ChromeContentBrowserClient::DetermineCommittedPreviews( |
| 5691 | content::PreviewsState initial_state, |
| 5692 | content::NavigationHandle* navigation_handle, |
| 5693 | const net::HttpResponseHeaders* response_headers) { |
Robert Ogden | 30bbc9d | 2019-04-30 20:15:13 | [diff] [blame] | 5694 | content::PreviewsState state = DetermineCommittedPreviewsWithoutHoldback( |
| 5695 | initial_state, navigation_handle, response_headers); |
| 5696 | |
| 5697 | return previews::MaybeCoinFlipHoldbackAfterCommit(state, navigation_handle); |
| 5698 | } |
| 5699 | |
| 5700 | content::PreviewsState |
| 5701 | ChromeContentBrowserClient::DetermineCommittedPreviewsWithoutHoldback( |
| 5702 | content::PreviewsState initial_state, |
| 5703 | content::NavigationHandle* navigation_handle, |
| 5704 | const net::HttpResponseHeaders* response_headers) { |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5705 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 5706 | // Only support HTTP and HTTPS. |
| 5707 | if (navigation_handle->IsErrorPage() || |
| 5708 | !navigation_handle->GetURL().SchemeIsHTTPOrHTTPS()) { |
| 5709 | return content::PREVIEWS_OFF; |
| 5710 | } |
| 5711 | |
| 5712 | // If this is not a main frame, return the initial state. If there are no |
| 5713 | // previews in the state, return the state as is. |
| 5714 | if (!previews::HasEnabledPreviews(initial_state) || |
| 5715 | !navigation_handle->IsInMainFrame() || |
| 5716 | navigation_handle->IsSameDocument()) { |
| 5717 | return initial_state; |
| 5718 | } |
| 5719 | |
| 5720 | // WebContents that don't have a PreviewsUITabHelper are not supported. |
| 5721 | PreviewsUITabHelper* ui_tab_helper = |
| 5722 | PreviewsUITabHelper::FromWebContents(navigation_handle->GetWebContents()); |
| 5723 | if (!ui_tab_helper) |
| 5724 | return content::PREVIEWS_OFF; |
| 5725 | |
| 5726 | // If we did not previously create a PreviewsUserData, do not go any further. |
| 5727 | previews::PreviewsUserData* previews_user_data = |
| 5728 | ui_tab_helper->GetPreviewsUserData(navigation_handle); |
| 5729 | if (!previews_user_data) |
| 5730 | return content::PREVIEWS_OFF; |
| 5731 | |
| 5732 | PreviewsService* previews_service = |
| 5733 | PreviewsServiceFactory::GetForProfile(Profile::FromBrowserContext( |
| 5734 | navigation_handle->GetWebContents()->GetBrowserContext())); |
| 5735 | |
| 5736 | if (!previews_service || !previews_service->previews_ui_service()) |
| 5737 | return content::PREVIEWS_OFF; |
| 5738 | |
| 5739 | // Check if offline previews are being used and set it in the user data. |
| 5740 | #if BUILDFLAG(ENABLE_OFFLINE_PAGES) |
| 5741 | offline_pages::OfflinePageTabHelper* tab_helper = |
| 5742 | offline_pages::OfflinePageTabHelper::FromWebContents( |
| 5743 | navigation_handle->GetWebContents()); |
| 5744 | |
Ryan Sturm | fc7d92f | 2019-02-12 02:24:23 | [diff] [blame] | 5745 | bool is_offline_page = tab_helper && tab_helper->IsLoadingOfflinePage(); |
| 5746 | bool is_offline_preview = tab_helper && tab_helper->GetOfflinePreviewItem(); |
| 5747 | |
| 5748 | // If this is an offline page, but not a preview, then we should not attempt |
| 5749 | // any previews or surface the previews UI. |
| 5750 | if (is_offline_page && !is_offline_preview) |
| 5751 | return content::PREVIEWS_OFF; |
| 5752 | |
| 5753 | previews_user_data->set_offline_preview_used(is_offline_preview); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5754 | #endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) |
| 5755 | |
| 5756 | // Annotate request if no-transform directive found in response headers. |
| 5757 | if (response_headers && |
| 5758 | response_headers->HasHeaderValue("cache-control", "no-transform")) { |
Jered Gray | ba1da12 | 2018-10-31 23:06:26 | [diff] [blame] | 5759 | previews_user_data->set_cache_control_no_transform_directive(); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5760 | } |
| 5761 | |
| 5762 | previews::PreviewsDeciderImpl* previews_decider_impl = |
| 5763 | previews_service->previews_ui_service()->previews_decider_impl(); |
| 5764 | DCHECK(previews_decider_impl); |
| 5765 | |
Clark DuVall | 9c5a72cc | 2018-10-25 01:29:21 | [diff] [blame] | 5766 | std::unique_ptr<data_reduction_proxy::DataReductionProxyData> drp_data; |
| 5767 | auto* settings = |
| 5768 | DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 5769 | navigation_handle->GetWebContents()->GetBrowserContext()); |
| 5770 | if (settings) { |
| 5771 | // TODO(898326): |drp_data| may be incomplete because |navigation_handle| |
| 5772 | // does not yet have all the response information. |
| 5773 | drp_data = settings->CreateDataFromNavigationHandle(navigation_handle, |
| 5774 | response_headers); |
| 5775 | } |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5776 | |
| 5777 | // Determine effective PreviewsState for this committed main frame response. |
| 5778 | content::PreviewsState committed_state = DetermineCommittedPreviewsForURL( |
Clark DuVall | 9c5a72cc | 2018-10-25 01:29:21 | [diff] [blame] | 5779 | navigation_handle->GetURL(), drp_data.get(), previews_user_data, |
Ryan Sturm | 737bd1d | 2019-02-28 01:38:05 | [diff] [blame] | 5780 | previews_decider_impl, initial_state, navigation_handle); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5781 | |
| 5782 | // Double check that we never serve a preview when we have a |
| 5783 | // cache-control:no-transform directive. |
| 5784 | DCHECK(!previews_user_data->cache_control_no_transform_directive() || |
| 5785 | !previews::HasEnabledPreviews(committed_state)); |
| 5786 | |
Robert Ogden | ded292c6f | 2019-05-03 22:44:51 | [diff] [blame] | 5787 | // TODO(robertogden): Consider moving this to after the holdback logic. |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5788 | previews_user_data->set_committed_previews_state(committed_state); |
| 5789 | |
| 5790 | previews::PreviewsType committed_type = |
| 5791 | previews::GetMainFramePreviewsType(committed_state); |
| 5792 | |
| 5793 | // Capture committed previews type, if any, in PreviewsUserData. |
| 5794 | // Note: this is for the subset of previews types that are decided upon |
| 5795 | // navigation commit. Previews types that are determined prior to |
| 5796 | // navigation (such as for offline pages or for redirecting to another |
| 5797 | // url), are not set here. |
| 5798 | previews_user_data->SetCommittedPreviewsType(committed_type); |
| 5799 | |
| 5800 | // Log the commit decision. |
| 5801 | std::vector<previews::PreviewsEligibilityReason> passed_reasons; |
| 5802 | previews_decider_impl->LogPreviewDecisionMade( |
| 5803 | (previews_user_data->cache_control_no_transform_directive() |
| 5804 | ? previews::PreviewsEligibilityReason::CACHE_CONTROL_NO_TRANSFORM |
| 5805 | : previews::PreviewsEligibilityReason::COMMITTED), |
| 5806 | navigation_handle->GetURL(), base::Time::Now(), |
Robert Ogden | 869986f | 2019-06-20 19:12:05 | [diff] [blame] | 5807 | previews_user_data->CommittedPreviewsType(), std::move(passed_reasons), |
Robert Ogden | 33e3631 | 2019-05-06 19:17:05 | [diff] [blame] | 5808 | previews_user_data); |
Ryan Sturm | aa05092f | 2018-10-21 03:56:54 | [diff] [blame] | 5809 | |
| 5810 | return committed_state; |
| 5811 | } |
Charlie Harrison | 650e1142 | 2018-12-04 00:37:26 | [diff] [blame] | 5812 | |
| 5813 | void ChromeContentBrowserClient::LogWebFeatureForCurrentPage( |
| 5814 | content::RenderFrameHost* render_frame_host, |
| 5815 | blink::mojom::WebFeature feature) { |
| 5816 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 5817 | page_load_metrics::mojom::PageLoadFeatures new_features({feature}, {}, {}); |
| 5818 | page_load_metrics::MetricsWebContentsObserver::RecordFeatureUsage( |
| 5819 | render_frame_host, new_features); |
| 5820 | } |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 5821 | |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5822 | std::string ChromeContentBrowserClient::GetProduct() { |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 5823 | return ::GetProduct(); |
| 5824 | } |
| 5825 | |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5826 | std::string ChromeContentBrowserClient::GetUserAgent() { |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 5827 | return ::GetUserAgent(); |
| 5828 | } |
Sam McNally | d54e23f9 | 2019-01-16 04:42:39 | [diff] [blame] | 5829 | |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5830 | blink::UserAgentMetadata ChromeContentBrowserClient::GetUserAgentMetadata() { |
Mike West | 6e4cbb3 | 2019-02-13 09:40:17 | [diff] [blame] | 5831 | return ::GetUserAgentMetadata(); |
| 5832 | } |
| 5833 | |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5834 | base::Optional<gfx::ImageSkia> ChromeContentBrowserClient::GetProductLogo() { |
Austin Orion | e250d01 | 2019-05-29 02:56:27 | [diff] [blame] | 5835 | // This icon is available on Android, but adds 19KiB to the APK. Since it |
| 5836 | // isn't used on Android we exclude it to avoid bloat. |
| 5837 | #if !defined(OS_ANDROID) |
| 5838 | return base::Optional<gfx::ImageSkia>( |
| 5839 | *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 5840 | IDR_PRODUCT_LOGO_256)); |
| 5841 | #else |
| 5842 | return base::nullopt; |
| 5843 | #endif |
| 5844 | } |
| 5845 | |
Sam McNally | d54e23f9 | 2019-01-16 04:42:39 | [diff] [blame] | 5846 | bool ChromeContentBrowserClient::IsBuiltinComponent( |
| 5847 | content::BrowserContext* browser_context, |
| 5848 | const url::Origin& origin) { |
| 5849 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 5850 | return ChromeContentBrowserClientExtensionsPart::IsBuiltinComponent( |
| 5851 | browser_context, origin); |
| 5852 | #else |
| 5853 | return false; |
| 5854 | #endif |
| 5855 | } |
Oleg Davydov | 2cc0167b | 2019-02-05 14:32:48 | [diff] [blame] | 5856 | |
| 5857 | bool ChromeContentBrowserClient::IsRendererDebugURLBlacklisted( |
| 5858 | const GURL& url, |
| 5859 | content::BrowserContext* context) { |
| 5860 | PolicyBlacklistService* service = |
| 5861 | PolicyBlacklistFactory::GetForBrowserContext(context); |
| 5862 | |
| 5863 | using URLBlacklistState = policy::URLBlacklist::URLBlacklistState; |
| 5864 | URLBlacklistState blacklist_state = service->GetURLBlacklistState(url); |
| 5865 | return blacklist_state == URLBlacklistState::URL_IN_BLACKLIST; |
| 5866 | } |
Dominic Mazzoni | 21fb028 | 2019-02-13 18:32:47 | [diff] [blame] | 5867 | |
| 5868 | ui::AXMode ChromeContentBrowserClient::GetAXModeForBrowserContext( |
| 5869 | content::BrowserContext* browser_context) { |
| 5870 | Profile* profile = Profile::FromBrowserContext(browser_context); |
| 5871 | return AccessibilityLabelsServiceFactory::GetForProfile(profile)->GetAXMode(); |
| 5872 | } |
Eric Karl | d6cd75b | 2019-03-14 22:01:36 | [diff] [blame] | 5873 | |
| 5874 | #if defined(OS_ANDROID) |
| 5875 | content::ContentBrowserClient::WideColorGamutHeuristic |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5876 | ChromeContentBrowserClient::GetWideColorGamutHeuristic() { |
Eric Karl | d6cd75b | 2019-03-14 22:01:36 | [diff] [blame] | 5877 | if (features::UseDisplayWideColorGamut()) { |
| 5878 | return WideColorGamutHeuristic::kUseDisplay; |
| 5879 | } |
| 5880 | return WideColorGamutHeuristic::kNone; |
| 5881 | } |
| 5882 | #endif |
Ehsan Karamad | 91413d7 | 2019-03-22 16:37:48 | [diff] [blame] | 5883 | |
| 5884 | base::flat_set<std::string> |
Ehsan Karamad | 466529d | 2019-05-24 03:24:43 | [diff] [blame] | 5885 | ChromeContentBrowserClient::GetPluginMimeTypesWithExternalHandlers( |
Ehsan Karamad | 91413d7 | 2019-03-22 16:37:48 | [diff] [blame] | 5886 | content::ResourceContext* resource_context) { |
| 5887 | base::flat_set<std::string> mime_types; |
| 5888 | #if BUILDFLAG(ENABLE_PLUGINS) |
| 5889 | auto map = PluginUtils::GetMimeTypeToExtensionIdMap(resource_context); |
| 5890 | for (const auto& pair : map) |
| 5891 | mime_types.insert(pair.first); |
| 5892 | #endif |
| 5893 | return mime_types; |
| 5894 | } |
Yao Xiao | d06607b | 2019-05-02 23:16:36 | [diff] [blame] | 5895 | |
| 5896 | void ChromeContentBrowserClient::AugmentNavigationDownloadPolicy( |
| 5897 | const content::WebContents* web_contents, |
| 5898 | const content::RenderFrameHost* frame_host, |
| 5899 | bool user_gesture, |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5900 | content::NavigationDownloadPolicy* download_policy) { |
Yao Xiao | d06607b | 2019-05-02 23:16:36 | [diff] [blame] | 5901 | const ChromeSubresourceFilterClient* client = |
| 5902 | ChromeSubresourceFilterClient::FromWebContents(web_contents); |
| 5903 | if (client && client->GetThrottleManager()->IsFrameTaggedAsAd(frame_host)) { |
| 5904 | if (!user_gesture) { |
| 5905 | if (base::FeatureList::IsEnabled( |
| 5906 | blink::features:: |
| 5907 | kBlockingDownloadsInAdFrameWithoutUserActivation)) { |
| 5908 | download_policy->SetDisallowed( |
| 5909 | content::NavigationDownloadType::kAdFrameNoGesture); |
| 5910 | } else { |
| 5911 | download_policy->SetAllowed( |
| 5912 | content::NavigationDownloadType::kAdFrameNoGesture); |
| 5913 | } |
| 5914 | } else { |
| 5915 | download_policy->SetAllowed( |
| 5916 | content::NavigationDownloadType::kAdFrameGesture); |
| 5917 | } |
| 5918 | } |
| 5919 | } |
Jun Cai | 732a05e3 | 2019-05-29 19:34:19 | [diff] [blame] | 5920 | |
| 5921 | bool ChromeContentBrowserClient::IsBluetoothScanningBlocked( |
| 5922 | content::BrowserContext* browser_context, |
| 5923 | const url::Origin& requesting_origin, |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5924 | const url::Origin& embedding_origin) { |
Jun Cai | 732a05e3 | 2019-05-29 19:34:19 | [diff] [blame] | 5925 | const HostContentSettingsMap* const content_settings = |
| 5926 | HostContentSettingsMapFactory::GetForProfile( |
| 5927 | Profile::FromBrowserContext(browser_context)); |
| 5928 | |
| 5929 | if (content_settings->GetContentSetting( |
| 5930 | requesting_origin.GetURL(), embedding_origin.GetURL(), |
| 5931 | CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING, |
| 5932 | std::string()) == CONTENT_SETTING_BLOCK) { |
| 5933 | return true; |
| 5934 | } |
| 5935 | |
| 5936 | return false; |
| 5937 | } |
| 5938 | |
| 5939 | void ChromeContentBrowserClient::BlockBluetoothScanning( |
| 5940 | content::BrowserContext* browser_context, |
| 5941 | const url::Origin& requesting_origin, |
Lucas Furukawa Gadani | 4909f3c | 2019-06-18 22:36:52 | [diff] [blame] | 5942 | const url::Origin& embedding_origin) { |
Jun Cai | 732a05e3 | 2019-05-29 19:34:19 | [diff] [blame] | 5943 | HostContentSettingsMap* const content_settings = |
| 5944 | HostContentSettingsMapFactory::GetForProfile( |
| 5945 | Profile::FromBrowserContext(browser_context)); |
| 5946 | |
| 5947 | content_settings->SetContentSettingDefaultScope( |
| 5948 | requesting_origin.GetURL(), embedding_origin.GetURL(), |
| 5949 | CONTENT_SETTINGS_TYPE_BLUETOOTH_SCANNING, std::string(), |
| 5950 | CONTENT_SETTING_BLOCK); |
| 5951 | } |