Commit 090544a4 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert VibrationManager client to use BrowserInterfaceBroker

This change converts VibrationManager mojom interface client in blink
to use BrowserInterfaceBroker.

Bug: 936482
Change-Id: Iab5ad8845989ec8a1c8c885f2d347feb6f0f2de3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824042
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700082}
parent 04afdb9e
......@@ -14,10 +14,14 @@
#include "content/browser/service_worker/service_worker_provider_host.h"
#include "content/browser/worker_host/dedicated_worker_host.h"
#include "content/browser/worker_host/shared_worker_host.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/shared_worker_instance.h"
#include "media/capture/mojom/image_capture.mojom.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/device/public/mojom/sensor_provider.mojom.h"
#include "services/device/public/mojom/vibration_manager.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "third_party/blink/public/mojom/appcache/appcache.mojom.h"
#include "third_party/blink/public/mojom/background_fetch/background_fetch.mojom.h"
#include "third_party/blink/public/mojom/bluetooth/web_bluetooth.mojom.h"
......@@ -40,6 +44,17 @@
namespace content {
namespace internal {
// Forwards service receivers to Service Manager since the renderer cannot
// launch out-of-process services on is own.
template <typename Interface>
void ForwardServiceReceiver(const char* service_name,
RenderFrameHostImpl* host,
mojo::PendingReceiver<Interface> receiver) {
auto* connector =
BrowserContext::GetConnectorFor(host->GetProcess()->GetBrowserContext());
connector->Connect(service_name, std::move(receiver));
}
// Documents/frames
void PopulateFrameBinders(RenderFrameHostImpl* host,
service_manager::BinderMap* map) {
......@@ -84,6 +99,10 @@ void PopulateFrameBinders(RenderFrameHostImpl* host,
map->Add<device::mojom::SensorProvider>(base::BindRepeating(
&RenderFrameHostImpl::GetSensorProvider, base::Unretained(host)));
map->Add<device::mojom::VibrationManager>(base::BindRepeating(
&ForwardServiceReceiver<device::mojom::VibrationManager>,
device::mojom::kServiceName, base::Unretained(host)));
map->Add<media::mojom::ImageCapture>(
base::BindRepeating(&ImageCaptureImpl::Create));
......
......@@ -35,10 +35,7 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/device/public/mojom/vibration_manager.mojom.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/shape_detection/public/mojom/barcodedetection_provider.mojom.h"
#include "services/shape_detection/public/mojom/facedetection_provider.mojom.h"
#include "services/shape_detection/public/mojom/shape_detection_service.mojom.h"
......@@ -139,17 +136,6 @@ void BindTextDetection(shape_detection::mojom::TextDetectionRequest request,
GetShapeDetectionService()->BindTextDetection(std::move(request));
}
// Forwards service requests to Service Manager since the renderer cannot launch
// out-of-process services on is own.
template <typename Interface>
void ForwardServiceRequest(const char* service_name,
mojo::InterfaceRequest<Interface> request,
RenderProcessHost* host,
const url::Origin& origin) {
auto* connector = BrowserContext::GetConnectorFor(host->GetBrowserContext());
connector->BindInterface(service_name, std::move(request));
}
// Register renderer-exposed interfaces. Each registered interface binder is
// exposed to all renderer-hosted execution context types (document/frame,
// dedicated worker, shared worker and service worker) where the appropriate
......@@ -164,10 +150,6 @@ void RendererInterfaceBinders::InitializeParameterizedBinderRegistry() {
parameterized_binder_registry_.AddInterface(
base::BindRepeating(&BindTextDetection));
parameterized_binder_registry_.AddInterface(
base::Bind(&ForwardServiceRequest<device::mojom::VibrationManager>,
device::mojom::kServiceName));
// Used for shared workers and service workers to create a websocket.
// In other cases, RenderFrameHostImpl for documents or DedicatedWorkerHost
// for dedicated workers handles interface requests in order to associate
......
......@@ -247,7 +247,6 @@ const service_manager::Manifest& GetContentBrowserManifest() {
"device.mojom.GamepadMonitor",
"device.mojom.Geolocation",
"device.mojom.NFC",
"device.mojom.VibrationManager",
"device.mojom.VRService",
"discardable_memory.mojom.DiscardableSharedMemoryManager",
"media.mojom.FuchsiaCdmProvider",
......
......@@ -19,7 +19,7 @@
#include "third_party/blink/renderer/modules/vibration/vibration_controller.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_or_unsigned_long_sequence.h"
......@@ -85,7 +85,7 @@ VibrationController::VibrationController(LocalFrame& frame)
is_running_(false),
is_calling_cancel_(false),
is_calling_vibrate_(false) {
frame.GetInterfaceProvider().GetInterface(
frame.GetBrowserInterfaceBroker().GetInterface(
vibration_manager_.BindNewPipeAndPassReceiver());
}
......
......@@ -23,7 +23,7 @@ class MockVibrationManager {
new mojo.BindingSet(device.mojom.VibrationManager);
this.interceptor_ = new MojoInterfaceInterceptor(
device.mojom.VibrationManager.name);
device.mojom.VibrationManager.name, "context", true);
this.interceptor_.oninterfacerequest =
e => this.bindingSet_.addBinding(this, e.handle);
this.interceptor_.start();
......@@ -37,7 +37,7 @@ class MockVibrationManager {
attachToWindow(otherWindow) {
otherWindow.vibrationManagerInterceptor =
new otherWindow.MojoInterfaceInterceptor(
device.mojom.VibrationManager.name);
device.mojom.VibrationManager.name, "context", true);
otherWindow.vibrationManagerInterceptor.oninterfacerequest =
e => this.crossFrameHandleProxy_.forwardHandle(e.handle);
otherWindow.vibrationManagerInterceptor.start();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment