| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "chrome/browser/media/router/media_router.h" | 18 #include "chrome/browser/media/router/media_router.h" |
| 19 #include "chrome/browser/media/router/media_source.h" | 19 #include "chrome/browser/media/router/media_source.h" |
| 20 #include "chrome/browser/media/router/presentation_request.h" | 20 #include "chrome/browser/media/router/presentation_request.h" |
| 21 #include "chrome/browser/media/router/presentation_service_delegate_observers.h" |
| 21 #include "chrome/browser/media/router/render_frame_host_id.h" | 22 #include "chrome/browser/media/router/render_frame_host_id.h" |
| 22 #include "content/public/browser/presentation_service_delegate.h" | 23 #include "content/public/browser/presentation_service_delegate.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "content/public/browser/web_contents_user_data.h" | 25 #include "content/public/browser/web_contents_user_data.h" |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 class PresentationScreenAvailabilityListener; | 28 class PresentationScreenAvailabilityListener; |
| 28 class WebContents; | 29 class WebContents; |
| 29 struct PresentationSessionInfo; | 30 struct PresentationSessionInfo; |
| 30 struct PresentationConnectionMessage; | 31 struct PresentationConnectionMessage; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 class RouteRequestResult; | 42 class RouteRequestResult; |
| 42 | 43 |
| 43 // Implementation of PresentationServiceDelegate that interfaces an instance of | 44 // Implementation of PresentationServiceDelegate that interfaces an instance of |
| 44 // WebContents with the Chrome Media Router. It uses the Media Router to handle | 45 // WebContents with the Chrome Media Router. It uses the Media Router to handle |
| 45 // presentation API calls forwarded from PresentationServiceImpl. In addition, | 46 // presentation API calls forwarded from PresentationServiceImpl. In addition, |
| 46 // it also provides default presentation URL that is required for creating | 47 // it also provides default presentation URL that is required for creating |
| 47 // browser-initiated sessions. It is scoped to the lifetime of a WebContents, | 48 // browser-initiated sessions. It is scoped to the lifetime of a WebContents, |
| 48 // and is managed by the associated WebContents. | 49 // and is managed by the associated WebContents. |
| 49 class PresentationServiceDelegateImpl | 50 class PresentationServiceDelegateImpl |
| 50 : public content::WebContentsUserData<PresentationServiceDelegateImpl>, | 51 : public content::WebContentsUserData<PresentationServiceDelegateImpl>, |
| 51 public content::PresentationServiceDelegate { | 52 public content::ControllerPresentationServiceDelegate { |
| 52 public: | 53 public: |
| 53 // Observer interface for listening to default presentation request | 54 // Observer interface for listening to default presentation request |
| 54 // changes for the WebContents. | 55 // changes for the WebContents. |
| 55 class DefaultPresentationRequestObserver { | 56 class DefaultPresentationRequestObserver { |
| 56 public: | 57 public: |
| 57 virtual ~DefaultPresentationRequestObserver() = default; | 58 virtual ~DefaultPresentationRequestObserver() = default; |
| 58 | 59 |
| 59 // Called when default presentation request for the corresponding | 60 // Called when default presentation request for the corresponding |
| 60 // WebContents is set or changed. | 61 // WebContents is set or changed. |
| 61 // |default_presentation_info|: New default presentation request. | 62 // |default_presentation_info|: New default presentation request. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 int render_frame_id, | 126 int render_frame_id, |
| 126 const content::PresentationSessionInfo& session, | 127 const content::PresentationSessionInfo& session, |
| 127 std::unique_ptr<content::PresentationConnectionMessage> message, | 128 std::unique_ptr<content::PresentationConnectionMessage> message, |
| 128 const SendMessageCallback& send_message_cb) override; | 129 const SendMessageCallback& send_message_cb) override; |
| 129 void ListenForConnectionStateChange( | 130 void ListenForConnectionStateChange( |
| 130 int render_process_id, | 131 int render_process_id, |
| 131 int render_frame_id, | 132 int render_frame_id, |
| 132 const content::PresentationSessionInfo& connection, | 133 const content::PresentationSessionInfo& connection, |
| 133 const content::PresentationConnectionStateChangedCallback& | 134 const content::PresentationConnectionStateChangedCallback& |
| 134 state_changed_cb) override; | 135 state_changed_cb) override; |
| 136 void ConnectToOffscreenPresentation( |
| 137 int render_process_id, |
| 138 int render_frame_id, |
| 139 const content::PresentationSessionInfo& session, |
| 140 content::PresentationConnectionPtr controller_conn_ptr, |
| 141 content::PresentationConnectionRequest receiver_conn_request) override; |
| 135 | 142 |
| 136 // Callback invoked when a default PresentationRequest is started from a | 143 // Callback invoked when a default PresentationRequest is started from a |
| 137 // browser-initiated dialog. | 144 // browser-initiated dialog. |
| 138 void OnRouteResponse(const PresentationRequest& request, | 145 void OnRouteResponse(const PresentationRequest& request, |
| 139 const RouteRequestResult& result); | 146 const RouteRequestResult& result); |
| 140 | 147 |
| 141 // Adds / removes an observer for listening to default PresentationRequest | 148 // Adds / removes an observer for listening to default PresentationRequest |
| 142 // changes. This class does not own |observer|. When |observer| is about to | 149 // changes. This class does not own |observer|. When |observer| is about to |
| 143 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. | 150 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. |
| 144 void AddDefaultPresentationRequestObserver( | 151 void AddDefaultPresentationRequestObserver( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // Returns true if auto-join requests should be cancelled for |origin|. | 211 // Returns true if auto-join requests should be cancelled for |origin|. |
| 205 bool ShouldCancelAutoJoinForOrigin(const url::Origin& origin) const; | 212 bool ShouldCancelAutoJoinForOrigin(const url::Origin& origin) const; |
| 206 #endif | 213 #endif |
| 207 | 214 |
| 208 // References to the WebContents that owns this instance, and associated | 215 // References to the WebContents that owns this instance, and associated |
| 209 // browser profile's MediaRouter instance. | 216 // browser profile's MediaRouter instance. |
| 210 content::WebContents* const web_contents_; | 217 content::WebContents* const web_contents_; |
| 211 MediaRouter* router_; | 218 MediaRouter* router_; |
| 212 | 219 |
| 213 std::unique_ptr<PresentationFrameManager> frame_manager_; | 220 std::unique_ptr<PresentationFrameManager> frame_manager_; |
| 221 PresentationServiceDelegateObservers observers_; |
| 214 | 222 |
| 215 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; | 223 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; |
| 216 | 224 |
| 217 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); | 225 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); |
| 218 }; | 226 }; |
| 219 | 227 |
| 220 } // namespace media_router | 228 } // namespace media_router |
| 221 | 229 |
| 222 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 230 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| OLD | NEW |