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 <vector> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" |
9 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
10 #include "content/public/browser/presentation_session.h" | 14 #include "content/public/browser/presentation_session.h" |
11 | 15 |
12 namespace content { | 16 namespace content { |
13 | 17 |
14 class PresentationScreenAvailabilityListener; | 18 class PresentationScreenAvailabilityListener; |
| 19 struct PresentationSessionMessage; |
15 | 20 |
16 // An interface implemented by embedders to handle presentation API calls | 21 // An interface implemented by embedders to handle presentation API calls |
17 // forwarded from PresentationServiceImpl. | 22 // forwarded from PresentationServiceImpl. |
18 class CONTENT_EXPORT PresentationServiceDelegate { | 23 class CONTENT_EXPORT PresentationServiceDelegate { |
19 public: | 24 public: |
20 // Observer interface to listen for changes to PresentationServiceDelegate. | 25 // Observer interface to listen for changes to PresentationServiceDelegate. |
21 class CONTENT_EXPORT Observer { | 26 class CONTENT_EXPORT Observer { |
22 public: | 27 public: |
23 // Called when the PresentationServiceDelegate is being destroyed. | 28 // Called when the PresentationServiceDelegate is being destroyed. |
24 virtual void OnDelegateDestroyed() = 0; | 29 virtual void OnDelegateDestroyed() = 0; |
25 | 30 |
26 // Called when the default presentation has been started outside of a | 31 // Called when the default presentation has been started outside of a |
27 // Presentation API context (e.g., browser action). This will not be called | 32 // Presentation API context (e.g., browser action). This will not be called |
28 // if the session was created as a result of Presentation API's | 33 // if the session was created as a result of Presentation API's |
29 // StartSession()/JoinSession(). | 34 // StartSession()/JoinSession(). |
30 virtual void OnDefaultPresentationStarted( | 35 virtual void OnDefaultPresentationStarted( |
31 const PresentationSessionInfo& session) = 0; | 36 const PresentationSessionInfo& session) = 0; |
32 | 37 |
33 protected: | 38 protected: |
34 virtual ~Observer() {} | 39 virtual ~Observer() {} |
35 }; | 40 }; |
36 | 41 |
37 using PresentationSessionSuccessCallback = | 42 using PresentationSessionSuccessCallback = |
38 base::Callback<void(const PresentationSessionInfo&)>; | 43 base::Callback<void(const PresentationSessionInfo&)>; |
39 using PresentationSessionErrorCallback = | 44 using PresentationSessionErrorCallback = |
40 base::Callback<void(const PresentationError&)>; | 45 base::Callback<void(const PresentationError&)>; |
| 46 using PresentationSessionMessageCallback = base::Callback<void( |
| 47 scoped_ptr<ScopedVector<PresentationSessionMessage>>)>; |
41 | 48 |
42 virtual ~PresentationServiceDelegate() {} | 49 virtual ~PresentationServiceDelegate() {} |
43 | 50 |
44 // Registers an observer associated with frame with |render_process_id| | 51 // Registers an observer associated with frame with |render_process_id| |
45 // and |render_frame_id| with this class to listen for updates. | 52 // and |render_frame_id| with this class to listen for updates. |
46 // This class does not own the observer. | 53 // This class does not own the observer. |
47 // It is an error to add an observer if there is already an observer for that | 54 // It is an error to add an observer if there is already an observer for that |
48 // frame. | 55 // frame. |
49 virtual void AddObserver(int render_process_id, | 56 virtual void AddObserver(int render_process_id, |
50 int render_frame_id, | 57 int render_frame_id, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // |success_cb|: Invoked with session info, if presentation session joined | 129 // |success_cb|: Invoked with session info, if presentation session joined |
123 // successfully. | 130 // successfully. |
124 // |error_cb|: Invoked with error reason, if joining failed. | 131 // |error_cb|: Invoked with error reason, if joining failed. |
125 virtual void JoinSession( | 132 virtual void JoinSession( |
126 int render_process_id, | 133 int render_process_id, |
127 int render_frame_id, | 134 int render_frame_id, |
128 const std::string& presentation_url, | 135 const std::string& presentation_url, |
129 const std::string& presentation_id, | 136 const std::string& presentation_id, |
130 const PresentationSessionSuccessCallback& success_cb, | 137 const PresentationSessionSuccessCallback& success_cb, |
131 const PresentationSessionErrorCallback& error_cb) = 0; | 138 const PresentationSessionErrorCallback& error_cb) = 0; |
| 139 |
| 140 // Gtts the next batch of messages of all presentation session in the frame. |
| 141 // |render_process_id|, |render_frame_id|: ID for originating frame. |
| 142 // |message_cb|: Invoked with a list of messages. |
| 143 virtual void ListenForSessionMessages( |
| 144 int render_process_id, |
| 145 int render_frame_id, |
| 146 const PresentationSessionMessageCallback& message_cb) = 0; |
132 }; | 147 }; |
133 | 148 |
134 } // namespace content | 149 } // namespace content |
135 | 150 |
136 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 151 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
OLD | NEW |