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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.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 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 class PresentationScreenAvailabilityListener; | 20 class PresentationScreenAvailabilityListener; |
21 class PresentationSessionStateListener; | 21 class PresentationSessionStateListener; |
22 | 22 |
23 // Param #0: a vector of messages that are received. | 23 // Param #0: a vector of messages that are received. |
24 // Param #1: tells the callback handler that it may reuse strings or buffers | 24 // Param #1: tells the callback handler that it may reuse strings or buffers |
25 // in the messages contained within param #0. | 25 // in the messages contained within param #0. |
26 using PresentationSessionMessageCallback = base::Callback< | 26 using PresentationSessionMessageCallback = base::Callback< |
27 void(const ScopedVector<content::PresentationSessionMessage>&, bool)>; | 27 void(const ScopedVector<content::PresentationSessionMessage>&, bool)>; |
28 | 28 |
29 using PresentationReceiverSessionAvailableCallback = | |
30 base::Callback<void(const content::PresentationSessionInfo*)>; | |
31 | |
32 using SendMessageCallback = base::Callback<void(bool)>; | |
33 | |
29 // An interface implemented by embedders to handle presentation API calls | 34 // An interface implemented by embedders to handle presentation API calls |
30 // forwarded from PresentationServiceImpl. | 35 // forwarded from PresentationServiceImpl. |
31 class CONTENT_EXPORT PresentationServiceDelegate { | 36 class CONTENT_EXPORT PresentationServiceDelegate { |
32 public: | 37 public: |
33 // Observer interface to listen for changes to PresentationServiceDelegate. | 38 // Observer interface to listen for changes to PresentationServiceDelegate. |
34 class CONTENT_EXPORT Observer { | 39 class CONTENT_EXPORT Observer { |
35 public: | 40 public: |
36 // Called when the PresentationServiceDelegate is being destroyed. | 41 // Called when the PresentationServiceDelegate is being destroyed. |
37 virtual void OnDelegateDestroyed() = 0; | 42 virtual void OnDelegateDestroyed() = 0; |
38 | 43 |
39 // Called when the default presentation has been started outside of a | 44 // Called when the default presentation has been started outside of a |
40 // Presentation API context (e.g., browser action). This will not be called | 45 // Presentation API context (e.g., browser action). This will not be called |
41 // if the session was created as a result of Presentation API's | 46 // if the session was created as a result of Presentation API's |
42 // StartSession()/JoinSession(). | 47 // StartSession()/JoinSession(). |
43 virtual void OnDefaultPresentationStarted( | 48 virtual void OnDefaultPresentationStarted( |
44 const PresentationSessionInfo& session) = 0; | 49 const PresentationSessionInfo& session) = 0; |
45 | 50 |
46 protected: | 51 protected: |
47 virtual ~Observer() {} | 52 virtual ~Observer() {} |
48 }; | 53 }; |
49 | 54 |
50 using PresentationSessionSuccessCallback = | 55 using PresentationSessionSuccessCallback = |
51 base::Callback<void(const PresentationSessionInfo&)>; | 56 base::Callback<void(const PresentationSessionInfo&)>; |
52 using PresentationSessionErrorCallback = | 57 using PresentationSessionErrorCallback = |
53 base::Callback<void(const PresentationError&)>; | 58 base::Callback<void(const PresentationError&)>; |
54 using SendMessageCallback = base::Callback<void(bool)>; | |
55 | 59 |
56 virtual ~PresentationServiceDelegate() {} | 60 virtual ~PresentationServiceDelegate() {} |
57 | 61 |
58 // Registers an observer associated with frame with |render_process_id| | 62 // Registers an observer associated with frame with |render_process_id| |
59 // and |render_frame_id| with this class to listen for updates. | 63 // and |render_frame_id| with this class to listen for updates. |
60 // This class does not own the observer. | 64 // This class does not own the observer. |
61 // It is an error to add an observer if there is already an observer for that | 65 // It is an error to add an observer if there is already an observer for that |
62 // frame. | 66 // frame. |
63 virtual void AddObserver(int render_process_id, | 67 virtual void AddObserver(int render_process_id, |
64 int render_frame_id, | 68 int render_frame_id, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 // Continuously listen for presentation session state changes for a session. | 176 // Continuously listen for presentation session state changes for a session. |
173 // Returns true if |listener| is sucessfully registered. | 177 // Returns true if |listener| is sucessfully registered. |
174 // |render_process_id|, |render_frame_id|: ID of frame. | 178 // |render_process_id|, |render_frame_id|: ID of frame. |
175 // |session|: Presentation session to listen for state changes. | 179 // |session|: Presentation session to listen for state changes. |
176 // |listener|: The listener to be invoked whenever there is a state change. | 180 // |listener|: The listener to be invoked whenever there is a state change. |
177 // Not owned by this class. | 181 // Not owned by this class. |
178 virtual bool ListenForSessionStateChange( | 182 virtual bool ListenForSessionStateChange( |
179 int render_process_id, | 183 int render_process_id, |
180 int render_frame_id, | 184 int render_frame_id, |
181 content::PresentationSessionStateListener* listener) = 0; | 185 content::PresentationSessionStateListener* listener) = 0; |
186 | |
187 // Gets a receiver presentation session for the offscreen presentation hosted | |
188 // on the offscreen tab containing this frame, or waits until one is | |
189 // available. | |
mark a. foltz
2015/10/12 21:56:10
Registers a callback to be notified when the offsc
miu
2015/10/14 01:54:57
I'm not sure "register" is the right verb here, th
| |
190 // Runs |callback| once the receiver becomes available. |callback| will be | |
191 // run during this method call if the receiver is already available, or at | |
192 // some later time when a receiver presentation session becomes available. | |
193 // It is possible that |callback| will never be run if a receiver never | |
194 // becomes available. | |
195 // If |render_process_id| and |render_frame_id| do not refer to the main | |
196 // render frame of this WebContents, |callback| will be immediately invoked | |
197 // with null. | |
198 virtual void NotifyWhenReceiverSessionIsAvailable( | |
199 int render_process_id, | |
200 int render_frame_id, | |
201 const PresentationReceiverSessionAvailableCallback& callback) = 0; | |
202 | |
203 // Gets all receiver presentation sessions for the offscreen presentation | |
204 // hosted on the offscreen tab containing this frame. | |
mark a. foltz
2015/10/12 21:56:10
Returns all presentation sessions for the offscree
imcheng
2015/10/17 01:00:24
Done.
| |
205 // Unlike |GetPresentationReceiverSession|, this method immediately returns | |
miu
2015/10/14 01:54:57
This part of the comment is stale now (GetPresenta
imcheng
2015/10/17 01:00:24
Done.
| |
206 // all receiver sessions that are currently available. | |
207 // If |render_process_id| and |render_frame_id| do not refer to the main | |
208 // render frame of this WebContents, an empty vector will be returned. | |
209 virtual std::vector<content::PresentationSessionInfo> | |
miu
2015/10/14 01:54:57
style: Per style guide, consider having the caller
imcheng
2015/10/17 01:00:24
Done.
| |
210 GetPresentationReceiverSessions(int render_process_id, | |
211 int render_frame_id) = 0; | |
182 }; | 212 }; |
183 | 213 |
184 } // namespace content | 214 } // namespace content |
185 | 215 |
186 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 216 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
OLD | NEW |