Commit 1dec3c1c authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert WakeLockService client to use BrowserInterfaceBroker

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

Bug: 936482
Change-Id: Ifd2473137781c496f96ec1e24939466fd4d4a096
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824521
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700553}
parent 9bc22399
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/screen_enumeration/screen_enumeration_impl.h" #include "content/browser/screen_enumeration/screen_enumeration_impl.h"
#include "content/browser/service_worker/service_worker_provider_host.h" #include "content/browser/service_worker/service_worker_provider_host.h"
#include "content/browser/wake_lock/wake_lock_service_impl.h"
#include "content/browser/worker_host/dedicated_worker_host.h" #include "content/browser/worker_host/dedicated_worker_host.h"
#include "content/browser/worker_host/shared_worker_host.h" #include "content/browser/worker_host/shared_worker_host.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
#include "third_party/blink/public/mojom/picture_in_picture/picture_in_picture.mojom.h" #include "third_party/blink/public/mojom/picture_in_picture/picture_in_picture.mojom.h"
#include "third_party/blink/public/mojom/presentation/presentation.mojom.h" #include "third_party/blink/public/mojom/presentation/presentation.mojom.h"
#include "third_party/blink/public/mojom/speech/speech_synthesis.mojom.h" #include "third_party/blink/public/mojom/speech/speech_synthesis.mojom.h"
#include "third_party/blink/public/mojom/wake_lock/wake_lock.mojom.h"
#include "third_party/blink/public/mojom/webaudio/audio_context_manager.mojom.h" #include "third_party/blink/public/mojom/webaudio/audio_context_manager.mojom.h"
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h" #include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h"
#include "third_party/blink/public/mojom/webauthn/virtual_authenticator.mojom.h" #include "third_party/blink/public/mojom/webauthn/virtual_authenticator.mojom.h"
...@@ -165,6 +167,8 @@ void PopulateBinderMapWithContext( ...@@ -165,6 +167,8 @@ void PopulateBinderMapWithContext(
base::BindRepeating(&KeyboardLockServiceImpl::CreateMojoService)); base::BindRepeating(&KeyboardLockServiceImpl::CreateMojoService));
map->Add<blink::mojom::PictureInPictureService>( map->Add<blink::mojom::PictureInPictureService>(
base::BindRepeating(&PictureInPictureServiceImpl::Create)); base::BindRepeating(&PictureInPictureServiceImpl::Create));
map->Add<blink::mojom::WakeLockService>(
base::BindRepeating(&WakeLockServiceImpl::Create));
GetContentClient()->browser()->RegisterBrowserInterfaceBindersForFrame(map); GetContentClient()->browser()->RegisterBrowserInterfaceBindersForFrame(map);
} }
......
...@@ -104,7 +104,6 @@ ...@@ -104,7 +104,6 @@
#include "content/browser/speech/speech_recognition_dispatcher_host.h" #include "content/browser/speech/speech_recognition_dispatcher_host.h"
#include "content/browser/speech/speech_synthesis_impl.h" #include "content/browser/speech/speech_synthesis_impl.h"
#include "content/browser/storage_partition_impl.h" #include "content/browser/storage_partition_impl.h"
#include "content/browser/wake_lock/wake_lock_service_impl.h"
#include "content/browser/web_package/bundled_exchanges_handle.h" #include "content/browser/web_package/bundled_exchanges_handle.h"
#include "content/browser/web_package/prefetched_signed_exchange_cache.h" #include "content/browser/web_package/prefetched_signed_exchange_cache.h"
#include "content/browser/webauth/authenticator_environment_impl.h" #include "content/browser/webauth/authenticator_environment_impl.h"
...@@ -4453,9 +4452,6 @@ void RenderFrameHostImpl::RegisterMojoInterfaces() { ...@@ -4453,9 +4452,6 @@ void RenderFrameHostImpl::RegisterMojoInterfaces() {
GetProcess()->GetStoragePartition()->GetFileSystemContext(), GetProcess()->GetStoragePartition()->GetFileSystemContext(),
ChromeBlobStorageContext::GetFor(GetProcess()->GetBrowserContext()))); ChromeBlobStorageContext::GetFor(GetProcess()->GetBrowserContext())));
registry_->AddInterface(base::BindRepeating(&WakeLockServiceImpl::Create,
base::Unretained(this)));
if (base::FeatureList::IsEnabled(blink::features::kNativeFileSystemAPI)) { if (base::FeatureList::IsEnabled(blink::features::kNativeFileSystemAPI)) {
registry_->AddInterface(base::BindRepeating( registry_->AddInterface(base::BindRepeating(
[](RenderFrameHostImpl* frame, [](RenderFrameHostImpl* frame,
......
...@@ -236,7 +236,6 @@ const service_manager::Manifest& GetContentBrowserManifest() { ...@@ -236,7 +236,6 @@ const service_manager::Manifest& GetContentBrowserManifest() {
"blink.mojom.SpeechRecognizer", "blink.mojom.SpeechRecognizer",
"blink.mojom.TextSuggestionHost", "blink.mojom.TextSuggestionHost",
"blink.mojom.UnhandledTapNotifier", "blink.mojom.UnhandledTapNotifier",
"blink.mojom.WakeLockService",
"blink.mojom.WebUsbService", "blink.mojom.WebUsbService",
"content.mojom.BrowserTarget", "content.mojom.BrowserTarget",
"content.mojom.InputInjector", "content.mojom.InputInjector",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "third_party/blink/renderer/core/html/media/video_wake_lock.h" #include "third_party/blink/renderer/core/html/media/video_wake_lock.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/mojom/wake_lock/wake_lock.mojom-blink.h" #include "third_party/blink/public/mojom/wake_lock/wake_lock.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
...@@ -115,7 +115,7 @@ void VideoWakeLock::EnsureWakeLockService() { ...@@ -115,7 +115,7 @@ void VideoWakeLock::EnsureWakeLockService() {
frame->GetTaskRunner(TaskType::kMediaElementEvent); frame->GetTaskRunner(TaskType::kMediaElementEvent);
mojo::Remote<blink::mojom::blink::WakeLockService> service; mojo::Remote<blink::mojom::blink::WakeLockService> service;
frame->GetInterfaceProvider().GetInterface( frame->GetBrowserInterfaceBroker().GetInterface(
service.BindNewPipeAndPassReceiver(task_runner)); service.BindNewPipeAndPassReceiver(task_runner));
service->GetWakeLock(device::mojom::WakeLockType::kPreventDisplaySleep, service->GetWakeLock(device::mojom::WakeLockType::kPreventDisplaySleep,
device::mojom::blink::WakeLockReason::kVideoPlayback, device::mojom::blink::WakeLockReason::kVideoPlayback,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "third_party/blink/renderer/modules/wake_lock/wake_lock_state_record.h" #include "third_party/blink/renderer/modules/wake_lock/wake_lock_state_record.h"
#include "base/logging.h" #include "base/logging.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/mojom/wake_lock/wake_lock.mojom-blink.h" #include "third_party/blink/public/mojom/wake_lock/wake_lock.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
...@@ -37,10 +37,8 @@ void WakeLockStateRecord::AcquireWakeLock(ScriptPromiseResolver* resolver) { ...@@ -37,10 +37,8 @@ void WakeLockStateRecord::AcquireWakeLock(ScriptPromiseResolver* resolver) {
// 4.3. Add lockPromise to record.[[WakeLockStateRecord]]. // 4.3. Add lockPromise to record.[[WakeLockStateRecord]].
// 5. Return active. // 5. Return active.
if (!wake_lock_) { if (!wake_lock_) {
auto* interface_provider = execution_context_->GetInterfaceProvider();
DCHECK(interface_provider);
mojo::Remote<mojom::blink::WakeLockService> wake_lock_service; mojo::Remote<mojom::blink::WakeLockService> wake_lock_service;
interface_provider->GetInterface( execution_context_->GetBrowserInterfaceBroker().GetInterface(
wake_lock_service.BindNewPipeAndPassReceiver()); wake_lock_service.BindNewPipeAndPassReceiver());
wake_lock_service->GetWakeLock( wake_lock_service->GetWakeLock(
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.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/common/browser_interface_broker_proxy.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h" #include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h" #include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h"
...@@ -248,9 +247,7 @@ void MockPermissionService::AddPermissionObserver( ...@@ -248,9 +247,7 @@ void MockPermissionService::AddPermissionObserver(
WakeLockTestingContext::WakeLockTestingContext( WakeLockTestingContext::WakeLockTestingContext(
MockWakeLockService* mock_wake_lock_service) { MockWakeLockService* mock_wake_lock_service) {
service_manager::InterfaceProvider::TestApi test_api( GetDocument()->GetBrowserInterfaceBroker().SetBinderForTesting(
GetDocument()->GetInterfaceProvider());
test_api.SetBinderForName(
mojom::blink::WakeLockService::Name_, mojom::blink::WakeLockService::Name_,
WTF::BindRepeating(&MockWakeLockService::BindRequest, WTF::BindRepeating(&MockWakeLockService::BindRequest,
WTF::Unretained(mock_wake_lock_service))); WTF::Unretained(mock_wake_lock_service)));
......
...@@ -141,7 +141,7 @@ class MockPermissionService final : public mojom::blink::PermissionService { ...@@ -141,7 +141,7 @@ class MockPermissionService final : public mojom::blink::PermissionService {
// MockWakeLockService mock_service; // MockWakeLockService mock_service;
// WakeLockTestingContext context(&mock_service); // WakeLockTestingContext context(&mock_service);
// mojo::Remote<mojom::blink::WakeLockService> service; // mojo::Remote<mojom::blink::WakeLockService> service;
// context.GetDocument()->GetInterfaceProvider()->GetInterface( // context.GetDocument()->GetBrowserInterfaceBroker().GetInterface(
// service.BindNewPipeAndPassReceiver()); // service.BindNewPipeAndPassReceiver());
// service->GetWakeLock(...); // Will call mock_service.GetWakeLock(). // service->GetWakeLock(...); // Will call mock_service.GetWakeLock().
// } // }
......
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