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