Chromium Code Reviews| Index: content/public/browser/presentation_service_delegate.h |
| diff --git a/content/public/browser/presentation_service_delegate.h b/content/public/browser/presentation_service_delegate.h |
| index 3588faf1ae883ce04c9c506b3d3e572f44252869..c8cc357ea2b93a4792ff998236cecbeea7f2e121 100644 |
| --- a/content/public/browser/presentation_service_delegate.h |
| +++ b/content/public/browser/presentation_service_delegate.h |
| @@ -5,6 +5,7 @@ |
| #ifndef CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
| #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
| +#include <map> |
| #include <memory> |
| #include <string> |
| #include <vector> |
| @@ -14,6 +15,7 @@ |
| #include "content/common/content_export.h" |
| #include "content/public/browser/presentation_session.h" |
| #include "content/public/browser/presentation_session_message.h" |
| +#include "third_party/WebKit/public/platform/modules/presentation/presentation.mojom.h" |
| class GURL; |
| @@ -49,12 +51,18 @@ struct PresentationConnectionStateChangeInfo { |
| using PresentationConnectionStateChangedCallback = |
| base::Callback<void(const PresentationConnectionStateChangeInfo&)>; |
| -// An interface implemented by embedders to handle presentation API calls |
| -// forwarded from PresentationServiceImpl. |
| +using PresentationConnectionPtr = blink::mojom::PresentationConnectionPtr; |
| + |
| +using ReceiverConnectionAvailableCallback = |
| + base::Callback<void(const content::PresentationSessionInfo&, |
| + PresentationConnectionPtr)>; |
| + |
| +// Base class for ControllerPresentationServiceDelegate and |
| +// ReceiverPresentationServiceDelegate. |
| class CONTENT_EXPORT PresentationServiceDelegate { |
| public: |
| // Observer interface to listen for changes to PresentationServiceDelegate. |
| - class CONTENT_EXPORT Observer { |
| + class Observer { |
| public: |
| // Called when the PresentationServiceDelegate is being destroyed. |
| virtual void OnDelegateDestroyed() = 0; |
| @@ -63,9 +71,8 @@ class CONTENT_EXPORT PresentationServiceDelegate { |
| virtual ~Observer() {} |
| }; |
| - using SendMessageCallback = base::Callback<void(bool)>; |
| - |
| - virtual ~PresentationServiceDelegate() {} |
| + PresentationServiceDelegate(); |
| + virtual ~PresentationServiceDelegate(); |
| // Registers an observer associated with frame with |render_process_id| |
| // and |render_frame_id| with this class to listen for updates. |
| @@ -74,12 +81,32 @@ class CONTENT_EXPORT PresentationServiceDelegate { |
| // frame. |
| virtual void AddObserver(int render_process_id, |
| int render_frame_id, |
| - Observer* observer) = 0; |
| + Observer* observer); |
| // Unregisters the observer associated with the frame with |render_process_id| |
| // and |render_frame_id|. |
| // The observer will no longer receive updates. |
| - virtual void RemoveObserver(int render_process_id, int render_frame_id) = 0; |
| + virtual void RemoveObserver(int render_process_id, int render_frame_id); |
| + |
| + // Resets the presentation state for the frame given by |render_process_id| |
| + // and |render_frame_id|. |
| + // This unregisters all screen availability associated with the given frame, |
| + // and clears the default presentation URL for the frame. |
| + virtual void Reset(int render_process_id, int render_frame_id) = 0; |
| + |
| + private: |
| + // Use as a key in the render frame map. Corresponds to a unique |
| + // RenderFrameHost. |
| + using RenderFrameHostID = std::pair<int, int>; |
| + std::map<RenderFrameHostID, Observer*> observers_; |
|
jam
2016/12/14 17:48:23
this is against the content api guidelines per htt
zhaobin
2016/12/15 02:55:59
Done.
|
| +}; |
| + |
| +// An interface implemented by embedders to handle Presentation API calls |
| +// forwarded from PresentationServiceImpl. |
| +class CONTENT_EXPORT ControllerPresentationServiceDelegate |
| + : public PresentationServiceDelegate { |
| + public: |
| + using SendMessageCallback = base::Callback<void(bool)>; |
| // Registers |listener| to continuously listen for |
| // availability updates for a presentation URL, originated from the frame |
| @@ -101,14 +128,6 @@ class CONTENT_EXPORT PresentationServiceDelegate { |
| int render_frame_id, |
| PresentationScreenAvailabilityListener* listener) = 0; |
| - // Resets the presentation state for the frame given by |render_process_id| |
| - // and |render_frame_id|. |
| - // This unregisters all listeners associated with the given frame, and clears |
| - // the default presentation URL and ID set for the frame. |
| - virtual void Reset( |
| - int render_process_id, |
| - int render_frame_id) = 0; |
| - |
| // Sets the default presentation URLs for frame given by |render_process_id| |
| // and |render_frame_id|. When the default presentation is started on this |
| // frame, |callback| will be invoked with the corresponding |
| @@ -202,6 +221,31 @@ class CONTENT_EXPORT PresentationServiceDelegate { |
| int render_frame_id, |
| const PresentationSessionInfo& connection, |
| const PresentationConnectionStateChangedCallback& state_changed_cb) = 0; |
| + |
| + // Connect |connection| owned by the controlling frame to the offscreen |
| + // presentation represented by |session|. |
| + // |render_process_id|, |render_frame_id|: ID of originating frame. |
| + // |connection|: Pointer to controller's presentation connection, |
| + // ownership passed from controlling frame to the offscreen presentation. |
| + virtual void ConnectToOffscreenPresentation( |
| + int render_process_id, |
| + int render_frame_id, |
| + const PresentationSessionInfo& session, |
| + PresentationConnectionPtr connection) = 0; |
| +}; |
| + |
| +// An interface implemented by embedders to handle |
| +// PresentationService calls from a presentation receiver. |
| +class CONTENT_EXPORT ReceiverPresentationServiceDelegate |
| + : public PresentationServiceDelegate { |
| + public: |
| + // Registers a callback from the embedder when an offscreeen presentation has |
| + // been successfully started. |
| + // |receiver_available_callback|: Invoked when successfully starting a |
| + // offscreen presentation session. |
| + virtual void RegisterReceiverConnectionAvailableCallback( |
| + const content::ReceiverConnectionAvailableCallback& |
| + receiver_available_callback) = 0; |
| }; |
| } // namespace content |