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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/browser/presentation_session.h" | 15 #include "content/public/browser/presentation_session.h" |
16 #include "content/public/browser/presentation_session_message.h" | 16 #include "content/public/browser/presentation_session_message.h" |
17 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" | |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
22 class PresentationScreenAvailabilityListener; | 23 class PresentationScreenAvailabilityListener; |
23 | 24 |
24 using PresentationSessionStartedCallback = | 25 using PresentationSessionStartedCallback = |
25 base::Callback<void(const PresentationSessionInfo&)>; | 26 base::Callback<void(const PresentationSessionInfo&)>; |
26 using PresentationSessionErrorCallback = | 27 using PresentationSessionErrorCallback = |
(...skipping 15 matching lines...) Expand all Loading... | |
42 PresentationConnectionState state; | 43 PresentationConnectionState state; |
43 | 44 |
44 // |close_reason| and |messsage| are only used for state change to CLOSED. | 45 // |close_reason| and |messsage| are only used for state change to CLOSED. |
45 PresentationConnectionCloseReason close_reason; | 46 PresentationConnectionCloseReason close_reason; |
46 std::string message; | 47 std::string message; |
47 }; | 48 }; |
48 | 49 |
49 using PresentationConnectionStateChangedCallback = | 50 using PresentationConnectionStateChangedCallback = |
50 base::Callback<void(const PresentationConnectionStateChangeInfo&)>; | 51 base::Callback<void(const PresentationConnectionStateChangeInfo&)>; |
51 | 52 |
52 // An interface implemented by embedders to handle presentation API calls | 53 using PresentationConnectionPtr = blink::mojom::PresentationConnectionPtr; |
53 // forwarded from PresentationServiceImpl. | 54 |
54 class CONTENT_EXPORT PresentationServiceDelegate { | 55 using ReceiverConnectionAvailableCallback = |
56 base::Callback<void(const content::PresentationSessionInfo&, | |
57 PresentationConnectionPtr&&)>; | |
58 | |
59 // Base class for ControllerPresentationServiceDelegate and | |
60 // ReceiverPresentationServiceDelegate. | |
61 class PresentationServiceDelegateBase { | |
55 public: | 62 public: |
56 // Observer interface to listen for changes to PresentationServiceDelegate. | 63 // Observer interface to listen for changes to PresentationServiceDelegate. |
57 class CONTENT_EXPORT Observer { | 64 class CONTENT_EXPORT Observer { |
58 public: | 65 public: |
59 // Called when the PresentationServiceDelegate is being destroyed. | 66 // Called when the PresentationServiceDelegate is being destroyed. |
60 virtual void OnDelegateDestroyed() = 0; | 67 virtual void OnDelegateDestroyed() = 0; |
61 | 68 |
62 protected: | 69 protected: |
63 virtual ~Observer() {} | 70 virtual ~Observer() {} |
64 }; | 71 }; |
65 | 72 |
66 using SendMessageCallback = base::Callback<void(bool)>; | |
67 | |
68 virtual ~PresentationServiceDelegate() {} | |
69 | |
70 // Registers an observer associated with frame with |render_process_id| | 73 // Registers an observer associated with frame with |render_process_id| |
71 // and |render_frame_id| with this class to listen for updates. | 74 // and |render_frame_id| with this class to listen for updates. |
72 // This class does not own the observer. | 75 // This class does not own the observer. |
73 // 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 |
74 // frame. | 77 // frame. |
75 virtual void AddObserver(int render_process_id, | 78 virtual void AddObserver(int render_process_id, |
76 int render_frame_id, | 79 int render_frame_id, |
77 Observer* observer) = 0; | 80 Observer* observer) = 0; |
78 | 81 |
79 // Unregisters the observer associated with the frame with |render_process_id| | 82 // Unregisters the observer associated with the frame with |render_process_id| |
80 // and |render_frame_id|. | 83 // and |render_frame_id|. |
81 // The observer will no longer receive updates. | 84 // The observer will no longer receive updates. |
82 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; |
83 | 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 | |
90 // the default presentation URL and ID set for the frame. | |
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 | |
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 | |
84 // Registers |listener| to continuously listen for | 103 // Registers |listener| to continuously listen for |
85 // availability updates for a presentation URL, originated from the frame | 104 // availability updates for a presentation URL, originated from the frame |
86 // given by |render_process_id| and |render_frame_id|. | 105 // given by |render_process_id| and |render_frame_id|. |
87 // This class does not own |listener|. | 106 // This class does not own |listener|. |
88 // Returns true on success. | 107 // Returns true on success. |
89 // 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 |
90 // from the same frame is already registered. | 109 // from the same frame is already registered. |
91 virtual bool AddScreenAvailabilityListener( | 110 virtual bool AddScreenAvailabilityListener( |
92 int render_process_id, | 111 int render_process_id, |
93 int render_frame_id, | 112 int render_frame_id, |
94 PresentationScreenAvailabilityListener* listener) = 0; | 113 PresentationScreenAvailabilityListener* listener) = 0; |
95 | 114 |
96 // Unregisters |listener| originated from the frame given by | 115 // Unregisters |listener| originated from the frame given by |
97 // |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 |
98 // will no longer receive availability updates. | 117 // will no longer receive availability updates. |
99 virtual void RemoveScreenAvailabilityListener( | 118 virtual void RemoveScreenAvailabilityListener( |
100 int render_process_id, | 119 int render_process_id, |
101 int render_frame_id, | 120 int render_frame_id, |
102 PresentationScreenAvailabilityListener* listener) = 0; | 121 PresentationScreenAvailabilityListener* listener) = 0; |
103 | 122 |
104 // Resets the presentation state for the frame given by |render_process_id| | |
105 // and |render_frame_id|. | |
106 // This unregisters all listeners associated with the given frame, and clears | |
107 // the default presentation URL and ID set for the frame. | |
108 virtual void Reset( | |
109 int render_process_id, | |
110 int render_frame_id) = 0; | |
111 | |
112 // 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| |
113 // 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 |
114 // frame, |callback| will be invoked with the corresponding | 125 // frame, |callback| will be invoked with the corresponding |
115 // PresentationSessionInfo object. | 126 // PresentationSessionInfo object. |
116 // If |default_presentation_urls| is empty, the default presentation URLs will | 127 // If |default_presentation_urls| is empty, the default presentation URLs will |
117 // 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. |
118 virtual void SetDefaultPresentationUrls( | 129 virtual void SetDefaultPresentationUrls( |
119 int render_process_id, | 130 int render_process_id, |
120 int render_frame_id, | 131 int render_frame_id, |
121 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... | |
195 // frame. | 206 // frame. |
196 // |render_process_id|, |render_frame_id|: ID of frame. | 207 // |render_process_id|, |render_frame_id|: ID of frame. |
197 // |connection|: PresentationConnection to listen for state changes. | 208 // |connection|: PresentationConnection to listen for state changes. |
198 // |state_changed_cb|: Invoked with the PresentationConnection and its new | 209 // |state_changed_cb|: Invoked with the PresentationConnection and its new |
199 // state whenever there is a state change. | 210 // state whenever there is a state change. |
200 virtual void ListenForConnectionStateChange( | 211 virtual void ListenForConnectionStateChange( |
201 int render_process_id, | 212 int render_process_id, |
202 int render_frame_id, | 213 int render_frame_id, |
203 const PresentationSessionInfo& connection, | 214 const PresentationSessionInfo& connection, |
204 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 RegisterOffscreenPresentationConnection( | |
mark a. foltz
2016/10/21 00:53:02
ConnectToOffscreenPresentation?
zhaobin
2016/10/22 02:44:13
Done.
| |
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 presentation API calls | |
230 // forwarded from receiver PresentationServiceImpl. | |
mark a. foltz
2016/10/21 00:53:02
handle PresentationService calls from a presentati
zhaobin
2016/10/22 02:44:13
Done.
| |
231 class CONTENT_EXPORT ReceiverPresentationServiceDelegate | |
232 : public PresentationServiceDelegateBase { | |
233 public: | |
234 // Registers a callback from the embedder when an offscreeen presentation has | |
235 // been | |
236 // successfully started. | |
mark a. foltz
2016/10/21 00:53:02
Can you rewrap this comment?
zhaobin
2016/10/22 02:44:13
Done.
| |
237 // |receiver_available_callback|: Invoked when successfully starting a | |
238 // offscreen presentation session. | |
239 virtual void RegisterReceiverAvailableCallback( | |
mark a. foltz
2016/10/21 00:53:02
RegisterReceiverConnectionAvailableCallback
zhaobin
2016/10/22 02:44:13
Done.
| |
240 const content::ReceiverConnectionAvailableCallback& | |
241 receiver_available_callback) = 0; | |
205 }; | 242 }; |
206 | 243 |
207 } // namespace content | 244 } // namespace content |
208 | 245 |
209 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 246 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
OLD | NEW |