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 <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "chrome/browser/media/router/media_router.h" | 17 #include "chrome/browser/media/router/media_router.h" |
18 #include "chrome/browser/media/router/media_source.h" | 18 #include "chrome/browser/media/router/media_source.h" |
| 19 #include "chrome/browser/media/router/render_frame_host_helper.h" |
19 #include "content/public/browser/presentation_service_delegate.h" | 20 #include "content/public/browser/presentation_service_delegate.h" |
20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/browser/web_contents_user_data.h" | 22 #include "content/public/browser/web_contents_user_data.h" |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 class RenderFrameHost; | 25 class RenderFrameHost; |
25 class PresentationScreenAvailabilityListener; | 26 class PresentationScreenAvailabilityListener; |
26 class WebContents; | 27 class WebContents; |
27 struct PresentationSessionInfo; | 28 struct PresentationSessionInfo; |
28 struct PresentationSessionMessage; | 29 struct PresentationSessionMessage; |
29 } // namespace content | 30 } // namespace content |
30 | 31 |
31 namespace media_router { | 32 namespace media_router { |
32 | 33 |
33 class MediaRoute; | 34 class MediaRoute; |
34 class MediaSinksObserver; | 35 class MediaSinksObserver; |
| 36 class OffscreenPresentationManager; |
35 class PresentationFrameManager; | 37 class PresentationFrameManager; |
36 class PresentationSessionStateObserver; | 38 class PresentationSessionStateObserver; |
37 | 39 |
38 // Implementation of PresentationServiceDelegate that interfaces an | 40 // Implementation of PresentationServiceDelegate that interfaces an |
39 // instance of WebContents with the Chrome Media Router. It uses the Media | 41 // instance of WebContents with the Chrome Media Router. It uses the Media |
40 // Router to handle presentation API calls forwarded from | 42 // Router to handle presentation API calls forwarded from |
41 // PresentationServiceImpl. In addition, it also | 43 // PresentationServiceImpl. In addition, it also |
42 // provides default presentation URL that is required for creating | 44 // provides default presentation URL that is required for creating |
43 // browser-initiated sessions. | 45 // browser-initiated sessions. |
44 // It is scoped to the lifetime of a WebContents, and is managed by the | 46 // It is scoped to the lifetime of a WebContents, and is managed by the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const PresentationSessionSuccessCallback& success_cb, | 88 const PresentationSessionSuccessCallback& success_cb, |
87 const PresentationSessionErrorCallback& error_cb) override; | 89 const PresentationSessionErrorCallback& error_cb) override; |
88 void CloseSession(int render_process_id, | 90 void CloseSession(int render_process_id, |
89 int render_frame_id, | 91 int render_frame_id, |
90 const std::string& presentation_id) override; | 92 const std::string& presentation_id) override; |
91 void ListenForSessionMessages( | 93 void ListenForSessionMessages( |
92 int render_process_id, | 94 int render_process_id, |
93 int render_frame_id, | 95 int render_frame_id, |
94 const content::PresentationSessionInfo& session, | 96 const content::PresentationSessionInfo& session, |
95 const content::PresentationSessionMessageCallback& message_cb) override; | 97 const content::PresentationSessionMessageCallback& message_cb) override; |
96 void SendMessage(int render_process_id, | 98 void SendMessage( |
97 int render_frame_id, | 99 int render_process_id, |
98 const content::PresentationSessionInfo& session, | 100 int render_frame_id, |
99 scoped_ptr<content::PresentationSessionMessage> message, | 101 const content::PresentationSessionInfo& session, |
100 const SendMessageCallback& send_message_cb) override; | 102 scoped_ptr<content::PresentationSessionMessage> message, |
| 103 const content::SendMessageCallback& send_message_cb) override; |
101 bool ListenForSessionStateChange( | 104 bool ListenForSessionStateChange( |
102 int render_process_id, | 105 int render_process_id, |
103 int render_frame_id, | 106 int render_frame_id, |
104 content::PresentationSessionStateListener* listener) override; | 107 content::PresentationSessionStateListener* listener) override; |
| 108 void GetPresentationReceiverSession( |
| 109 int render_process_id, |
| 110 int render_frame_id, |
| 111 const content::PresentationReceiverSessionAvailableCallback& |
| 112 success_callback, |
| 113 const base::Callback<void(const std::string&)>& error_callback) override; |
| 114 std::vector<content::PresentationSessionInfo> GetPresentationReceiverSessions( |
| 115 int render_process_id, |
| 116 int render_frame_id) override; |
105 | 117 |
106 // Callback invoked when there is a route response from CreateRoute/JoinRoute | 118 // Callback invoked when there is a route response from CreateRoute/JoinRoute |
107 // outside of a Presentation API request. This could be due to | 119 // outside of a Presentation API request. This could be due to |
108 // browser action (e.g., browser initiated media router dialog) or | 120 // browser action (e.g., browser initiated media router dialog) or |
109 // a media route provider (e.g., autojoin). | 121 // a media route provider (e.g., autojoin). |
110 void OnRouteResponse(const MediaRoute* route, | 122 void OnRouteResponse(const MediaRoute* route, |
111 const std::string& presentation_id, | 123 const std::string& presentation_id, |
112 const std::string& error); | 124 const std::string& error); |
113 | 125 |
114 // Returns the default MediaSource for this tab if there is one. | 126 // Returns the default MediaSource for this tab if there is one. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const PresentationSessionErrorCallback& error_cb, | 178 const PresentationSessionErrorCallback& error_cb, |
167 const MediaRoute* route, | 179 const MediaRoute* route, |
168 const std::string& presentation_id, | 180 const std::string& presentation_id, |
169 const std::string& error_text); | 181 const std::string& error_text); |
170 | 182 |
171 void OnStartSessionSucceeded( | 183 void OnStartSessionSucceeded( |
172 int render_process_id, | 184 int render_process_id, |
173 int render_frame_id, | 185 int render_frame_id, |
174 const PresentationSessionSuccessCallback& success_cb, | 186 const PresentationSessionSuccessCallback& success_cb, |
175 const content::PresentationSessionInfo& new_session, | 187 const content::PresentationSessionInfo& new_session, |
176 const MediaRoute::Id& route_id); | 188 const MediaRoute& route); |
177 | 189 |
178 // Returns |true| if the frame is the main frame of |web_contents_|. | 190 // Returns |true| if the frame is the main frame of |web_contents_|. |
179 bool IsMainFrame(int render_process_id, int render_frame_id) const; | 191 bool IsMainFrame(int render_process_id, int render_frame_id) const; |
180 | 192 |
181 // Updates tab-level default MediaSource and/or default frame URL. If either | 193 // Updates tab-level default MediaSource and/or default frame URL. If either |
182 // changed, notify the observers. | 194 // changed, notify the observers. |
183 void UpdateDefaultMediaSourceAndNotifyObservers( | 195 void UpdateDefaultMediaSourceAndNotifyObservers( |
184 const MediaSource& new_default_source, | 196 const MediaSource& new_default_source, |
185 const GURL& new_default_frame_url); | 197 const GURL& new_default_frame_url); |
186 | 198 |
| 199 void RegisterOffscreenPresentationController( |
| 200 const content::PresentationSessionInfo& session, |
| 201 const RenderFrameHostId& controller_frame_id); |
| 202 |
187 // Default MediaSource for the tab associated with this instance. | 203 // Default MediaSource for the tab associated with this instance. |
188 MediaSource default_source_; | 204 MediaSource default_source_; |
189 // URL of the frame that contains the default MediaSource. | 205 // URL of the frame that contains the default MediaSource. |
190 GURL default_frame_url_; | 206 GURL default_frame_url_; |
191 | 207 |
192 // References to the observers listening for changes to default media source. | 208 // References to the observers listening for changes to default media source. |
193 base::ObserverList< | 209 base::ObserverList< |
194 DefaultMediaSourceObserver> default_media_source_observers_; | 210 DefaultMediaSourceObserver> default_media_source_observers_; |
195 | 211 |
196 // References to the WebContents that owns this instance, and associated | 212 // References to the WebContents that owns this instance, and associated |
197 // browser profile's MediaRouter instance. | 213 // browser profile's MediaRouter/OffscreenPresentationManager instances. |
198 content::WebContents* web_contents_; | 214 content::WebContents* const web_contents_; |
199 MediaRouter* router_; | 215 MediaRouter* router_; |
| 216 OffscreenPresentationManager* const offscreen_presentation_manager_; |
200 | 217 |
201 scoped_ptr<PresentationFrameManager> frame_manager_; | 218 scoped_ptr<PresentationFrameManager> frame_manager_; |
202 | 219 |
203 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; | 220 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; |
204 | 221 |
205 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); | 222 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); |
206 }; | 223 }; |
207 | 224 |
208 } // namespace media_router | 225 } // namespace media_router |
209 | 226 |
210 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ | 227 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
OLD | NEW |