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