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. |
| 190 // If there is at least one receiver presentation session, |callback| will |
| 191 // be invoked with one of the sessions immediately. |
| 192 // Otherwise, |callback| will be invoked when a receiver presentation session |
| 193 // becomes available. |
| 194 // If the calling frame is not the main frame of an offscreen tab, |
| 195 // |callback| will be invoked with null. |
| 196 virtual void GetPresentationReceiverSession( |
| 197 int render_process_id, |
| 198 int render_frame_id, |
| 199 const PresentationReceiverSessionAvailableCallback& callback) = 0; |
| 200 |
| 201 // Gets all receiver presentation sessions for the offscreen presentation |
| 202 // hosted |
| 203 // on the offscreen tab containing this frame. |
| 204 // If the calling frame is not the main frame of an offscreen tab, an empty |
| 205 // vector will be returned. |
| 206 virtual std::vector<content::PresentationSessionInfo> |
| 207 GetPresentationReceiverSessions(int render_process_id, |
| 208 int render_frame_id) = 0; |
182 }; | 209 }; |
183 | 210 |
184 } // namespace content | 211 } // namespace content |
185 | 212 |
186 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 213 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
OLD | NEW |