Commit 3532f449 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate blink.mojom.PresentationService to BrowserInterfaceBroker

This CL migrates code to the new BrowserInterfaceBroker class. This
allows retrieving the remote implementation from the renderer process
without relying on FrameClient's InterfaceProvider, as well as simplify
code in RenderFrameHostImpl by using the new service_manager::BinderMap
class directly, instead of using the old service_manager::BinderRegistry
object.

Last, this CL also adds missing includes in browser_interface_binders.cc

Bug: 955171, 978694, 936482
Change-Id: I72354777751fe407680d7935db6e6bd41d194095
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768338Reviewed-by: default avatarmark a. foltz <mfoltz@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#695078}
parent b5a8f334
......@@ -13,6 +13,11 @@
#include "content/browser/worker_host/shared_worker_host.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/shared_worker_instance.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/filesystem/file_system.mojom.h"
#include "third_party/blink/public/mojom/idle/idle_manager.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/webaudio/audio_context_manager.mojom.h"
......@@ -34,6 +39,9 @@ void PopulateFrameBinders(RenderFrameHostImpl* host,
map->Add<blink::mojom::IdleManager>(base::BindRepeating(
&RenderFrameHostImpl::GetIdleManager, base::Unretained(host)));
map->Add<blink::mojom::PresentationService>(base::BindRepeating(
&RenderFrameHostImpl::GetPresentationService, base::Unretained(host)));
map->Add<blink::mojom::SpeechSynthesis>(base::BindRepeating(
&RenderFrameHostImpl::GetSpeechSynthesis, base::Unretained(host)));
......
......@@ -4312,16 +4312,6 @@ void RenderFrameHostImpl::RegisterMojoInterfaces() {
base::BindRepeating(&PermissionServiceContext::CreateService,
base::Unretained(permission_service_context_.get())));
registry_->AddInterface(base::BindRepeating(
[](RenderFrameHostImpl* frame,
mojo::PendingReceiver<blink::mojom::PresentationService> receiver) {
if (!frame->presentation_service_)
frame->presentation_service_ = PresentationServiceImpl::Create(frame);
frame->presentation_service_->Bind(std::move(receiver));
},
base::Unretained(this)));
registry_->AddInterface(
base::Bind(&MediaSessionServiceImpl::Create, base::Unretained(this)));
......@@ -6345,6 +6335,13 @@ void RenderFrameHostImpl::GetIdleManager(
->CreateService(std::move(receiver));
}
void RenderFrameHostImpl::GetPresentationService(
mojo::PendingReceiver<blink::mojom::PresentationService> receiver) {
if (!presentation_service_)
presentation_service_ = PresentationServiceImpl::Create(this);
presentation_service_->Bind(std::move(receiver));
}
void RenderFrameHostImpl::GetSpeechSynthesis(
mojo::PendingReceiver<blink::mojom::SpeechSynthesis> receiver) {
if (!speech_synthesis_impl_) {
......
......@@ -1031,6 +1031,9 @@ class CONTENT_EXPORT RenderFrameHostImpl
void GetIdleManager(
mojo::PendingReceiver<blink::mojom::IdleManager> receiver);
void GetPresentationService(
mojo::PendingReceiver<blink::mojom::PresentationService> receiver);
void GetSpeechSynthesis(
mojo::PendingReceiver<blink::mojom::SpeechSynthesis> receiver);
......
......@@ -244,7 +244,6 @@ const service_manager::Manifest& GetContentBrowserManifest() {
"blink.mojom.PictureInPictureService",
"blink.mojom.Portal",
"blink.mojom.PrefetchURLLoaderService",
"blink.mojom.PresentationService",
"blink.mojom.QuotaDispatcherHost",
"blink.mojom.SerialService",
"blink.mojom.SharedWorkerConnector",
......
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/modules/presentation/presentation_controller.h"
#include <memory>
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/renderer/core/dom/document.h"
......@@ -153,14 +154,11 @@ PresentationController::FindExistingConnection(
mojo::Remote<mojom::blink::PresentationService>&
PresentationController::GetPresentationService() {
if (!presentation_service_remote_ && GetFrame() && GetFrame()->Client()) {
auto* interface_provider = GetFrame()->Client()->GetInterfaceProvider();
if (!presentation_service_remote_ && GetFrame()) {
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
GetFrame()->GetTaskRunner(TaskType::kPresentation);
interface_provider->GetInterface(
GetFrame()->GetBrowserInterfaceBroker().GetInterface(
presentation_service_remote_.BindNewPipeAndPassReceiver(task_runner));
presentation_service_remote_->SetController(
presentation_controller_receiver_.BindNewPipeAndPassRemote(
task_runner));
......
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/modules/presentation/presentation_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/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/core/dom/document.h"
......@@ -27,16 +28,14 @@ PresentationReceiver::PresentationReceiver(LocalFrame* frame)
: ContextLifecycleObserver(frame->GetDocument()),
connection_list_(MakeGarbageCollected<PresentationConnectionList>(
frame->GetDocument())) {
auto* interface_provider = GetFrame()->Client()->GetInterfaceProvider();
interface_provider->GetInterface(
frame->GetBrowserInterfaceBroker().GetInterface(
presentation_service_remote_.BindNewPipeAndPassReceiver());
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
frame->GetTaskRunner(TaskType::kPresentation);
// Set the mojo::Remote<T> that remote implementation of PresentationService
// will use to interact with the associated PresentationReceiver, in order to
// receive updates on new connections becoming available.
// will use to interact with the associated PresentationReceiver, in order
// to receive updates on new connections becoming available.
presentation_service_remote_->SetReceiver(
presentation_receiver_receiver_.BindNewPipeAndPassRemote(task_runner));
}
......
......@@ -15,7 +15,7 @@ class PresentationServiceMock {
this.receiverConnectionRequest_ = null;
this.interceptor_ = new MojoInterfaceInterceptor(
blink.mojom.PresentationService.name);
blink.mojom.PresentationService.name, "context", true);
this.interceptor_.oninterfacerequest =
e => this.bindingSet_.addBinding(this, e.handle);
this.interceptor_.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