Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: content/public/browser/presentation_service_delegate.h

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: merge with master Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // This callback will create a receiver PresentationConnectionPtr, and connect
56 // it with the passed in controller PresentationConnectionPtr.
57 using ReceiverConnectionAvailableCallback =
58 base::Callback<void(const content::PresentationSessionInfo&,
59 PresentationConnectionPtr&&)>;
60
61 // Base class for ControllerPresentationServiceDelegate and
62 // ReceiverPresentationServiceDelegate.
63 class PresentationServiceDelegateBase {
55 public: 64 public:
56 // Observer interface to listen for changes to PresentationServiceDelegate. 65 // Observer interface to listen for changes to PresentationServiceDelegate.
57 class CONTENT_EXPORT Observer { 66 class CONTENT_EXPORT Observer {
58 public: 67 public:
59 // Called when the PresentationServiceDelegate is being destroyed. 68 // Called when the PresentationServiceDelegate is being destroyed.
60 virtual void OnDelegateDestroyed() = 0; 69 virtual void OnDelegateDestroyed() = 0;
61 70
62 protected: 71 protected:
63 virtual ~Observer() {} 72 virtual ~Observer() {}
64 }; 73 };
65 74
66 using SendMessageCallback = base::Callback<void(bool)>;
67
68 virtual ~PresentationServiceDelegate() {}
69
70 // Registers an observer associated with frame with |render_process_id| 75 // Registers an observer associated with frame with |render_process_id|
71 // and |render_frame_id| with this class to listen for updates. 76 // and |render_frame_id| with this class to listen for updates.
72 // This class does not own the observer. 77 // This class does not own the observer.
73 // 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
74 // frame. 79 // frame.
75 virtual void AddObserver(int render_process_id, 80 virtual void AddObserver(int render_process_id,
76 int render_frame_id, 81 int render_frame_id,
77 Observer* observer) = 0; 82 Observer* observer) = 0;
78 83
79 // Unregisters the observer associated with the frame with |render_process_id| 84 // Unregisters the observer associated with the frame with |render_process_id|
80 // and |render_frame_id|. 85 // and |render_frame_id|.
81 // The observer will no longer receive updates. 86 // The observer will no longer receive updates.
82 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;
83 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
84 // Registers |listener| to continuously listen for 105 // Registers |listener| to continuously listen for
85 // availability updates for a presentation URL, originated from the frame 106 // availability updates for a presentation URL, originated from the frame
86 // given by |render_process_id| and |render_frame_id|. 107 // given by |render_process_id| and |render_frame_id|.
87 // This class does not own |listener|. 108 // This class does not own |listener|.
88 // Returns true on success. 109 // Returns true on success.
89 // 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
90 // from the same frame is already registered. 111 // from the same frame is already registered.
91 virtual bool AddScreenAvailabilityListener( 112 virtual bool AddScreenAvailabilityListener(
92 int render_process_id, 113 int render_process_id,
93 int render_frame_id, 114 int render_frame_id,
94 PresentationScreenAvailabilityListener* listener) = 0; 115 PresentationScreenAvailabilityListener* listener) = 0;
95 116
96 // Unregisters |listener| originated from the frame given by 117 // Unregisters |listener| originated from the frame given by
97 // |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
98 // will no longer receive availability updates. 119 // will no longer receive availability updates.
99 virtual void RemoveScreenAvailabilityListener( 120 virtual void RemoveScreenAvailabilityListener(
100 int render_process_id, 121 int render_process_id,
101 int render_frame_id, 122 int render_frame_id,
102 PresentationScreenAvailabilityListener* listener) = 0; 123 PresentationScreenAvailabilityListener* listener) = 0;
103 124
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| 125 // 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 126 // and |render_frame_id|. When the default presentation is started on this
114 // frame, |callback| will be invoked with the corresponding 127 // frame, |callback| will be invoked with the corresponding
115 // PresentationSessionInfo object. 128 // PresentationSessionInfo object.
116 // If |default_presentation_urls| is empty, the default presentation URLs will 129 // If |default_presentation_urls| is empty, the default presentation URLs will
117 // 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.
118 virtual void SetDefaultPresentationUrls( 131 virtual void SetDefaultPresentationUrls(
119 int render_process_id, 132 int render_process_id,
120 int render_frame_id, 133 int render_frame_id,
121 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
195 // frame. 208 // frame.
196 // |render_process_id|, |render_frame_id|: ID of frame. 209 // |render_process_id|, |render_frame_id|: ID of frame.
197 // |connection|: PresentationConnection to listen for state changes. 210 // |connection|: PresentationConnection to listen for state changes.
198 // |state_changed_cb|: Invoked with the PresentationConnection and its new 211 // |state_changed_cb|: Invoked with the PresentationConnection and its new
199 // state whenever there is a state change. 212 // state whenever there is a state change.
200 virtual void ListenForConnectionStateChange( 213 virtual void ListenForConnectionStateChange(
201 int render_process_id, 214 int render_process_id,
202 int render_frame_id, 215 int render_frame_id,
203 const PresentationSessionInfo& connection, 216 const PresentationSessionInfo& connection,
204 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;
205 }; 243 };
206 244
207 } // namespace content 245 } // namespace content
208 246
209 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ 247 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
OLDNEW
« no previous file with comments | « content/public/browser/content_browser_client.cc ('k') | content/public/browser/presentation_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698