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 <map> |
8 #include <memory> | 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
15 #include "content/public/browser/presentation_session.h" | 16 #include "content/public/browser/presentation_session.h" |
16 #include "content/public/browser/presentation_session_message.h" | 17 #include "content/public/browser/presentation_session_message.h" |
| 18 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m
ojom.h" |
17 | 19 |
18 class GURL; | 20 class GURL; |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
22 class PresentationScreenAvailabilityListener; | 24 class PresentationScreenAvailabilityListener; |
23 | 25 |
24 using PresentationSessionStartedCallback = | 26 using PresentationSessionStartedCallback = |
25 base::Callback<void(const PresentationSessionInfo&)>; | 27 base::Callback<void(const PresentationSessionInfo&)>; |
26 using PresentationSessionErrorCallback = | 28 using PresentationSessionErrorCallback = |
(...skipping 15 matching lines...) Expand all Loading... |
42 PresentationConnectionState state; | 44 PresentationConnectionState state; |
43 | 45 |
44 // |close_reason| and |messsage| are only used for state change to CLOSED. | 46 // |close_reason| and |messsage| are only used for state change to CLOSED. |
45 PresentationConnectionCloseReason close_reason; | 47 PresentationConnectionCloseReason close_reason; |
46 std::string message; | 48 std::string message; |
47 }; | 49 }; |
48 | 50 |
49 using PresentationConnectionStateChangedCallback = | 51 using PresentationConnectionStateChangedCallback = |
50 base::Callback<void(const PresentationConnectionStateChangeInfo&)>; | 52 base::Callback<void(const PresentationConnectionStateChangeInfo&)>; |
51 | 53 |
52 // An interface implemented by embedders to handle presentation API calls | 54 using PresentationConnectionPtr = blink::mojom::PresentationConnectionPtr; |
53 // forwarded from PresentationServiceImpl. | 55 |
| 56 using ReceiverConnectionAvailableCallback = |
| 57 base::Callback<void(const content::PresentationSessionInfo&, |
| 58 PresentationConnectionPtr)>; |
| 59 |
| 60 // Base class for ControllerPresentationServiceDelegate and |
| 61 // ReceiverPresentationServiceDelegate. |
54 class CONTENT_EXPORT PresentationServiceDelegate { | 62 class CONTENT_EXPORT PresentationServiceDelegate { |
55 public: | 63 public: |
56 // Observer interface to listen for changes to PresentationServiceDelegate. | 64 // Observer interface to listen for changes to PresentationServiceDelegate. |
57 class CONTENT_EXPORT Observer { | 65 class Observer { |
58 public: | 66 public: |
59 // Called when the PresentationServiceDelegate is being destroyed. | 67 // Called when the PresentationServiceDelegate is being destroyed. |
60 virtual void OnDelegateDestroyed() = 0; | 68 virtual void OnDelegateDestroyed() = 0; |
61 | 69 |
62 protected: | 70 protected: |
63 virtual ~Observer() {} | 71 virtual ~Observer() {} |
64 }; | 72 }; |
65 | 73 |
66 using SendMessageCallback = base::Callback<void(bool)>; | |
67 | |
68 virtual ~PresentationServiceDelegate() {} | 74 virtual ~PresentationServiceDelegate() {} |
69 | 75 |
70 // Registers an observer associated with frame with |render_process_id| | 76 // Registers an observer associated with frame with |render_process_id| |
71 // and |render_frame_id| with this class to listen for updates. | 77 // and |render_frame_id| with this class to listen for updates. |
72 // This class does not own the observer. | 78 // This class does not own the observer. |
73 // It is an error to add an observer if there is already an observer for that | 79 // It is an error to add an observer if there is already an observer for that |
74 // frame. | 80 // frame. |
75 virtual void AddObserver(int render_process_id, | 81 virtual void AddObserver(int render_process_id, |
76 int render_frame_id, | 82 int render_frame_id, |
77 Observer* observer) = 0; | 83 Observer* observer) = 0; |
78 | 84 |
79 // Unregisters the observer associated with the frame with |render_process_id| | 85 // Unregisters the observer associated with the frame with |render_process_id| |
80 // and |render_frame_id|. | 86 // and |render_frame_id|. |
81 // The observer will no longer receive updates. | 87 // The observer will no longer receive updates. |
82 virtual void RemoveObserver(int render_process_id, int render_frame_id) = 0; | 88 virtual void RemoveObserver(int render_process_id, int render_frame_id) = 0; |
83 | 89 |
| 90 // Resets the presentation state for the frame given by |render_process_id| |
| 91 // and |render_frame_id|. |
| 92 // This unregisters all screen availability associated with the given frame, |
| 93 // and clears the default presentation URL for the frame. |
| 94 virtual void Reset(int render_process_id, int render_frame_id) = 0; |
| 95 }; |
| 96 |
| 97 // An interface implemented by embedders to handle Presentation API calls |
| 98 // forwarded from PresentationServiceImpl. |
| 99 class CONTENT_EXPORT ControllerPresentationServiceDelegate |
| 100 : public PresentationServiceDelegate { |
| 101 public: |
| 102 using SendMessageCallback = base::Callback<void(bool)>; |
| 103 |
84 // Registers |listener| to continuously listen for | 104 // Registers |listener| to continuously listen for |
85 // availability updates for a presentation URL, originated from the frame | 105 // availability updates for a presentation URL, originated from the frame |
86 // given by |render_process_id| and |render_frame_id|. | 106 // given by |render_process_id| and |render_frame_id|. |
87 // This class does not own |listener|. | 107 // This class does not own |listener|. |
88 // Returns true on success. | 108 // Returns true on success. |
89 // This call will return false if a listener with the same presentation URL | 109 // This call will return false if a listener with the same presentation URL |
90 // from the same frame is already registered. | 110 // from the same frame is already registered. |
91 virtual bool AddScreenAvailabilityListener( | 111 virtual bool AddScreenAvailabilityListener( |
92 int render_process_id, | 112 int render_process_id, |
93 int render_frame_id, | 113 int render_frame_id, |
94 PresentationScreenAvailabilityListener* listener) = 0; | 114 PresentationScreenAvailabilityListener* listener) = 0; |
95 | 115 |
96 // Unregisters |listener| originated from the frame given by | 116 // Unregisters |listener| originated from the frame given by |
97 // |render_process_id| and |render_frame_id| from this class. The listener | 117 // |render_process_id| and |render_frame_id| from this class. The listener |
98 // will no longer receive availability updates. | 118 // will no longer receive availability updates. |
99 virtual void RemoveScreenAvailabilityListener( | 119 virtual void RemoveScreenAvailabilityListener( |
100 int render_process_id, | 120 int render_process_id, |
101 int render_frame_id, | 121 int render_frame_id, |
102 PresentationScreenAvailabilityListener* listener) = 0; | 122 PresentationScreenAvailabilityListener* listener) = 0; |
103 | 123 |
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| | 124 // 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 | 125 // and |render_frame_id|. When the default presentation is started on this |
114 // frame, |callback| will be invoked with the corresponding | 126 // frame, |callback| will be invoked with the corresponding |
115 // PresentationSessionInfo object. | 127 // PresentationSessionInfo object. |
116 // If |default_presentation_urls| is empty, the default presentation URLs will | 128 // If |default_presentation_urls| is empty, the default presentation URLs will |
117 // be cleared and the previously registered callback (if any) will be removed. | 129 // be cleared and the previously registered callback (if any) will be removed. |
118 virtual void SetDefaultPresentationUrls( | 130 virtual void SetDefaultPresentationUrls( |
119 int render_process_id, | 131 int render_process_id, |
120 int render_frame_id, | 132 int render_frame_id, |
121 const std::vector<GURL>& default_presentation_urls, | 133 const std::vector<GURL>& default_presentation_urls, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // frame. | 207 // frame. |
196 // |render_process_id|, |render_frame_id|: ID of frame. | 208 // |render_process_id|, |render_frame_id|: ID of frame. |
197 // |connection|: PresentationConnection to listen for state changes. | 209 // |connection|: PresentationConnection to listen for state changes. |
198 // |state_changed_cb|: Invoked with the PresentationConnection and its new | 210 // |state_changed_cb|: Invoked with the PresentationConnection and its new |
199 // state whenever there is a state change. | 211 // state whenever there is a state change. |
200 virtual void ListenForConnectionStateChange( | 212 virtual void ListenForConnectionStateChange( |
201 int render_process_id, | 213 int render_process_id, |
202 int render_frame_id, | 214 int render_frame_id, |
203 const PresentationSessionInfo& connection, | 215 const PresentationSessionInfo& connection, |
204 const PresentationConnectionStateChangedCallback& state_changed_cb) = 0; | 216 const PresentationConnectionStateChangedCallback& state_changed_cb) = 0; |
| 217 |
| 218 // Connect |connection| owned by the controlling frame to the offscreen |
| 219 // presentation represented by |session|. |
| 220 // |render_process_id|, |render_frame_id|: ID of originating frame. |
| 221 // |connection|: Pointer to controller's presentation connection, |
| 222 // ownership passed from controlling frame to the offscreen presentation. |
| 223 virtual void ConnectToOffscreenPresentation( |
| 224 int render_process_id, |
| 225 int render_frame_id, |
| 226 const PresentationSessionInfo& session, |
| 227 PresentationConnectionPtr connection) = 0; |
| 228 }; |
| 229 |
| 230 // An interface implemented by embedders to handle |
| 231 // PresentationService calls from a presentation receiver. |
| 232 class CONTENT_EXPORT ReceiverPresentationServiceDelegate |
| 233 : public PresentationServiceDelegate { |
| 234 public: |
| 235 // Registers a callback from the embedder when an offscreeen presentation has |
| 236 // been successfully started. |
| 237 // |receiver_available_callback|: Invoked when successfully starting a |
| 238 // offscreen presentation session. |
| 239 virtual void RegisterReceiverConnectionAvailableCallback( |
| 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 |