Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [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 "content/browser/browser_interface_binders.h" |
Matt Falkenhagen | fc796d6 | 2019-08-22 09:01:26 | [diff] [blame] | 6 | |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 7 | #include "base/check_op.h" |
Miyoung Shin | 56d4732 | 2019-12-03 13:01:16 | [diff] [blame] | 8 | #include "base/command_line.h" |
Miyoung Shin | b5630d7 | 2019-09-26 13:11:45 | [diff] [blame] | 9 | #include "base/feature_list.h" |
Mingyu Lei | eca89f2 | 2024-01-15 04:44:51 | [diff] [blame] | 10 | #include "base/functional/bind.h" |
Avi Drissman | adac2199 | 2023-01-11 23:46:39 | [diff] [blame] | 11 | #include "base/functional/callback.h" |
| 12 | #include "base/functional/callback_helpers.h" |
David Sanders | de533fce | 2021-12-15 14:59:43 | [diff] [blame] | 13 | #include "base/no_destructor.h" |
Mingyu Lei | f6f9bc1c | 2024-08-15 05:23:21 | [diff] [blame] | 14 | #include "base/supports_user_data.h" |
Gabriel Charette | 99f5df3 | 2021-03-19 19:55:55 | [diff] [blame] | 15 | #include "base/task/thread_pool.h" |
Azeem Arshad | 8282d3d | 2020-12-03 17:45:48 | [diff] [blame] | 16 | #include "build/branding_buildflags.h" |
Miyoung Shin | 282efa1 | 2019-09-24 09:34:21 | [diff] [blame] | 17 | #include "build/build_config.h" |
Miyoung Shin | 56d4732 | 2019-12-03 13:01:16 | [diff] [blame] | 18 | #include "cc/base/switches.h" |
Fergal Daly | b65f07b | 2024-12-09 07:52:38 | [diff] [blame] | 19 | #include "components/language_detection/content/common/language_detection.mojom.h" |
Steven Holte | defae36d | 2025-04-21 21:11:41 | [diff] [blame] | 20 | #include "components/optimization_guide/public/mojom/model_broker.mojom.h" |
Austin Sullivan | 38614b4e | 2024-09-17 18:02:44 | [diff] [blame] | 21 | #include "components/viz/host/gpu_client.h" |
Andrew Paseltiner | e265e306 | 2021-10-12 19:28:03 | [diff] [blame] | 22 | #include "content/browser/attribution_reporting/attribution_internals.mojom.h" |
| 23 | #include "content/browser/attribution_reporting/attribution_internals_ui.h" |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 24 | #include "content/browser/background_fetch/background_fetch_service_impl.h" |
Mario Sanchez Prada | 5509ddb | 2019-12-17 08:49:11 | [diff] [blame] | 25 | #include "content/browser/bad_message.h" |
Daniel Cheng | d6978b06 | 2023-11-16 00:11:38 | [diff] [blame] | 26 | #include "content/browser/bluetooth/web_bluetooth_service_impl.h" |
Johannes Kron | b1209bd | 2022-02-15 10:32:39 | [diff] [blame] | 27 | #include "content/browser/browser_context_impl.h" |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 28 | #include "content/browser/browser_main_loop.h" |
Yao Xiao | cc37939 | 2022-03-25 21:39:06 | [diff] [blame] | 29 | #include "content/browser/browsing_topics/browsing_topics_document_host.h" |
Dominic Farolino | 822b4300 | 2021-10-18 16:47:00 | [diff] [blame] | 30 | #include "content/browser/contacts/contacts_manager_impl.h" |
Miyoung Shin | f9dd145 | 2019-09-24 12:57:46 | [diff] [blame] | 31 | #include "content/browser/content_index/content_index_service_impl.h" |
Victor Costan | 2f6509e8 | 2021-08-04 14:32:41 | [diff] [blame] | 32 | #include "content/browser/cookie_store/cookie_store_manager.h" |
Alexis Menard | d99e01f | 2024-01-29 14:39:37 | [diff] [blame] | 33 | #include "content/browser/device_posture/device_posture_provider_impl.h" |
Ionel Popescu | 9330e9a | 2020-03-27 03:52:56 | [diff] [blame] | 34 | #include "content/browser/eye_dropper_chooser_impl.h" |
Honglin Yu | 6cdb4b3 | 2021-02-23 13:14:33 | [diff] [blame] | 35 | #include "content/browser/handwriting/handwriting_recognition_service_factory.h" |
Mario Sanchez Prada | aa35b42 | 2019-09-24 06:50:31 | [diff] [blame] | 36 | #include "content/browser/image_capture/image_capture_impl.h" |
Nathan Memmott | 6729cf5 | 2022-10-18 20:04:07 | [diff] [blame] | 37 | #include "content/browser/indexed_db/indexed_db_internals.mojom.h" |
| 38 | #include "content/browser/indexed_db/indexed_db_internals_ui.h" |
Takuto Ikuta | 08008015 | 2024-02-09 09:15:19 | [diff] [blame] | 39 | #include "content/browser/interest_group/ad_auction_service_impl.h" |
Takuto Ikuta | 7cdebf6 | 2024-02-09 09:01:41 | [diff] [blame] | 40 | #include "content/browser/keyboard_lock/keyboard_lock_service_impl.h" |
Hiroki Nakagawa | 761b9b0 | 2020-07-13 11:12:02 | [diff] [blame] | 41 | #include "content/browser/loader/content_security_notifier.h" |
evliu | 5e44d85c | 2021-09-24 22:56:07 | [diff] [blame] | 42 | #include "content/browser/media/media_web_contents_observer.h" |
Johann | a445d5d | 2020-09-15 04:45:27 | [diff] [blame] | 43 | #include "content/browser/media/midi_host.h" |
Mario Sanchez Prada | a00e5616 | 2019-09-28 05:26:57 | [diff] [blame] | 44 | #include "content/browser/media/session/media_session_service_impl.h" |
Takashi Toyoshima | bfc3b281 | 2022-10-07 23:51:37 | [diff] [blame] | 45 | #include "content/browser/network/reporting_service_proxy.h" |
Miyoung Shin | 059c0ff7 | 2019-09-26 11:13:39 | [diff] [blame] | 46 | #include "content/browser/picture_in_picture/picture_in_picture_service_impl.h" |
Iman Saboori | 1607172 | 2022-11-04 14:59:46 | [diff] [blame] | 47 | #include "content/browser/preloading/anchor_element_interaction_host_impl.h" |
Sreeja Kamishetty | 9deccf0f | 2022-07-14 18:12:16 | [diff] [blame] | 48 | #include "content/browser/preloading/speculation_rules/speculation_host_impl.h" |
Dan McArdle | c8fe5af | 2023-11-02 18:59:25 | [diff] [blame] | 49 | #include "content/browser/private_aggregation/private_aggregation_internals.mojom.h" |
| 50 | #include "content/browser/private_aggregation/private_aggregation_internals_ui.h" |
Miyoung Shin | b14602b | 2019-11-19 05:25:51 | [diff] [blame] | 51 | #include "content/browser/process_internals/process_internals.mojom.h" |
| 52 | #include "content/browser/process_internals/process_internals_ui.h" |
Marijn Kruisselbrink | 6058902 | 2022-05-03 19:54:18 | [diff] [blame] | 53 | #include "content/browser/quota/quota_context.h" |
Christine Smith | 0d90bd4e | 2021-12-14 03:24:54 | [diff] [blame] | 54 | #include "content/browser/quota/quota_internals_ui.h" |
danakj | e94b7c84 | 2020-09-16 18:47:43 | [diff] [blame] | 55 | #include "content/browser/renderer_host/clipboard_host_impl.h" |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 56 | #include "content/browser/renderer_host/file_utilities_host_impl.h" |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 57 | #include "content/browser/renderer_host/media/media_devices_dispatcher_host.h" |
| 58 | #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
Tom Sepez | 76125888 | 2022-11-23 23:47:00 | [diff] [blame] | 59 | #include "content/browser/renderer_host/media/media_stream_manager.h" |
Tal Pressman | 06a62f2 | 2021-03-02 04:34:11 | [diff] [blame] | 60 | #include "content/browser/renderer_host/media/video_capture_host.h" |
danakj | e94b7c84 | 2020-09-16 18:47:43 | [diff] [blame] | 61 | #include "content/browser/renderer_host/render_frame_host_impl.h" |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 62 | #include "content/browser/renderer_host/render_process_host_impl.h" |
David Sanders | c7dd8a8 | 2025-07-02 16:59:44 | [diff] [blame] | 63 | #include "content/browser/service_worker/service_worker_context_core.h" |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 64 | #include "content/browser/service_worker/service_worker_host.h" |
dongguoz | 25a9fff | 2025-08-07 11:35:13 | [diff] [blame] | 65 | #include "content/browser/shape_detection/shape_detection_service_host.h" |
Yao Xiao | 94203f5 | 2024-09-13 17:35:57 | [diff] [blame] | 66 | #include "content/browser/shared_storage/shared_storage_worklet_host.h" |
Miyoung Shin | 8f0d858 | 2019-10-02 01:12:28 | [diff] [blame] | 67 | #include "content/browser/speech/speech_recognition_dispatcher_host.h" |
Ari Chivukula | ecfaa9d | 2023-10-26 16:21:21 | [diff] [blame] | 68 | #include "content/browser/storage_access/storage_access_handle.h" |
Etienne Pierre-doray | 6db6af4f | 2025-06-05 14:20:59 | [diff] [blame] | 69 | #include "content/browser/tracing/traces_internals/traces_internals.mojom.h" |
| 70 | #include "content/browser/tracing/traces_internals/traces_internals_ui.h" |
Miyoung Shin | 1dec3c1 | 2019-09-27 02:19:51 | [diff] [blame] | 71 | #include "content/browser/wake_lock/wake_lock_service_impl.h" |
Avi Drissman | bd3e98644 | 2020-05-20 21:09:20 | [diff] [blame] | 72 | #include "content/browser/web_contents/file_chooser_impl.h" |
Miyoung Shin | cb6475a | 2019-11-09 10:49:45 | [diff] [blame] | 73 | #include "content/browser/web_contents/web_contents_impl.h" |
Sam Goto | 2d3ee64 | 2021-01-21 01:27:32 | [diff] [blame] | 74 | #include "content/browser/webid/flags.h" |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 75 | #include "content/browser/worker_host/dedicated_worker_host.h" |
Miyoung Shin | e6ff4b5b | 2019-11-27 17:36:29 | [diff] [blame] | 76 | #include "content/browser/worker_host/shared_worker_connector_impl.h" |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 77 | #include "content/browser/worker_host/shared_worker_host.h" |
Alexander Cooper | 6e5bf7c6 | 2020-04-23 00:40:09 | [diff] [blame] | 78 | #include "content/browser/xr/service/vr_service_impl.h" |
Miyoung Shin | 56d4732 | 2019-12-03 13:01:16 | [diff] [blame] | 79 | #include "content/common/input/input_injector.mojom.h" |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 80 | #include "content/public/browser/browser_thread.h" |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 81 | #include "content/public/browser/content_browser_client.h" |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 82 | #include "content/public/browser/device_service.h" |
Mingyu Lei | 6d78af3 | 2022-11-03 14:50:08 | [diff] [blame] | 83 | #include "content/public/browser/global_routing_id.h" |
Matt Falkenhagen | fc796d6 | 2019-08-22 09:01:26 | [diff] [blame] | 84 | #include "content/public/browser/service_worker_context.h" |
Julie Jeongeun Kim | e58b0f4 | 2021-04-22 05:33:28 | [diff] [blame] | 85 | #include "content/public/browser/service_worker_version_base_info.h" |
Patrick Monette | 986c8c3 | 2019-09-04 05:59:58 | [diff] [blame] | 86 | #include "content/public/browser/shared_worker_instance.h" |
Andrew Rayskiy | ed1d870 | 2022-02-16 13:23:53 | [diff] [blame] | 87 | #include "content/public/browser/site_isolation_policy.h" |
Adrienne Walker | 840d717 | 2020-08-11 05:55:57 | [diff] [blame] | 88 | #include "content/public/browser/storage_partition.h" |
Robert Sesek | 976c70cf | 2022-08-12 19:17:57 | [diff] [blame] | 89 | #include "content/public/browser/web_ui_controller_interface_binder.h" |
Hans Wennborg | 5ffd139 | 2019-10-16 11:00:02 | [diff] [blame] | 90 | #include "content/public/common/content_client.h" |
Miyoung Shin | 97be5ad | 2019-09-27 12:40:54 | [diff] [blame] | 91 | #include "content/public/common/content_features.h" |
Miyoung Shin | b14602b | 2019-11-19 05:25:51 | [diff] [blame] | 92 | #include "content/public/common/url_constants.h" |
Tal Pressman | 78369f6 | 2021-01-06 05:21:53 | [diff] [blame] | 93 | #include "device/gamepad/gamepad_haptics_manager.h" |
Miyoung Shin | c9f4dac | 2019-09-26 15:14:10 | [diff] [blame] | 94 | #include "device/gamepad/gamepad_monitor.h" |
| 95 | #include "device/gamepad/public/mojom/gamepad.mojom.h" |
Alexander Cooper | 6e5bf7c6 | 2020-04-23 00:40:09 | [diff] [blame] | 96 | #include "device/vr/buildflags/buildflags.h" |
Miyoung Shin | 87cd452 | 2019-10-04 05:00:05 | [diff] [blame] | 97 | #include "device/vr/public/mojom/vr_service.mojom.h" |
Mario Sanchez Prada | aa35b42 | 2019-09-24 06:50:31 | [diff] [blame] | 98 | #include "media/capture/mojom/image_capture.mojom.h" |
Tal Pressman | 06a62f2 | 2021-03-02 04:34:11 | [diff] [blame] | 99 | #include "media/capture/mojom/video_capture.mojom.h" |
Daniel Cheng | 08fa43f1 | 2022-11-24 15:19:09 | [diff] [blame] | 100 | #include "media/midi/midi_service.h" |
Lei Zhang | d9e3fc5 | 2021-08-25 03:08:40 | [diff] [blame] | 101 | #include "media/mojo/mojom/interface_factory.mojom.h" |
Feras Aldahlawi | d996da75 | 2024-04-04 19:27:29 | [diff] [blame] | 102 | #include "media/mojo/mojom/key_system_support.mojom.h" |
Miyoung Shin | ce54860 | 2019-12-03 04:05:49 | [diff] [blame] | 103 | #include "media/mojo/mojom/media_metrics_provider.mojom.h" |
evliu | 5e44d85c | 2021-09-24 22:56:07 | [diff] [blame] | 104 | #include "media/mojo/mojom/media_player.mojom.h" |
Hans Wennborg | 8ee798d | 2020-02-07 15:30:35 | [diff] [blame] | 105 | #include "media/mojo/mojom/remoting.mojom.h" |
Evan Liu | d725228 | 2024-05-16 20:10:32 | [diff] [blame] | 106 | #include "media/mojo/mojom/speech_recognizer.mojom.h" |
Mario Sanchez Prada | 416cfd4 | 2019-09-30 15:15:29 | [diff] [blame] | 107 | #include "media/mojo/mojom/video_decode_perf_history.mojom.h" |
Hirokazu Honda | 09fab5f | 2023-06-13 02:40:10 | [diff] [blame] | 108 | #include "media/mojo/mojom/video_encoder_metrics_provider.mojom.h" |
Johannes Kron | b1209bd | 2022-02-15 10:32:39 | [diff] [blame] | 109 | #include "media/mojo/mojom/webrtc_video_perf.mojom.h" |
Hirokazu Honda | 2f21b044 | 2023-08-02 04:47:01 | [diff] [blame] | 110 | #include "media/mojo/services/mojo_video_encoder_metrics_provider_service.h" |
Johannes Kron | b1209bd | 2022-02-15 10:32:39 | [diff] [blame] | 111 | #include "media/mojo/services/webrtc_video_perf_recorder.h" |
François Doray | 869d4bf | 2025-06-30 21:20:11 | [diff] [blame] | 112 | #include "mojo/public/cpp/bindings/binder_map.h" |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 113 | #include "mojo/public/cpp/bindings/message.h" |
Fergal Daly | b65f07b | 2024-12-09 07:52:38 | [diff] [blame] | 114 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
Nan Lin | 0aa0aa2 | 2023-09-05 20:01:25 | [diff] [blame] | 115 | #include "net/base/features.h" |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 116 | #include "services/device/public/cpp/compute_pressure/buildflags.h" |
Johann | 165093e3 | 2020-11-18 04:25:30 | [diff] [blame] | 117 | #include "services/device/public/mojom/battery_monitor.mojom.h" |
Miyoung Shin | 090544a4 | 2019-09-26 03:48:16 | [diff] [blame] | 118 | #include "services/device/public/mojom/vibration_manager.mojom.h" |
Alex Turner | 7ea6baaf | 2020-09-23 15:23:41 | [diff] [blame] | 119 | #include "services/metrics/public/mojom/ukm_interface.mojom.h" |
Aman Verma | 8c1c5e61 | 2023-04-03 23:33:58 | [diff] [blame] | 120 | #include "services/metrics/ukm_recorder_factory_impl.h" |
Sandor Major | f42e6bd6 | 2025-02-28 00:12:04 | [diff] [blame] | 121 | #include "services/network/public/cpp/features.h" |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 122 | #include "services/network/public/cpp/is_potentially_trustworthy.h" |
Tal Pressman | 6b5c300 | 2021-05-13 06:48:09 | [diff] [blame] | 123 | #include "services/network/public/mojom/p2p.mojom.h" |
Sandor «Alex» Major | c41217f | 2025-02-14 23:33:13 | [diff] [blame] | 124 | #include "services/network/public/mojom/permissions_policy/permissions_policy_feature.mojom.h" |
Miyoung Shin | 58d0b6c | 2019-12-03 07:38:18 | [diff] [blame] | 125 | #include "services/network/public/mojom/restricted_cookie_manager.mojom.h" |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 126 | #include "services/shape_detection/public/mojom/barcodedetection_provider.mojom.h" |
| 127 | #include "services/shape_detection/public/mojom/facedetection_provider.mojom.h" |
| 128 | #include "services/shape_detection/public/mojom/shape_detection_service.mojom.h" |
| 129 | #include "services/shape_detection/public/mojom/textdetection.mojom.h" |
Austin Sullivan | d57e157 | 2024-06-24 20:53:16 | [diff] [blame] | 130 | #include "services/webnn/public/mojom/features.mojom-features.h" |
junwei | cdff0aee | 2024-03-26 05:40:31 | [diff] [blame] | 131 | #include "services/webnn/public/mojom/webnn_context_provider.mojom.h" |
Christine Smith | 0d90bd4e | 2021-12-14 03:24:54 | [diff] [blame] | 132 | #include "storage/browser/quota/quota_internals.mojom.h" |
| 133 | #include "storage/browser/quota/quota_manager.h" |
| 134 | #include "storage/browser/quota/quota_manager_proxy.h" |
Miyoung Shin | 1395210d | 2019-11-22 04:36:21 | [diff] [blame] | 135 | #include "third_party/blink/public/common/features.h" |
Mingyu Lei | eca89f2 | 2024-01-15 04:44:51 | [diff] [blame] | 136 | #include "third_party/blink/public/common/features_generated.h" |
Joshua Hood | bd47013d | 2022-01-06 19:45:04 | [diff] [blame] | 137 | #include "third_party/blink/public/common/storage_key/storage_key.h" |
Mingyu Lei | 9de94c6 | 2024-05-29 07:14:42 | [diff] [blame] | 138 | #include "third_party/blink/public/mojom/ai/ai_manager.mojom.h" |
Mario Sanchez Prada | 3532f44 | 2019-09-10 08:28:08 | [diff] [blame] | 139 | #include "third_party/blink/public/mojom/background_fetch/background_fetch.mojom.h" |
Lingqi Chi | bcc673e | 2020-09-16 03:12:03 | [diff] [blame] | 140 | #include "third_party/blink/public/mojom/background_sync/background_sync.mojom.h" |
Andrew Williams | 39151a7 | 2022-10-18 23:12:41 | [diff] [blame] | 141 | #include "third_party/blink/public/mojom/blob/blob_url_store.mojom.h" |
Daniel Brinkers | 9004610c | 2023-10-23 15:27:51 | [diff] [blame] | 142 | #include "third_party/blink/public/mojom/blob/file_backed_blob_factory.mojom.h" |
Mario Sanchez Prada | 19294b5 | 2019-09-24 10:57:14 | [diff] [blame] | 143 | #include "third_party/blink/public/mojom/bluetooth/web_bluetooth.mojom.h" |
Ayu Ishii | 1d05bfe9 | 2021-02-02 21:42:33 | [diff] [blame] | 144 | #include "third_party/blink/public/mojom/buckets/bucket_manager_host.mojom.h" |
Mario Sanchez Prada | c71a630 | 2019-11-25 14:47:20 | [diff] [blame] | 145 | #include "third_party/blink/public/mojom/cache_storage/cache_storage.mojom.h" |
Miyoung Shin | cb6475a | 2019-11-09 10:49:45 | [diff] [blame] | 146 | #include "third_party/blink/public/mojom/choosers/color_chooser.mojom.h" |
Lei Zhang | 059bf73e | 2021-05-19 18:29:53 | [diff] [blame] | 147 | #include "third_party/blink/public/mojom/contacts/contacts_manager.mojom.h" |
Miyoung Shin | f9dd145 | 2019-09-24 12:57:46 | [diff] [blame] | 148 | #include "third_party/blink/public/mojom/content_index/content_index.mojom.h" |
Victor Costan | 31ca3d2 | 2019-10-11 02:33:37 | [diff] [blame] | 149 | #include "third_party/blink/public/mojom/cookie_store/cookie_store.mojom.h" |
Arthur Sonzogni | fc9275f | 2022-03-17 09:43:14 | [diff] [blame] | 150 | #include "third_party/blink/public/mojom/credentialmanagement/credential_manager.mojom.h" |
Anatoliy Potapchuk | 096e4d0a | 2020-12-01 16:49:21 | [diff] [blame] | 151 | #include "third_party/blink/public/mojom/device/device.mojom.h" |
Adrienne Walker | 80d95f0 | 2020-02-07 22:37:04 | [diff] [blame] | 152 | #include "third_party/blink/public/mojom/feature_observer/feature_observer.mojom.h" |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 153 | #include "third_party/blink/public/mojom/file/file_utilities.mojom.h" |
Austin Sullivan | d35c3346 | 2021-01-06 21:16:32 | [diff] [blame] | 154 | #include "third_party/blink/public/mojom/file_system_access/file_system_access_manager.mojom.h" |
Mario Sanchez Prada | 3532f44 | 2019-09-10 08:28:08 | [diff] [blame] | 155 | #include "third_party/blink/public/mojom/filesystem/file_system.mojom.h" |
Lei Zhang | 059bf73e | 2021-05-19 18:29:53 | [diff] [blame] | 156 | #include "third_party/blink/public/mojom/font_access/font_access.mojom.h" |
Minoru Chikamune | c2d363c | 2022-11-28 08:26:24 | [diff] [blame] | 157 | #include "third_party/blink/public/mojom/frame/frame.mojom.h" |
Mario Sanchez Prada | fa6dda8c | 2019-11-25 18:20:19 | [diff] [blame] | 158 | #include "third_party/blink/public/mojom/geolocation/geolocation_service.mojom.h" |
Mario Sanchez Prada | 3532f44 | 2019-09-10 08:28:08 | [diff] [blame] | 159 | #include "third_party/blink/public/mojom/idle/idle_manager.mojom.h" |
Francois Doray | 1be23f1 | 2019-10-01 16:37:51 | [diff] [blame] | 160 | #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h" |
Oksana Zhuravlova | 963e24e | 2020-03-10 02:38:29 | [diff] [blame] | 161 | #include "third_party/blink/public/mojom/input/input_host.mojom.h" |
Miyoung Shin | 8989f09 | 2019-09-26 06:13:12 | [diff] [blame] | 162 | #include "third_party/blink/public/mojom/keyboard_lock/keyboard_lock.mojom.h" |
Kouhei Ueno | 94a25ff | 2023-06-09 06:25:04 | [diff] [blame] | 163 | #include "third_party/blink/public/mojom/lcp_critical_path_predictor/lcp_critical_path_predictor.mojom.h" |
Mythri A | fefc0c46 | 2021-05-26 08:37:26 | [diff] [blame] | 164 | #include "third_party/blink/public/mojom/loader/code_cache.mojom.h" |
Hiroki Nakagawa | 761b9b0 | 2020-07-13 11:12:02 | [diff] [blame] | 165 | #include "third_party/blink/public/mojom/loader/content_security_notifier.mojom.h" |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 166 | #include "third_party/blink/public/mojom/loader/navigation_predictor.mojom.h" |
Oksana Zhuravlova | 4a9804e | 2019-09-11 19:35:50 | [diff] [blame] | 167 | #include "third_party/blink/public/mojom/locks/lock_manager.mojom.h" |
Guido Urdaneta | 3a7cd9e6 | 2020-07-21 08:31:28 | [diff] [blame] | 168 | #include "third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom.h" |
Guido Urdaneta | 9d773b1 | 2020-07-21 08:45:45 | [diff] [blame] | 169 | #include "third_party/blink/public/mojom/media/renderer_audio_output_stream_factory.mojom.h" |
Mario Sanchez Prada | a00e5616 | 2019-09-28 05:26:57 | [diff] [blame] | 170 | #include "third_party/blink/public/mojom/mediasession/media_session.mojom.h" |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 171 | #include "third_party/blink/public/mojom/mediastream/media_devices.mojom.h" |
| 172 | #include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h" |
Miyoung Shin | db479fec4 | 2019-11-22 06:29:20 | [diff] [blame] | 173 | #include "third_party/blink/public/mojom/notifications/notification_service.mojom.h" |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 174 | #include "third_party/blink/public/mojom/on_device_translation/translation_manager.mojom.h" |
Jason Chase | 1439d2fe | 2024-10-16 17:12:51 | [diff] [blame] | 175 | #include "third_party/blink/public/mojom/origin_trials/origin_trial_state_host.mojom.h" |
Miyoung Shin | 8aa77f29 | 2019-09-27 10:46:46 | [diff] [blame] | 176 | #include "third_party/blink/public/mojom/payments/payment_app.mojom.h" |
Stephen McGruer | 18ed1a06 | 2025-01-20 20:18:52 | [diff] [blame] | 177 | #include "third_party/blink/public/mojom/payments/secure_payment_confirmation_service.mojom.h" |
Tal Pressman | d7f6d6f | 2021-03-02 00:10:04 | [diff] [blame] | 178 | #include "third_party/blink/public/mojom/peerconnection/peer_connection_tracker.mojom.h" |
Miyoung Shin | e676be1f | 2019-09-25 00:47:02 | [diff] [blame] | 179 | #include "third_party/blink/public/mojom/permissions/permission.mojom.h" |
Miyoung Shin | 059c0ff7 | 2019-09-26 11:13:39 | [diff] [blame] | 180 | #include "third_party/blink/public/mojom/picture_in_picture/picture_in_picture.mojom.h" |
Iman Saboori | 1607172 | 2022-11-04 14:59:46 | [diff] [blame] | 181 | #include "third_party/blink/public/mojom/preloading/anchor_element_interaction_host.mojom.h" |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 182 | #include "third_party/blink/public/mojom/prerender/prerender.mojom.h" |
Mario Sanchez Prada | 3532f44 | 2019-09-10 08:28:08 | [diff] [blame] | 183 | #include "third_party/blink/public/mojom/presentation/presentation.mojom.h" |
Hans Wennborg | 78b5218 | 2021-06-15 13:42:15 | [diff] [blame] | 184 | #include "third_party/blink/public/mojom/push_messaging/push_messaging.mojom.h" |
Victor Costan | 52fc24b | 2020-03-12 23:36:59 | [diff] [blame] | 185 | #include "third_party/blink/public/mojom/quota/quota_manager_host.mojom.h" |
Raphael Kubo da Costa | 73975654 | 2023-10-06 22:41:53 | [diff] [blame] | 186 | #include "third_party/blink/public/mojom/sensor/web_sensor_provider.mojom.h" |
Garfield Tan | 6aba003 | 2025-02-14 02:07:35 | [diff] [blame] | 187 | #include "third_party/blink/public/mojom/serial/serial.mojom.h" |
Majid Valipour | ae11335e | 2020-10-14 04:09:24 | [diff] [blame] | 188 | #include "third_party/blink/public/mojom/sms/webotp_service.mojom.h" |
Lingqi Chi | eed2ceb | 2021-05-19 11:31:46 | [diff] [blame] | 189 | #include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h" |
Darin Fisher | a26aa7e | 2019-09-02 20:22:59 | [diff] [blame] | 190 | #include "third_party/blink/public/mojom/speech/speech_synthesis.mojom.h" |
Ari Chivukula | ecfaa9d | 2023-10-26 16:21:21 | [diff] [blame] | 191 | #include "third_party/blink/public/mojom/storage_access/storage_access_handle.mojom.h" |
Miyoung Shin | 12048384 | 2019-10-08 06:59:41 | [diff] [blame] | 192 | #include "third_party/blink/public/mojom/usb/web_usb_service.mojom.h" |
Miyoung Shin | 1dec3c1 | 2019-09-27 02:19:51 | [diff] [blame] | 193 | #include "third_party/blink/public/mojom/wake_lock/wake_lock.mojom.h" |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 194 | #include "third_party/blink/public/mojom/webaudio/audio_context_manager.mojom.h" |
Oksana Zhuravlova | 567040b | 2019-09-25 20:45:22 | [diff] [blame] | 195 | #include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h" |
Peter Kotwicz | 3a1ff04 | 2024-02-07 20:50:39 | [diff] [blame] | 196 | #include "third_party/blink/public/mojom/webid/digital_identity_request.mojom.h" |
Ken Buchanan | c47efed | 2020-11-05 23:07:17 | [diff] [blame] | 197 | #include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h" |
Miyoung Shin | e5cb8f1 | 2019-11-27 16:40:54 | [diff] [blame] | 198 | #include "third_party/blink/public/mojom/websockets/websocket_connector.mojom.h" |
Adam Rice | e98a2232 | 2021-04-27 08:26:26 | [diff] [blame] | 199 | #include "third_party/blink/public/mojom/webtransport/web_transport_connector.mojom.h" |
Miyoung Shin | 996cb65 | 2019-11-28 03:27:22 | [diff] [blame] | 200 | #include "third_party/blink/public/mojom/worker/dedicated_worker_host_factory.mojom.h" |
Miyoung Shin | e6ff4b5b | 2019-11-27 17:36:29 | [diff] [blame] | 201 | #include "third_party/blink/public/mojom/worker/shared_worker_connector.mojom.h" |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 202 | #include "third_party/blink/public/public_buildflags.h" |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 203 | #include "url/origin.h" |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 204 | |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 205 | #if BUILDFLAG(IS_ANDROID) |
Miyoung Shin | 192c780 | 2020-01-17 10:32:27 | [diff] [blame] | 206 | #include "content/browser/android/text_suggestion_host_android.h" |
Miyoung Shin | 0c2012b | 2019-10-31 08:03:05 | [diff] [blame] | 207 | #include "content/browser/renderer_host/render_widget_host_view_android.h" |
Dave Tapuska | 20433a5 | 2023-11-06 22:02:39 | [diff] [blame] | 208 | #include "content/common/gin_java_bridge.mojom.h" |
Miyoung Shin | b5630d7 | 2019-09-26 13:11:45 | [diff] [blame] | 209 | #include "services/device/public/mojom/nfc.mojom.h" |
Miyoung Shin | 74a9bdcc | 2019-10-01 01:59:05 | [diff] [blame] | 210 | #include "third_party/blink/public/mojom/hid/hid.mojom.h" |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 211 | #include "third_party/blink/public/mojom/unhandled_tap_notifier/unhandled_tap_notifier.mojom.h" |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 212 | #else // BUILDFLAG(IS_ANDROID) |
Lei Zhang | 0c429ef | 2021-07-16 23:40:16 | [diff] [blame] | 213 | #include "content/browser/direct_sockets/direct_sockets_service_impl.h" |
Evan Liu | d1ebc4e0a | 2022-04-29 20:57:54 | [diff] [blame] | 214 | #include "media/mojo/mojom/renderer_extensions.mojom.h" |
Andrew Moylan | aad6265f | 2022-06-07 03:52:56 | [diff] [blame] | 215 | #include "media/mojo/mojom/speech_recognition.mojom.h" // nogncheck |
Lei Zhang | 0c429ef | 2021-07-16 23:40:16 | [diff] [blame] | 216 | #include "third_party/blink/public/mojom/hid/hid.mojom.h" |
| 217 | #include "third_party/blink/public/mojom/installedapp/installed_app_provider.mojom.h" |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 218 | #endif // BUILDFLAG(IS_ANDROID) |
Miyoung Shin | b5630d7 | 2019-09-26 13:11:45 | [diff] [blame] | 219 | |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 220 | #if BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
| 221 | #include "content/browser/compute_pressure/pressure_service_for_frame.h" |
| 222 | #include "third_party/blink/public/mojom/compute_pressure/web_pressure_manager.mojom.h" |
| 223 | #endif // BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
| 224 | |
Julie Jeongeun Kim | eac2fe2 | 2023-07-18 11:55:02 | [diff] [blame] | 225 | #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) |
| 226 | #include "content/browser/date_time_chooser/date_time_chooser.h" |
| 227 | #endif |
| 228 | |
Miyoung Shin | 09b6456 | 2019-11-28 02:49:02 | [diff] [blame] | 229 | #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 230 | #include "media/mojo/mojom/remoting.mojom-forward.h" |
| 231 | #endif |
| 232 | |
Mahmoud Ahmed | c4eee9a3 | 2023-07-21 17:19:24 | [diff] [blame] | 233 | #if BUILDFLAG(ENABLE_VR) |
| 234 | #include "content/browser/xr/webxr_internals/mojom/webxr_internals.mojom.h" |
| 235 | #include "content/browser/xr/webxr_internals/webxr_internals_ui.h" |
| 236 | #endif |
| 237 | |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 238 | #if BUILDFLAG(IS_MAC) |
Julie Jeongeun Kim | 8e157b2 | 2020-04-22 04:02:41 | [diff] [blame] | 239 | #include "content/browser/renderer_host/text_input_host_impl.h" |
Phillis Tang | 4247919 | 2025-02-09 06:02:06 | [diff] [blame] | 240 | #include "services/webnn/public/cpp/coreml_initializer.h" |
Julie Jeongeun Kim | 8e157b2 | 2020-04-22 04:02:41 | [diff] [blame] | 241 | #include "third_party/blink/public/mojom/input/text_input_host.mojom.h" |
| 242 | #endif |
| 243 | |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 244 | #if BUILDFLAG(IS_CHROMEOS) |
Raymes Khoury | e24e0a9 | 2021-12-20 01:16:16 | [diff] [blame] | 245 | #include "content/browser/lock_screen/lock_screen_service_impl.h" |
| 246 | #include "third_party/blink/public/mojom/lock_screen/lock_screen.mojom.h" |
Daniel d'Andrada | 8ed516f | 2023-02-28 15:46:16 | [diff] [blame] | 247 | #include "third_party/blink/public/mojom/smart_card/smart_card.mojom.h" |
Sergey Ulanov | ff752e4a | 2022-04-06 23:04:36 | [diff] [blame] | 248 | #endif |
| 249 | |
| 250 | #if BUILDFLAG(IS_FUCHSIA) |
Guocheng Wei | b4535741 | 2022-11-28 23:39:54 | [diff] [blame] | 251 | #include "content/browser/renderer_host/media/fuchsia_media_cdm_provider_impl.h" |
Sergey Ulanov | 385c553 | 2023-02-15 07:24:10 | [diff] [blame] | 252 | #include "media/mojo/mojom/fuchsia_media.mojom.h" |
Sergey Ulanov | ff752e4a | 2022-04-06 23:04:36 | [diff] [blame] | 253 | #endif |
Raymes Khoury | e24e0a9 | 2021-12-20 01:16:16 | [diff] [blame] | 254 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 255 | namespace blink { |
| 256 | class StorageKey; |
| 257 | } // namespace blink |
| 258 | |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 259 | namespace content { |
| 260 | namespace internal { |
| 261 | |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 262 | namespace { |
| 263 | |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 264 | void BindBarcodeDetectionProvider( |
| 265 | mojo::PendingReceiver<shape_detection::mojom::BarcodeDetectionProvider> |
| 266 | receiver) { |
| 267 | GetShapeDetectionService()->BindBarcodeDetectionProvider(std::move(receiver)); |
| 268 | } |
| 269 | |
| 270 | void BindFaceDetectionProvider( |
| 271 | mojo::PendingReceiver<shape_detection::mojom::FaceDetectionProvider> |
| 272 | receiver) { |
| 273 | GetShapeDetectionService()->BindFaceDetectionProvider(std::move(receiver)); |
| 274 | } |
| 275 | |
| 276 | void BindTextDetection( |
| 277 | mojo::PendingReceiver<shape_detection::mojom::TextDetection> receiver) { |
| 278 | GetShapeDetectionService()->BindTextDetection(std::move(receiver)); |
| 279 | } |
| 280 | |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 281 | void BindWebNNContextProviderForRenderFrame( |
Enrico Galli | ccbdee2 | 2023-09-08 00:26:16 | [diff] [blame] | 282 | RenderFrameHost* host, |
junwei | d4ed5a81 | 2023-04-19 03:19:26 | [diff] [blame] | 283 | mojo::PendingReceiver<webnn::mojom::WebNNContextProvider> receiver) { |
Enrico Galli | ccbdee2 | 2023-09-08 00:26:16 | [diff] [blame] | 284 | auto* process_host = static_cast<RenderProcessHostImpl*>(host->GetProcess()); |
Phillis Tang | 4247919 | 2025-02-09 06:02:06 | [diff] [blame] | 285 | #if BUILDFLAG(IS_MAC) |
| 286 | webnn::InitializeCacheDirAndRun(base::BindOnce( |
| 287 | &viz::GpuClient::BindWebNNContextProvider, |
| 288 | process_host->GetGpuClient()->GetWeakPtr(), std::move(receiver))); |
| 289 | #else |
Enrico Galli | ccbdee2 | 2023-09-08 00:26:16 | [diff] [blame] | 290 | process_host->GetGpuClient()->BindWebNNContextProvider(std::move(receiver)); |
Phillis Tang | 4247919 | 2025-02-09 06:02:06 | [diff] [blame] | 291 | #endif |
junwei | d4ed5a81 | 2023-04-19 03:19:26 | [diff] [blame] | 292 | } |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 293 | |
Joshua Bell | bc43ccf | 2025-03-05 23:21:22 | [diff] [blame] | 294 | template <typename WorkerHost> |
| 295 | void BindWebNNContextProviderForWorker( |
| 296 | WorkerHost* host, |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 297 | mojo::PendingReceiver<webnn::mojom::WebNNContextProvider> receiver) { |
| 298 | auto* process_host = |
| 299 | static_cast<RenderProcessHostImpl*>(host->GetProcessHost()); |
Phillis Tang | 4247919 | 2025-02-09 06:02:06 | [diff] [blame] | 300 | #if BUILDFLAG(IS_MAC) |
| 301 | webnn::InitializeCacheDirAndRun(base::BindOnce( |
| 302 | &viz::GpuClient::BindWebNNContextProvider, |
| 303 | process_host->GetGpuClient()->GetWeakPtr(), std::move(receiver))); |
| 304 | #else |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 305 | process_host->GetGpuClient()->BindWebNNContextProvider(std::move(receiver)); |
Phillis Tang | 4247919 | 2025-02-09 06:02:06 | [diff] [blame] | 306 | #endif |
junwei | cdff0aee | 2024-03-26 05:40:31 | [diff] [blame] | 307 | } |
junwei | d4ed5a81 | 2023-04-19 03:19:26 | [diff] [blame] | 308 | |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 309 | #if BUILDFLAG(IS_MAC) |
Julie Jeongeun Kim | 8e157b2 | 2020-04-22 04:02:41 | [diff] [blame] | 310 | void BindTextInputHost( |
| 311 | mojo::PendingReceiver<blink::mojom::TextInputHost> receiver) { |
Gabriel Charette | e7cdc5cd | 2020-05-27 23:35:05 | [diff] [blame] | 312 | GetIOThreadTaskRunner({})->PostTask( |
| 313 | FROM_HERE, |
Julie Jeongeun Kim | 8e157b2 | 2020-04-22 04:02:41 | [diff] [blame] | 314 | base::BindOnce(&TextInputHostImpl::Create, std::move(receiver))); |
| 315 | } |
| 316 | #endif |
| 317 | |
Aman Verma | 8c1c5e61 | 2023-04-03 23:33:58 | [diff] [blame] | 318 | void BindUkmRecorderFactory( |
| 319 | mojo::PendingReceiver<ukm::mojom::UkmRecorderFactory> receiver) { |
| 320 | metrics::UkmRecorderFactoryImpl::Create(ukm::UkmRecorder::Get(), |
| 321 | std::move(receiver)); |
Alex Turner | 7ea6baaf | 2020-09-23 15:23:41 | [diff] [blame] | 322 | } |
| 323 | |
Miyoung Shin | cb6475a | 2019-11-09 10:49:45 | [diff] [blame] | 324 | void BindColorChooserFactoryForFrame( |
| 325 | RenderFrameHost* host, |
| 326 | mojo::PendingReceiver<blink::mojom::ColorChooserFactory> receiver) { |
| 327 | auto* web_contents = |
| 328 | static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host)); |
| 329 | web_contents->OnColorChooserFactoryReceiver(std::move(receiver)); |
| 330 | } |
| 331 | |
Victor Costan | 52fc24b | 2020-03-12 23:36:59 | [diff] [blame] | 332 | void BindQuotaManagerHost( |
Marijn Kruisselbrink | 6058902 | 2022-05-03 19:54:18 | [diff] [blame] | 333 | RenderFrameHostImpl* host, |
Victor Costan | 52fc24b | 2020-03-12 23:36:59 | [diff] [blame] | 334 | mojo::PendingReceiver<blink::mojom::QuotaManagerHost> receiver) { |
Marijn Kruisselbrink | 6058902 | 2022-05-03 19:54:18 | [diff] [blame] | 335 | host->GetStoragePartition()->GetQuotaContext()->BindQuotaManagerHost( |
Mariam Ali | 8338d9fa | 2023-07-24 16:57:31 | [diff] [blame] | 336 | host->GetStorageKey(), std::move(receiver)); |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 337 | } |
| 338 | |
Miyoung Shin | e6ff4b5b | 2019-11-27 17:36:29 | [diff] [blame] | 339 | void BindSharedWorkerConnector( |
| 340 | RenderFrameHostImpl* host, |
| 341 | mojo::PendingReceiver<blink::mojom::SharedWorkerConnector> receiver) { |
Alexander Timin | 8690530c | 2021-06-19 00:34:32 | [diff] [blame] | 342 | SharedWorkerConnectorImpl::Create(host->GetGlobalId(), std::move(receiver)); |
Miyoung Shin | e6ff4b5b | 2019-11-27 17:36:29 | [diff] [blame] | 343 | } |
| 344 | |
Gyuyoung Kim | 3bd4ce0 | 2025-06-25 21:28:01 | [diff] [blame] | 345 | #if BUILDFLAG(IS_ANDROID) || (BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)) |
Oksana Zhuravlova | 0b63433 | 2019-10-28 23:04:22 | [diff] [blame] | 346 | void BindDateTimeChooserForFrame( |
Victor Costan | dbb6677 | 2021-10-27 21:00:50 | [diff] [blame] | 347 | RenderFrameHost* host, |
Oksana Zhuravlova | 0b63433 | 2019-10-28 23:04:22 | [diff] [blame] | 348 | mojo::PendingReceiver<blink::mojom::DateTimeChooser> receiver) { |
Julie Jeongeun Kim | d6a3c1fc | 2023-07-15 08:37:03 | [diff] [blame] | 349 | auto* date_time_chooser = DateTimeChooser::GetDateTimeChooser( |
Oksana Zhuravlova | 0b63433 | 2019-10-28 23:04:22 | [diff] [blame] | 350 | WebContents::FromRenderFrameHost(host)); |
| 351 | date_time_chooser->OnDateTimeChooserReceiver(std::move(receiver)); |
| 352 | } |
Julie Jeongeun Kim | eac2fe2 | 2023-07-18 11:55:02 | [diff] [blame] | 353 | #endif |
Miyoung Shin | 0c2012b | 2019-10-31 08:03:05 | [diff] [blame] | 354 | |
Julie Jeongeun Kim | eac2fe2 | 2023-07-18 11:55:02 | [diff] [blame] | 355 | #if BUILDFLAG(IS_ANDROID) |
Miyoung Shin | 0c2012b | 2019-10-31 08:03:05 | [diff] [blame] | 356 | void BindTextSuggestionHostForFrame( |
Victor Costan | dbb6677 | 2021-10-27 21:00:50 | [diff] [blame] | 357 | RenderFrameHost* host, |
Miyoung Shin | 0c2012b | 2019-10-31 08:03:05 | [diff] [blame] | 358 | mojo::PendingReceiver<blink::mojom::TextSuggestionHost> receiver) { |
Jinsuk Kim | 7a7e482 | 2023-11-08 19:19:22 | [diff] [blame] | 359 | auto* view = |
| 360 | RenderWidgetHostViewAndroid::FromRenderWidgetHostView(host->GetView()); |
Miyoung Shin | ce932c76b | 2020-08-25 20:49:42 | [diff] [blame] | 361 | if (!view || !view->text_suggestion_host()) |
Oksana Zhuravlova | e830d58 | 2019-12-19 23:01:16 | [diff] [blame] | 362 | return; |
| 363 | |
Miyoung Shin | 192c780 | 2020-01-17 10:32:27 | [diff] [blame] | 364 | view->text_suggestion_host()->BindTextSuggestionHost(std::move(receiver)); |
Miyoung Shin | 0c2012b | 2019-10-31 08:03:05 | [diff] [blame] | 365 | } |
Oksana Zhuravlova | 0b63433 | 2019-10-28 23:04:22 | [diff] [blame] | 366 | #endif |
| 367 | |
Tal Pressman | e2123a8e | 2021-07-21 09:11:13 | [diff] [blame] | 368 | // Get the service worker's worker process ID and post a task to bind the |
| 369 | // receiver on a USER_VISIBLE task runner. |
| 370 | // This is necessary because: |
| 371 | // - Binding the host itself and checking the ID on the task's thread may cause |
| 372 | // a UAF if the host has been deleted in the meantime. |
| 373 | // - The process ID is not yet populated at the time `PopulateInterfaceBinders` |
| 374 | // is called. |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 375 | void BindFileUtilitiesHost( |
Tal Pressman | e2123a8e | 2021-07-21 09:11:13 | [diff] [blame] | 376 | ServiceWorkerHost* host, |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 377 | mojo::PendingReceiver<blink::mojom::FileUtilitiesHost> receiver) { |
Tal Pressman | e2123a8e | 2021-07-21 09:11:13 | [diff] [blame] | 378 | auto task_runner = base::ThreadPool::CreateSequencedTaskRunner( |
| 379 | {base::MayBlock(), base::TaskPriority::USER_VISIBLE}); |
| 380 | task_runner->PostTask( |
| 381 | FROM_HERE, |
| 382 | base::BindOnce(&FileUtilitiesHostImpl::Create, host->worker_process_id(), |
| 383 | std::move(receiver))); |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 384 | } |
| 385 | |
Andrew Williams | fc09056 | 2022-12-05 17:53:48 | [diff] [blame] | 386 | // The following two functions bind the RenderFrameHost ID, the storage key, and |
| 387 | // the notification service creator type to the notification service creation |
Mingyu Lei | 6d78af3 | 2022-11-03 14:50:08 | [diff] [blame] | 388 | // function. The RenderFrameHost ID is used instead of the pointer because the |
| 389 | // WorkerHost may outlive the RenderFrameHost and thus causing UAF issue when |
| 390 | // the callback runs. |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 391 | template <typename WorkerHost> |
| 392 | base::RepeatingCallback< |
Andrew Williams | fc09056 | 2022-12-05 17:53:48 | [diff] [blame] | 393 | void(mojo::PendingReceiver<blink::mojom::NotificationService>)> |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 394 | BindNotificationService( |
Mingyu Lei | 6d78af3 | 2022-11-03 14:50:08 | [diff] [blame] | 395 | GlobalRenderFrameHostId rfh_id, |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 396 | RenderProcessHost::NotificationServiceCreatorType creator_type, |
| 397 | WorkerHost* host) { |
| 398 | DCHECK_NE(creator_type, |
| 399 | RenderProcessHost::NotificationServiceCreatorType::kServiceWorker); |
| 400 | return base::BindRepeating( |
Mingyu Lei | 6d78af3 | 2022-11-03 14:50:08 | [diff] [blame] | 401 | [](WorkerHost* host, GlobalRenderFrameHostId rfh_id, |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 402 | RenderProcessHost::NotificationServiceCreatorType creator_type, |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 403 | mojo::PendingReceiver<blink::mojom::NotificationService> receiver) { |
| 404 | auto* process_host = |
| 405 | static_cast<RenderProcessHostImpl*>(host->GetProcessHost()); |
| 406 | CHECK(process_host); |
Andrew Williams | fc09056 | 2022-12-05 17:53:48 | [diff] [blame] | 407 | process_host->CreateNotificationService( |
| 408 | rfh_id, creator_type, host->GetStorageKey(), std::move(receiver)); |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 409 | }, |
Mingyu Lei | 6d78af3 | 2022-11-03 14:50:08 | [diff] [blame] | 410 | base::Unretained(host), rfh_id, creator_type); |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 411 | } |
| 412 | |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 413 | base::RepeatingCallback< |
| 414 | void(const ServiceWorkerVersionBaseInfo&, |
| 415 | mojo::PendingReceiver<blink::mojom::NotificationService>)> |
| 416 | BindNotificationService(ServiceWorkerHost* host) { |
| 417 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 418 | return base::BindRepeating( |
| 419 | [](ServiceWorkerHost* host, const ServiceWorkerVersionBaseInfo& info, |
| 420 | mojo::PendingReceiver<blink::mojom::NotificationService> receiver) { |
| 421 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 422 | auto* process_host = static_cast<RenderProcessHostImpl*>( |
| 423 | RenderProcessHost::FromID(host->worker_process_id())); |
Mingyu Lei | 38c67be | 2023-01-20 07:52:55 | [diff] [blame] | 424 | |
| 425 | // It's possible that the callback is run between the destruction of the |
| 426 | // RenderProcessHost and the disconnection of the ServiceWorkerHost, so |
| 427 | // we should add the check here to avoid unexpected behaviour if the |
| 428 | // `process_host` is cast from a nullptr. |
| 429 | // See `ServiceWorkerHost::GetStoragePartition()`. |
| 430 | if (process_host) { |
| 431 | process_host->CreateNotificationService( |
| 432 | GlobalRenderFrameHostId(), |
| 433 | RenderProcessHost::NotificationServiceCreatorType::kServiceWorker, |
| 434 | info.storage_key, std::move(receiver)); |
| 435 | } |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 436 | }, |
| 437 | base::Unretained(host)); |
| 438 | } |
| 439 | |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 440 | template <typename WorkerHost, typename Interface> |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 441 | base::RepeatingCallback<void(mojo::PendingReceiver<Interface>)> |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 442 | BindWorkerReceiver( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 443 | void (RenderProcessHostImpl::*method)(mojo::PendingReceiver<Interface>), |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 444 | WorkerHost* host) { |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 445 | return base::BindRepeating( |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 446 | [](WorkerHost* host, |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 447 | void (RenderProcessHostImpl::*method)( |
| 448 | mojo::PendingReceiver<Interface>), |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 449 | mojo::PendingReceiver<Interface> receiver) { |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 450 | auto* process_host = |
| 451 | static_cast<RenderProcessHostImpl*>(host->GetProcessHost()); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 452 | if (process_host) |
| 453 | (process_host->*method)(std::move(receiver)); |
| 454 | }, |
| 455 | base::Unretained(host), method); |
| 456 | } |
| 457 | |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 458 | template <typename WorkerHost, typename Interface> |
| 459 | base::RepeatingCallback<void(const url::Origin&, |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 460 | mojo::PendingReceiver<Interface>)> |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 461 | BindWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 462 | void (RenderProcessHostImpl::*method)(const url::Origin&, |
| 463 | mojo::PendingReceiver<Interface>), |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 464 | WorkerHost* host) { |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 465 | return base::BindRepeating( |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 466 | [](WorkerHost* host, |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 467 | void (RenderProcessHostImpl::*method)( |
| 468 | const url::Origin&, mojo::PendingReceiver<Interface>), |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 469 | const url::Origin& origin, mojo::PendingReceiver<Interface> receiver) { |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 470 | auto* process_host = |
| 471 | static_cast<RenderProcessHostImpl*>(host->GetProcessHost()); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 472 | if (process_host) |
| 473 | (process_host->*method)(origin, std::move(receiver)); |
| 474 | }, |
| 475 | base::Unretained(host), method); |
| 476 | } |
| 477 | |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 478 | template <typename WorkerHost, typename Interface> |
Antonio Sartori | 12147a8 | 2021-07-13 15:40:53 | [diff] [blame] | 479 | base::RepeatingCallback<void(mojo::PendingReceiver<Interface>)> |
| 480 | BindWorkerReceiverForStorageKey( |
| 481 | void (RenderProcessHostImpl::*method)(const blink::StorageKey&, |
| 482 | mojo::PendingReceiver<Interface>), |
| 483 | WorkerHost* host) { |
| 484 | return base::BindRepeating( |
| 485 | [](WorkerHost* host, |
| 486 | void (RenderProcessHostImpl::*method)( |
| 487 | const blink::StorageKey&, mojo::PendingReceiver<Interface>), |
| 488 | mojo::PendingReceiver<Interface> receiver) { |
| 489 | auto* process_host = |
| 490 | static_cast<RenderProcessHostImpl*>(host->GetProcessHost()); |
| 491 | if (process_host) |
| 492 | (process_host->*method)(host->GetStorageKey(), std::move(receiver)); |
| 493 | }, |
| 494 | base::Unretained(host), method); |
| 495 | } |
| 496 | |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 497 | template <typename Interface> |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 498 | using StorageKeyAndBucketContextMethod = |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 499 | void (RenderProcessHostImpl::*)(const blink::StorageKey&, |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 500 | BucketContext&, |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 501 | mojo::PendingReceiver<Interface>); |
| 502 | |
| 503 | template <typename WorkerHost, typename Interface> |
| 504 | base::RepeatingCallback<void(mojo::PendingReceiver<Interface>)> |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 505 | BindWorkerReceiverForStorageKeyAndBucketContext( |
| 506 | StorageKeyAndBucketContextMethod<Interface> method, |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 507 | WorkerHost* host) { |
| 508 | return base::BindRepeating( |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 509 | [](WorkerHost* host, StorageKeyAndBucketContextMethod<Interface> method, |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 510 | mojo::PendingReceiver<Interface> receiver) { |
| 511 | auto* process_host = |
| 512 | static_cast<RenderProcessHostImpl*>(host->GetProcessHost()); |
| 513 | if (process_host) |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 514 | (process_host->*method)(host->GetStorageKey(), *host, |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 515 | std::move(receiver)); |
| 516 | }, |
| 517 | base::Unretained(host), method); |
| 518 | } |
| 519 | |
| 520 | template <typename Interface> |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 521 | base::RepeatingCallback<void(mojo::PendingReceiver<Interface>)> |
| 522 | BindServiceWorkerReceiver( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 523 | void (RenderProcessHostImpl::*method)(mojo::PendingReceiver<Interface>), |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 524 | ServiceWorkerHost* host) { |
Matt Falkenhagen | 03dfa02 | 2021-09-07 08:16:26 | [diff] [blame] | 525 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 526 | return base::BindRepeating( |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 527 | [](ServiceWorkerHost* host, |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 528 | void (RenderProcessHostImpl::*method)( |
| 529 | mojo::PendingReceiver<Interface>), |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 530 | mojo::PendingReceiver<Interface> receiver) { |
Matt Falkenhagen | 03dfa02 | 2021-09-07 08:16:26 | [diff] [blame] | 531 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 532 | auto* process_host = static_cast<RenderProcessHostImpl*>( |
| 533 | RenderProcessHost::FromID(host->worker_process_id())); |
| 534 | if (!process_host) |
| 535 | return; |
| 536 | (process_host->*method)(std::move(receiver)); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 537 | }, |
| 538 | base::Unretained(host), method); |
| 539 | } |
| 540 | |
| 541 | template <typename Interface> |
Julie Jeongeun Kim | e58b0f4 | 2021-04-22 05:33:28 | [diff] [blame] | 542 | base::RepeatingCallback<void(const ServiceWorkerVersionBaseInfo&, |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 543 | mojo::PendingReceiver<Interface>)> |
| 544 | BindServiceWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 545 | void (RenderProcessHostImpl::*method)(const url::Origin&, |
| 546 | mojo::PendingReceiver<Interface>), |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 547 | ServiceWorkerHost* host) { |
Matt Falkenhagen | 03dfa02 | 2021-09-07 08:16:26 | [diff] [blame] | 548 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 549 | return base::BindRepeating( |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 550 | [](ServiceWorkerHost* host, |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 551 | void (RenderProcessHostImpl::*method)( |
| 552 | const url::Origin&, mojo::PendingReceiver<Interface>), |
Julie Jeongeun Kim | e58b0f4 | 2021-04-22 05:33:28 | [diff] [blame] | 553 | const ServiceWorkerVersionBaseInfo& info, |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 554 | mojo::PendingReceiver<Interface> receiver) { |
Matt Falkenhagen | 03dfa02 | 2021-09-07 08:16:26 | [diff] [blame] | 555 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Antonio Sartori | a6093adb | 2021-06-24 07:48:46 | [diff] [blame] | 556 | auto origin = info.storage_key.origin(); |
Matt Falkenhagen | 03dfa02 | 2021-09-07 08:16:26 | [diff] [blame] | 557 | auto* process_host = static_cast<RenderProcessHostImpl*>( |
| 558 | RenderProcessHost::FromID(host->worker_process_id())); |
| 559 | if (!process_host) |
| 560 | return; |
| 561 | (process_host->*method)(origin, std::move(receiver)); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 562 | }, |
| 563 | base::Unretained(host), method); |
| 564 | } |
| 565 | |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 566 | template <typename Interface> |
Julie Jeongeun Kim | e58b0f4 | 2021-04-22 05:33:28 | [diff] [blame] | 567 | base::RepeatingCallback<void(const ServiceWorkerVersionBaseInfo&, |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 568 | mojo::PendingReceiver<Interface>)> |
Antonio Sartori | 12147a8 | 2021-07-13 15:40:53 | [diff] [blame] | 569 | BindServiceWorkerReceiverForStorageKey( |
| 570 | void (RenderProcessHostImpl::*method)(const blink::StorageKey&, |
| 571 | mojo::PendingReceiver<Interface>), |
| 572 | ServiceWorkerHost* host) { |
Matt Falkenhagen | 03dfa02 | 2021-09-07 08:16:26 | [diff] [blame] | 573 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Antonio Sartori | 12147a8 | 2021-07-13 15:40:53 | [diff] [blame] | 574 | return base::BindRepeating( |
| 575 | [](ServiceWorkerHost* host, |
| 576 | void (RenderProcessHostImpl::*method)( |
| 577 | const blink::StorageKey&, mojo::PendingReceiver<Interface>), |
| 578 | const ServiceWorkerVersionBaseInfo& info, |
| 579 | mojo::PendingReceiver<Interface> receiver) { |
Matt Falkenhagen | 03dfa02 | 2021-09-07 08:16:26 | [diff] [blame] | 580 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 581 | auto* process_host = static_cast<RenderProcessHostImpl*>( |
| 582 | RenderProcessHost::FromID(host->worker_process_id())); |
| 583 | if (!process_host) |
| 584 | return; |
| 585 | (process_host->*method)(info.storage_key, std::move(receiver)); |
Antonio Sartori | 12147a8 | 2021-07-13 15:40:53 | [diff] [blame] | 586 | }, |
| 587 | base::Unretained(host), method); |
| 588 | } |
| 589 | |
arthursonzogni | 3d5cc6d | 2019-12-20 14:08:30 | [diff] [blame] | 590 | template <typename Interface> |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 591 | base::RepeatingCallback<void(const ServiceWorkerVersionBaseInfo&, |
| 592 | mojo::PendingReceiver<Interface>)> |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 593 | BindServiceWorkerReceiverForStorageKeyAndBucketContext( |
| 594 | StorageKeyAndBucketContextMethod<Interface> method, |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 595 | ServiceWorkerHost* host) { |
| 596 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 597 | return base::BindRepeating( |
| 598 | [](ServiceWorkerHost* host, |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 599 | StorageKeyAndBucketContextMethod<Interface> method, |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 600 | const ServiceWorkerVersionBaseInfo& info, |
| 601 | mojo::PendingReceiver<Interface> receiver) { |
| 602 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 603 | auto* process_host = static_cast<RenderProcessHostImpl*>( |
| 604 | RenderProcessHost::FromID(host->worker_process_id())); |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 605 | if (!process_host) { |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 606 | return; |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 607 | } |
| 608 | (process_host->*method)(info.storage_key, *host, std::move(receiver)); |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 609 | }, |
| 610 | base::Unretained(host), method); |
| 611 | } |
| 612 | |
| 613 | template <typename Interface> |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 614 | void EmptyBinderForFrame(RenderFrameHost* host, |
| 615 | mojo::PendingReceiver<Interface> receiver) { |
Simon Pelchat | 06406ad | 2022-06-16 00:05:01 | [diff] [blame] | 616 | DVLOG(1) << "Empty binder for interface " << Interface::Name_ |
| 617 | << " for the frame/document scope"; |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 618 | } |
| 619 | |
Johann | 165093e3 | 2020-11-18 04:25:30 | [diff] [blame] | 620 | BatteryMonitorBinder& GetBatteryMonitorBinderOverride() { |
| 621 | static base::NoDestructor<BatteryMonitorBinder> binder; |
| 622 | return *binder; |
| 623 | } |
| 624 | |
| 625 | void BindBatteryMonitor( |
Yoshisato Yanagisawa | 0d8d2ed6 | 2022-01-31 00:41:33 | [diff] [blame] | 626 | RenderFrameHostImpl* host, |
Johann | 165093e3 | 2020-11-18 04:25:30 | [diff] [blame] | 627 | mojo::PendingReceiver<device::mojom::BatteryMonitor> receiver) { |
| 628 | const auto& binder = GetBatteryMonitorBinderOverride(); |
Yoshisato Yanagisawa | 0d8d2ed6 | 2022-01-31 00:41:33 | [diff] [blame] | 629 | // TODO(crbug.com/1007264, crbug.com/1290231): remove fenced frame specific |
| 630 | // code when permission policy implements the battery status API support. |
| 631 | if (host->IsNestedWithinFencedFrame()) { |
| 632 | bad_message::ReceivedBadMessage( |
| 633 | host->GetProcess(), bad_message::BadMessageReason:: |
| 634 | BIBI_BIND_BATTERY_MONITOR_FOR_FENCED_FRAME); |
| 635 | return; |
| 636 | } |
Johann | 165093e3 | 2020-11-18 04:25:30 | [diff] [blame] | 637 | if (binder) |
| 638 | binder.Run(std::move(receiver)); |
| 639 | else |
| 640 | GetDeviceService().BindBatteryMonitor(std::move(receiver)); |
| 641 | } |
| 642 | |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 643 | #if BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 644 | void BindPressureManager( |
| 645 | RenderFrameHostImpl* host, |
Raphael Kubo da Costa | e8d284a | 2024-07-01 08:46:30 | [diff] [blame] | 646 | mojo::PendingReceiver<blink::mojom::WebPressureManager> receiver) { |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 647 | if (!network::IsOriginPotentiallyTrustworthy( |
| 648 | host->GetLastCommittedOrigin())) { |
| 649 | bad_message::ReceivedBadMessage( |
| 650 | host->GetProcess(), bad_message::BadMessageReason:: |
| 651 | BIBI_BIND_PRESSURE_MANAGER_FOR_INSECURE_ORIGIN); |
| 652 | return; |
| 653 | } |
| 654 | |
| 655 | if (host->IsNestedWithinFencedFrame()) { |
| 656 | // The renderer is supposed to disallow the use of compute pressure API |
| 657 | // when inside a fenced frame. Anything getting past the renderer checks |
| 658 | // must be marked as a bad request. |
| 659 | bad_message::ReceivedBadMessage( |
| 660 | host->GetProcess(), bad_message::BadMessageReason:: |
| 661 | BIBI_BIND_PRESSURE_MANAGER_FOR_FENCED_FRAME); |
| 662 | return; |
| 663 | } |
| 664 | |
| 665 | if (!host->IsFeatureEnabled( |
Sandor «Alex» Major | e9545a7 | 2025-01-31 20:40:46 | [diff] [blame] | 666 | network::mojom::PermissionsPolicyFeature::kComputePressure)) { |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 667 | bad_message::ReceivedBadMessage( |
| 668 | host->GetProcess(), |
| 669 | bad_message::BadMessageReason:: |
| 670 | BIBI_BIND_PRESSURE_MANAGER_BLOCKED_BY_PERMISSIONS_POLICY); |
| 671 | return; |
| 672 | } |
| 673 | |
Wei4 Wang | a90dd31 | 2023-12-14 02:35:32 | [diff] [blame] | 674 | PressureServiceForFrame::GetOrCreateForCurrentDocument(host)->BindReceiver( |
Wei4 Wang | 78e6eab | 2023-12-14 01:47:28 | [diff] [blame] | 675 | std::move(receiver)); |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 676 | } |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 677 | #endif // BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 678 | |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 679 | VibrationManagerBinder& GetVibrationManagerBinderOverride() { |
| 680 | static base::NoDestructor<VibrationManagerBinder> binder; |
| 681 | return *binder; |
| 682 | } |
| 683 | |
| 684 | void BindVibrationManager( |
Seung Jae Lim | c16c5e1 | 2024-05-10 23:30:00 | [diff] [blame] | 685 | RenderFrameHostImpl* frame, |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 686 | mojo::PendingReceiver<device::mojom::VibrationManager> receiver) { |
| 687 | const auto& binder = GetVibrationManagerBinderOverride(); |
Seung Jae Lim | c16c5e1 | 2024-05-10 23:30:00 | [diff] [blame] | 688 | if (binder) { |
| 689 | binder.Run(std::move(receiver), frame->CreateVibrationManagerListener()); |
| 690 | } else { |
| 691 | GetDeviceService().BindVibrationManager( |
| 692 | std::move(receiver), frame->CreateVibrationManagerListener()); |
| 693 | } |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 694 | } |
| 695 | |
evliu | 5e44d85c | 2021-09-24 22:56:07 | [diff] [blame] | 696 | void BindMediaPlayerObserverClientHandler( |
Victor Costan | dbb6677 | 2021-10-27 21:00:50 | [diff] [blame] | 697 | RenderFrameHost* frame_host, |
evliu | 5e44d85c | 2021-09-24 22:56:07 | [diff] [blame] | 698 | mojo::PendingReceiver<media::mojom::MediaPlayerObserverClient> receiver) { |
Victor Costan | dbb6677 | 2021-10-27 21:00:50 | [diff] [blame] | 699 | WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 700 | WebContents::FromRenderFrameHost(frame_host)); |
evliu | 5e44d85c | 2021-09-24 22:56:07 | [diff] [blame] | 701 | web_contents->media_web_contents_observer()->BindMediaPlayerObserverClient( |
| 702 | std::move(receiver)); |
| 703 | } |
| 704 | |
Tal Pressman | 6b5c300 | 2021-05-13 06:48:09 | [diff] [blame] | 705 | void BindSocketManager( |
| 706 | RenderFrameHostImpl* frame, |
| 707 | mojo::PendingReceiver<network::mojom::P2PSocketManager> receiver) { |
| 708 | static_cast<RenderProcessHostImpl*>(frame->GetProcess()) |
Brianna Goldstein | d22b064 | 2022-10-11 16:30:50 | [diff] [blame] | 709 | ->BindP2PSocketManager( |
| 710 | frame->GetIsolationInfoForSubresources().network_anonymization_key(), |
| 711 | std::move(receiver), frame->GetGlobalId()); |
Tal Pressman | 6b5c300 | 2021-05-13 06:48:09 | [diff] [blame] | 712 | } |
| 713 | |
Alexis Menard | d99e01f | 2024-01-29 14:39:37 | [diff] [blame] | 714 | void BindDevicePostureProvider( |
| 715 | RenderFrameHost* frame_host, |
| 716 | mojo::PendingReceiver<blink::mojom::DevicePostureProvider> receiver) { |
| 717 | DevicePostureProviderImpl::GetOrCreate( |
| 718 | WebContents::FromRenderFrameHost(frame_host)) |
| 719 | ->Bind(std::move(receiver)); |
| 720 | } |
| 721 | |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 722 | } // namespace |
| 723 | |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 724 | // Documents/frames |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 725 | void PopulateFrameBinders(RenderFrameHostImpl* host, mojo::BinderMap* map) { |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 726 | map->Add<blink::mojom::AudioContextManager>(base::BindRepeating( |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 727 | &RenderFrameHostImpl::GetAudioContextManager, base::Unretained(host))); |
Oksana Zhuravlova | ab9ff30 | 2019-08-08 22:31:00 | [diff] [blame] | 728 | |
Johann | 165093e3 | 2020-11-18 04:25:30 | [diff] [blame] | 729 | map->Add<device::mojom::BatteryMonitor>( |
Yoshisato Yanagisawa | 0d8d2ed6 | 2022-01-31 00:41:33 | [diff] [blame] | 730 | base::BindRepeating(&BindBatteryMonitor, base::Unretained(host))); |
Johann | 165093e3 | 2020-11-18 04:25:30 | [diff] [blame] | 731 | |
Mario Sanchez Prada | c71a630 | 2019-11-25 14:47:20 | [diff] [blame] | 732 | map->Add<blink::mojom::CacheStorage>(base::BindRepeating( |
| 733 | &RenderFrameHostImpl::BindCacheStorage, base::Unretained(host))); |
| 734 | |
Mythri A | fefc0c46 | 2021-05-26 08:37:26 | [diff] [blame] | 735 | map->Add<blink::mojom::CodeCacheHost>(base::BindRepeating( |
| 736 | &RenderFrameHostImpl::CreateCodeCacheHost, base::Unretained(host))); |
| 737 | |
janiceliu | 2457d49d | 2024-07-09 18:15:57 | [diff] [blame] | 738 | map->Add<blink::mojom::BlobURLStore>(base::BindRepeating( |
| 739 | &RenderFrameHostImpl::BindBlobUrlStoreReceiver, base::Unretained(host))); |
Andrew Williams | 39151a7 | 2022-10-18 23:12:41 | [diff] [blame] | 740 | |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 741 | #if BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Wei4 Wang | 0b2ecad | 2022-07-19 00:36:11 | [diff] [blame] | 742 | if (base::FeatureList::IsEnabled(blink::features::kComputePressure)) { |
Raphael Kubo da Costa | e8d284a | 2024-07-01 08:46:30 | [diff] [blame] | 743 | map->Add<blink::mojom::WebPressureManager>( |
Wei4 Wang | 1dfb1de0 | 2023-01-23 17:57:44 | [diff] [blame] | 744 | base::BindRepeating(&BindPressureManager, base::Unretained(host))); |
Wei4 Wang | 0b2ecad | 2022-07-19 00:36:11 | [diff] [blame] | 745 | } |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 746 | #endif // BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Olivier Yiptong | 8a3945e | 2021-05-05 22:19:52 | [diff] [blame] | 747 | |
danakj | c70aec1f | 2022-07-07 15:48:19 | [diff] [blame] | 748 | map->Add<blink::mojom::ContactsManager>( |
| 749 | base::BindRepeating(ContactsManagerImpl::Create, base::Unretained(host))); |
Miyoung Shin | 3b15d4d | 2019-09-24 10:38:44 | [diff] [blame] | 750 | |
Hiroki Nakagawa | 761b9b0 | 2020-07-13 11:12:02 | [diff] [blame] | 751 | map->Add<blink::mojom::ContentSecurityNotifier>(base::BindRepeating( |
| 752 | [](RenderFrameHostImpl* host, |
| 753 | mojo::PendingReceiver<blink::mojom::ContentSecurityNotifier> |
| 754 | receiver) { |
Alexander Timin | 8690530c | 2021-06-19 00:34:32 | [diff] [blame] | 755 | mojo::MakeSelfOwnedReceiver( |
| 756 | std::make_unique<ContentSecurityNotifier>(host->GetGlobalId()), |
| 757 | std::move(receiver)); |
Hiroki Nakagawa | 761b9b0 | 2020-07-13 11:12:02 | [diff] [blame] | 758 | }, |
| 759 | base::Unretained(host))); |
| 760 | |
Miyoung Shin | 996cb65 | 2019-11-28 03:27:22 | [diff] [blame] | 761 | map->Add<blink::mojom::DedicatedWorkerHostFactory>(base::BindRepeating( |
| 762 | &RenderFrameHostImpl::CreateDedicatedWorkerHostFactory, |
| 763 | base::Unretained(host))); |
| 764 | |
Alexis Menard | d99e01f | 2024-01-29 14:39:37 | [diff] [blame] | 765 | map->Add<blink::mojom::DevicePostureProvider>( |
| 766 | base::BindRepeating(&BindDevicePostureProvider, base::Unretained(host))); |
| 767 | |
Adrienne Walker | 80d95f0 | 2020-02-07 22:37:04 | [diff] [blame] | 768 | map->Add<blink::mojom::FeatureObserver>(base::BindRepeating( |
| 769 | &RenderFrameHostImpl::GetFeatureObserver, base::Unretained(host))); |
| 770 | |
Austin Sullivan | 559bb38 | 2021-01-26 00:52:43 | [diff] [blame] | 771 | map->Add<blink::mojom::FileSystemAccessManager>( |
| 772 | base::BindRepeating(&RenderFrameHostImpl::GetFileSystemAccessManager, |
| 773 | base::Unretained(host))); |
Olivier Yiptong | 5a58487e | 2020-08-07 19:04:24 | [diff] [blame] | 774 | |
Oksana Zhuravlova | ab9ff30 | 2019-08-08 22:31:00 | [diff] [blame] | 775 | map->Add<blink::mojom::FileSystemManager>(base::BindRepeating( |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 776 | &RenderFrameHostImpl::GetFileSystemManager, base::Unretained(host))); |
Oksana Zhuravlova | 99a8e52 | 2019-08-20 21:58:11 | [diff] [blame] | 777 | |
Ayu Ishii | 68366d3 | 2021-07-09 04:18:28 | [diff] [blame] | 778 | if (base::FeatureList::IsEnabled(blink::features::kFontAccess)) { |
| 779 | map->Add<blink::mojom::FontAccessManager>(base::BindRepeating( |
| 780 | &RenderFrameHostImpl::GetFontAccessManager, base::Unretained(host))); |
| 781 | } |
Austin Sullivan | 559bb38 | 2021-01-26 00:52:43 | [diff] [blame] | 782 | |
Tal Pressman | 78369f6 | 2021-01-06 05:21:53 | [diff] [blame] | 783 | map->Add<device::mojom::GamepadHapticsManager>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 784 | &device::GamepadHapticsManager::Create); |
Tal Pressman | 78369f6 | 2021-01-06 05:21:53 | [diff] [blame] | 785 | |
Mario Sanchez Prada | fa6dda8c | 2019-11-25 18:20:19 | [diff] [blame] | 786 | map->Add<blink::mojom::GeolocationService>(base::BindRepeating( |
| 787 | &RenderFrameHostImpl::GetGeolocationService, base::Unretained(host))); |
| 788 | |
Oksana Zhuravlova | 99a8e52 | 2019-08-20 21:58:11 | [diff] [blame] | 789 | map->Add<blink::mojom::IdleManager>(base::BindRepeating( |
Maksim Sadym | a30263e | 2020-07-29 17:09:27 | [diff] [blame] | 790 | &RenderFrameHostImpl::BindIdleManager, base::Unretained(host))); |
Staphany Park | afda6dd7 | 2019-09-02 08:51:49 | [diff] [blame] | 791 | |
Tal Pressman | 70dc3639 | 2021-05-25 04:11:57 | [diff] [blame] | 792 | #if BUILDFLAG(ENABLE_MDNS) |
| 793 | map->Add<network::mojom::MdnsResponder>(base::BindRepeating( |
| 794 | &RenderFrameHostImpl::CreateMdnsResponder, base::Unretained(host))); |
| 795 | #endif // BUILDFLAG(ENABLE_MDNS) |
| 796 | |
Johann | a445d5d | 2020-09-15 04:45:27 | [diff] [blame] | 797 | // BrowserMainLoop::GetInstance() may be null on unit tests. |
| 798 | if (BrowserMainLoop::GetInstance()) { |
| 799 | map->Add<midi::mojom::MidiSessionProvider>( |
| 800 | base::BindRepeating(&MidiHost::BindReceiver, |
Emily Andrews | d15fd76 | 2024-12-10 20:41:54 | [diff] [blame] | 801 | host->GetProcess()->GetDeprecatedID(), |
Johann | a445d5d | 2020-09-15 04:45:27 | [diff] [blame] | 802 | BrowserMainLoop::GetInstance()->midi_service()), |
| 803 | GetIOThreadTaskRunner({})); |
| 804 | } |
| 805 | |
evliu | 5e44d85c | 2021-09-24 22:56:07 | [diff] [blame] | 806 | map->Add<media::mojom::MediaPlayerObserverClient>(base::BindRepeating( |
| 807 | &BindMediaPlayerObserverClientHandler, base::Unretained(host))); |
| 808 | |
Miyoung Shin | db479fec4 | 2019-11-22 06:29:20 | [diff] [blame] | 809 | map->Add<blink::mojom::NotificationService>(base::BindRepeating( |
| 810 | &RenderFrameHostImpl::CreateNotificationService, base::Unretained(host))); |
| 811 | |
Andrew Verge | 9c6d421 | 2024-07-03 11:43:56 | [diff] [blame] | 812 | // WebRTC p2p connections are disallowed in fenced frames. Creation of |
| 813 | // RTCPeerConnection is already disabled in the renderer, so in theory this |
| 814 | // unbound interface should never present an issue. |
| 815 | bool should_ban_p2p = |
| 816 | base::FeatureList::IsEnabled( |
| 817 | blink::features::kFencedFramesLocalUnpartitionedDataAccess) && |
| 818 | host->IsNestedWithinFencedFrame(); |
| 819 | if (!should_ban_p2p) { |
| 820 | map->Add<network::mojom::P2PSocketManager>( |
| 821 | base::BindRepeating(&BindSocketManager, base::Unretained(host))); |
| 822 | } |
Tal Pressman | 6b5c300 | 2021-05-13 06:48:09 | [diff] [blame] | 823 | |
Tal Pressman | d7f6d6f | 2021-03-02 00:10:04 | [diff] [blame] | 824 | map->Add<blink::mojom::PeerConnectionTrackerHost>( |
| 825 | base::BindRepeating(&RenderFrameHostImpl::BindPeerConnectionTrackerHost, |
| 826 | base::Unretained(host))); |
| 827 | |
Miyoung Shin | e676be1f | 2019-09-25 00:47:02 | [diff] [blame] | 828 | map->Add<blink::mojom::PermissionService>(base::BindRepeating( |
| 829 | &RenderFrameHostImpl::CreatePermissionService, base::Unretained(host))); |
| 830 | |
Mario Sanchez Prada | 3532f44 | 2019-09-10 08:28:08 | [diff] [blame] | 831 | map->Add<blink::mojom::PresentationService>(base::BindRepeating( |
| 832 | &RenderFrameHostImpl::GetPresentationService, base::Unretained(host))); |
| 833 | |
Victor Costan | 52fc24b | 2020-03-12 23:36:59 | [diff] [blame] | 834 | map->Add<blink::mojom::QuotaManagerHost>( |
| 835 | base::BindRepeating(&BindQuotaManagerHost, base::Unretained(host))); |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 836 | |
Matt Menke | 6751f66 | 2020-12-01 05:44:00 | [diff] [blame] | 837 | map->Add<blink::mojom::ReportingServiceProxy>(base::BindRepeating( |
| 838 | &CreateReportingServiceProxyForFrame, base::Unretained(host))); |
Matt Menke | 6751f66 | 2020-12-01 05:44:00 | [diff] [blame] | 839 | |
Miyoung Shin | e6ff4b5b | 2019-11-27 17:36:29 | [diff] [blame] | 840 | map->Add<blink::mojom::SharedWorkerConnector>( |
| 841 | base::BindRepeating(&BindSharedWorkerConnector, base::Unretained(host))); |
| 842 | |
Evan Liu | d725228 | 2024-05-16 20:10:32 | [diff] [blame] | 843 | map->Add<media::mojom::SpeechRecognizer>( |
Miyoung Shin | 8f0d858 | 2019-10-02 01:12:28 | [diff] [blame] | 844 | base::BindRepeating(&SpeechRecognitionDispatcherHost::Create, |
Emily Andrews | d15fd76 | 2024-12-10 20:41:54 | [diff] [blame] | 845 | host->GetProcess()->GetDeprecatedID(), |
| 846 | host->GetRoutingID()), |
Gabriel Charette | e7cdc5cd | 2020-05-27 23:35:05 | [diff] [blame] | 847 | GetIOThreadTaskRunner({})); |
Miyoung Shin | 8f0d858 | 2019-10-02 01:12:28 | [diff] [blame] | 848 | |
Darin Fisher | a26aa7e | 2019-09-02 20:22:59 | [diff] [blame] | 849 | map->Add<blink::mojom::SpeechSynthesis>(base::BindRepeating( |
| 850 | &RenderFrameHostImpl::GetSpeechSynthesis, base::Unretained(host))); |
| 851 | |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 852 | #if !BUILDFLAG(IS_ANDROID) |
Anatoliy Potapchuk | 096e4d0a | 2020-12-01 16:49:21 | [diff] [blame] | 853 | map->Add<blink::mojom::DeviceAPIService>(base::BindRepeating( |
| 854 | &RenderFrameHostImpl::GetDeviceInfoService, base::Unretained(host))); |
Anatoliy Potapchuk | dbe8904 | 2021-03-30 23:04:02 | [diff] [blame] | 855 | map->Add<blink::mojom::ManagedConfigurationService>( |
| 856 | base::BindRepeating(&RenderFrameHostImpl::GetManagedConfigurationService, |
| 857 | base::Unretained(host))); |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 858 | #endif // !BUILDFLAG(IS_ANDROID) |
Anatoliy Potapchuk | 096e4d0a | 2020-12-01 16:49:21 | [diff] [blame] | 859 | |
Majid Valipour | ae11335e | 2020-10-14 04:09:24 | [diff] [blame] | 860 | if (base::FeatureList::IsEnabled(features::kWebOTP)) { |
| 861 | map->Add<blink::mojom::WebOTPService>( |
| 862 | base::BindRepeating(&RenderFrameHostImpl::BindWebOTPServiceReceiver, |
| 863 | base::Unretained(host))); |
Miyoung Shin | 97be5ad | 2019-09-27 12:40:54 | [diff] [blame] | 864 | } |
| 865 | |
Peter Kotwicz | 3a1ff04 | 2024-02-07 20:50:39 | [diff] [blame] | 866 | map->Add<blink::mojom::DigitalIdentityRequest>(base::BindRepeating( |
| 867 | &RenderFrameHostImpl::BindDigitalIdentityRequestReceiver, |
| 868 | base::Unretained(host))); |
| 869 | |
Yi Gu | d328cc2 | 2022-03-25 19:07:19 | [diff] [blame] | 870 | map->Add<blink::mojom::FederatedAuthRequest>(base::BindRepeating( |
| 871 | &RenderFrameHostImpl::BindFederatedAuthRequestReceiver, |
| 872 | base::Unretained(host))); |
Ken Buchanan | c47efed | 2020-11-05 23:07:17 | [diff] [blame] | 873 | |
Miyoung Shin | 12048384 | 2019-10-08 06:59:41 | [diff] [blame] | 874 | map->Add<blink::mojom::WebUsbService>(base::BindRepeating( |
| 875 | &RenderFrameHostImpl::CreateWebUsbService, base::Unretained(host))); |
| 876 | |
Miyoung Shin | e5cb8f1 | 2019-11-27 16:40:54 | [diff] [blame] | 877 | map->Add<blink::mojom::WebSocketConnector>(base::BindRepeating( |
| 878 | &RenderFrameHostImpl::CreateWebSocketConnector, base::Unretained(host))); |
| 879 | |
Oksana Zhuravlova | 4a9804e | 2019-09-11 19:35:50 | [diff] [blame] | 880 | map->Add<blink::mojom::LockManager>(base::BindRepeating( |
| 881 | &RenderFrameHostImpl::CreateLockManager, base::Unretained(host))); |
Mario Sanchez Prada | aa35b42 | 2019-09-24 06:50:31 | [diff] [blame] | 882 | |
Francois Doray | 1be23f1 | 2019-10-01 16:37:51 | [diff] [blame] | 883 | map->Add<blink::mojom::IDBFactory>(base::BindRepeating( |
| 884 | &RenderFrameHostImpl::CreateIDBFactory, base::Unretained(host))); |
| 885 | |
Ayu Ishii | 1d05bfe9 | 2021-02-02 21:42:33 | [diff] [blame] | 886 | map->Add<blink::mojom::BucketManagerHost>(base::BindRepeating( |
| 887 | &RenderFrameHostImpl::CreateBucketManagerHost, base::Unretained(host))); |
| 888 | |
Avi Drissman | bd3e98644 | 2020-05-20 21:09:20 | [diff] [blame] | 889 | map->Add<blink::mojom::FileChooser>( |
Jeremy Roman | 5936f39 | 2020-05-21 01:38:12 | [diff] [blame] | 890 | base::BindRepeating(&FileChooserImpl::Create, base::Unretained(host))); |
Mario Sanchez Prada | aa35b42 | 2019-09-24 06:50:31 | [diff] [blame] | 891 | |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 892 | map->Add<blink::mojom::FileUtilitiesHost>( |
| 893 | base::BindRepeating(FileUtilitiesHostImpl::Create, |
Emily Andrews | d15fd76 | 2024-12-10 20:41:54 | [diff] [blame] | 894 | host->GetProcess()->GetDeprecatedID()), |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 895 | base::ThreadPool::CreateSequencedTaskRunner( |
| 896 | {base::MayBlock(), base::TaskPriority::USER_VISIBLE})); |
| 897 | |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 898 | map->Add<device::mojom::GamepadMonitor>(&device::GamepadMonitor::Create); |
Miyoung Shin | c9f4dac | 2019-09-26 15:14:10 | [diff] [blame] | 899 | |
Raphael Kubo da Costa | 73975654 | 2023-10-06 22:41:53 | [diff] [blame] | 900 | map->Add<blink::mojom::WebSensorProvider>(base::BindRepeating( |
Miyoung Shin | 561a338c | 2019-09-26 01:13:14 | [diff] [blame] | 901 | &RenderFrameHostImpl::GetSensorProvider, base::Unretained(host))); |
| 902 | |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 903 | map->Add<device::mojom::VibrationManager>( |
Seung Jae Lim | c16c5e1 | 2024-05-10 23:30:00 | [diff] [blame] | 904 | base::BindRepeating(&BindVibrationManager, base::Unretained(host))); |
Miyoung Shin | 090544a4 | 2019-09-26 03:48:16 | [diff] [blame] | 905 | |
Rouslan Solomakhin | 8788e254 | 2019-10-24 01:10:05 | [diff] [blame] | 906 | map->Add<payments::mojom::PaymentManager>(base::BindRepeating( |
| 907 | &RenderFrameHostImpl::CreatePaymentManager, base::Unretained(host))); |
Miyoung Shin | 8aa77f29 | 2019-09-27 10:46:46 | [diff] [blame] | 908 | |
Jiewei Qian | 87fc9846 | 2022-03-29 09:59:31 | [diff] [blame] | 909 | map->Add<handwriting::mojom::HandwritingRecognitionService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 910 | &CreateHandwritingRecognitionService); |
Honglin Yu | 6cdb4b3 | 2021-02-23 13:14:33 | [diff] [blame] | 911 | |
Honglin Yu | a0a14fa | 2022-03-31 22:40:05 | [diff] [blame] | 912 | if (base::FeatureList::IsEnabled( |
Alex Gough | 6ae9128 | 2023-12-18 23:19:23 | [diff] [blame] | 913 | webnn::mojom::features::kWebMachineLearningNeuralNetwork)) { |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 914 | map->Add<webnn::mojom::WebNNContextProvider>(base::BindRepeating( |
| 915 | &BindWebNNContextProviderForRenderFrame, base::Unretained(host))); |
junwei | d4ed5a81 | 2023-04-19 03:19:26 | [diff] [blame] | 916 | } |
junwei | d4ed5a81 | 2023-04-19 03:19:26 | [diff] [blame] | 917 | |
Mario Sanchez Prada | 19294b5 | 2019-09-24 10:57:14 | [diff] [blame] | 918 | map->Add<blink::mojom::WebBluetoothService>(base::BindRepeating( |
Daniel Cheng | d6978b06 | 2023-11-16 00:11:38 | [diff] [blame] | 919 | &WebBluetoothServiceImpl::BindIfAllowed, base::Unretained(host))); |
Oksana Zhuravlova | 16498df8 | 2019-09-25 17:33:18 | [diff] [blame] | 920 | |
| 921 | map->Add<blink::mojom::PushMessaging>(base::BindRepeating( |
| 922 | &RenderFrameHostImpl::GetPushMessaging, base::Unretained(host))); |
Oksana Zhuravlova | 567040b | 2019-09-25 20:45:22 | [diff] [blame] | 923 | |
Adam Rice | e98a2232 | 2021-04-27 08:26:26 | [diff] [blame] | 924 | map->Add<blink::mojom::WebTransportConnector>( |
| 925 | base::BindRepeating(&RenderFrameHostImpl::CreateWebTransportConnector, |
Yutaka Hirano | 492c93d | 2019-11-05 11:28:03 | [diff] [blame] | 926 | base::Unretained(host))); |
| 927 | |
Stephen McGruer | 18ed1a06 | 2025-01-20 20:18:52 | [diff] [blame] | 928 | map->Add<payments::mojom::SecurePaymentConfirmationService>( |
| 929 | base::BindRepeating( |
| 930 | &RenderFrameHostImpl::CreateSecurePaymentConfirmationService, |
| 931 | base::Unretained(host))); |
Stephen McGruer | b721a3f | 2024-01-18 14:58:12 | [diff] [blame] | 932 | |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 933 | // BrowserMainLoop::GetInstance() may be null on unit tests. |
| 934 | if (BrowserMainLoop::GetInstance()) { |
| 935 | // BrowserMainLoop, which owns MediaStreamManager, is alive for the lifetime |
| 936 | // of Mojo communication (see BrowserMainLoop::ShutdownThreadsAndCleanUp(), |
| 937 | // which shuts down Mojo). Hence, passing that MediaStreamManager instance |
| 938 | // as a raw pointer here is safe. |
| 939 | MediaStreamManager* media_stream_manager = |
| 940 | BrowserMainLoop::GetInstance()->media_stream_manager(); |
| 941 | |
| 942 | map->Add<blink::mojom::MediaDevicesDispatcherHost>( |
| 943 | base::BindRepeating(&MediaDevicesDispatcherHost::Create, |
Sunggook Chue | 469ea177 | 2024-12-11 01:12:54 | [diff] [blame] | 944 | host->GetMainFrame()->GetGlobalFrameToken(), |
Bryant Chandler | 915a45c9 | 2023-11-01 20:02:16 | [diff] [blame] | 945 | host->GetGlobalId(), |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 946 | base::Unretained(media_stream_manager)), |
Gabriel Charette | e7cdc5cd | 2020-05-27 23:35:05 | [diff] [blame] | 947 | GetIOThreadTaskRunner({})); |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 948 | |
| 949 | map->Add<blink::mojom::MediaStreamDispatcherHost>( |
| 950 | base::BindRepeating(&MediaStreamDispatcherHost::Create, |
Bryant Chandler | 915a45c9 | 2023-11-01 20:02:16 | [diff] [blame] | 951 | host->GetGlobalId(), |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 952 | base::Unretained(media_stream_manager)), |
Gabriel Charette | e7cdc5cd | 2020-05-27 23:35:05 | [diff] [blame] | 953 | GetIOThreadTaskRunner({})); |
Tal Pressman | 06a62f2 | 2021-03-02 04:34:11 | [diff] [blame] | 954 | |
| 955 | map->Add<media::mojom::VideoCaptureHost>( |
Patrick Monette | 031229b | 2023-11-02 17:21:18 | [diff] [blame] | 956 | base::BindRepeating(&VideoCaptureHost::Create, host->GetGlobalId(), |
Tal Pressman | 06a62f2 | 2021-03-02 04:34:11 | [diff] [blame] | 957 | base::Unretained(media_stream_manager)), |
| 958 | GetIOThreadTaskRunner({})); |
Miyoung Shin | 8d654258 | 2019-10-08 12:30:55 | [diff] [blame] | 959 | } |
| 960 | |
Guido Urdaneta | 3a7cd9e6 | 2020-07-21 08:31:28 | [diff] [blame] | 961 | map->Add<blink::mojom::RendererAudioInputStreamFactory>( |
Miyoung Shin | 7e7af08 | 2019-12-04 03:39:42 | [diff] [blame] | 962 | base::BindRepeating(&RenderFrameHostImpl::CreateAudioInputStreamFactory, |
| 963 | base::Unretained(host))); |
| 964 | |
Guido Urdaneta | 9d773b1 | 2020-07-21 08:45:45 | [diff] [blame] | 965 | map->Add<blink::mojom::RendererAudioOutputStreamFactory>( |
Miyoung Shin | 7e7af08 | 2019-12-04 03:39:42 | [diff] [blame] | 966 | base::BindRepeating(&RenderFrameHostImpl::CreateAudioOutputStreamFactory, |
| 967 | base::Unretained(host))); |
| 968 | |
Mario Sanchez Prada | 416cfd4 | 2019-09-30 15:15:29 | [diff] [blame] | 969 | map->Add<media::mojom::ImageCapture>( |
François Beaufort | b9c083e5 | 2020-05-12 18:00:00 | [diff] [blame] | 970 | base::BindRepeating(&ImageCaptureImpl::Create, base::Unretained(host))); |
Mario Sanchez Prada | 416cfd4 | 2019-09-30 15:15:29 | [diff] [blame] | 971 | |
Miyoung Shin | 3f38bc8 | 2019-11-29 17:25:14 | [diff] [blame] | 972 | map->Add<media::mojom::InterfaceFactory>(base::BindRepeating( |
| 973 | &RenderFrameHostImpl::BindMediaInterfaceFactoryReceiver, |
| 974 | base::Unretained(host))); |
| 975 | |
Feras Aldahlawi | d996da75 | 2024-04-04 19:27:29 | [diff] [blame] | 976 | #if BUILDFLAG(ENABLE_LIBRARY_CDMS) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID) |
| 977 | map->Add<media::mojom::KeySystemSupport>( |
| 978 | base::BindRepeating(&RenderFrameHostImpl::BindKeySystemSupportReceiver, |
| 979 | base::Unretained(host))); |
| 980 | #endif |
| 981 | |
Miyoung Shin | ce54860 | 2019-12-03 04:05:49 | [diff] [blame] | 982 | map->Add<media::mojom::MediaMetricsProvider>(base::BindRepeating( |
| 983 | &RenderFrameHostImpl::BindMediaMetricsProviderReceiver, |
| 984 | base::Unretained(host))); |
| 985 | |
Hirokazu Honda | 09fab5f | 2023-06-13 02:40:10 | [diff] [blame] | 986 | map->Add<media::mojom::VideoEncoderMetricsProvider>(base::BindRepeating( |
| 987 | &RenderFrameHostImpl::BindVideoEncoderMetricsProviderReceiver, |
| 988 | base::Unretained(host))); |
| 989 | |
Johannes Kron | b1209bd | 2022-02-15 10:32:39 | [diff] [blame] | 990 | map->Add<media::mojom::WebrtcVideoPerfRecorder>(base::BindRepeating( |
| 991 | [](RenderFrameHostImpl* host, |
| 992 | mojo::PendingReceiver<media::mojom::WebrtcVideoPerfRecorder> |
| 993 | receiver) { |
Johannes Kron | 98aca402 | 2022-02-18 21:15:24 | [diff] [blame] | 994 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Johannes Kron | b1209bd | 2022-02-15 10:32:39 | [diff] [blame] | 995 | media::WebrtcVideoPerfRecorder::Create( |
Johannes Kron | 98aca402 | 2022-02-18 21:15:24 | [diff] [blame] | 996 | BrowserContextImpl::From(host->GetBrowserContext()) |
Johannes Kron | b1209bd | 2022-02-15 10:32:39 | [diff] [blame] | 997 | ->GetWebrtcVideoPerfHistory(), |
| 998 | std::move(receiver)); |
| 999 | }, |
| 1000 | base::Unretained(host))); |
| 1001 | |
Johannes Kron | 98aca402 | 2022-02-18 21:15:24 | [diff] [blame] | 1002 | map->Add<media::mojom::WebrtcVideoPerfHistory>(base::BindRepeating( |
| 1003 | [](RenderFrameHostImpl* host, |
| 1004 | mojo::PendingReceiver<media::mojom::WebrtcVideoPerfHistory> receiver) { |
| 1005 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1006 | BrowserContextImpl::From(host->GetBrowserContext()) |
| 1007 | ->GetWebrtcVideoPerfHistory() |
| 1008 | ->BindReceiver(std::move(receiver)); |
| 1009 | }, |
| 1010 | base::Unretained(host))); |
| 1011 | |
Miyoung Shin | 09b6456 | 2019-11-28 02:49:02 | [diff] [blame] | 1012 | #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 1013 | map->Add<media::mojom::RemoterFactory>( |
| 1014 | base::BindRepeating(&RenderFrameHostImpl::BindMediaRemoterFactoryReceiver, |
| 1015 | base::Unretained(host))); |
| 1016 | #endif |
| 1017 | |
Rayan Kanso | 2b1096c | 2021-09-21 09:49:14 | [diff] [blame] | 1018 | map->Add<blink::mojom::OneShotBackgroundSyncService>(base::BindRepeating( |
| 1019 | [](RenderFrameHostImpl* host, |
| 1020 | mojo::PendingReceiver<blink::mojom::OneShotBackgroundSyncService> |
| 1021 | receiver) { |
| 1022 | host->GetProcess()->CreateOneShotSyncService( |
Mariam Ali | 8338d9fa | 2023-07-24 16:57:31 | [diff] [blame] | 1023 | host->GetStorageKey().origin(), std::move(receiver)); |
Rayan Kanso | 2b1096c | 2021-09-21 09:49:14 | [diff] [blame] | 1024 | }, |
| 1025 | base::Unretained(host))); |
Lingqi Chi | bcc673e | 2020-09-16 03:12:03 | [diff] [blame] | 1026 | |
Rayan Kanso | 2b1096c | 2021-09-21 09:49:14 | [diff] [blame] | 1027 | map->Add<blink::mojom::PeriodicBackgroundSyncService>(base::BindRepeating( |
| 1028 | [](RenderFrameHostImpl* host, |
| 1029 | mojo::PendingReceiver<blink::mojom::PeriodicBackgroundSyncService> |
| 1030 | receiver) { |
| 1031 | host->GetProcess()->CreatePeriodicSyncService( |
Mariam Ali | 8338d9fa | 2023-07-24 16:57:31 | [diff] [blame] | 1032 | host->GetStorageKey().origin(), std::move(receiver)); |
Rayan Kanso | 2b1096c | 2021-09-21 09:49:14 | [diff] [blame] | 1033 | }, |
| 1034 | base::Unretained(host))); |
Lingqi Chi | 128fbd7 | 2020-09-16 03:36:09 | [diff] [blame] | 1035 | |
Mario Sanchez Prada | 416cfd4 | 2019-09-30 15:15:29 | [diff] [blame] | 1036 | map->Add<media::mojom::VideoDecodePerfHistory>( |
| 1037 | base::BindRepeating(&RenderProcessHost::BindVideoDecodePerfHistory, |
| 1038 | base::Unretained(host->GetProcess()))); |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1039 | |
Miyoung Shin | 58d0b6c | 2019-12-03 07:38:18 | [diff] [blame] | 1040 | map->Add<network::mojom::RestrictedCookieManager>( |
| 1041 | base::BindRepeating(&RenderFrameHostImpl::BindRestrictedCookieManager, |
| 1042 | base::Unretained(host))); |
| 1043 | |
Aykut Bulut | b988425 | 2022-07-18 16:18:38 | [diff] [blame] | 1044 | map->Add<network::mojom::TrustTokenQueryAnswerer>( |
| 1045 | base::BindRepeating(&RenderFrameHostImpl::BindTrustTokenQueryAnswerer, |
David Van Cleve | 8a36b0f | 2020-04-08 17:44:03 | [diff] [blame] | 1046 | base::Unretained(host))); |
| 1047 | |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1048 | map->Add<shape_detection::mojom::BarcodeDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1049 | &BindBarcodeDetectionProvider); |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1050 | |
| 1051 | map->Add<shape_detection::mojom::FaceDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1052 | &BindFaceDetectionProvider); |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1053 | |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1054 | map->Add<shape_detection::mojom::TextDetection>(&BindTextDetection); |
Miyoung Shin | 74a9bdcc | 2019-10-01 01:59:05 | [diff] [blame] | 1055 | |
Miyoung Shin | 56d4732 | 2019-12-03 13:01:16 | [diff] [blame] | 1056 | auto* command_line = base::CommandLine::ForCurrentProcess(); |
Peter Kasting | 6e6af3c | 2024-10-15 00:13:18 | [diff] [blame] | 1057 | if (command_line->HasSwitch(switches::kEnableGpuBenchmarking)) { |
Miyoung Shin | 56d4732 | 2019-12-03 13:01:16 | [diff] [blame] | 1058 | map->Add<mojom::InputInjector>( |
| 1059 | base::BindRepeating(&RenderFrameHostImpl::BindInputInjectorReceiver, |
| 1060 | base::Unretained(host))); |
| 1061 | } |
| 1062 | |
Gyuyoung Kim | 9ce9ddda | 2025-06-19 02:01:14 | [diff] [blame] | 1063 | #if BUILDFLAG(IS_ANDROID) || (BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)) |
Nathan Memmott | b3e20ab | 2024-12-14 02:04:42 | [diff] [blame] | 1064 | map->Add<device::mojom::NFC>(base::BindRepeating( |
| 1065 | &RenderFrameHostImpl::BindNFCReceiver, base::Unretained(host))); |
Miyoung Shin | 74a9bdcc | 2019-10-01 01:59:05 | [diff] [blame] | 1066 | #else |
| 1067 | map->Add<blink::mojom::HidService>(base::BindRepeating( |
| 1068 | &RenderFrameHostImpl::GetHidService, base::Unretained(host))); |
| 1069 | |
Rayan Kanso | fbd962fe | 2020-05-27 17:26:47 | [diff] [blame] | 1070 | map->Add<blink::mojom::InstalledAppProvider>( |
| 1071 | base::BindRepeating(&RenderFrameHostImpl::CreateInstalledAppProvider, |
| 1072 | base::Unretained(host))); |
Gyuyoung Kim | 9ce9ddda | 2025-06-19 02:01:14 | [diff] [blame] | 1073 | #endif // BUILDFLAG(IS_ANDROID) || (BUILDFLAG(IS_IOS) && |
| 1074 | // !BUILDFLAG(IS_IOS_TVOS)) |
Rayan Kanso | fbd962fe | 2020-05-27 17:26:47 | [diff] [blame] | 1075 | |
Reilly Grant | 276296b | 2019-10-17 20:00:15 | [diff] [blame] | 1076 | map->Add<blink::mojom::SerialService>(base::BindRepeating( |
| 1077 | &RenderFrameHostImpl::BindSerialService, base::Unretained(host))); |
Julie Jeongeun Kim | 8e157b2 | 2020-04-22 04:02:41 | [diff] [blame] | 1078 | |
Daniel d'Andrada | 8ed516f | 2023-02-28 15:46:16 | [diff] [blame] | 1079 | #if BUILDFLAG(IS_CHROMEOS) |
Daniel d'Andrada | a028934 | 2022-12-14 08:48:04 | [diff] [blame] | 1080 | map->Add<blink::mojom::SmartCardService>(base::BindRepeating( |
| 1081 | &RenderFrameHostImpl::GetSmartCardService, base::Unretained(host))); |
| 1082 | #endif |
| 1083 | |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 1084 | #if BUILDFLAG(IS_MAC) |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1085 | map->Add<blink::mojom::TextInputHost>(&BindTextInputHost); |
Julie Jeongeun Kim | 8e157b2 | 2020-04-22 04:02:41 | [diff] [blame] | 1086 | #endif |
Dan Elphick | 1a677ec | 2021-06-29 11:15:31 | [diff] [blame] | 1087 | |
Chris Harrelson | d2fe06ad | 2022-07-11 21:36:23 | [diff] [blame] | 1088 | map->Add<blink::mojom::RenderAccessibilityHost>( |
Dan Elphick | 1a677ec | 2021-06-29 11:15:31 | [diff] [blame] | 1089 | base::BindRepeating(&RenderFrameHostImpl::BindRenderAccessibilityHost, |
| 1090 | base::Unretained(host))); |
Guocheng Wei | ae52cc3 | 2022-11-24 01:45:40 | [diff] [blame] | 1091 | |
Minoru Chikamune | c2d363c | 2022-11-28 08:26:24 | [diff] [blame] | 1092 | map->Add<blink::mojom::NonAssociatedLocalFrameHost>( |
| 1093 | base::BindRepeating(&RenderFrameHostImpl::BindNonAssociatedLocalFrameHost, |
| 1094 | base::Unretained(host))); |
| 1095 | |
Guocheng Wei | ae52cc3 | 2022-11-24 01:45:40 | [diff] [blame] | 1096 | #if BUILDFLAG(IS_FUCHSIA) |
| 1097 | map->Add<media::mojom::FuchsiaMediaCodecProvider>( |
| 1098 | base::BindRepeating(&RenderProcessHost::BindMediaCodecProvider, |
| 1099 | base::Unretained(host->GetProcess()))); |
| 1100 | #endif |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 1101 | |
Fergal Daly | b810d69 | 2024-11-22 04:07:23 | [diff] [blame] | 1102 | if (base::FeatureList::IsEnabled(blink::features::kBuiltInAIAPI)) { |
Fergal Daly | 2935c7a | 2024-11-07 06:29:43 | [diff] [blame] | 1103 | // We take the `document_associated_data` when the callback runs because |
| 1104 | // RenderFrameHosts live across multiple documents. Even though the current |
| 1105 | // implementation of `document_associated_data` persists across documents, |
| 1106 | // that is an implementation detail, without a guarantee. |
Mingyu Lei | f6f9bc1c | 2024-08-15 05:23:21 | [diff] [blame] | 1107 | map->Add<blink::mojom::AIManager>(base::BindRepeating( |
Fergal Daly | 2935c7a | 2024-11-07 06:29:43 | [diff] [blame] | 1108 | [](ContentBrowserClient* browser_client, RenderFrameHostImpl* host, |
| 1109 | mojo::PendingReceiver<blink::mojom::AIManager> receiver) { |
| 1110 | browser_client->BindAIManager(host->GetBrowserContext(), |
Clark DuVall | b0423977 | 2025-04-14 20:37:04 | [diff] [blame] | 1111 | &host->document_associated_data(), host, |
Fergal Daly | 2935c7a | 2024-11-07 06:29:43 | [diff] [blame] | 1112 | std::move(receiver)); |
| 1113 | }, |
Mingyu Lei | f6f9bc1c | 2024-08-15 05:23:21 | [diff] [blame] | 1114 | base::Unretained(GetContentClient()->browser()), |
Fergal Daly | 2935c7a | 2024-11-07 06:29:43 | [diff] [blame] | 1115 | base::Unretained(host))); |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 1116 | } |
Fergal Daly | b65f07b | 2024-12-09 07:52:38 | [diff] [blame] | 1117 | |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1118 | if (base::FeatureList::IsEnabled(blink::features::kTranslationAPI)) { |
| 1119 | map->Add<blink::mojom::TranslationManager>(base::BindRepeating( |
| 1120 | [](RenderFrameHostImpl* host, |
| 1121 | mojo::PendingReceiver<blink::mojom::TranslationManager> receiver) { |
| 1122 | GetContentClient()->browser()->BindTranslationManager( |
Christine Hollingsworth | a1142ee | 2025-06-26 14:55:26 | [diff] [blame] | 1123 | host->GetProcess(), host->GetBrowserContext(), |
| 1124 | &host->document_associated_data(), host->GetLastCommittedOrigin(), |
| 1125 | std::move(receiver)); |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1126 | }, |
| 1127 | base::Unretained(host))); |
| 1128 | } |
Fergal Daly | b65f07b | 2024-12-09 07:52:38 | [diff] [blame] | 1129 | |
| 1130 | if (base::FeatureList::IsEnabled(blink::features::kLanguageDetectionAPI)) { |
| 1131 | map->Add<language_detection::mojom::ContentLanguageDetectionDriver>( |
| 1132 | base::BindRepeating( |
| 1133 | [](RenderFrameHostImpl* host, |
| 1134 | mojo::PendingReceiver< |
| 1135 | language_detection::mojom::ContentLanguageDetectionDriver> |
| 1136 | receiver) { |
| 1137 | GetContentClient()->browser()->BindLanguageDetectionDriver( |
| 1138 | host->GetBrowserContext(), &host->document_associated_data(), |
| 1139 | std::move(receiver)); |
| 1140 | }, |
| 1141 | base::Unretained(host))); |
| 1142 | } |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 1143 | } |
| 1144 | |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1145 | void PopulateBinderMapWithContext( |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1146 | RenderFrameHostImpl* host, |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1147 | mojo::BinderMapWithContext<RenderFrameHost*>* map) { |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1148 | // Register empty binders for interfaces not bound by content but requested |
| 1149 | // by blink. |
| 1150 | // This avoids renderer kills when no binder is found in the absence of the |
| 1151 | // production embedder (such as in tests). |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1152 | map->Add<blink::mojom::NoStatePrefetchProcessor>( |
| 1153 | &EmptyBinderForFrame<blink::mojom::NoStatePrefetchProcessor>); |
| 1154 | map->Add<payments::mojom::PaymentRequest>( |
| 1155 | &EmptyBinderForFrame<payments::mojom::PaymentRequest>); |
| 1156 | map->Add<blink::mojom::AnchorElementMetricsHost>( |
| 1157 | &EmptyBinderForFrame<blink::mojom::AnchorElementMetricsHost>); |
| 1158 | map->Add<blink::mojom::CredentialManager>( |
| 1159 | &EmptyBinderForFrame<blink::mojom::CredentialManager>); |
| 1160 | map->Add<blink::mojom::LCPCriticalPathPredictorHost>( |
| 1161 | &EmptyBinderForFrame<blink::mojom::LCPCriticalPathPredictorHost>); |
Sandor Major | f42e6bd6 | 2025-02-28 00:12:04 | [diff] [blame] | 1162 | if (base::FeatureList::IsEnabled(network::features::kBrowsingTopics) && |
Abigail Katcoff | 0e9e310 | 2023-05-30 16:55:41 | [diff] [blame] | 1163 | base::FeatureList::IsEnabled( |
| 1164 | blink::features::kBrowsingTopicsDocumentAPI)) { |
Yao Xiao | da2481e | 2022-03-31 21:20:04 | [diff] [blame] | 1165 | map->Add<blink::mojom::BrowsingTopicsDocumentService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1166 | &BrowsingTopicsDocumentHost::CreateMojoService); |
Yao Xiao | da2481e | 2022-03-31 21:20:04 | [diff] [blame] | 1167 | } |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 1168 | #if !BUILDFLAG(IS_ANDROID) |
Andrew Rayskiy | b6d99498 | 2022-09-01 10:24:42 | [diff] [blame] | 1169 | map->Add<blink::mojom::DirectSocketsService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1170 | &DirectSocketsServiceImpl::CreateForFrame); |
| 1171 | map->Add<media::mojom::SpeechRecognitionContext>( |
| 1172 | &EmptyBinderForFrame<media::mojom::SpeechRecognitionContext>); |
evliu | 3b6e6d5 | 2020-10-20 17:34:14 | [diff] [blame] | 1173 | map->Add<media::mojom::SpeechRecognitionClientBrowserInterface>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1174 | &EmptyBinderForFrame< |
| 1175 | media::mojom::SpeechRecognitionClientBrowserInterface>); |
| 1176 | map->Add<media::mojom::MediaFoundationRendererNotifier>( |
| 1177 | &EmptyBinderForFrame<media::mojom::MediaFoundationRendererNotifier>); |
| 1178 | map->Add<media::mojom::MediaPlayerObserverClient>( |
| 1179 | &EmptyBinderForFrame<media::mojom::MediaPlayerObserverClient>); |
Abigail Klein | 82807c55 | 2020-04-06 19:58:07 | [diff] [blame] | 1180 | #endif |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1181 | #if BUILDFLAG(ENABLE_UNHANDLED_TAP) |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1182 | map->Add<blink::mojom::UnhandledTapNotifier>( |
| 1183 | &EmptyBinderForFrame<blink::mojom::UnhandledTapNotifier>); |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1184 | #endif |
| 1185 | |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1186 | map->Add<blink::mojom::BackgroundFetchService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1187 | &BackgroundFetchServiceImpl::CreateForFrame); |
| 1188 | map->Add<blink::mojom::ColorChooserFactory>(&BindColorChooserFactoryForFrame); |
| 1189 | map->Add<blink::mojom::EyeDropperChooser>(&EyeDropperChooserImpl::Create); |
Victor Costan | 31ca3d2 | 2019-10-11 02:33:37 | [diff] [blame] | 1190 | map->Add<blink::mojom::CookieStore>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1191 | &CookieStoreManager::BindReceiverForFrame); |
Miyoung Shin | f9dd145 | 2019-09-24 12:57:46 | [diff] [blame] | 1192 | map->Add<blink::mojom::ContentIndexService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1193 | &ContentIndexServiceImpl::CreateForFrame); |
Takuto Ikuta | 7cdebf6 | 2024-02-09 09:01:41 | [diff] [blame] | 1194 | map->Add<blink::mojom::KeyboardLockService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1195 | &KeyboardLockServiceImpl::CreateMojoService); |
Sandor Major | f42e6bd6 | 2025-02-28 00:12:04 | [diff] [blame] | 1196 | if (base::FeatureList::IsEnabled(network::features::kInterestGroupStorage)) { |
Takuto Ikuta | 08008015 | 2024-02-09 09:15:19 | [diff] [blame] | 1197 | map->Add<blink::mojom::AdAuctionService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1198 | &AdAuctionServiceImpl::CreateMojoService); |
Caleb Raitto | 6c7f5e68 | 2021-04-07 23:58:05 | [diff] [blame] | 1199 | } |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1200 | map->Add<blink::mojom::MediaSessionService>(&MediaSessionServiceImpl::Create); |
Miyoung Shin | 059c0ff7 | 2019-09-26 11:13:39 | [diff] [blame] | 1201 | map->Add<blink::mojom::PictureInPictureService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1202 | &PictureInPictureServiceImpl::Create); |
| 1203 | map->Add<blink::mojom::WakeLockService>(&WakeLockServiceImpl::Create); |
Alexander Cooper | 6e5bf7c6 | 2020-04-23 00:40:09 | [diff] [blame] | 1204 | #if BUILDFLAG(ENABLE_VR) |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1205 | map->Add<device::mojom::VRService>(&VRServiceImpl::Create); |
Alexander Cooper | 6e5bf7c6 | 2020-04-23 00:40:09 | [diff] [blame] | 1206 | #else |
| 1207 | map->Add<device::mojom::VRService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1208 | &EmptyBinderForFrame<device::mojom::VRService>); |
Alexander Cooper | 6e5bf7c6 | 2020-04-23 00:40:09 | [diff] [blame] | 1209 | #endif |
John Delaney | 35c275f | 2022-08-19 19:31:54 | [diff] [blame] | 1210 | RegisterWebUIControllerInterfaceBinder< |
Dan McArdle | c8fe5af | 2023-11-02 18:59:25 | [diff] [blame] | 1211 | private_aggregation_internals::mojom::Factory, |
| 1212 | PrivateAggregationInternalsUI>(map); |
Andrew Paseltiner | 88f6d95 | 2023-02-15 21:17:00 | [diff] [blame] | 1213 | RegisterWebUIControllerInterfaceBinder<attribution_internals::mojom::Factory, |
Robert Sesek | 976c70cf | 2022-08-12 19:17:57 | [diff] [blame] | 1214 | AttributionInternalsUI>(map); |
Nathan Memmott | 6729cf5 | 2022-10-18 20:04:07 | [diff] [blame] | 1215 | RegisterWebUIControllerInterfaceBinder<storage::mojom::IdbInternalsHandler, |
Evan Stade | cbb1e00 | 2024-09-13 20:06:57 | [diff] [blame] | 1216 | indexed_db::IndexedDBInternalsUI>(map); |
Robert Sesek | 976c70cf | 2022-08-12 19:17:57 | [diff] [blame] | 1217 | RegisterWebUIControllerInterfaceBinder<::mojom::ProcessInternalsHandler, |
| 1218 | ProcessInternalsUI>(map); |
| 1219 | RegisterWebUIControllerInterfaceBinder<storage::mojom::QuotaInternalsHandler, |
| 1220 | QuotaInternalsUI>(map); |
Sergey Ulanov | 647ad46 | 2025-02-19 19:34:33 | [diff] [blame] | 1221 | #if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_FUCHSIA) |
Alex Attar | 9624dfb | 2023-09-28 01:32:35 | [diff] [blame] | 1222 | RegisterWebUIControllerInterfaceBinder< |
Etienne Pierre-doray | 6db6af4f | 2025-06-05 14:20:59 | [diff] [blame] | 1223 | traces_internals::mojom::TracesInternalsHandlerFactory, |
| 1224 | TracesInternalsUI>(map); |
Alex Attar | 4ee3fa3d | 2023-11-06 16:33:11 | [diff] [blame] | 1225 | #endif |
Mahmoud Ahmed | c4eee9a3 | 2023-07-21 17:19:24 | [diff] [blame] | 1226 | #if BUILDFLAG(ENABLE_VR) |
| 1227 | RegisterWebUIControllerInterfaceBinder<webxr::mojom::WebXrInternalsHandler, |
| 1228 | WebXrInternalsUI>(map); |
| 1229 | #endif |
Gyuyoung Kim | 3bd4ce0 | 2025-06-25 21:28:01 | [diff] [blame] | 1230 | #if BUILDFLAG(IS_ANDROID) || (BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)) |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1231 | map->Add<blink::mojom::DateTimeChooser>(&BindDateTimeChooserForFrame); |
Julie Jeongeun Kim | eac2fe2 | 2023-07-18 11:55:02 | [diff] [blame] | 1232 | #endif |
| 1233 | #if BUILDFLAG(IS_ANDROID) |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1234 | map->Add<blink::mojom::TextSuggestionHost>(&BindTextSuggestionHostForFrame); |
Kalvin Lee | e0f0c49 | 2025-07-01 06:40:58 | [diff] [blame] | 1235 | #else |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1236 | map->Add<blink::mojom::TextSuggestionHost>( |
| 1237 | &EmptyBinderForFrame<blink::mojom::TextSuggestionHost>); |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 1238 | #endif // BUILDFLAG(IS_ANDROID) |
Miyoung Shin | 87cd452 | 2019-10-04 05:00:05 | [diff] [blame] | 1239 | |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1240 | map->Add<blink::mojom::Authenticator>( |
Chris Staite | 8d2ebea | 2025-05-01 17:30:11 | [diff] [blame] | 1241 | [](RenderFrameHost* host, |
| 1242 | mojo::PendingReceiver<blink::mojom::Authenticator> receiver) { |
| 1243 | static_cast<RenderFrameHostImpl*>(host)->GetWebAuthenticationService( |
| 1244 | std::move(receiver)); |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1245 | }); |
| 1246 | map->Add<blink::mojom::ClipboardHost>(&ClipboardHostImpl::Create); |
| 1247 | map->Add<blink::mojom::SpeculationHost>(&SpeculationHostImpl::Bind); |
Adithya Srinivasan | 0d3e5718 | 2024-09-10 14:10:34 | [diff] [blame] | 1248 | map->Add<blink::mojom::AnchorElementInteractionHost>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1249 | &AnchorElementInteractionHostImpl::Create); |
Raymes Khoury | e24e0a9 | 2021-12-20 01:16:16 | [diff] [blame] | 1250 | |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 1251 | #if BUILDFLAG(IS_CHROMEOS) |
Raymes Khoury | e24e0a9 | 2021-12-20 01:16:16 | [diff] [blame] | 1252 | if (base::FeatureList::IsEnabled(features::kWebLockScreenApi)) { |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1253 | map->Add<blink::mojom::LockScreenService>(&LockScreenServiceImpl::Create); |
Raymes Khoury | e24e0a9 | 2021-12-20 01:16:16 | [diff] [blame] | 1254 | } |
| 1255 | #endif |
Sergey Ulanov | ff752e4a | 2022-04-06 23:04:36 | [diff] [blame] | 1256 | |
| 1257 | #if BUILDFLAG(IS_FUCHSIA) |
Guocheng Wei | b4535741 | 2022-11-28 23:39:54 | [diff] [blame] | 1258 | map->Add<media::mojom::FuchsiaMediaCdmProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1259 | &FuchsiaMediaCdmProviderImpl::Bind); |
Sergey Ulanov | ff752e4a | 2022-04-06 23:04:36 | [diff] [blame] | 1260 | #endif |
kyraseevers | 2ca6dec | 2023-02-28 00:52:11 | [diff] [blame] | 1261 | |
Jiewei Qian | c7a39e3 | 2023-09-28 06:25:40 | [diff] [blame] | 1262 | map->Add<blink::mojom::OriginTrialStateHost>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1263 | &OriginTrialStateHostImpl::Create); |
| 1264 | map->Add<blink::mojom::StorageAccessHandle>(&StorageAccessHandle::Create); |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 1265 | |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1266 | map->Add<optimization_guide::mojom::ModelBroker>( |
| 1267 | &EmptyBinderForFrame<optimization_guide::mojom::ModelBroker>); |
Fergal Daly | b810d69 | 2024-11-22 04:07:23 | [diff] [blame] | 1268 | if (base::FeatureList::IsEnabled(blink::features::kBuiltInAIAPI)) { |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 1269 | map->Add<blink::mojom::AIManager>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1270 | &EmptyBinderForFrame<blink::mojom::AIManager>); |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 1271 | } |
Chris Staite | 8d2ebea | 2025-05-01 17:30:11 | [diff] [blame] | 1272 | |
| 1273 | // This should be last to allow overrides of any interface. |
| 1274 | GetContentClient()->browser()->RegisterBrowserInterfaceBindersForFrame(host, |
| 1275 | map); |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1276 | } |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1277 | |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1278 | void PopulateBinderMap(RenderFrameHostImpl* host, mojo::BinderMap* map) { |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1279 | PopulateFrameBinders(host, map); |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 1280 | } |
| 1281 | |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1282 | RenderFrameHost* GetContextForHost(RenderFrameHostImpl* host) { |
| 1283 | return host; |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1284 | } |
| 1285 | |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1286 | // Dedicated workers |
| 1287 | const url::Origin& GetContextForHost(DedicatedWorkerHost* host) { |
Antonio Sartori | 4c385ecc | 2021-06-30 09:14:25 | [diff] [blame] | 1288 | return host->GetStorageKey().origin(); |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | void PopulateDedicatedWorkerBinders(DedicatedWorkerHost* host, |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1292 | mojo::BinderMap* map) { |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1293 | // Do nothing for interfaces that the renderer might request, but doesn't |
| 1294 | // always expect to be bound. |
| 1295 | map->Add<blink::mojom::FeatureObserver>(base::DoNothing()); |
| 1296 | |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1297 | // static binders |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1298 | map->Add<shape_detection::mojom::BarcodeDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1299 | &BindBarcodeDetectionProvider); |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1300 | map->Add<shape_detection::mojom::FaceDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1301 | &BindFaceDetectionProvider); |
| 1302 | map->Add<shape_detection::mojom::TextDetection>(&BindTextDetection); |
| 1303 | map->Add<ukm::mojom::UkmRecorderFactory>(&BindUkmRecorderFactory); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1304 | |
| 1305 | // worker host binders |
| 1306 | // base::Unretained(host) is safe because the map is owned by |
| 1307 | // |DedicatedWorkerHost::broker_|. |
| 1308 | map->Add<blink::mojom::IdleManager>(base::BindRepeating( |
| 1309 | &DedicatedWorkerHost::CreateIdleManager, base::Unretained(host))); |
Miyoung Shin | 996cb65 | 2019-11-28 03:27:22 | [diff] [blame] | 1310 | map->Add<blink::mojom::DedicatedWorkerHostFactory>( |
| 1311 | base::BindRepeating(&DedicatedWorkerHost::CreateNestedDedicatedWorker, |
| 1312 | base::Unretained(host))); |
Tal Pressman | c6192c1 | 2021-03-08 06:46:02 | [diff] [blame] | 1313 | |
| 1314 | map->Add<blink::mojom::FileUtilitiesHost>( |
| 1315 | base::BindRepeating(FileUtilitiesHostImpl::Create, |
Emily Andrews | d15fd76 | 2024-12-10 20:41:54 | [diff] [blame] | 1316 | host->GetProcessHost()->GetDeprecatedID()), |
Tal Pressman | c6192c1 | 2021-03-08 06:46:02 | [diff] [blame] | 1317 | base::ThreadPool::CreateSequencedTaskRunner( |
| 1318 | {base::MayBlock(), base::TaskPriority::USER_VISIBLE})); |
| 1319 | |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 1320 | if (base::FeatureList::IsEnabled( |
Alex Gough | 6ae9128 | 2023-12-18 23:19:23 | [diff] [blame] | 1321 | webnn::mojom::features::kWebMachineLearningNeuralNetwork)) { |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 1322 | // base::Unretained(host->GetProcessHost()) is safe because the map is owned |
| 1323 | // by |DedicatedWorkerHost::broker_|. |
| 1324 | map->Add<webnn::mojom::WebNNContextProvider>(base::BindRepeating( |
Joshua Bell | bc43ccf | 2025-03-05 23:21:22 | [diff] [blame] | 1325 | &BindWebNNContextProviderForWorker<DedicatedWorkerHost>, |
| 1326 | base::Unretained(host))); |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 1327 | } |
Enrico Galli | 19271ea | 2023-10-04 01:41:48 | [diff] [blame] | 1328 | |
Andrew Rayskiy | 0b29f12 | 2023-06-21 14:30:43 | [diff] [blame] | 1329 | #if !BUILDFLAG(IS_ANDROID) |
| 1330 | map->Add<blink::mojom::DirectSocketsService>( |
| 1331 | base::BindRepeating(&DedicatedWorkerHost::CreateDirectSocketsService, |
| 1332 | base::Unretained(host))); |
| 1333 | #endif |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1334 | map->Add<blink::mojom::WebUsbService>(base::BindRepeating( |
| 1335 | &DedicatedWorkerHost::CreateWebUsbService, base::Unretained(host))); |
Miyoung Shin | e5cb8f1 | 2019-11-27 16:40:54 | [diff] [blame] | 1336 | map->Add<blink::mojom::WebSocketConnector>(base::BindRepeating( |
| 1337 | &DedicatedWorkerHost::CreateWebSocketConnector, base::Unretained(host))); |
Adam Rice | e98a2232 | 2021-04-27 08:26:26 | [diff] [blame] | 1338 | map->Add<blink::mojom::WebTransportConnector>( |
| 1339 | base::BindRepeating(&DedicatedWorkerHost::CreateWebTransportConnector, |
Yutaka Hirano | 492c93d | 2019-11-05 11:28:03 | [diff] [blame] | 1340 | base::Unretained(host))); |
Reilly Grant | d6714bc | 2020-03-18 20:46:57 | [diff] [blame] | 1341 | map->Add<blink::mojom::WakeLockService>(base::BindRepeating( |
| 1342 | &DedicatedWorkerHost::CreateWakeLockService, base::Unretained(host))); |
Hiroki Nakagawa | 761b9b0 | 2020-07-13 11:12:02 | [diff] [blame] | 1343 | map->Add<blink::mojom::ContentSecurityNotifier>( |
| 1344 | base::BindRepeating(&DedicatedWorkerHost::CreateContentSecurityNotifier, |
| 1345 | base::Unretained(host))); |
arthursonzogni | bb006d8 | 2020-03-11 14:30:06 | [diff] [blame] | 1346 | map->Add<blink::mojom::CacheStorage>(base::BindRepeating( |
| 1347 | &DedicatedWorkerHost::BindCacheStorage, base::Unretained(host))); |
Mythri A | 25d7bdd | 2021-06-15 11:20:48 | [diff] [blame] | 1348 | map->Add<blink::mojom::CodeCacheHost>(base::BindRepeating( |
| 1349 | &DedicatedWorkerHost::CreateCodeCacheHost, base::Unretained(host))); |
Andrew Williams | 61e816d | 2021-11-01 04:41:04 | [diff] [blame] | 1350 | map->Add<blink::mojom::BroadcastChannelProvider>( |
| 1351 | base::BindRepeating(&DedicatedWorkerHost::CreateBroadcastChannelProvider, |
| 1352 | base::Unretained(host))); |
janiceliu | 2457d49d | 2024-07-09 18:15:57 | [diff] [blame] | 1353 | map->Add<blink::mojom::BlobURLStore>( |
| 1354 | base::BindRepeating(&DedicatedWorkerHost::CreateBlobUrlStoreProvider, |
| 1355 | base::Unretained(host))); |
Matt Menke | 6751f66 | 2020-12-01 05:44:00 | [diff] [blame] | 1356 | map->Add<blink::mojom::ReportingServiceProxy>(base::BindRepeating( |
| 1357 | &CreateReportingServiceProxyForDedicatedWorker, base::Unretained(host))); |
Reilly Grant | 276296b | 2019-10-17 20:00:15 | [diff] [blame] | 1358 | map->Add<blink::mojom::SerialService>(base::BindRepeating( |
| 1359 | &DedicatedWorkerHost::BindSerialService, base::Unretained(host))); |
Garfield Tan | 6aba003 | 2025-02-14 02:07:35 | [diff] [blame] | 1360 | #if !BUILDFLAG(IS_ANDROID) |
François Beaufort | d7269ab | 2024-09-18 13:18:00 | [diff] [blame] | 1361 | map->Add<blink::mojom::HidService>(base::BindRepeating( |
| 1362 | &DedicatedWorkerHost::BindHidService, base::Unretained(host))); |
Xiaohan Wang | 1ecfd00 | 2022-01-19 22:33:10 | [diff] [blame] | 1363 | #endif // !BUILDFLAG(IS_ANDROID) |
Evan Stade | 88ef2232 | 2022-09-12 21:19:09 | [diff] [blame] | 1364 | map->Add<blink::mojom::BucketManagerHost>(base::BindRepeating( |
| 1365 | &DedicatedWorkerHost::CreateBucketManagerHost, base::Unretained(host))); |
Nathan Memmott | a9fcfeb | 2023-10-31 19:58:30 | [diff] [blame] | 1366 | map->Add<blink::mojom::FileSystemAccessManager>( |
| 1367 | base::BindRepeating(&DedicatedWorkerHost::GetFileSystemAccessManager, |
| 1368 | base::Unretained(host))); |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 1369 | #if BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Wei4 Wang | 353aca0 | 2023-12-14 03:40:58 | [diff] [blame] | 1370 | if (base::FeatureList::IsEnabled(blink::features::kComputePressure)) { |
Raphael Kubo da Costa | e8d284a | 2024-07-01 08:46:30 | [diff] [blame] | 1371 | map->Add<blink::mojom::WebPressureManager>(base::BindRepeating( |
Wei4 Wang | 353aca0 | 2023-12-14 03:40:58 | [diff] [blame] | 1372 | &DedicatedWorkerHost::BindPressureService, base::Unretained(host))); |
| 1373 | } |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 1374 | #endif // BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1375 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1376 | // RenderProcessHost binders |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1377 | map->Add<media::mojom::VideoDecodePerfHistory>(BindWorkerReceiver( |
| 1378 | &RenderProcessHostImpl::BindVideoDecodePerfHistory, host)); |
Johannes Kron | 98aca402 | 2022-02-18 21:15:24 | [diff] [blame] | 1379 | map->Add<media::mojom::WebrtcVideoPerfHistory>(BindWorkerReceiver( |
| 1380 | &RenderProcessHostImpl::BindWebrtcVideoPerfHistory, host)); |
Guocheng Wei | ae52cc3 | 2022-11-24 01:45:40 | [diff] [blame] | 1381 | #if BUILDFLAG(IS_FUCHSIA) |
| 1382 | map->Add<media::mojom::FuchsiaMediaCodecProvider>( |
| 1383 | BindWorkerReceiver(&RenderProcessHostImpl::BindMediaCodecProvider, host)); |
| 1384 | #endif |
Antonio Sartori | 12147a8 | 2021-07-13 15:40:53 | [diff] [blame] | 1385 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1386 | // RenderProcessHost binders taking a StorageKey |
kyraseevers | 28b58f56 | 2021-09-09 16:09:04 | [diff] [blame] | 1387 | map->Add<blink::mojom::FileSystemManager>(BindWorkerReceiverForStorageKey( |
| 1388 | &RenderProcessHostImpl::BindFileSystemManager, host)); |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 1389 | map->Add<blink::mojom::IDBFactory>( |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 1390 | BindWorkerReceiverForStorageKeyAndBucketContext( |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 1391 | &RenderProcessHostImpl::BindIndexedDB, host)); |
Joshua Hood | bd47013d | 2022-01-06 19:45:04 | [diff] [blame] | 1392 | map->Add<blink::mojom::LockManager>(BindWorkerReceiverForStorageKey( |
| 1393 | &RenderProcessHostImpl::CreateLockManager, host)); |
Marijn Kruisselbrink | 6058902 | 2022-05-03 19:54:18 | [diff] [blame] | 1394 | map->Add<blink::mojom::QuotaManagerHost>(BindWorkerReceiverForStorageKey( |
| 1395 | &RenderProcessHostImpl::BindQuotaManagerHost, host)); |
Andrew Williams | fc09056 | 2022-12-05 17:53:48 | [diff] [blame] | 1396 | map->Add<blink::mojom::NotificationService>(BindNotificationService( |
| 1397 | host->GetAncestorRenderFrameHostId(), |
| 1398 | RenderProcessHost::NotificationServiceCreatorType::kDedicatedWorker, |
| 1399 | host)); |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 1400 | |
Fergal Daly | b810d69 | 2024-11-22 04:07:23 | [diff] [blame] | 1401 | if (base::FeatureList::IsEnabled(blink::features::kBuiltInAIAPI)) { |
Clark DuVall | b0423977 | 2025-04-14 20:37:04 | [diff] [blame] | 1402 | map->Add<blink::mojom::AIManager>( |
| 1403 | base::BindRepeating(&ContentBrowserClient::BindAIManager, |
| 1404 | base::Unretained(GetContentClient()->browser()), |
| 1405 | host->GetProcessHost()->GetBrowserContext(), |
| 1406 | base::Unretained(host), /*rfh=*/nullptr)); |
Mingyu Lei | 682f658 | 2024-06-14 04:26:59 | [diff] [blame] | 1407 | } |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1408 | if (base::FeatureList::IsEnabled(blink::features::kTranslationAPI)) { |
| 1409 | map->Add<blink::mojom::TranslationManager>(base::BindRepeating( |
| 1410 | [](DedicatedWorkerHost* host, |
| 1411 | mojo::PendingReceiver<blink::mojom::TranslationManager> receiver) { |
Christine Hollingsworth | a1142ee | 2025-06-26 14:55:26 | [diff] [blame] | 1412 | auto* process_host = host->GetProcessHost(); |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1413 | GetContentClient()->browser()->BindTranslationManager( |
Christine Hollingsworth | a1142ee | 2025-06-26 14:55:26 | [diff] [blame] | 1414 | process_host, process_host->GetBrowserContext(), host, |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1415 | host->GetStorageKey().origin(), std::move(receiver)); |
| 1416 | }, |
| 1417 | base::Unretained(host))); |
| 1418 | } |
Jiacheng Guo | c62e3c02 | 2025-01-10 08:37:57 | [diff] [blame] | 1419 | if (base::FeatureList::IsEnabled(blink::features::kLanguageDetectionAPI)) { |
| 1420 | map->Add<language_detection::mojom::ContentLanguageDetectionDriver>( |
| 1421 | base::BindRepeating( |
| 1422 | [](DedicatedWorkerHost* host, |
| 1423 | mojo::PendingReceiver< |
| 1424 | language_detection::mojom::ContentLanguageDetectionDriver> |
| 1425 | receiver) { |
| 1426 | GetContentClient()->browser()->BindLanguageDetectionDriver( |
| 1427 | host->GetProcessHost()->GetBrowserContext(), host, |
| 1428 | std::move(receiver)); |
| 1429 | }, |
| 1430 | base::Unretained(host))); |
| 1431 | } |
Oksana Zhuravlova | 99a8e52 | 2019-08-20 21:58:11 | [diff] [blame] | 1432 | } |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 1433 | |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1434 | void PopulateBinderMapWithContext( |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1435 | DedicatedWorkerHost* host, |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1436 | mojo::BinderMapWithContext<const url::Origin&>* map) { |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1437 | // RenderProcessHost binders taking an origin |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 1438 | map->Add<payments::mojom::PaymentManager>(BindWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1439 | &RenderProcessHostImpl::CreatePaymentManagerForOrigin, host)); |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 1440 | map->Add<blink::mojom::PermissionService>(BindWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1441 | &RenderProcessHostImpl::CreatePermissionService, host)); |
Daniel Brinkers | 9004610c | 2023-10-23 15:27:51 | [diff] [blame] | 1442 | map->Add<blink::mojom::FileBackedBlobFactory>(BindWorkerReceiverForOrigin( |
| 1443 | &RenderProcessHostImpl::BindFileBackedBlobFactory, host)); |
David Risney | 909ecfc | 2025-06-25 21:23:24 | [diff] [blame] | 1444 | |
| 1445 | if (base::FeatureList::IsEnabled( |
| 1446 | blink::features::kServiceWorkerInDedicatedWorker) && |
| 1447 | base::FeatureList::IsEnabled( |
| 1448 | blink::features::kServiceWorkerBackgroundSyncInDedicatedWorker)) { |
| 1449 | map->Add<blink::mojom::OneShotBackgroundSyncService>( |
| 1450 | BindWorkerReceiverForOrigin( |
| 1451 | &RenderProcessHostImpl::CreateOneShotSyncService, host)); |
| 1452 | map->Add<blink::mojom::PeriodicBackgroundSyncService>( |
| 1453 | BindWorkerReceiverForOrigin( |
| 1454 | &RenderProcessHostImpl::CreatePeriodicSyncService, host)); |
| 1455 | } |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1456 | } |
| 1457 | |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1458 | void PopulateBinderMap(DedicatedWorkerHost* host, mojo::BinderMap* map) { |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1459 | PopulateDedicatedWorkerBinders(host, map); |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 1460 | } |
| 1461 | |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1462 | // Shared workers |
| 1463 | url::Origin GetContextForHost(SharedWorkerHost* host) { |
Patrick Monette | 608f1c5 | 2019-08-16 18:56:02 | [diff] [blame] | 1464 | return url::Origin::Create(host->instance().url()); |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1465 | } |
| 1466 | |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1467 | void PopulateSharedWorkerBinders(SharedWorkerHost* host, mojo::BinderMap* map) { |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1468 | // Do nothing for interfaces that the renderer might request, but doesn't |
| 1469 | // always expect to be bound. |
| 1470 | map->Add<blink::mojom::FeatureObserver>(base::DoNothing()); |
Hiroki Nakagawa | 761b9b0 | 2020-07-13 11:12:02 | [diff] [blame] | 1471 | // Ignore the pending receiver because it's not clear how to handle |
| 1472 | // notifications about content security (e.g., mixed contents and certificate |
| 1473 | // errors) on shared workers. Generally these notifications are routed to the |
| 1474 | // ancestor frame's WebContents like dedicated workers, but shared workers |
| 1475 | // don't have the ancestor frame. |
| 1476 | map->Add<blink::mojom::ContentSecurityNotifier>(base::DoNothing()); |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1477 | |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1478 | // static binders |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1479 | map->Add<shape_detection::mojom::BarcodeDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1480 | &BindBarcodeDetectionProvider); |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1481 | map->Add<shape_detection::mojom::FaceDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1482 | &BindFaceDetectionProvider); |
| 1483 | map->Add<shape_detection::mojom::TextDetection>(&BindTextDetection); |
| 1484 | map->Add<ukm::mojom::UkmRecorderFactory>(&BindUkmRecorderFactory); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1485 | |
| 1486 | // worker host binders |
| 1487 | // base::Unretained(host) is safe because the map is owned by |
| 1488 | // |SharedWorkerHost::broker_|. |
Tal Pressman | c6192c1 | 2021-03-08 06:46:02 | [diff] [blame] | 1489 | map->Add<blink::mojom::FileUtilitiesHost>( |
| 1490 | base::BindRepeating(FileUtilitiesHostImpl::Create, |
Emily Andrews | d15fd76 | 2024-12-10 20:41:54 | [diff] [blame] | 1491 | host->GetProcessHost()->GetDeprecatedID()), |
Tal Pressman | c6192c1 | 2021-03-08 06:46:02 | [diff] [blame] | 1492 | base::ThreadPool::CreateSequencedTaskRunner( |
| 1493 | {base::MayBlock(), base::TaskPriority::USER_VISIBLE})); |
| 1494 | |
Adam Rice | e98a2232 | 2021-04-27 08:26:26 | [diff] [blame] | 1495 | map->Add<blink::mojom::WebTransportConnector>(base::BindRepeating( |
| 1496 | &SharedWorkerHost::CreateWebTransportConnector, base::Unretained(host))); |
Hubert Chao | 0c32c1ab | 2025-08-22 13:06:10 | [diff] [blame] | 1497 | map->Add<blink::mojom::WebSocketConnector>(base::BindRepeating( |
| 1498 | &SharedWorkerHost::CreateWebSocketConnector, base::Unretained(host))); |
arthursonzogni | bb006d8 | 2020-03-11 14:30:06 | [diff] [blame] | 1499 | map->Add<blink::mojom::CacheStorage>(base::BindRepeating( |
| 1500 | &SharedWorkerHost::BindCacheStorage, base::Unretained(host))); |
Mythri A | 25d7bdd | 2021-06-15 11:20:48 | [diff] [blame] | 1501 | map->Add<blink::mojom::CodeCacheHost>(base::BindRepeating( |
| 1502 | &SharedWorkerHost::CreateCodeCacheHost, base::Unretained(host))); |
Andrew Williams | 61e816d | 2021-11-01 04:41:04 | [diff] [blame] | 1503 | map->Add<blink::mojom::BroadcastChannelProvider>( |
| 1504 | base::BindRepeating(&SharedWorkerHost::CreateBroadcastChannelProvider, |
| 1505 | base::Unretained(host))); |
janiceliu | 2457d49d | 2024-07-09 18:15:57 | [diff] [blame] | 1506 | map->Add<blink::mojom::BlobURLStore>(base::BindRepeating( |
| 1507 | &SharedWorkerHost::CreateBlobUrlStoreProvider, base::Unretained(host))); |
Matt Menke | 6751f66 | 2020-12-01 05:44:00 | [diff] [blame] | 1508 | map->Add<blink::mojom::ReportingServiceProxy>(base::BindRepeating( |
| 1509 | &CreateReportingServiceProxyForSharedWorker, base::Unretained(host))); |
Evan Stade | 88ef2232 | 2022-09-12 21:19:09 | [diff] [blame] | 1510 | map->Add<blink::mojom::BucketManagerHost>(base::BindRepeating( |
| 1511 | &SharedWorkerHost::CreateBucketManagerHost, base::Unretained(host))); |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 1512 | #if BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Wei4 Wang | 353aca0 | 2023-12-14 03:40:58 | [diff] [blame] | 1513 | if (base::FeatureList::IsEnabled(blink::features::kComputePressure)) { |
Raphael Kubo da Costa | e8d284a | 2024-07-01 08:46:30 | [diff] [blame] | 1514 | map->Add<blink::mojom::WebPressureManager>(base::BindRepeating( |
Wei4 Wang | 353aca0 | 2023-12-14 03:40:58 | [diff] [blame] | 1515 | &SharedWorkerHost::BindPressureService, base::Unretained(host))); |
| 1516 | } |
Arnaud Mandy | 624afa332 | 2024-08-09 13:33:54 | [diff] [blame] | 1517 | #endif // BUILDFLAG(ENABLE_COMPUTE_PRESSURE) |
Joshua Bell | bc43ccf | 2025-03-05 23:21:22 | [diff] [blame] | 1518 | if (base::FeatureList::IsEnabled( |
| 1519 | webnn::mojom::features::kWebMachineLearningNeuralNetwork)) { |
| 1520 | map->Add<webnn::mojom::WebNNContextProvider>(base::BindRepeating( |
| 1521 | &BindWebNNContextProviderForWorker<SharedWorkerHost>, |
| 1522 | base::Unretained(host))); |
| 1523 | } |
Fergal Daly | b810d69 | 2024-11-22 04:07:23 | [diff] [blame] | 1524 | if (base::FeatureList::IsEnabled(blink::features::kBuiltInAIAPI)) { |
Clark DuVall | b0423977 | 2025-04-14 20:37:04 | [diff] [blame] | 1525 | map->Add<blink::mojom::AIManager>( |
| 1526 | base::BindRepeating(&ContentBrowserClient::BindAIManager, |
| 1527 | base::Unretained(GetContentClient()->browser()), |
| 1528 | host->GetProcessHost()->GetBrowserContext(), |
| 1529 | base::Unretained(host), /*rfh=*/nullptr)); |
Mingyu Lei | 3cb40d60 | 2024-06-14 04:38:19 | [diff] [blame] | 1530 | } |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1531 | if (base::FeatureList::IsEnabled(blink::features::kTranslationAPI)) { |
| 1532 | map->Add<blink::mojom::TranslationManager>(base::BindRepeating( |
| 1533 | [](SharedWorkerHost* host, |
| 1534 | mojo::PendingReceiver<blink::mojom::TranslationManager> receiver) { |
Christine Hollingsworth | a1142ee | 2025-06-26 14:55:26 | [diff] [blame] | 1535 | auto* process_host = host->GetProcessHost(); |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1536 | GetContentClient()->browser()->BindTranslationManager( |
Christine Hollingsworth | a1142ee | 2025-06-26 14:55:26 | [diff] [blame] | 1537 | process_host, process_host->GetBrowserContext(), host, |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1538 | host->GetStorageKey().origin(), std::move(receiver)); |
| 1539 | }, |
| 1540 | base::Unretained(host))); |
| 1541 | } |
Jiacheng Guo | c62e3c02 | 2025-01-10 08:37:57 | [diff] [blame] | 1542 | if (base::FeatureList::IsEnabled(blink::features::kLanguageDetectionAPI)) { |
| 1543 | map->Add<language_detection::mojom::ContentLanguageDetectionDriver>( |
| 1544 | base::BindRepeating( |
| 1545 | [](SharedWorkerHost* host, |
| 1546 | mojo::PendingReceiver< |
| 1547 | language_detection::mojom::ContentLanguageDetectionDriver> |
| 1548 | receiver) { |
| 1549 | GetContentClient()->browser()->BindLanguageDetectionDriver( |
| 1550 | host->GetProcessHost()->GetBrowserContext(), host, |
| 1551 | std::move(receiver)); |
| 1552 | }, |
| 1553 | base::Unretained(host))); |
| 1554 | } |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1555 | |
Andrew Rayskiy | f807b71 | 2025-02-10 20:31:56 | [diff] [blame] | 1556 | #if !BUILDFLAG(IS_ANDROID) |
| 1557 | map->Add<blink::mojom::DirectSocketsService>(base::BindRepeating( |
| 1558 | [](SharedWorkerHost* host, |
| 1559 | mojo::PendingReceiver<blink::mojom::DirectSocketsService> receiver) { |
| 1560 | DirectSocketsServiceImpl::CreateForSharedWorker(*host, |
| 1561 | std::move(receiver)); |
| 1562 | }, |
| 1563 | base::Unretained(host))); |
| 1564 | #endif |
| 1565 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1566 | // RenderProcessHost binders |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1567 | map->Add<media::mojom::VideoDecodePerfHistory>(BindWorkerReceiver( |
| 1568 | &RenderProcessHostImpl::BindVideoDecodePerfHistory, host)); |
Johannes Kron | 98aca402 | 2022-02-18 21:15:24 | [diff] [blame] | 1569 | map->Add<media::mojom::WebrtcVideoPerfHistory>(BindWorkerReceiver( |
| 1570 | &RenderProcessHostImpl::BindWebrtcVideoPerfHistory, host)); |
kyraseevers | 28b58f56 | 2021-09-09 16:09:04 | [diff] [blame] | 1571 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1572 | // RenderProcessHost binders taking a StorageKey |
kyraseevers | 28b58f56 | 2021-09-09 16:09:04 | [diff] [blame] | 1573 | map->Add<blink::mojom::FileSystemAccessManager>( |
| 1574 | BindWorkerReceiverForStorageKey( |
| 1575 | &RenderProcessHostImpl::BindFileSystemAccessManager, host)); |
| 1576 | map->Add<blink::mojom::FileSystemManager>(BindWorkerReceiverForStorageKey( |
| 1577 | &RenderProcessHostImpl::BindFileSystemManager, host)); |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 1578 | map->Add<blink::mojom::IDBFactory>( |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 1579 | BindWorkerReceiverForStorageKeyAndBucketContext( |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 1580 | &RenderProcessHostImpl::BindIndexedDB, host)); |
Joshua Hood | bd47013d | 2022-01-06 19:45:04 | [diff] [blame] | 1581 | map->Add<blink::mojom::LockManager>(BindWorkerReceiverForStorageKey( |
| 1582 | &RenderProcessHostImpl::CreateLockManager, host)); |
Marijn Kruisselbrink | 6058902 | 2022-05-03 19:54:18 | [diff] [blame] | 1583 | map->Add<blink::mojom::QuotaManagerHost>(BindWorkerReceiverForStorageKey( |
| 1584 | &RenderProcessHostImpl::BindQuotaManagerHost, host)); |
Andrew Williams | fc09056 | 2022-12-05 17:53:48 | [diff] [blame] | 1585 | map->Add<blink::mojom::NotificationService>(BindNotificationService( |
| 1586 | GlobalRenderFrameHostId(), |
| 1587 | RenderProcessHost::NotificationServiceCreatorType::kSharedWorker, host)); |
Hiroki Nakagawa | a5b40765 | 2019-08-21 09:56:54 | [diff] [blame] | 1588 | } |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1589 | |
| 1590 | void PopulateBinderMapWithContext( |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1591 | SharedWorkerHost* host, |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1592 | mojo::BinderMapWithContext<const url::Origin&>* map) { |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1593 | // RenderProcessHost binders taking an origin |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 1594 | map->Add<payments::mojom::PaymentManager>(BindWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1595 | &RenderProcessHostImpl::CreatePaymentManagerForOrigin, host)); |
Miyoung Shin | 0e38e91 | 2019-12-04 01:52:15 | [diff] [blame] | 1596 | map->Add<blink::mojom::PermissionService>(BindWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1597 | &RenderProcessHostImpl::CreatePermissionService, host)); |
Daniel Brinkers | 9004610c | 2023-10-23 15:27:51 | [diff] [blame] | 1598 | map->Add<blink::mojom::FileBackedBlobFactory>(BindWorkerReceiverForOrigin( |
| 1599 | &RenderProcessHostImpl::BindFileBackedBlobFactory, host)); |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1600 | } |
| 1601 | |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1602 | void PopulateBinderMap(SharedWorkerHost* host, mojo::BinderMap* map) { |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1603 | PopulateSharedWorkerBinders(host, map); |
| 1604 | } |
| 1605 | |
Yao Xiao | 94203f5 | 2024-09-13 17:35:57 | [diff] [blame] | 1606 | // Shared storage worklets |
| 1607 | SharedStorageWorkletHost* GetContextForHost(SharedStorageWorkletHost* host) { |
| 1608 | return host; |
| 1609 | } |
| 1610 | |
| 1611 | void PopulateSharedStorageWorkletBinders(SharedStorageWorkletHost* host, |
| 1612 | mojo::BinderMap* map) { |
Yao Xiao | bfec2c82 | 2024-10-18 22:34:52 | [diff] [blame] | 1613 | // Ignore requests to bind UkmRecorderFactory and FeatureObserver, since there |
| 1614 | // is no current plan to support them for worklets and the renderer always |
| 1615 | // tries to bind them. TODO(crbug.com/366293454). |
Yao Xiao | 94203f5 | 2024-09-13 17:35:57 | [diff] [blame] | 1616 | map->Add<ukm::mojom::UkmRecorderFactory>(base::DoNothing()); |
Yao Xiao | bfec2c82 | 2024-10-18 22:34:52 | [diff] [blame] | 1617 | map->Add<blink::mojom::FeatureObserver>(base::DoNothing()); |
| 1618 | |
| 1619 | // SharedStorageWorkletHost binders |
| 1620 | // base::Unretained(host) is safe because the map is owned by |
| 1621 | // |SharedStorageWorkletHost::broker_|. |
| 1622 | map->Add<blink::mojom::LockManager>(base::BindRepeating( |
| 1623 | &SharedStorageWorkletHost::GetLockManager, base::Unretained(host))); |
Yao Xiao | 94203f5 | 2024-09-13 17:35:57 | [diff] [blame] | 1624 | } |
| 1625 | |
| 1626 | void PopulateBinderMapWithContext( |
| 1627 | SharedStorageWorkletHost* host, |
| 1628 | mojo::BinderMapWithContext<SharedStorageWorkletHost*>* map) {} |
| 1629 | |
| 1630 | void PopulateBinderMap(SharedStorageWorkletHost* host, mojo::BinderMap* map) { |
| 1631 | PopulateSharedStorageWorkletBinders(host, map); |
| 1632 | } |
| 1633 | |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1634 | // Service workers |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 1635 | ServiceWorkerVersionInfo GetContextForHost(ServiceWorkerHost* host) { |
Matt Falkenhagen | db5d03e | 2021-09-28 10:14:21 | [diff] [blame] | 1636 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Hiroki Nakagawa | cd1e538 | 2020-05-25 04:14:48 | [diff] [blame] | 1637 | return host->version()->GetInfo(); |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1638 | } |
| 1639 | |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 1640 | void PopulateServiceWorkerBinders(ServiceWorkerHost* host, |
Robert Sesek | 5a5fbb8 | 2020-05-04 16:18:28 | [diff] [blame] | 1641 | mojo::BinderMap* map) { |
Matt Falkenhagen | db5d03e | 2021-09-28 10:14:21 | [diff] [blame] | 1642 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1643 | |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1644 | // Do nothing for interfaces that the renderer might request, but doesn't |
| 1645 | // always expect to be bound. |
| 1646 | map->Add<blink::mojom::FeatureObserver>(base::DoNothing()); |
Hiroki Nakagawa | 761b9b0 | 2020-07-13 11:12:02 | [diff] [blame] | 1647 | // Ignore the pending receiver because it's not clear how to handle |
| 1648 | // notifications about content security (e.g., mixed contents and certificate |
| 1649 | // errors) on service workers. Generally these notifications are routed to the |
| 1650 | // ancestor frame's WebContents like dedicated workers, but service workers |
| 1651 | // don't have the ancestor frame. |
| 1652 | map->Add<blink::mojom::ContentSecurityNotifier>(base::DoNothing()); |
Oksana Zhuravlova | 3f3295d | 2020-03-06 21:43:07 | [diff] [blame] | 1653 | |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1654 | // static binders |
Tal Pressman | 0c234289 | 2020-12-11 06:37:57 | [diff] [blame] | 1655 | map->Add<blink::mojom::FileUtilitiesHost>( |
Tal Pressman | e2123a8e | 2021-07-21 09:11:13 | [diff] [blame] | 1656 | base::BindRepeating(&BindFileUtilitiesHost, host)); |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1657 | map->Add<shape_detection::mojom::BarcodeDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1658 | &BindBarcodeDetectionProvider); |
Mario Sanchez Prada | baa89373 | 2019-09-30 22:10:17 | [diff] [blame] | 1659 | map->Add<shape_detection::mojom::FaceDetectionProvider>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1660 | &BindFaceDetectionProvider); |
| 1661 | map->Add<shape_detection::mojom::TextDetection>(&BindTextDetection); |
| 1662 | map->Add<ukm::mojom::UkmRecorderFactory>(&BindUkmRecorderFactory); |
Yutaka Hirano | 492c93d | 2019-11-05 11:28:03 | [diff] [blame] | 1663 | |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1664 | // worker host binders |
Hubert Chao | 0c32c1ab | 2025-08-22 13:06:10 | [diff] [blame] | 1665 | map->Add<blink::mojom::WebSocketConnector>(base::BindRepeating( |
| 1666 | &ServiceWorkerHost::CreateWebSocketConnector, base::Unretained(host))); |
Adam Rice | e98a2232 | 2021-04-27 08:26:26 | [diff] [blame] | 1667 | map->Add<blink::mojom::WebTransportConnector>(base::BindRepeating( |
| 1668 | &ServiceWorkerHost::CreateWebTransportConnector, base::Unretained(host))); |
arthursonzogni | b59742e | 2020-03-11 12:19:20 | [diff] [blame] | 1669 | map->Add<blink::mojom::CacheStorage>(base::BindRepeating( |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 1670 | &ServiceWorkerHost::BindCacheStorage, base::Unretained(host))); |
Mythri A | 25d7bdd | 2021-06-15 11:20:48 | [diff] [blame] | 1671 | map->Add<blink::mojom::CodeCacheHost>(base::BindRepeating( |
| 1672 | &ServiceWorkerHost::CreateCodeCacheHost, base::Unretained(host))); |
Andrew Williams | 61e816d | 2021-11-01 04:41:04 | [diff] [blame] | 1673 | map->Add<blink::mojom::BroadcastChannelProvider>( |
| 1674 | base::BindRepeating(&ServiceWorkerHost::CreateBroadcastChannelProvider, |
| 1675 | base::Unretained(host))); |
janiceliu | 2457d49d | 2024-07-09 18:15:57 | [diff] [blame] | 1676 | map->Add<blink::mojom::BlobURLStore>(base::BindRepeating( |
| 1677 | &ServiceWorkerHost::CreateBlobUrlStoreProvider, base::Unretained(host))); |
Matt Menke | 6751f66 | 2020-12-01 05:44:00 | [diff] [blame] | 1678 | map->Add<blink::mojom::ReportingServiceProxy>(base::BindRepeating( |
| 1679 | &CreateReportingServiceProxyForServiceWorker, base::Unretained(host))); |
Jack Hsieh | d38699b | 2022-07-01 16:25:58 | [diff] [blame] | 1680 | #if !BUILDFLAG(IS_ANDROID) |
Andrew Rayskiy | fa93b8274 | 2025-02-11 10:24:16 | [diff] [blame] | 1681 | map->Add<blink::mojom::DirectSocketsService>(base::BindRepeating( |
| 1682 | [](ServiceWorkerHost* host, |
| 1683 | mojo::PendingReceiver<blink::mojom::DirectSocketsService> receiver) { |
| 1684 | DirectSocketsServiceImpl::CreateForServiceWorker(*host->version(), |
| 1685 | std::move(receiver)); |
| 1686 | }, |
| 1687 | base::Unretained(host))); |
Jack Hsieh | d38699b | 2022-07-01 16:25:58 | [diff] [blame] | 1688 | map->Add<blink::mojom::HidService>(base::BindRepeating( |
| 1689 | &ServiceWorkerHost::BindHidService, base::Unretained(host))); |
| 1690 | #endif |
Evan Stade | 88ef2232 | 2022-09-12 21:19:09 | [diff] [blame] | 1691 | map->Add<blink::mojom::BucketManagerHost>(base::BindRepeating( |
| 1692 | &ServiceWorkerHost::CreateBucketManagerHost, base::Unretained(host))); |
Matt Reynolds | 033387d | 2022-10-07 20:59:37 | [diff] [blame] | 1693 | map->Add<blink::mojom::WebUsbService>(base::BindRepeating( |
| 1694 | &ServiceWorkerHost::BindUsbService, base::Unretained(host))); |
Joshua Bell | bc43ccf | 2025-03-05 23:21:22 | [diff] [blame] | 1695 | if (base::FeatureList::IsEnabled( |
| 1696 | webnn::mojom::features::kWebMachineLearningNeuralNetwork)) { |
| 1697 | map->Add<webnn::mojom::WebNNContextProvider>(base::BindRepeating( |
| 1698 | &BindWebNNContextProviderForWorker<ServiceWorkerHost>, |
| 1699 | base::Unretained(host))); |
| 1700 | } |
Fergal Daly | b810d69 | 2024-11-22 04:07:23 | [diff] [blame] | 1701 | if (base::FeatureList::IsEnabled(blink::features::kBuiltInAIAPI)) { |
Mingyu Lei | 3cb40d60 | 2024-06-14 04:38:19 | [diff] [blame] | 1702 | map->Add<blink::mojom::AIManager>(base::BindRepeating( |
| 1703 | &ServiceWorkerHost::BindAIManager, base::Unretained(host))); |
| 1704 | } |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1705 | if (base::FeatureList::IsEnabled(blink::features::kTranslationAPI)) { |
| 1706 | map->Add<blink::mojom::TranslationManager>(base::BindRepeating( |
| 1707 | [](ServiceWorkerHost* host, |
| 1708 | mojo::PendingReceiver<blink::mojom::TranslationManager> receiver) { |
| 1709 | if (auto* process_host = static_cast<RenderProcessHostImpl*>( |
| 1710 | RenderProcessHost::FromID(host->worker_process_id()))) { |
| 1711 | GetContentClient()->browser()->BindTranslationManager( |
Christine Hollingsworth | a1142ee | 2025-06-26 14:55:26 | [diff] [blame] | 1712 | process_host, process_host->GetBrowserContext(), host, |
Tsuyoshi Horo | 5f067a2a | 2024-12-06 12:01:44 | [diff] [blame] | 1713 | host->GetBucketStorageKey().origin(), std::move(receiver)); |
| 1714 | } |
| 1715 | }, |
| 1716 | base::Unretained(host))); |
| 1717 | } |
Jiacheng Guo | c62e3c02 | 2025-01-10 08:37:57 | [diff] [blame] | 1718 | if (base::FeatureList::IsEnabled(blink::features::kLanguageDetectionAPI)) { |
| 1719 | map->Add<language_detection::mojom::ContentLanguageDetectionDriver>( |
| 1720 | base::BindRepeating( |
| 1721 | [](ServiceWorkerHost* host, |
| 1722 | mojo::PendingReceiver< |
| 1723 | language_detection::mojom::ContentLanguageDetectionDriver> |
| 1724 | receiver) { |
| 1725 | if (auto* process_host = static_cast<RenderProcessHostImpl*>( |
| 1726 | RenderProcessHost::FromID(host->worker_process_id()))) { |
| 1727 | GetContentClient()->browser()->BindLanguageDetectionDriver( |
| 1728 | process_host->GetBrowserContext(), host, |
| 1729 | std::move(receiver)); |
| 1730 | } |
| 1731 | }, |
| 1732 | base::Unretained(host))); |
| 1733 | } |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1734 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1735 | // RenderProcessHost binders |
Oksana Zhuravlova | 9d0c3e3 | 2019-11-19 05:10:07 | [diff] [blame] | 1736 | map->Add<media::mojom::VideoDecodePerfHistory>(BindServiceWorkerReceiver( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1737 | &RenderProcessHostImpl::BindVideoDecodePerfHistory, host)); |
Johannes Kron | 98aca402 | 2022-02-18 21:15:24 | [diff] [blame] | 1738 | map->Add<media::mojom::WebrtcVideoPerfHistory>(BindServiceWorkerReceiver( |
| 1739 | &RenderProcessHostImpl::BindWebrtcVideoPerfHistory, host)); |
Tal Pressman | d0c2fd8 | 2021-01-08 03:08:10 | [diff] [blame] | 1740 | map->Add<blink::mojom::PushMessaging>(BindServiceWorkerReceiver( |
| 1741 | &RenderProcessHostImpl::BindPushMessaging, host)); |
Matt Falkenhagen | 8f68c20 | 2019-08-16 04:40:34 | [diff] [blame] | 1742 | } |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1743 | |
| 1744 | void PopulateBinderMapWithContext( |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 1745 | ServiceWorkerHost* host, |
Julie Jeongeun Kim | e58b0f4 | 2021-04-22 05:33:28 | [diff] [blame] | 1746 | mojo::BinderMapWithContext<const ServiceWorkerVersionBaseInfo&>* map) { |
Matt Falkenhagen | db5d03e | 2021-09-28 10:14:21 | [diff] [blame] | 1747 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Matt Falkenhagen | 8f68c20 | 2019-08-16 04:40:34 | [diff] [blame] | 1748 | |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 1749 | // static binders |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 1750 | // Use a task runner if ServiceWorkerHost lives on the IO thread, as |
| 1751 | // CreateForWorker() needs to be called on the UI thread. |
Asami Doi | a99b5fd5 | 2020-12-01 04:15:24 | [diff] [blame] | 1752 | map->Add<blink::mojom::BackgroundFetchService>( |
Rayan Kanso | fd260c29 | 2021-10-12 15:05:10 | [diff] [blame] | 1753 | base::BindRepeating(&BackgroundFetchServiceImpl::CreateForWorker, |
| 1754 | host->GetNetworkIsolationKey())); |
Asami Doi | a99b5fd5 | 2020-12-01 04:15:24 | [diff] [blame] | 1755 | map->Add<blink::mojom::ContentIndexService>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1756 | &ContentIndexServiceImpl::CreateForWorker); |
Asami Doi | a99b5fd5 | 2020-12-01 04:15:24 | [diff] [blame] | 1757 | map->Add<blink::mojom::CookieStore>( |
Aldo Culquicondor | ed054b9 | 2025-07-02 19:13:38 | [diff] [blame] | 1758 | &CookieStoreManager::BindReceiverForWorker); |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 1759 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1760 | // RenderProcessHost binders taking an origin |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 1761 | map->Add<payments::mojom::PaymentManager>(BindServiceWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1762 | &RenderProcessHostImpl::CreatePaymentManagerForOrigin, host)); |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 1763 | map->Add<blink::mojom::PermissionService>(BindServiceWorkerReceiverForOrigin( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1764 | &RenderProcessHostImpl::CreatePermissionService, host)); |
Miyoung Shin | 58d0b6c | 2019-12-03 07:38:18 | [diff] [blame] | 1765 | map->Add<network::mojom::RestrictedCookieManager>( |
Dylan Cutler | 0d2654e6 | 2021-10-05 16:34:51 | [diff] [blame] | 1766 | BindServiceWorkerReceiverForStorageKey( |
Victor Costan | db4002e | 2020-03-25 19:09:03 | [diff] [blame] | 1767 | &RenderProcessHostImpl::BindRestrictedCookieManagerForServiceWorker, |
Miyoung Shin | 58d0b6c | 2019-12-03 07:38:18 | [diff] [blame] | 1768 | host)); |
Rayan Kanso | 2b1096c | 2021-09-21 09:49:14 | [diff] [blame] | 1769 | map->Add<blink::mojom::OneShotBackgroundSyncService>( |
| 1770 | BindServiceWorkerReceiverForOrigin( |
| 1771 | &RenderProcessHostImpl::CreateOneShotSyncService, host)); |
| 1772 | map->Add<blink::mojom::PeriodicBackgroundSyncService>( |
| 1773 | BindServiceWorkerReceiverForOrigin( |
| 1774 | &RenderProcessHostImpl::CreatePeriodicSyncService, host)); |
Oksana Zhuravlova | 0235d7bd | 2019-11-19 06:40:54 | [diff] [blame] | 1775 | |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1776 | // RenderProcessHost binders taking a storage key |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 1777 | map->Add<blink::mojom::IDBFactory>( |
Abhishek Shanthkumar | 7aee48b | 2024-06-24 15:02:47 | [diff] [blame] | 1778 | BindServiceWorkerReceiverForStorageKeyAndBucketContext( |
Mingyu Lei | 0fe8df7 | 2022-12-16 06:44:48 | [diff] [blame] | 1779 | &RenderProcessHostImpl::BindIndexedDB, host)); |
Kyra Seevers | 9e56602 | 2021-09-01 15:49:25 | [diff] [blame] | 1780 | map->Add<blink::mojom::FileSystemAccessManager>( |
| 1781 | BindServiceWorkerReceiverForStorageKey( |
| 1782 | &RenderProcessHostImpl::BindFileSystemAccessManager, host)); |
Joshua Hood | bd47013d | 2022-01-06 19:45:04 | [diff] [blame] | 1783 | map->Add<blink::mojom::LockManager>(BindServiceWorkerReceiverForStorageKey( |
| 1784 | &RenderProcessHostImpl::CreateLockManager, host)); |
Marijn Kruisselbrink | 6058902 | 2022-05-03 19:54:18 | [diff] [blame] | 1785 | map->Add<blink::mojom::QuotaManagerHost>( |
| 1786 | BindServiceWorkerReceiverForStorageKey( |
| 1787 | &RenderProcessHostImpl::BindQuotaManagerHost, host)); |
Mingyu Lei | 0ece2ab | 2022-10-28 11:58:54 | [diff] [blame] | 1788 | map->Add<blink::mojom::NotificationService>(BindNotificationService(host)); |
Daniel Brinkers | 9004610c | 2023-10-23 15:27:51 | [diff] [blame] | 1789 | map->Add<blink::mojom::FileBackedBlobFactory>( |
| 1790 | BindServiceWorkerReceiverForOrigin( |
| 1791 | &RenderProcessHostImpl::BindFileBackedBlobFactory, host)); |
Julie Jeongeun Kim | e58b0f4 | 2021-04-22 05:33:28 | [diff] [blame] | 1792 | |
Giovanni Ortuño Urquidi | 5d63257b | 2022-07-08 04:01:07 | [diff] [blame] | 1793 | // This is called when `host` is constructed. ServiceWorkerVersion, which |
| 1794 | // constructs `host`, checks that context() is not null and also uses |
| 1795 | // BrowserContext right after constructing `host`, so this is safe. |
| 1796 | BrowserContext* browser_context = |
| 1797 | host->version()->context()->wrapper()->browser_context(); |
| 1798 | |
Giovanni Ortuño Urquidi | fc39f14 | 2022-09-26 05:05:09 | [diff] [blame] | 1799 | const auto service_worker_version_info = host->version()->GetInfo(); |
| 1800 | |
Julie Jeongeun Kim | e58b0f4 | 2021-04-22 05:33:28 | [diff] [blame] | 1801 | // Give the embedder a chance to register binders. |
| 1802 | GetContentClient() |
| 1803 | ->browser() |
Giovanni Ortuño Urquidi | fc39f14 | 2022-09-26 05:05:09 | [diff] [blame] | 1804 | ->RegisterBrowserInterfaceBindersForServiceWorker( |
| 1805 | browser_context, service_worker_version_info, map); |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1806 | } |
| 1807 | |
Hiroki Nakagawa | 593b6f5 | 2020-05-25 03:10:25 | [diff] [blame] | 1808 | void PopulateBinderMap(ServiceWorkerHost* host, mojo::BinderMap* map) { |
Matt Falkenhagen | db5d03e | 2021-09-28 10:14:21 | [diff] [blame] | 1809 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Oksana Zhuravlova | d4bbeec | 2019-08-13 21:43:57 | [diff] [blame] | 1810 | PopulateServiceWorkerBinders(host, map); |
Oksana Zhuravlova | ceb2cef5 | 2019-08-09 01:09:59 | [diff] [blame] | 1811 | } |
| 1812 | |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 1813 | } // namespace internal |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 1814 | |
Johann | 165093e3 | 2020-11-18 04:25:30 | [diff] [blame] | 1815 | void OverrideBatteryMonitorBinderForTesting(BatteryMonitorBinder binder) { |
| 1816 | internal::GetBatteryMonitorBinderOverride() = std::move(binder); |
| 1817 | } |
| 1818 | |
Ken Rockot | 05499cf | 2019-12-12 05:22:54 | [diff] [blame] | 1819 | void OverrideVibrationManagerBinderForTesting(VibrationManagerBinder binder) { |
| 1820 | internal::GetVibrationManagerBinderOverride() = std::move(binder); |
| 1821 | } |
| 1822 | |
Matt Falkenhagen | 8f68c20 | 2019-08-16 04:40:34 | [diff] [blame] | 1823 | } // namespace content |