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. | 79 // content::PresentationServiceDelegate implementation. |
77 void AddObserver( | 80 void AddObserver( |
mark a. foltz
2016/11/15 23:41:46
You don't need to declare Add/RemoveObserver here
zhaobin
2016/11/16 18:02:41
Done.
| |
78 int render_process_id, | 81 int render_process_id, |
79 int render_frame_id, | 82 int render_frame_id, |
80 content::PresentationServiceDelegate::Observer* observer) override; | 83 content::PresentationServiceDelegateBase::Observer* observer) override; |
81 void RemoveObserver(int render_process_id, int render_frame_id) override; | 84 void RemoveObserver(int render_process_id, int render_frame_id) override; |
82 bool AddScreenAvailabilityListener( | 85 bool AddScreenAvailabilityListener( |
83 int render_process_id, | 86 int render_process_id, |
84 int render_frame_id, | 87 int render_frame_id, |
85 content::PresentationScreenAvailabilityListener* listener) override; | 88 content::PresentationScreenAvailabilityListener* listener) override; |
86 void RemoveScreenAvailabilityListener( | 89 void RemoveScreenAvailabilityListener( |
87 int render_process_id, | 90 int render_process_id, |
88 int render_frame_id, | 91 int render_frame_id, |
89 content::PresentationScreenAvailabilityListener* listener) override; | 92 content::PresentationScreenAvailabilityListener* listener) override; |
90 void Reset(int render_process_id, int render_frame_id) override; | 93 void Reset(int render_process_id, int render_frame_id) override; |
(...skipping 30 matching lines...) Expand all Loading... | |
121 int render_frame_id, | 124 int render_frame_id, |
122 const content::PresentationSessionInfo& session, | 125 const content::PresentationSessionInfo& session, |
123 std::unique_ptr<content::PresentationSessionMessage> message, | 126 std::unique_ptr<content::PresentationSessionMessage> message, |
124 const SendMessageCallback& send_message_cb) override; | 127 const SendMessageCallback& send_message_cb) override; |
125 void ListenForConnectionStateChange( | 128 void ListenForConnectionStateChange( |
126 int render_process_id, | 129 int render_process_id, |
127 int render_frame_id, | 130 int render_frame_id, |
128 const content::PresentationSessionInfo& connection, | 131 const content::PresentationSessionInfo& connection, |
129 const content::PresentationConnectionStateChangedCallback& | 132 const content::PresentationConnectionStateChangedCallback& |
130 state_changed_cb) override; | 133 state_changed_cb) override; |
134 void ConnectToOffscreenPresentation( | |
135 int render_process_id, | |
136 int render_frame_id, | |
137 const content::PresentationSessionInfo& session, | |
138 content::PresentationConnectionPtr connection) override; | |
131 | 139 |
132 // Callback invoked when a default PresentationRequest is started from a | 140 // Callback invoked when a default PresentationRequest is started from a |
133 // browser-initiated dialog. | 141 // browser-initiated dialog. |
134 void OnRouteResponse(const PresentationRequest& request, | 142 void OnRouteResponse(const PresentationRequest& request, |
135 const RouteRequestResult& result); | 143 const RouteRequestResult& result); |
136 | 144 |
137 // Adds / removes an observer for listening to default PresentationRequest | 145 // Adds / removes an observer for listening to default PresentationRequest |
138 // changes. This class does not own |observer|. When |observer| is about to | 146 // changes. This class does not own |observer|. When |observer| is about to |
139 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. | 147 // be destroyed, |RemoveDefaultPresentationRequestObserver| must be called. |
140 void AddDefaultPresentationRequestObserver( | 148 void AddDefaultPresentationRequestObserver( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 std::unique_ptr<PresentationFrameManager> frame_manager_; | 212 std::unique_ptr<PresentationFrameManager> frame_manager_; |
205 | 213 |
206 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; | 214 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; |
207 | 215 |
208 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); | 216 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); |
209 }; | 217 }; |
210 | 218 |
211 } // namespace media_router | 219 } // namespace media_router |
212 | 220 |
213 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 221 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
OLD | NEW |