| 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 CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class PresentationScreenAvailabilityListener; | 28 class PresentationScreenAvailabilityListener; |
| 29 class WebContents; | 29 class WebContents; |
| 30 struct PresentationSessionInfo; | 30 struct PresentationSessionInfo; |
| 31 struct PresentationSessionMessage; | 31 struct PresentationSessionMessage; |
| 32 } // namespace content | 32 } // namespace content |
| 33 | 33 |
| 34 namespace media_router { | 34 namespace media_router { |
| 35 | 35 |
| 36 class MediaRoute; | 36 class MediaRoute; |
| 37 class MediaSinksObserver; | 37 class MediaSinksObserver; |
| 38 class OffscreenPresentationManager; |
| 38 class PresentationFrameManager; | 39 class PresentationFrameManager; |
| 39 class RouteRequestResult; | 40 class RouteRequestResult; |
| 40 | 41 |
| 41 // Implementation of PresentationServiceDelegate that interfaces an instance of | 42 // Implementation of PresentationServiceDelegate that interfaces an instance of |
| 42 // WebContents with the Chrome Media Router. It uses the Media Router to handle | 43 // WebContents with the Chrome Media Router. It uses the Media Router to handle |
| 43 // presentation API calls forwarded from PresentationServiceImpl. In addition, | 44 // presentation API calls forwarded from PresentationServiceImpl. In addition, |
| 44 // it also provides default presentation URL that is required for creating | 45 // it also provides default presentation URL that is required for creating |
| 45 // browser-initiated sessions. It is scoped to the lifetime of a WebContents, | 46 // browser-initiated sessions. It is scoped to the lifetime of a WebContents, |
| 46 // and is managed by the associated WebContents. | 47 // and is managed by the associated WebContents. |
| 47 class PresentationServiceDelegateImpl | 48 class PresentationServiceDelegateImpl |
| 48 : public content::WebContentsUserData<PresentationServiceDelegateImpl>, | 49 : public content::WebContentsUserData<PresentationServiceDelegateImpl>, |
| 49 public content::PresentationServiceDelegate { | 50 public content::ControllerPresentationServiceDelegate { |
| 50 public: | 51 public: |
| 51 // Observer interface for listening to default presentation request | 52 // Observer interface for listening to default presentation request |
| 52 // changes for the WebContents. | 53 // changes for the WebContents. |
| 53 class DefaultPresentationRequestObserver { | 54 class DefaultPresentationRequestObserver { |
| 54 public: | 55 public: |
| 55 virtual ~DefaultPresentationRequestObserver() = default; | 56 virtual ~DefaultPresentationRequestObserver() = default; |
| 56 | 57 |
| 57 // Called when default presentation request for the corresponding | 58 // Called when default presentation request for the corresponding |
| 58 // WebContents is set or changed. | 59 // WebContents is set or changed. |
| 59 // |default_presentation_info|: New default presentation request. | 60 // |default_presentation_info|: New default presentation request. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 70 // and attaches it to the specified WebContents. | 71 // and attaches it to the specified WebContents. |
| 71 static PresentationServiceDelegateImpl* GetOrCreateForWebContents( | 72 static PresentationServiceDelegateImpl* GetOrCreateForWebContents( |
| 72 content::WebContents* web_contents); | 73 content::WebContents* web_contents); |
| 73 | 74 |
| 74 ~PresentationServiceDelegateImpl() override; | 75 ~PresentationServiceDelegateImpl() override; |
| 75 | 76 |
| 76 // content::PresentationServiceDelegate implementation. | 77 // content::PresentationServiceDelegate implementation. |
| 77 void AddObserver( | 78 void AddObserver( |
| 78 int render_process_id, | 79 int render_process_id, |
| 79 int render_frame_id, | 80 int render_frame_id, |
| 80 content::PresentationServiceDelegate::Observer* observer) override; | 81 content::PresentationServiceDelegateBase::Observer* observer) override; |
| 81 void RemoveObserver(int render_process_id, int render_frame_id) override; | 82 void RemoveObserver(int render_process_id, int render_frame_id) override; |
| 82 bool AddScreenAvailabilityListener( | 83 bool AddScreenAvailabilityListener( |
| 83 int render_process_id, | 84 int render_process_id, |
| 84 int render_frame_id, | 85 int render_frame_id, |
| 85 content::PresentationScreenAvailabilityListener* listener) override; | 86 content::PresentationScreenAvailabilityListener* listener) override; |
| 86 void RemoveScreenAvailabilityListener( | 87 void RemoveScreenAvailabilityListener( |
| 87 int render_process_id, | 88 int render_process_id, |
| 88 int render_frame_id, | 89 int render_frame_id, |
| 89 content::PresentationScreenAvailabilityListener* listener) override; | 90 content::PresentationScreenAvailabilityListener* listener) override; |
| 90 void Reset(int render_process_id, int render_frame_id) override; | 91 void Reset(int render_process_id, int render_frame_id) override; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 121 int render_frame_id, | 122 int render_frame_id, |
| 122 const content::PresentationSessionInfo& session, | 123 const content::PresentationSessionInfo& session, |
| 123 std::unique_ptr<content::PresentationSessionMessage> message, | 124 std::unique_ptr<content::PresentationSessionMessage> message, |
| 124 const SendMessageCallback& send_message_cb) override; | 125 const SendMessageCallback& send_message_cb) override; |
| 125 void ListenForConnectionStateChange( | 126 void ListenForConnectionStateChange( |
| 126 int render_process_id, | 127 int render_process_id, |
| 127 int render_frame_id, | 128 int render_frame_id, |
| 128 const content::PresentationSessionInfo& connection, | 129 const content::PresentationSessionInfo& connection, |
| 129 const content::PresentationConnectionStateChangedCallback& | 130 const content::PresentationConnectionStateChangedCallback& |
| 130 state_changed_cb) override; | 131 state_changed_cb) override; |
| 132 void ConnectToOffscreenPresentation( |
| 133 int render_process_id, |
| 134 int render_frame_id, |
| 135 const content::PresentationSessionInfo& session, |
| 136 content::PresentationConnectionPtr connection) override; |
| 131 | 137 |
| 132 // Callback invoked when a default PresentationRequest is started from a | 138 // Callback invoked when a default PresentationRequest is started from a |
| 133 // browser-initiated dialog. | 139 // browser-initiated dialog. |
| 134 void OnRouteResponse(const PresentationRequest& request, | 140 void OnRouteResponse(const PresentationRequest& request, |
| 135 const RouteRequestResult& result); | 141 const RouteRequestResult& result); |
| 136 | 142 |
| 137 // Adds / removes an observer for listening to default PresentationRequest | 143 // Adds / removes an observer for listening to default PresentationRequest |
| 138 // changes. This class does not own |observer|. When |observer| is about to | 144 // changes. This class does not own |observer|. When |observer| is about to |
| 139 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. | 145 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. |
| 140 void AddDefaultPresentationRequestObserver( | 146 void AddDefaultPresentationRequestObserver( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 const content::PresentationSessionInfo& session, | 192 const content::PresentationSessionInfo& session, |
| 187 const content::PresentationSessionStartedCallback& success_cb, | 193 const content::PresentationSessionStartedCallback& success_cb, |
| 188 const content::PresentationSessionErrorCallback& error_cb, | 194 const content::PresentationSessionErrorCallback& error_cb, |
| 189 const RouteRequestResult& result); | 195 const RouteRequestResult& result); |
| 190 | 196 |
| 191 void OnStartSessionSucceeded( | 197 void OnStartSessionSucceeded( |
| 192 int render_process_id, | 198 int render_process_id, |
| 193 int render_frame_id, | 199 int render_frame_id, |
| 194 const content::PresentationSessionStartedCallback& success_cb, | 200 const content::PresentationSessionStartedCallback& success_cb, |
| 195 const content::PresentationSessionInfo& new_session, | 201 const content::PresentationSessionInfo& new_session, |
| 196 const MediaRoute::Id& route_id); | 202 const MediaRoute& route); |
| 197 | 203 |
| 198 // References to the WebContents that owns this instance, and associated | 204 // References to the WebContents that owns this instance, and associated |
| 199 // browser profile's MediaRouter instance. | 205 // browser profile's MediaRouter instance. |
| 200 content::WebContents* const web_contents_; | 206 content::WebContents* const web_contents_; |
| 201 MediaRouter* router_; | 207 MediaRouter* router_; |
| 202 | 208 |
| 203 std::unique_ptr<PresentationFrameManager> frame_manager_; | 209 std::unique_ptr<PresentationFrameManager> frame_manager_; |
| 204 | 210 |
| 205 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; | 211 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; |
| 206 | 212 |
| 207 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); | 213 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); |
| 208 }; | 214 }; |
| 209 | 215 |
| 210 } // namespace media_router | 216 } // namespace media_router |
| 211 | 217 |
| 212 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 218 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| OLD | NEW |