Commit 11c9dde5 authored by imcheng's avatar imcheng Committed by Commit bot

Add content public APIs for Presentation API.

The pieces added are as follows:

1. PresentationServiceDelegate: An interface to be implemented by an
embedder to handle Presentation API requests. Includes an Observer
interface to observe the lifetime of the delegate object.
2. PresentationScreenAvailabilityListener: An interface to be
implemented by content/ code to receive screen availability results
from the embedder.
3. Added method to ContentBrowserClient: GetPresentationServiceDelegate.
Returns nullptr by default. Embedder may override it with an
implementation that can handle Presentation API requests. Added to
allow content/ code to obtain a reference to a
PresentationServiceDelegate to forward presentation API requests to.

Presentation Mojo service patch: crrev.com/839773002/
Blink plumbing: crrev.com/832263007

The Chrome implementation of PresentationServiceDelegate is currently
in a private repo.

BUG=412331

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

Cr-Commit-Position: refs/heads/master@{#313563}
parent 3c52f3b7
...@@ -178,6 +178,8 @@ ...@@ -178,6 +178,8 @@
'public/browser/plugin_service.h', 'public/browser/plugin_service.h',
'public/browser/plugin_service_filter.h', 'public/browser/plugin_service_filter.h',
'public/browser/power_save_blocker.h', 'public/browser/power_save_blocker.h',
'public/browser/presentation_screen_availability_listener.h',
'public/browser/presentation_service_delegate.h',
'public/browser/profiler_controller.h', 'public/browser/profiler_controller.h',
'public/browser/profiler_subscriber.h', 'public/browser/profiler_subscriber.h',
'public/browser/push_messaging_service.h', 'public/browser/push_messaging_service.h',
......
...@@ -336,6 +336,12 @@ bool ContentBrowserClient::CheckMediaAccessPermission( ...@@ -336,6 +336,12 @@ bool ContentBrowserClient::CheckMediaAccessPermission(
return false; return false;
} }
PresentationServiceDelegate*
ContentBrowserClient::GetPresentationServiceDelegate(
WebContents* web_contents) {
return nullptr;
}
#if defined(OS_WIN) #if defined(OS_WIN)
const wchar_t* ContentBrowserClient::GetResourceDllName() { const wchar_t* ContentBrowserClient::GetResourceDllName() {
return nullptr; return nullptr;
......
...@@ -96,6 +96,7 @@ class MediaObserver; ...@@ -96,6 +96,7 @@ class MediaObserver;
class NavigatorConnectContext; class NavigatorConnectContext;
class NavigatorConnectServiceFactory; class NavigatorConnectServiceFactory;
class PlatformNotificationService; class PlatformNotificationService;
class PresentationServiceDelegate;
class QuotaPermissionContext; class QuotaPermissionContext;
class RenderFrameHost; class RenderFrameHost;
class RenderProcessHost; class RenderProcessHost;
...@@ -602,6 +603,11 @@ class CONTENT_EXPORT ContentBrowserClient { ...@@ -602,6 +603,11 @@ class CONTENT_EXPORT ContentBrowserClient {
RenderFrameHost* render_frame_host, RenderFrameHost* render_frame_host,
blink::WebPageVisibilityState* visibility_state) {} blink::WebPageVisibilityState* visibility_state) {}
// Allows an embedder to provide its own PresentationServiceDelegate
// implementation. Returns nullptr if unavailable.
virtual PresentationServiceDelegate* GetPresentationServiceDelegate(
WebContents* web_contents);
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_POSIX) && !defined(OS_MACOSX)
// Populates |mappings| with all files that need to be mapped before launching // Populates |mappings| with all files that need to be mapped before launching
// a child process. // a child process.
......
// 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_PUBLIC_BROWSER_PRESENTATION_SCREEN_AVAILABILITY_LISTENER_H_
#define CONTENT_PUBLIC_BROWSER_PRESENTATION_SCREEN_AVAILABILITY_LISTENER_H_
#include <string>
namespace content {
// A listener interface used for receiving updates on screen availability
// associated with a presentation URL from an embedder.
// See also PresentationServiceDelegate.
class PresentationScreenAvailabilityListener {
public:
// Returns the Presentation URL associated with this listener.
virtual std::string GetPresentationUrl() = 0;
// Called when screen availability for the associated Presentation URL has
// changed to |available|.
virtual void OnScreenAvailabilityChanged(bool available) = 0;
protected:
virtual ~ScreenAvailabilityListener() {}
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SCREEN_AVAILABILITY_LISTENER_H_
// 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_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
#define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
namespace content {
class PresentationScreenAvailabilityListener;
// An interface implemented by embedders to handle presentation API calls
// forwarded from PresentationServiceImpl.
class PresentationServiceDelegate {
public:
// Observer interface to listen for changes to PresentationServiceDelegate.
class Observer {
public:
// Called when the PresentationServiceDelegate is being destroyed.
virtual void OnDelegateDestroyed() = 0;
protected:
virtual ~Observer() {}
};
// Registers an observer with this class to listen for updates to this class.
// This class does not own the observer.
// It is an error to add an observer if it has already been added before.
virtual void AddObserver(Observer* observer) = 0;
// Unregisters an observer with this class.
virtual void RemoveObserver(Observer* observer) = 0;
// Registers |listener| to continuously listen for
// availability updates for a presentation URL, originated from the frame
// given by |render_process_id| and |render_frame_id|.
// This class does not own |listener|.
// Returns true on success.
// This call will return false if a listener with the same presentation URL
// from the same frame is already registered.
virtual bool AddScreenAvailabilityListener(
int render_process_id,
int render_frame_id,
PresentationScreenAvailabilityListener* listener) = 0;
// Unregisters |listener| originated from the frame given by
// |render_process_id| and |render_frame_id| from this class. The listener
// will no longer receive availability updates.
virtual void RemoveScreenAvailabilityListener(
int render_process_id,
int render_frame_id,
PresentationScreenAvailabilityListener* listener) = 0;
// Unregisters all listeners associated with the frame given by
// |render_process_id| and |render_frame_id|.
virtual void RemoveAllScreenAvailabilityListeners(
int render_process_id,
int render_frame_id) = 0;
protected:
virtual ~PresentationServiceDelegate() {}
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
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