Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 | 49 |
| 50 using PresentationConnectionStateChangedCallback = | 50 using PresentationConnectionStateChangedCallback = |
| 51 base::Callback<void(const PresentationConnectionStateChangeInfo&)>; | 51 base::Callback<void(const PresentationConnectionStateChangeInfo&)>; |
| 52 | 52 |
| 53 using PresentationConnectionPtr = blink::mojom::PresentationConnectionPtr; | 53 using PresentationConnectionPtr = blink::mojom::PresentationConnectionPtr; |
| 54 | 54 |
| 55 using ReceiverConnectionAvailableCallback = | 55 using ReceiverConnectionAvailableCallback = |
| 56 base::Callback<void(const content::PresentationSessionInfo&, | 56 base::Callback<void(const content::PresentationSessionInfo&, |
| 57 PresentationConnectionPtr&&)>; | 57 PresentationConnectionPtr&&)>; |
| 58 | 58 |
| 59 // An interface implemented by embedders to handle presentation API calls | 59 // Base class for ControllerPresentationServiceDelegate and |
| 60 // forwarded from PresentationServiceImpl. | 60 // ReceiverPresentationServiceDelegate. |
| 61 class CONTENT_EXPORT PresentationServiceDelegate { | 61 class PresentationServiceDelegateBase { |
| 62 public: | 62 public: |
| 63 // Observer interface to listen for changes to PresentationServiceDelegate. | 63 // Observer interface to listen for changes to PresentationServiceDelegate. |
| 64 class CONTENT_EXPORT Observer { | 64 class CONTENT_EXPORT Observer { |
|
mark a. foltz
2016/11/15 23:41:47
Maybe this should become PresentatonServiceDelegat
zhaobin
2016/11/16 18:02:42
Done.
| |
| 65 public: | 65 public: |
| 66 // Called when the PresentationServiceDelegate is being destroyed. | 66 // Called when the PresentationServiceDelegate is being destroyed. |
| 67 virtual void OnDelegateDestroyed() = 0; | 67 virtual void OnDelegateDestroyed() = 0; |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 virtual ~Observer() {} | 70 virtual ~Observer() {} |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 using SendMessageCallback = base::Callback<void(bool)>; | |
| 74 | |
| 75 virtual ~PresentationServiceDelegate() {} | |
| 76 | |
| 77 // Registers an observer associated with frame with |render_process_id| | 73 // Registers an observer associated with frame with |render_process_id| |
| 78 // and |render_frame_id| with this class to listen for updates. | 74 // and |render_frame_id| with this class to listen for updates. |
| 79 // This class does not own the observer. | 75 // This class does not own the observer. |
| 80 // It is an error to add an observer if there is already an observer for that | 76 // It is an error to add an observer if there is already an observer for that |
| 81 // frame. | 77 // frame. |
| 82 virtual void AddObserver(int render_process_id, | 78 virtual void AddObserver(int render_process_id, |
| 83 int render_frame_id, | 79 int render_frame_id, |
| 84 Observer* observer) = 0; | 80 Observer* observer) = 0; |
| 85 | 81 |
| 86 // Unregisters the observer associated with the frame with |render_process_id| | 82 // Unregisters the observer associated with the frame with |render_process_id| |
| 87 // and |render_frame_id|. | 83 // and |render_frame_id|. |
| 88 // The observer will no longer receive updates. | 84 // The observer will no longer receive updates. |
| 89 virtual void RemoveObserver(int render_process_id, int render_frame_id) = 0; | 85 virtual void RemoveObserver(int render_process_id, int render_frame_id) = 0; |
| 90 | 86 |
| 87 // Resets the presentation state for the frame given by |render_process_id| | |
| 88 // and |render_frame_id|. | |
| 89 // This unregisters all listeners associated with the given frame, and clears | |
|
mark a. foltz
2016/11/15 23:41:47
screen availability listeners
zhaobin
2016/11/16 18:02:42
Done.
| |
| 90 // the default presentation URL and ID set for the frame. | |
|
mark a. foltz
2016/11/15 23:41:47
the default presentation URL for the frame.
zhaobin
2016/11/16 18:02:42
Done.
| |
| 91 virtual void Reset(int render_process_id, int render_frame_id) = 0; | |
| 92 }; | |
| 93 | |
| 94 // An interface implemented by embedders to handle presentation API calls | |
|
mark a. foltz
2016/11/15 23:41:47
nit: Presentation
zhaobin
2016/11/16 18:02:42
Done.
| |
| 95 // forwarded from PresentationServiceImpl. | |
| 96 class CONTENT_EXPORT ControllerPresentationServiceDelegate | |
| 97 : public PresentationServiceDelegateBase { | |
| 98 public: | |
| 99 using SendMessageCallback = base::Callback<void(bool)>; | |
| 100 | |
| 101 virtual ~ControllerPresentationServiceDelegate() {} | |
| 102 | |
| 91 // Registers |listener| to continuously listen for | 103 // Registers |listener| to continuously listen for |
| 92 // availability updates for a presentation URL, originated from the frame | 104 // availability updates for a presentation URL, originated from the frame |
| 93 // given by |render_process_id| and |render_frame_id|. | 105 // given by |render_process_id| and |render_frame_id|. |
| 94 // This class does not own |listener|. | 106 // This class does not own |listener|. |
| 95 // Returns true on success. | 107 // Returns true on success. |
| 96 // This call will return false if a listener with the same presentation URL | 108 // This call will return false if a listener with the same presentation URL |
| 97 // from the same frame is already registered. | 109 // from the same frame is already registered. |
| 98 virtual bool AddScreenAvailabilityListener( | 110 virtual bool AddScreenAvailabilityListener( |
| 99 int render_process_id, | 111 int render_process_id, |
| 100 int render_frame_id, | 112 int render_frame_id, |
| 101 PresentationScreenAvailabilityListener* listener) = 0; | 113 PresentationScreenAvailabilityListener* listener) = 0; |
| 102 | 114 |
| 103 // Unregisters |listener| originated from the frame given by | 115 // Unregisters |listener| originated from the frame given by |
| 104 // |render_process_id| and |render_frame_id| from this class. The listener | 116 // |render_process_id| and |render_frame_id| from this class. The listener |
| 105 // will no longer receive availability updates. | 117 // will no longer receive availability updates. |
| 106 virtual void RemoveScreenAvailabilityListener( | 118 virtual void RemoveScreenAvailabilityListener( |
| 107 int render_process_id, | 119 int render_process_id, |
| 108 int render_frame_id, | 120 int render_frame_id, |
| 109 PresentationScreenAvailabilityListener* listener) = 0; | 121 PresentationScreenAvailabilityListener* listener) = 0; |
| 110 | 122 |
| 111 // Resets the presentation state for the frame given by |render_process_id| | |
| 112 // and |render_frame_id|. | |
| 113 // This unregisters all listeners associated with the given frame, and clears | |
| 114 // the default presentation URL and ID set for the frame. | |
| 115 virtual void Reset( | |
| 116 int render_process_id, | |
| 117 int render_frame_id) = 0; | |
| 118 | |
| 119 // Sets the default presentation URLs for frame given by |render_process_id| | 123 // Sets the default presentation URLs for frame given by |render_process_id| |
| 120 // and |render_frame_id|. When the default presentation is started on this | 124 // and |render_frame_id|. When the default presentation is started on this |
| 121 // frame, |callback| will be invoked with the corresponding | 125 // frame, |callback| will be invoked with the corresponding |
| 122 // PresentationSessionInfo object. | 126 // PresentationSessionInfo object. |
| 123 // If |default_presentation_urls| is empty, the default presentation URLs will | 127 // If |default_presentation_urls| is empty, the default presentation URLs will |
| 124 // be cleared and the previously registered callback (if any) will be removed. | 128 // be cleared and the previously registered callback (if any) will be removed. |
| 125 virtual void SetDefaultPresentationUrls( | 129 virtual void SetDefaultPresentationUrls( |
| 126 int render_process_id, | 130 int render_process_id, |
| 127 int render_frame_id, | 131 int render_frame_id, |
| 128 const std::vector<GURL>& default_presentation_urls, | 132 const std::vector<GURL>& default_presentation_urls, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 // frame. | 206 // frame. |
| 203 // |render_process_id|, |render_frame_id|: ID of frame. | 207 // |render_process_id|, |render_frame_id|: ID of frame. |
| 204 // |connection|: PresentationConnection to listen for state changes. | 208 // |connection|: PresentationConnection to listen for state changes. |
| 205 // |state_changed_cb|: Invoked with the PresentationConnection and its new | 209 // |state_changed_cb|: Invoked with the PresentationConnection and its new |
| 206 // state whenever there is a state change. | 210 // state whenever there is a state change. |
| 207 virtual void ListenForConnectionStateChange( | 211 virtual void ListenForConnectionStateChange( |
| 208 int render_process_id, | 212 int render_process_id, |
| 209 int render_frame_id, | 213 int render_frame_id, |
| 210 const PresentationSessionInfo& connection, | 214 const PresentationSessionInfo& connection, |
| 211 const PresentationConnectionStateChangedCallback& state_changed_cb) = 0; | 215 const PresentationConnectionStateChangedCallback& state_changed_cb) = 0; |
| 216 | |
| 217 // Connect |connection| owned by the controlling frame to the offscreen | |
| 218 // presentation represented by |session|. | |
| 219 // |render_process_id|, |render_frame_id|: ID of originating frame. | |
| 220 // |connection|: Pointer to controller's presentation connection, | |
| 221 // ownership passed from controlling frame to the offscreen presentation. | |
| 222 virtual void ConnectToOffscreenPresentation( | |
| 223 int render_process_id, | |
| 224 int render_frame_id, | |
| 225 const PresentationSessionInfo& session, | |
| 226 PresentationConnectionPtr connection) = 0; | |
| 227 }; | |
| 228 | |
| 229 // An interface implemented by embedders to handle | |
| 230 // PresentationService calls from a presentation receiver. | |
| 231 class CONTENT_EXPORT ReceiverPresentationServiceDelegate | |
| 232 : public PresentationServiceDelegateBase { | |
| 233 public: | |
| 234 // Registers a callback from the embedder when an offscreeen presentation has | |
| 235 // been successfully started. | |
| 236 // |receiver_available_callback|: Invoked when successfully starting a | |
| 237 // offscreen presentation session. | |
| 238 virtual void RegisterReceiverConnectionAvailableCallback( | |
| 239 const content::ReceiverConnectionAvailableCallback& | |
| 240 receiver_available_callback) = 0; | |
| 212 }; | 241 }; |
| 213 | 242 |
| 214 } // namespace content | 243 } // namespace content |
| 215 | 244 |
| 216 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 245 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
| OLD | NEW |