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 "base/callback.h" | |
| 8 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/presentation_session.h" | |
| 9 | 11 |
| 10 namespace content { | 12 namespace content { |
| 11 | 13 |
| 12 class PresentationScreenAvailabilityListener; | 14 class PresentationScreenAvailabilityListener; |
| 13 | 15 |
| 14 // An interface implemented by embedders to handle presentation API calls | 16 // An interface implemented by embedders to handle presentation API calls |
| 15 // forwarded from PresentationServiceImpl. | 17 // forwarded from PresentationServiceImpl. |
| 16 class CONTENT_EXPORT PresentationServiceDelegate { | 18 class CONTENT_EXPORT PresentationServiceDelegate { |
| 17 public: | 19 public: |
| 18 // Observer interface to listen for changes to PresentationServiceDelegate. | 20 // Observer interface to listen for changes to PresentationServiceDelegate. |
| 19 class CONTENT_EXPORT Observer { | 21 class CONTENT_EXPORT Observer { |
| 20 public: | 22 public: |
| 21 // Called when the PresentationServiceDelegate is being destroyed. | 23 // Called when the PresentationServiceDelegate is being destroyed. |
| 22 virtual void OnDelegateDestroyed() = 0; | 24 virtual void OnDelegateDestroyed() = 0; |
| 23 | 25 |
| 24 protected: | 26 protected: |
| 25 virtual ~Observer() {} | 27 virtual ~Observer() {} |
| 26 }; | 28 }; |
| 27 | 29 |
| 30 using PresentationSessionSuccessCallback = | |
| 31 base::Callback<void(const PresentationSessionInfo&)>; | |
| 32 using PresentationSessionErrorCallback = | |
| 33 base::Callback<void(const PresentationError&)>; | |
| 34 | |
| 28 virtual ~PresentationServiceDelegate() {} | 35 virtual ~PresentationServiceDelegate() {} |
| 29 | 36 |
| 30 // Registers an observer with this class to listen for updates to this class. | 37 // Registers an observer with this class to listen for updates to this class. |
| 31 // This class does not own the observer. | 38 // This class does not own the observer. |
| 32 // It is an error to add an observer if it has already been added before. | 39 // It is an error to add an observer if it has already been added before. |
| 33 virtual void AddObserver(Observer* observer) = 0; | 40 virtual void AddObserver(Observer* observer) = 0; |
| 34 // Unregisters an observer with this class. | 41 // Unregisters an observer with this class. |
| 35 virtual void RemoveObserver(Observer* observer) = 0; | 42 virtual void RemoveObserver(Observer* observer) = 0; |
| 36 | 43 |
| 37 // Registers |listener| to continuously listen for | 44 // Registers |listener| to continuously listen for |
| 38 // availability updates for a presentation URL, originated from the frame | 45 // availability updates for a presentation URL, originated from the frame |
| 39 // given by |render_process_id| and |render_frame_id|. | 46 // given by |render_process_id| and |render_frame_id|. |
| 40 // This class does not own |listener|. | 47 // This class does not own |listener|. |
| 41 // Returns true on success. | 48 // Returns true on success. |
| 42 // This call will return false if a listener with the same presentation URL | 49 // This call will return false if a listener with the same presentation URL |
| 43 // from the same frame is already registered. | 50 // from the same frame is already registered. |
| 44 virtual bool AddScreenAvailabilityListener( | 51 virtual bool AddScreenAvailabilityListener( |
| 45 int render_process_id, | 52 int render_process_id, |
| 46 int render_frame_id, | 53 int render_frame_id, |
| 47 PresentationScreenAvailabilityListener* listener) = 0; | 54 PresentationScreenAvailabilityListener* listener) = 0; |
| 48 | 55 |
| 49 // Unregisters |listener| originated from the frame given by | 56 // Unregisters |listener| originated from the frame given by |
| 50 // |render_process_id| and |render_frame_id| from this class. The listener | 57 // |render_process_id| and |render_frame_id| from this class. The listener |
| 51 // will no longer receive availability updates. | 58 // will no longer receive availability updates. |
| 52 virtual void RemoveScreenAvailabilityListener( | 59 virtual void RemoveScreenAvailabilityListener( |
| 53 int render_process_id, | 60 int render_process_id, |
| 54 int render_frame_id, | 61 int render_frame_id, |
| 55 PresentationScreenAvailabilityListener* listener) = 0; | 62 PresentationScreenAvailabilityListener* listener) = 0; |
| 56 | 63 |
| 57 // Unregisters all listeners associated with the frame given by | 64 // Resets the presentation state for the frame given by |render_process_id| |
| 58 // |render_process_id| and |render_frame_id|. | 65 // and |render_frame_id|. |
| 59 virtual void RemoveAllScreenAvailabilityListeners( | 66 // This unregisters all listeners associated with the given frame, and clears |
| 67 // the default presentation URL and ID set for the frame. | |
| 68 virtual void Reset( | |
| 60 int render_process_id, | 69 int render_process_id, |
| 61 int render_frame_id) = 0; | 70 int render_frame_id) = 0; |
| 71 | |
| 72 // Sets the default presentation URL and ID for frame given by | |
| 73 // |render_process_id| and |render_frame_id|. | |
| 74 // If |default_presentation_url| is empty, the default presentation URL will | |
| 75 // be cleared. | |
| 76 virtual void SetDefaultPresentationUrl( | |
| 77 int render_process_id, | |
| 78 int render_frame_id, | |
| 79 const std::string& default_presentation_url, | |
| 80 const std::string& default_presentation_id) = 0; | |
| 81 | |
| 82 // Starts a new presentation session. | |
| 83 // This brings up a screen list for the user to select a screen to | |
|
mark a. foltz
2015/03/18 00:10:58
Actually that's up to the embedder :)
Maybe, "Typ
imcheng
2015/03/18 00:56:53
Done.
| |
| 84 // establish the presentation session on. | |
| 85 // |render_process_id|, |render_frame_id|: ID of originating frame. | |
| 86 // |presentation_url|: URL of the presentation. If empty, fall back to | |
|
mark a. foltz
2015/03/18 00:10:58
presentation_url should be mandatory for all calls
imcheng
2015/03/18 00:56:53
Done.
| |
| 87 // falling back on "1-UA" mode, i.e. offscreen tab rendering. | |
| 88 // |presentation_id|: The caller may provide an non-empty string to be used | |
| 89 // as the ID of the presentation. If this is an empty string, the embedder | |
| 90 // will automatically generate one. | |
| 91 // |success_cb|: Invoked with session info, if presentation session started | |
| 92 // successfully. | |
| 93 // |error_cb|: Invoked with error reason, if presentation session did not | |
| 94 // start. | |
| 95 virtual void StartSession( | |
| 96 int render_process_id, | |
| 97 int render_frame_id, | |
| 98 const std::string& presentation_url, | |
| 99 const std::string& presentation_id, | |
| 100 const PresentationSessionSuccessCallback& success_cb, | |
| 101 const PresentationSessionErrorCallback& error_cb) = 0; | |
| 102 | |
| 103 // Joins an existing presentation session. Unlike StartSession(), this | |
| 104 // does not bring a screen list UI. | |
| 105 // |render_process_id|, |render_frame_id|: ID for originating frame. | |
| 106 // |presentation_url|: URL of the presentation. If empty, fall back to | |
|
mark a. foltz
2015/03/18 00:10:58
Also mandatory for joinSession().
imcheng
2015/03/18 00:56:53
Done.
| |
| 107 // falling back on "1-UA" mode, i.e. offscreen tab rendering. | |
| 108 // |presentation_id|: The ID of the presentation to join. | |
| 109 // |success_cb|: Invoked with session info, if presentation session joined | |
| 110 // successfully. | |
| 111 // |error_cb|: Invoked with error reason, if joining failed. | |
| 112 virtual void JoinSession( | |
| 113 int render_process_id, | |
| 114 int render_frame_id, | |
| 115 const std::string& presentation_url, | |
| 116 const std::string& presentation_id, | |
| 117 const PresentationSessionSuccessCallback& success_cb, | |
| 118 const PresentationSessionErrorCallback& error_cb) = 0; | |
| 62 }; | 119 }; |
| 63 | 120 |
| 64 } // namespace content | 121 } // namespace content |
| 65 | 122 |
| 66 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ | 123 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ |
| OLD | NEW |