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 | 21 |
22 using PresentationSessionStartedCallback = | |
23 base::Callback<void(const PresentationSessionInfo&)>; | |
24 using PresentationSessionErrorCallback = | |
25 base::Callback<void(const PresentationError&)>; | |
26 using SessionStateChangedCallback = | 22 using SessionStateChangedCallback = |
27 base::Callback<void(const PresentationSessionInfo&, | 23 base::Callback<void(const PresentationSessionInfo&, |
28 PresentationConnectionState)>; | 24 PresentationConnectionState)>; |
29 | 25 |
30 // Param #0: a vector of messages that are received. | 26 // Param #0: a vector of messages that are received. |
31 // Param #1: tells the callback handler that it may reuse strings or buffers | 27 // Param #1: tells the callback handler that it may reuse strings or buffers |
32 // in the messages contained within param #0. | 28 // in the messages contained within param #0. |
33 using PresentationSessionMessageCallback = base::Callback< | 29 using PresentationSessionMessageCallback = base::Callback< |
34 void(const ScopedVector<content::PresentationSessionMessage>&, bool)>; | 30 void(const ScopedVector<content::PresentationSessionMessage>&, bool)>; |
35 | 31 |
36 // An interface implemented by embedders to handle presentation API calls | 32 // An interface implemented by embedders to handle presentation API calls |
37 // forwarded from PresentationServiceImpl. | 33 // forwarded from PresentationServiceImpl. |
38 class CONTENT_EXPORT PresentationServiceDelegate { | 34 class CONTENT_EXPORT PresentationServiceDelegate { |
39 public: | 35 public: |
40 // Observer interface to listen for changes to PresentationServiceDelegate. | 36 // Observer interface to listen for changes to PresentationServiceDelegate. |
41 class CONTENT_EXPORT Observer { | 37 class CONTENT_EXPORT Observer { |
42 public: | 38 public: |
43 // Called when the PresentationServiceDelegate is being destroyed. | 39 // Called when the PresentationServiceDelegate is being destroyed. |
44 virtual void OnDelegateDestroyed() = 0; | 40 virtual void OnDelegateDestroyed() = 0; |
45 | 41 |
| 42 // Called when the default presentation has been started outside of a |
| 43 // Presentation API context (e.g., browser action). This will not be called |
| 44 // if the session was created as a result of Presentation API's |
| 45 // StartSession()/JoinSession(). |
| 46 virtual void OnDefaultPresentationStarted( |
| 47 const PresentationSessionInfo& session) = 0; |
| 48 |
46 protected: | 49 protected: |
47 virtual ~Observer() {} | 50 virtual ~Observer() {} |
48 }; | 51 }; |
49 | 52 |
| 53 using PresentationSessionSuccessCallback = |
| 54 base::Callback<void(const PresentationSessionInfo&)>; |
| 55 using PresentationSessionErrorCallback = |
| 56 base::Callback<void(const PresentationError&)>; |
50 using SendMessageCallback = base::Callback<void(bool)>; | 57 using SendMessageCallback = base::Callback<void(bool)>; |
51 | 58 |
52 virtual ~PresentationServiceDelegate() {} | 59 virtual ~PresentationServiceDelegate() {} |
53 | 60 |
54 // Registers an observer associated with frame with |render_process_id| | 61 // Registers an observer associated with frame with |render_process_id| |
55 // and |render_frame_id| with this class to listen for updates. | 62 // and |render_frame_id| with this class to listen for updates. |
56 // This class does not own the observer. | 63 // This class does not own the observer. |
57 // It is an error to add an observer if there is already an observer for that | 64 // It is an error to add an observer if there is already an observer for that |
58 // frame. | 65 // frame. |
59 virtual void AddObserver(int render_process_id, | 66 virtual void AddObserver(int render_process_id, |
(...skipping 27 matching lines...) Expand all Loading... |
87 | 94 |
88 // Resets the presentation state for the frame given by |render_process_id| | 95 // Resets the presentation state for the frame given by |render_process_id| |
89 // and |render_frame_id|. | 96 // and |render_frame_id|. |
90 // This unregisters all listeners associated with the given frame, and clears | 97 // This unregisters all listeners associated with the given frame, and clears |
91 // the default presentation URL and ID set for the frame. | 98 // the default presentation URL and ID set for the frame. |
92 virtual void Reset( | 99 virtual void Reset( |
93 int render_process_id, | 100 int render_process_id, |
94 int render_frame_id) = 0; | 101 int render_frame_id) = 0; |
95 | 102 |
96 // Sets the default presentation URL for frame given by |render_process_id| | 103 // Sets the default presentation URL for frame given by |render_process_id| |
97 // and |render_frame_id|. When the default presentation is started on this | 104 // and |render_frame_id|. |
98 // frame, |callback| will be invoked with the corresponding | |
99 // PresentationSessionInfo object. | |
100 // If |default_presentation_url| is empty, the default presentation URL will | 105 // If |default_presentation_url| is empty, the default presentation URL will |
101 // be cleared and the previously registered callback (if any) will be removed. | 106 // be cleared. |
102 virtual void SetDefaultPresentationUrl( | 107 virtual void SetDefaultPresentationUrl( |
103 int render_process_id, | 108 int render_process_id, |
104 int render_frame_id, | 109 int render_frame_id, |
105 const std::string& default_presentation_url, | 110 const std::string& default_presentation_url) = 0; |
106 const PresentationSessionStartedCallback& callback) = 0; | |
107 | 111 |
108 // Starts a new presentation session. The presentation id of the session will | 112 // Starts a new presentation session. The presentation id of the session will |
109 // be the default presentation ID if any or a generated one otherwise. | 113 // be the default presentation ID if any or a generated one otherwise. |
110 // Typically, the embedder will allow the user to select a screen to show | 114 // Typically, the embedder will allow the user to select a screen to show |
111 // |presentation_url|. | 115 // |presentation_url|. |
112 // |render_process_id|, |render_frame_id|: ID of originating frame. | 116 // |render_process_id|, |render_frame_id|: ID of originating frame. |
113 // |presentation_url|: URL of the presentation. | 117 // |presentation_url|: URL of the presentation. |
114 // |success_cb|: Invoked with session info, if presentation session started | 118 // |success_cb|: Invoked with session info, if presentation session started |
115 // successfully. | 119 // successfully. |
116 // |error_cb|: Invoked with error reason, if presentation session did not | 120 // |error_cb|: Invoked with error reason, if presentation session did not |
117 // start. | 121 // start. |
118 virtual void StartSession( | 122 virtual void StartSession( |
119 int render_process_id, | 123 int render_process_id, |
120 int render_frame_id, | 124 int render_frame_id, |
121 const std::string& presentation_url, | 125 const std::string& presentation_url, |
122 const PresentationSessionStartedCallback& success_cb, | 126 const PresentationSessionSuccessCallback& success_cb, |
123 const PresentationSessionErrorCallback& error_cb) = 0; | 127 const PresentationSessionErrorCallback& error_cb) = 0; |
124 | 128 |
125 // Joins an existing presentation session. Unlike StartSession(), this | 129 // Joins an existing presentation session. Unlike StartSession(), this |
126 // does not bring a screen list UI. | 130 // does not bring a screen list UI. |
127 // |render_process_id|, |render_frame_id|: ID for originating frame. | 131 // |render_process_id|, |render_frame_id|: ID for originating frame. |
128 // |presentation_url|: URL of the presentation. | 132 // |presentation_url|: URL of the presentation. |
129 // |presentation_id|: The ID of the presentation to join. | 133 // |presentation_id|: The ID of the presentation to join. |
130 // |success_cb|: Invoked with session info, if presentation session joined | 134 // |success_cb|: Invoked with session info, if presentation session joined |
131 // successfully. | 135 // successfully. |
132 // |error_cb|: Invoked with error reason, if joining failed. | 136 // |error_cb|: Invoked with error reason, if joining failed. |
133 virtual void JoinSession( | 137 virtual void JoinSession( |
134 int render_process_id, | 138 int render_process_id, |
135 int render_frame_id, | 139 int render_frame_id, |
136 const std::string& presentation_url, | 140 const std::string& presentation_url, |
137 const std::string& presentation_id, | 141 const std::string& presentation_id, |
138 const PresentationSessionStartedCallback& success_cb, | 142 const PresentationSessionSuccessCallback& success_cb, |
139 const PresentationSessionErrorCallback& error_cb) = 0; | 143 const PresentationSessionErrorCallback& error_cb) = 0; |
140 | 144 |
141 // Close an existing presentation session. | 145 // Close an existing presentation session. |
142 // |render_process_id|, |render_frame_id|: ID for originating frame. | 146 // |render_process_id|, |render_frame_id|: ID for originating frame. |
143 // |presentation_id|: The ID of the presentation to close. | 147 // |presentation_id|: The ID of the presentation to close. |
144 virtual void CloseSession(int render_process_id, | 148 virtual void CloseSession(int render_process_id, |
145 int render_frame_id, | 149 int render_frame_id, |
146 const std::string& presentation_id) = 0; | 150 const std::string& presentation_id) = 0; |
147 | 151 |
148 // Listen for messages for a presentation session. | 152 // Listen for messages for a presentation session. |
(...skipping 25 matching lines...) Expand all Loading... |
174 // there is a state change. | 178 // there is a state change. |
175 virtual void ListenForSessionStateChange( | 179 virtual void ListenForSessionStateChange( |
176 int render_process_id, | 180 int render_process_id, |
177 int render_frame_id, | 181 int render_frame_id, |
178 const SessionStateChangedCallback& state_changed_cb) = 0; | 182 const SessionStateChangedCallback& state_changed_cb) = 0; |
179 }; | 183 }; |
180 | 184 |
181 } // namespace content | 185 } // namespace content |
182 | 186 |
183 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 187 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
OLD | NEW |