Commit bca35fad authored by avayvod's avatar avayvod Committed by Commit bot

Plumbing from WebPresentationClient to the Presentation Mojo service for

availablechange event. Blink CL: https://codereview.chromium.org/832263007

BUG=412331

Review URL: https://codereview.chromium.org/839773002

Cr-Commit-Position: refs/heads/master@{#313772}
parent 38923567
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "content/browser/geolocation/geolocation_service_context.h" #include "content/browser/geolocation/geolocation_service_context.h"
#include "content/browser/permissions/permission_service_context.h" #include "content/browser/permissions/permission_service_context.h"
#include "content/browser/permissions/permission_service_impl.h" #include "content/browser/permissions/permission_service_impl.h"
#include "content/browser/presentation/presentation_service_impl.h"
#include "content/browser/renderer_host/input/input_router.h" #include "content/browser/renderer_host/input/input_router.h"
#include "content/browser/renderer_host/input/timeout_monitor.h" #include "content/browser/renderer_host/input/timeout_monitor.h"
#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h"
...@@ -1308,6 +1309,9 @@ void RenderFrameHostImpl::RegisterMojoServices() { ...@@ -1308,6 +1309,9 @@ void RenderFrameHostImpl::RegisterMojoServices() {
base::Bind(&PermissionServiceContext::CreateService, base::Bind(&PermissionServiceContext::CreateService,
base::Unretained(permission_service_context_.get()))); base::Unretained(permission_service_context_.get())));
GetServiceRegistry()->AddService<presentation::PresentationService>(
base::Bind(&PresentationServiceImpl::CreateMojoService));
#if defined(ENABLE_MEDIA_MOJO_RENDERER) #if defined(ENABLE_MEDIA_MOJO_RENDERER)
GetServiceRegistry()->AddService<mojo::MediaRenderer>( GetServiceRegistry()->AddService<mojo::MediaRenderer>(
base::Bind(&CreateMediaRendererService)); base::Bind(&CreateMediaRendererService));
......
avayvod@chromium.org
imcheng@chromium.org
mfoltz@chromium.org
\ No newline at end of file
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/presentation/presentation_service_impl.h"
#include "base/logging.h"
namespace content {
PresentationServiceImpl::PresentationServiceImpl() {
}
PresentationServiceImpl::~PresentationServiceImpl() {
}
// static
void PresentationServiceImpl::CreateMojoService(
mojo::InterfaceRequest<presentation::PresentationService> request) {
mojo::BindToRequest(new PresentationServiceImpl(), &request);
}
void PresentationServiceImpl::GetScreenAvailability(
const mojo::String& presentation_url,
const AvailabilityCallback& callback) {
NOTIMPLEMENTED();
}
void PresentationServiceImpl::OnScreenAvailabilityListenerRemoved() {
NOTIMPLEMENTED();
}
} // namespace content
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
#define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
#include "base/macros.h"
#include "content/common/presentation/presentation_service.mojom.h"
#include "mojo/public/cpp/bindings/interface_request.h"
namespace content {
// Implements the PresentationService Mojo interface.
// This service can be created from a RenderFrameHost.
class PresentationServiceImpl :
public mojo::InterfaceImpl<presentation::PresentationService> {
public:
~PresentationServiceImpl() override;
static void CreateMojoService(
mojo::InterfaceRequest<presentation::PresentationService> request);
protected:
PresentationServiceImpl();
private:
typedef mojo::Callback<void(bool)> AvailabilityCallback;
// PresentationService implementation.
void GetScreenAvailability(
const mojo::String& presentation_url,
const AvailabilityCallback& callback) override;
void OnScreenAvailabilityListenerRemoved() override;
DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl);
};
} // namespace content
#endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
...@@ -409,6 +409,7 @@ mojom("mojo_bindings") { ...@@ -409,6 +409,7 @@ mojom("mojo_bindings") {
"application_setup.mojom", "application_setup.mojom",
"geolocation_service.mojom", "geolocation_service.mojom",
"permission_service.mojom", "permission_service.mojom",
"presentation/presentation_service.mojom",
"render_frame_setup.mojom", "render_frame_setup.mojom",
] ]
......
avayvod@chromium.org
imcheng@chromium.org
mfoltz@chromium.org
\ No newline at end of file
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module presentation;
interface PresentationService {
// Returns the last screen availability state if it’s changed since the last
// time the method was called. The client has to call this method again when
// handling the result (provided via Mojo callback) to get the next update
// about the availability status.
// May start discovery of the presentation screens. The implementation might
// stop discovery once there are no active calls to GetScreenAvailability.
// |presentation_url| can be specified to help the implementation to filter
// out incompatible screens.
GetScreenAvailability(string? presentation_url) => (bool available);
// Called when the frame no longer listens to the
// |availablechange| event.
OnScreenAvailabilityListenerRemoved();
};
\ No newline at end of file
...@@ -1000,6 +1000,8 @@ ...@@ -1000,6 +1000,8 @@
'browser/power_save_blocker_x11.cc', 'browser/power_save_blocker_x11.cc',
'browser/power_usage_monitor_impl.cc', 'browser/power_usage_monitor_impl.cc',
'browser/power_usage_monitor_impl.h', 'browser/power_usage_monitor_impl.h',
'browser/presentation/presentation_service_impl.cc',
'browser/presentation/presentation_service_impl.h',
'browser/profiler_controller_impl.cc', 'browser/profiler_controller_impl.cc',
'browser/profiler_controller_impl.h', 'browser/profiler_controller_impl.h',
'browser/profiler_message_filter.cc', 'browser/profiler_message_filter.cc',
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
'common/application_setup.mojom', 'common/application_setup.mojom',
'common/geolocation_service.mojom', 'common/geolocation_service.mojom',
'common/permission_service.mojom', 'common/permission_service.mojom',
'common/presentation/presentation_service.mojom',
'common/render_frame_setup.mojom', 'common/render_frame_setup.mojom',
# NOTE: Sources duplicated in # NOTE: Sources duplicated in
......
...@@ -312,6 +312,8 @@ ...@@ -312,6 +312,8 @@
'renderer/net_info_helper.h', 'renderer/net_info_helper.h',
'renderer/notification_permission_dispatcher.cc', 'renderer/notification_permission_dispatcher.cc',
'renderer/notification_permission_dispatcher.h', 'renderer/notification_permission_dispatcher.h',
'renderer/presentation/presentation_dispatcher.cc',
'renderer/presentation/presentation_dispatcher.h',
'renderer/push_messaging/push_messaging_dispatcher.cc', 'renderer/push_messaging/push_messaging_dispatcher.cc',
'renderer/push_messaging/push_messaging_dispatcher.h', 'renderer/push_messaging/push_messaging_dispatcher.h',
'renderer/render_font_warmup_win.cc', 'renderer/render_font_warmup_win.cc',
......
avayvod@chromium.org
imcheng@chromium.org
mfoltz@chromium.org
\ No newline at end of file
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/presentation/presentation_dispatcher.h"
#include "content/common/presentation/presentation_service.mojom.h"
#include "content/public/common/service_registry.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/WebKit/public/platform/WebPresentationController.h"
namespace content {
PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame)
: RenderFrameObserver(render_frame),
controller_(nullptr) {
}
PresentationDispatcher::~PresentationDispatcher() {
// Controller should be destroyed before the dispatcher when frame is
// destroyed.
DCHECK(!controller_);
}
void PresentationDispatcher::setController(
blink::WebPresentationController* controller) {
// There shouldn't be any swapping from one non-null controller to another.
DCHECK(controller != controller_ && (!controller || !controller_));
controller_ = controller;
// The controller is set to null when the frame is about to be detached.
// Nothing is listening for screen availability anymore but the Mojo service
// will know about the frame being detached anyway.
}
void PresentationDispatcher::updateAvailableChangeWatched(bool watched) {
ConnectToPresentationServiceIfNeeded();
if (watched) {
presentation_service_->GetScreenAvailability(
mojo::String(),
base::Bind(&PresentationDispatcher::OnScreenAvailabilityChanged,
base::Unretained(this)));
} else {
presentation_service_->OnScreenAvailabilityListenerRemoved();
}
}
void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) {
if (!controller_)
return;
// Reset the callback to get the next event.
updateAvailableChangeWatched(controller_->isAvailableChangeWatched());
controller_->didChangeAvailability(available);
}
void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
if (presentation_service_.get())
return;
render_frame()->GetServiceRegistry()->ConnectToRemoteService(
&presentation_service_);
}
} // namespace content
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
#define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
#include "content/common/presentation/presentation_service.mojom.h"
#include "content/public/renderer/render_frame_observer.h"
#include "third_party/WebKit/public/platform/WebPresentationClient.h"
namespace content {
// PresentationDispatcher is a delegate for Presentation API messages used by
// Blink. It forwards the calls to the Mojo PresentationService.
class PresentationDispatcher
: public RenderFrameObserver,
public blink::WebPresentationClient {
public:
explicit PresentationDispatcher(RenderFrame* render_frame);
~PresentationDispatcher() override;
private:
// WebPresentationClient implementation.
virtual void setController(
blink::WebPresentationController* controller);
virtual void updateAvailableChangeWatched(bool watched);
void OnScreenAvailabilityChanged(bool available);
void ConnectToPresentationServiceIfNeeded();
// Used as a weak reference. Can be null since lifetime is bound to the frame.
blink::WebPresentationController* controller_;
presentation::PresentationServicePtr presentation_service_;
};
} // namespace content
#endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#include "content/renderer/notification_permission_dispatcher.h" #include "content/renderer/notification_permission_dispatcher.h"
#include "content/renderer/npapi/plugin_channel_host.h" #include "content/renderer/npapi/plugin_channel_host.h"
#include "content/renderer/pepper/plugin_instance_throttler_impl.h" #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
#include "content/renderer/presentation/presentation_dispatcher.h"
#include "content/renderer/push_messaging/push_messaging_dispatcher.h" #include "content/renderer/push_messaging/push_messaging_dispatcher.h"
#include "content/renderer/render_frame_proxy.h" #include "content/renderer/render_frame_proxy.h"
#include "content/renderer/render_process.h" #include "content/renderer/render_process.h"
...@@ -695,6 +696,7 @@ RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) ...@@ -695,6 +696,7 @@ RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id)
#endif #endif
geolocation_dispatcher_(NULL), geolocation_dispatcher_(NULL),
push_messaging_dispatcher_(NULL), push_messaging_dispatcher_(NULL),
presentation_dispatcher_(NULL),
screen_orientation_dispatcher_(NULL), screen_orientation_dispatcher_(NULL),
manifest_manager_(NULL), manifest_manager_(NULL),
accessibility_mode_(AccessibilityModeOff), accessibility_mode_(AccessibilityModeOff),
...@@ -3365,6 +3367,12 @@ blink::WebGeolocationClient* RenderFrameImpl::geolocationClient() { ...@@ -3365,6 +3367,12 @@ blink::WebGeolocationClient* RenderFrameImpl::geolocationClient() {
return geolocation_dispatcher_; return geolocation_dispatcher_;
} }
blink::WebPresentationClient* RenderFrameImpl::presentationClient() {
if (!presentation_dispatcher_)
presentation_dispatcher_ = new PresentationDispatcher(this);
return presentation_dispatcher_;
}
blink::WebPushClient* RenderFrameImpl::pushClient() { blink::WebPushClient* RenderFrameImpl::pushClient() {
if (!push_messaging_dispatcher_) if (!push_messaging_dispatcher_)
push_messaging_dispatcher_ = new PushMessagingDispatcher(this); push_messaging_dispatcher_ = new PushMessagingDispatcher(this);
......
...@@ -52,6 +52,7 @@ class WebGeolocationClient; ...@@ -52,6 +52,7 @@ class WebGeolocationClient;
class WebMouseEvent; class WebMouseEvent;
class WebContentDecryptionModule; class WebContentDecryptionModule;
class WebMediaPlayer; class WebMediaPlayer;
class WebPresentationClient;
class WebPushClient; class WebPushClient;
class WebSecurityOrigin; class WebSecurityOrigin;
struct WebCompositionUnderline; struct WebCompositionUnderline;
...@@ -84,6 +85,7 @@ class MidiDispatcher; ...@@ -84,6 +85,7 @@ class MidiDispatcher;
class NotificationPermissionDispatcher; class NotificationPermissionDispatcher;
class PageState; class PageState;
class PepperPluginInstanceImpl; class PepperPluginInstanceImpl;
class PresentationDispatcher;
class PushMessagingDispatcher; class PushMessagingDispatcher;
class RendererAccessibility; class RendererAccessibility;
class RendererCdmManager; class RendererCdmManager;
...@@ -484,6 +486,7 @@ class CONTENT_EXPORT RenderFrameImpl ...@@ -484,6 +486,7 @@ class CONTENT_EXPORT RenderFrameImpl
virtual void willOpenWebSocket(blink::WebSocketHandle* handle); virtual void willOpenWebSocket(blink::WebSocketHandle* handle);
virtual blink::WebGeolocationClient* geolocationClient(); virtual blink::WebGeolocationClient* geolocationClient();
virtual blink::WebPushClient* pushClient(); virtual blink::WebPushClient* pushClient();
virtual blink::WebPresentationClient* presentationClient();
virtual void willStartUsingPeerConnectionHandler( virtual void willStartUsingPeerConnectionHandler(
blink::WebLocalFrame* frame, blink::WebLocalFrame* frame,
blink::WebRTCPeerConnectionHandler* handler); blink::WebRTCPeerConnectionHandler* handler);
...@@ -845,6 +848,10 @@ class CONTENT_EXPORT RenderFrameImpl ...@@ -845,6 +848,10 @@ class CONTENT_EXPORT RenderFrameImpl
// The push messaging dispatcher attached to this frame, lazily initialized. // The push messaging dispatcher attached to this frame, lazily initialized.
PushMessagingDispatcher* push_messaging_dispatcher_; PushMessagingDispatcher* push_messaging_dispatcher_;
// The presentation dispatcher implementation attached to this frame, lazily
// initialized.
PresentationDispatcher* presentation_dispatcher_;
ServiceRegistryImpl service_registry_; ServiceRegistryImpl service_registry_;
// The screen orientation dispatcher attached to the frame, lazily // The screen orientation dispatcher attached to the frame, lazily
......
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