| 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_base_impl.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 RenderFrameHost; | 28 class RenderFrameHost; |
| 28 class PresentationScreenAvailabilityListener; | 29 class PresentationScreenAvailabilityListener; |
| 29 class WebContents; | 30 class WebContents; |
| 30 struct PresentationSessionInfo; | 31 struct PresentationSessionInfo; |
| 31 struct PresentationSessionMessage; | 32 struct PresentationSessionMessage; |
| 32 } // namespace content | 33 } // namespace content |
| 33 | 34 |
| 34 namespace media_router { | 35 namespace media_router { |
| 35 | 36 |
| 36 class MediaRoute; | 37 class MediaRoute; |
| 37 class MediaSinksObserver; | 38 class MediaSinksObserver; |
| 39 class OffscreenPresentationManager; |
| 38 class PresentationFrameManager; | 40 class PresentationFrameManager; |
| 39 class RouteRequestResult; | 41 class RouteRequestResult; |
| 40 | 42 |
| 41 // Implementation of PresentationServiceDelegate that interfaces an instance of | 43 // Implementation of PresentationServiceDelegate that interfaces an instance of |
| 42 // WebContents with the Chrome Media Router. It uses the Media Router to handle | 44 // WebContents with the Chrome Media Router. It uses the Media Router to handle |
| 43 // presentation API calls forwarded from PresentationServiceImpl. In addition, | 45 // presentation API calls forwarded from PresentationServiceImpl. In addition, |
| 44 // it also provides default presentation URL that is required for creating | 46 // it also provides default presentation URL that is required for creating |
| 45 // browser-initiated sessions. It is scoped to the lifetime of a WebContents, | 47 // browser-initiated sessions. It is scoped to the lifetime of a WebContents, |
| 46 // and is managed by the associated WebContents. | 48 // and is managed by the associated WebContents. |
| 47 class PresentationServiceDelegateImpl | 49 class PresentationServiceDelegateImpl |
| 48 : public content::WebContentsUserData<PresentationServiceDelegateImpl>, | 50 : public content::WebContentsUserData<PresentationServiceDelegateImpl>, |
| 49 public content::PresentationServiceDelegate { | 51 public content::ControllerPresentationServiceDelegate, |
| 52 public PresentationServiceDelegateBaseImpl { |
| 50 public: | 53 public: |
| 51 // Observer interface for listening to default presentation request | 54 // Observer interface for listening to default presentation request |
| 52 // changes for the WebContents. | 55 // changes for the WebContents. |
| 53 class DefaultPresentationRequestObserver { | 56 class DefaultPresentationRequestObserver { |
| 54 public: | 57 public: |
| 55 virtual ~DefaultPresentationRequestObserver() = default; | 58 virtual ~DefaultPresentationRequestObserver() = default; |
| 56 | 59 |
| 57 // Called when default presentation request for the corresponding | 60 // Called when default presentation request for the corresponding |
| 58 // WebContents is set or changed. | 61 // WebContents is set or changed. |
| 59 // |default_presentation_info|: New default presentation request. | 62 // |default_presentation_info|: New default presentation request. |
| 60 virtual void OnDefaultPresentationChanged( | 63 virtual void OnDefaultPresentationChanged( |
| 61 const PresentationRequest& default_presentation_request) = 0; | 64 const PresentationRequest& default_presentation_request) = 0; |
| 62 | 65 |
| 63 // Called when default presentation request for the corresponding | 66 // Called when default presentation request for the corresponding |
| 64 // WebContents has been removed. | 67 // WebContents has been removed. |
| 65 virtual void OnDefaultPresentationRemoved() = 0; | 68 virtual void OnDefaultPresentationRemoved() = 0; |
| 66 }; | 69 }; |
| 67 | 70 |
| 68 // Retrieves the instance of PresentationServiceDelegateImpl that was attached | 71 // Retrieves the instance of PresentationServiceDelegateImpl that was attached |
| 69 // to the specified WebContents. If no instance was attached, creates one, | 72 // to the specified WebContents. If no instance was attached, creates one, |
| 70 // and attaches it to the specified WebContents. | 73 // and attaches it to the specified WebContents. |
| 71 static PresentationServiceDelegateImpl* GetOrCreateForWebContents( | 74 static PresentationServiceDelegateImpl* GetOrCreateForWebContents( |
| 72 content::WebContents* web_contents); | 75 content::WebContents* web_contents); |
| 73 | 76 |
| 74 ~PresentationServiceDelegateImpl() override; | 77 ~PresentationServiceDelegateImpl() override; |
| 75 | 78 |
| 76 // content::PresentationServiceDelegate implementation. | |
| 77 void AddObserver( | |
| 78 int render_process_id, | |
| 79 int render_frame_id, | |
| 80 content::PresentationServiceDelegate::Observer* observer) override; | |
| 81 void RemoveObserver(int render_process_id, int render_frame_id) override; | |
| 82 bool AddScreenAvailabilityListener( | 79 bool AddScreenAvailabilityListener( |
| 83 int render_process_id, | 80 int render_process_id, |
| 84 int render_frame_id, | 81 int render_frame_id, |
| 85 content::PresentationScreenAvailabilityListener* listener) override; | 82 content::PresentationScreenAvailabilityListener* listener) override; |
| 86 void RemoveScreenAvailabilityListener( | 83 void RemoveScreenAvailabilityListener( |
| 87 int render_process_id, | 84 int render_process_id, |
| 88 int render_frame_id, | 85 int render_frame_id, |
| 89 content::PresentationScreenAvailabilityListener* listener) override; | 86 content::PresentationScreenAvailabilityListener* listener) override; |
| 90 void Reset(int render_process_id, int render_frame_id) override; | 87 void Reset(int render_process_id, int render_frame_id) override; |
| 91 void SetDefaultPresentationUrls( | 88 void SetDefaultPresentationUrls( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 121 int render_frame_id, | 118 int render_frame_id, |
| 122 const content::PresentationSessionInfo& session, | 119 const content::PresentationSessionInfo& session, |
| 123 std::unique_ptr<content::PresentationSessionMessage> message, | 120 std::unique_ptr<content::PresentationSessionMessage> message, |
| 124 const SendMessageCallback& send_message_cb) override; | 121 const SendMessageCallback& send_message_cb) override; |
| 125 void ListenForConnectionStateChange( | 122 void ListenForConnectionStateChange( |
| 126 int render_process_id, | 123 int render_process_id, |
| 127 int render_frame_id, | 124 int render_frame_id, |
| 128 const content::PresentationSessionInfo& connection, | 125 const content::PresentationSessionInfo& connection, |
| 129 const content::PresentationConnectionStateChangedCallback& | 126 const content::PresentationConnectionStateChangedCallback& |
| 130 state_changed_cb) override; | 127 state_changed_cb) override; |
| 128 void ConnectToOffscreenPresentation( |
| 129 int render_process_id, |
| 130 int render_frame_id, |
| 131 const content::PresentationSessionInfo& session, |
| 132 content::PresentationConnectionPtr connection) override; |
| 131 | 133 |
| 132 // Callback invoked when a default PresentationRequest is started from a | 134 // Callback invoked when a default PresentationRequest is started from a |
| 133 // browser-initiated dialog. | 135 // browser-initiated dialog. |
| 134 void OnRouteResponse(const PresentationRequest& request, | 136 void OnRouteResponse(const PresentationRequest& request, |
| 135 const RouteRequestResult& result); | 137 const RouteRequestResult& result); |
| 136 | 138 |
| 137 // Adds / removes an observer for listening to default PresentationRequest | 139 // Adds / removes an observer for listening to default PresentationRequest |
| 138 // changes. This class does not own |observer|. When |observer| is about to | 140 // changes. This class does not own |observer|. When |observer| is about to |
| 139 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. | 141 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. |
| 140 void AddDefaultPresentationRequestObserver( | 142 void AddDefaultPresentationRequestObserver( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 std::unique_ptr<PresentationFrameManager> frame_manager_; | 206 std::unique_ptr<PresentationFrameManager> frame_manager_; |
| 205 | 207 |
| 206 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; | 208 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; |
| 207 | 209 |
| 208 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); | 210 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); |
| 209 }; | 211 }; |
| 210 | 212 |
| 211 } // namespace media_router | 213 } // namespace media_router |
| 212 | 214 |
| 213 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 215 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| OLD | NEW |