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 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" | 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/containers/small_map.h" | 12 #include "base/containers/small_map.h" |
13 #include "base/guid.h" | 13 #include "base/guid.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "chrome/browser/media/router/browser_presentation_connection_proxy.h" | |
16 #include "chrome/browser/media/router/create_presentation_connection_request.h" | 17 #include "chrome/browser/media/router/create_presentation_connection_request.h" |
17 #include "chrome/browser/media/router/media_route.h" | 18 #include "chrome/browser/media/router/media_route.h" |
18 #include "chrome/browser/media/router/media_router.h" | 19 #include "chrome/browser/media/router/media_router.h" |
19 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 20 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
20 #include "chrome/browser/media/router/media_router_factory.h" | 21 #include "chrome/browser/media/router/media_router_factory.h" |
21 #include "chrome/browser/media/router/media_sink.h" | 22 #include "chrome/browser/media/router/media_sink.h" |
22 #include "chrome/browser/media/router/media_source_helper.h" | 23 #include "chrome/browser/media/router/media_source_helper.h" |
23 #include "chrome/browser/media/router/offscreen_presentation_manager.h" | 24 #include "chrome/browser/media/router/offscreen_presentation_manager.h" |
24 #include "chrome/browser/media/router/offscreen_presentation_manager_factory.h" | 25 #include "chrome/browser/media/router/offscreen_presentation_manager_factory.h" |
25 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" | 26 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 | 158 |
158 void OnPresentationSessionStarted( | 159 void OnPresentationSessionStarted( |
159 const content::PresentationSessionInfo& session, | 160 const content::PresentationSessionInfo& session, |
160 const MediaRoute& route); | 161 const MediaRoute& route); |
161 void OnPresentationServiceDelegateDestroyed() const; | 162 void OnPresentationServiceDelegateDestroyed() const; |
162 | 163 |
163 void set_delegate_observer(DelegateObserver* observer) { | 164 void set_delegate_observer(DelegateObserver* observer) { |
164 delegate_observer_ = observer; | 165 delegate_observer_ = observer; |
165 } | 166 } |
166 | 167 |
168 bool IsOffscreenPresentation(const std::string& presentation_id); | |
169 void OnBrowserConnectionAvailable( | |
170 const content::PresentationSessionInfo& session, | |
171 content::PresentationConnectionPtr source_conn, | |
mark a. foltz
2017/01/23 22:29:34
source_connection
zhaobin
2017/01/24 19:28:46
Done.
| |
172 content::PresentationConnectionRequest target_conn_request); | |
mark a. foltz
2017/01/23 22:29:34
target_connection_request
zhaobin
2017/01/24 19:28:46
Done.
| |
173 | |
167 private: | 174 private: |
168 MediaSource GetMediaSourceFromListener( | 175 MediaSource GetMediaSourceFromListener( |
169 content::PresentationScreenAvailabilityListener* listener) const; | 176 content::PresentationScreenAvailabilityListener* listener) const; |
170 base::SmallMap<std::map<std::string, MediaRoute::Id>> | 177 base::SmallMap<std::map<std::string, MediaRoute>> presentation_id_to_route_; |
171 presentation_id_to_route_id_; | |
172 base::SmallMap< | 178 base::SmallMap< |
173 std::map<std::string, std::unique_ptr<PresentationMediaSinksObserver>>> | 179 std::map<std::string, std::unique_ptr<PresentationMediaSinksObserver>>> |
174 url_to_sinks_observer_; | 180 url_to_sinks_observer_; |
175 std::unordered_map< | 181 std::unordered_map< |
176 MediaRoute::Id, | 182 MediaRoute::Id, |
177 std::unique_ptr<PresentationConnectionStateSubscription>> | 183 std::unique_ptr<PresentationConnectionStateSubscription>> |
178 connection_state_subscriptions_; | 184 connection_state_subscriptions_; |
179 std::unordered_map< | 185 std::unordered_map< |
180 MediaRoute::Id, | 186 MediaRoute::Id, |
181 std::unique_ptr<PresentationSessionMessagesObserver>> | 187 std::unique_ptr<PresentationSessionMessagesObserver>> |
182 session_messages_observers_; | 188 session_messages_observers_; |
189 std::set<std::unique_ptr<BrowserPresentationConnectionProxy>> | |
190 browser_connection_proxies_; | |
183 | 191 |
184 RenderFrameHostId render_frame_host_id_; | 192 RenderFrameHostId render_frame_host_id_; |
185 | 193 |
186 // References to the owning WebContents, and the corresponding MediaRouter. | 194 // References to the owning WebContents, and the corresponding MediaRouter. |
187 content::WebContents* web_contents_; | 195 content::WebContents* web_contents_; |
188 MediaRouter* router_; | 196 MediaRouter* router_; |
189 | 197 |
190 DelegateObserver* delegate_observer_; | 198 DelegateObserver* delegate_observer_; |
191 }; | 199 }; |
192 | 200 |
193 PresentationFrame::PresentationFrame( | 201 PresentationFrame::PresentationFrame( |
194 const RenderFrameHostId& render_frame_host_id, | 202 const RenderFrameHostId& render_frame_host_id, |
195 content::WebContents* web_contents, | 203 content::WebContents* web_contents, |
196 MediaRouter* router) | 204 MediaRouter* router) |
197 : render_frame_host_id_(render_frame_host_id), | 205 : render_frame_host_id_(render_frame_host_id), |
198 web_contents_(web_contents), | 206 web_contents_(web_contents), |
199 router_(router) { | 207 router_(router) { |
200 DCHECK(web_contents_); | 208 DCHECK(web_contents_); |
201 DCHECK(router_); | 209 DCHECK(router_); |
202 } | 210 } |
203 | 211 |
204 PresentationFrame::~PresentationFrame() { | 212 PresentationFrame::~PresentationFrame() { |
205 } | 213 } |
206 | 214 |
207 void PresentationFrame::OnPresentationSessionStarted( | 215 void PresentationFrame::OnPresentationSessionStarted( |
208 const content::PresentationSessionInfo& session, | 216 const content::PresentationSessionInfo& session, |
209 const MediaRoute& route) { | 217 const MediaRoute& route) { |
210 presentation_id_to_route_id_[session.presentation_id] = | 218 presentation_id_to_route_.insert( |
211 route.media_route_id(); | 219 std::make_pair(session.presentation_id, route)); |
212 } | 220 } |
213 | 221 |
214 const MediaRoute::Id PresentationFrame::GetRouteId( | 222 const MediaRoute::Id PresentationFrame::GetRouteId( |
215 const std::string& presentation_id) const { | 223 const std::string& presentation_id) const { |
216 auto it = presentation_id_to_route_id_.find(presentation_id); | 224 auto it = presentation_id_to_route_.find(presentation_id); |
217 return it != presentation_id_to_route_id_.end() ? it->second : ""; | 225 return it != presentation_id_to_route_.end() ? it->second.media_route_id() |
226 : ""; | |
218 } | 227 } |
219 | 228 |
220 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const { | 229 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const { |
221 std::vector<MediaRoute::Id> route_ids; | 230 std::vector<MediaRoute::Id> route_ids; |
222 for (const auto& e : presentation_id_to_route_id_) | 231 for (const auto& e : presentation_id_to_route_) |
223 route_ids.push_back(e.second); | 232 route_ids.push_back(e.second.media_route_id()); |
224 return route_ids; | 233 return route_ids; |
225 } | 234 } |
226 | 235 |
227 bool PresentationFrame::SetScreenAvailabilityListener( | 236 bool PresentationFrame::SetScreenAvailabilityListener( |
228 content::PresentationScreenAvailabilityListener* listener) { | 237 content::PresentationScreenAvailabilityListener* listener) { |
229 MediaSource source(GetMediaSourceFromListener(listener)); | 238 MediaSource source(GetMediaSourceFromListener(listener)); |
230 auto& sinks_observer = url_to_sinks_observer_[source.id()]; | 239 auto& sinks_observer = url_to_sinks_observer_[source.id()]; |
231 if (sinks_observer && sinks_observer->listener() == listener) | 240 if (sinks_observer && sinks_observer->listener() == listener) |
232 return false; | 241 return false; |
233 | 242 |
(...skipping 21 matching lines...) Expand all Loading... | |
255 } | 264 } |
256 return false; | 265 return false; |
257 } | 266 } |
258 | 267 |
259 bool PresentationFrame::HasScreenAvailabilityListenerForTest( | 268 bool PresentationFrame::HasScreenAvailabilityListenerForTest( |
260 const MediaSource::Id& source_id) const { | 269 const MediaSource::Id& source_id) const { |
261 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end(); | 270 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end(); |
262 } | 271 } |
263 | 272 |
264 void PresentationFrame::Reset() { | 273 void PresentationFrame::Reset() { |
265 for (const auto& pid_route_id : presentation_id_to_route_id_) | 274 auto offscreen_presentation_manager = |
266 router_->DetachRoute(pid_route_id.second); | 275 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( |
276 web_contents_); | |
267 | 277 |
268 presentation_id_to_route_id_.clear(); | 278 for (const auto& pid_route : presentation_id_to_route_) { |
279 offscreen_presentation_manager->UnregisterOffscreenPresentationController( | |
280 pid_route.first, render_frame_host_id_); | |
281 router_->DetachRoute(pid_route.second.media_route_id()); | |
282 } | |
283 | |
284 presentation_id_to_route_.clear(); | |
269 url_to_sinks_observer_.clear(); | 285 url_to_sinks_observer_.clear(); |
270 connection_state_subscriptions_.clear(); | 286 connection_state_subscriptions_.clear(); |
271 session_messages_observers_.clear(); | 287 session_messages_observers_.clear(); |
272 } | 288 } |
273 | 289 |
274 void PresentationFrame::RemoveConnection(const std::string& presentation_id, | 290 void PresentationFrame::RemoveConnection(const std::string& presentation_id, |
275 const MediaRoute::Id& route_id) { | 291 const MediaRoute::Id& route_id) { |
276 // Remove the presentation id mapping so a later call to Reset is a no-op. | 292 // Remove the presentation id mapping so a later call to Reset is a no-op. |
277 presentation_id_to_route_id_.erase(presentation_id); | 293 presentation_id_to_route_.erase(presentation_id); |
278 | 294 |
279 // We no longer need to observe route messages. | 295 // We no longer need to observe route messages. |
280 session_messages_observers_.erase(route_id); | 296 session_messages_observers_.erase(route_id); |
281 | 297 |
282 // We keep the PresentationConnectionStateChangedCallback registered with MR | 298 // We keep the PresentationConnectionStateChangedCallback registered with MR |
283 // so the MRP can tell us when terminate() completed. | 299 // so the MRP can tell us when terminate() completed. |
284 } | 300 } |
285 | 301 |
286 void PresentationFrame::ListenForConnectionStateChange( | 302 void PresentationFrame::ListenForConnectionStateChange( |
287 const content::PresentationSessionInfo& connection, | 303 const content::PresentationSessionInfo& connection, |
288 const content::PresentationConnectionStateChangedCallback& | 304 const content::PresentationConnectionStateChangedCallback& |
289 state_changed_cb) { | 305 state_changed_cb) { |
290 auto it = presentation_id_to_route_id_.find(connection.presentation_id); | 306 auto it = presentation_id_to_route_.find(connection.presentation_id); |
291 if (it == presentation_id_to_route_id_.end()) { | 307 if (it == presentation_id_to_route_.end()) { |
292 DLOG(ERROR) << __func__ << "route id not found for presentation: " | 308 DLOG(ERROR) << __func__ << "route id not found for presentation: " |
293 << connection.presentation_id; | 309 << connection.presentation_id; |
294 return; | 310 return; |
295 } | 311 } |
296 | 312 |
297 const MediaRoute::Id& route_id = it->second; | 313 const MediaRoute::Id& route_id = it->second.media_route_id(); |
298 if (connection_state_subscriptions_.find(route_id) != | 314 if (connection_state_subscriptions_.find(route_id) != |
299 connection_state_subscriptions_.end()) { | 315 connection_state_subscriptions_.end()) { |
300 DLOG(ERROR) << __func__ | 316 DLOG(ERROR) << __func__ |
301 << "Already listening connection state change for route: " | 317 << "Already listening connection state change for route: " |
302 << route_id; | 318 << route_id; |
303 return; | 319 return; |
304 } | 320 } |
305 | 321 |
306 connection_state_subscriptions_.insert(std::make_pair( | 322 connection_state_subscriptions_.insert(std::make_pair( |
307 route_id, router_->AddPresentationConnectionStateChangedCallback( | 323 route_id, router_->AddPresentationConnectionStateChangedCallback( |
308 it->second, state_changed_cb))); | 324 route_id, state_changed_cb))); |
309 } | 325 } |
310 | 326 |
311 void PresentationFrame::ListenForSessionMessages( | 327 void PresentationFrame::ListenForSessionMessages( |
312 const content::PresentationSessionInfo& session, | 328 const content::PresentationSessionInfo& session, |
313 const content::PresentationConnectionMessageCallback& message_cb) { | 329 const content::PresentationConnectionMessageCallback& message_cb) { |
314 auto it = presentation_id_to_route_id_.find(session.presentation_id); | 330 auto it = presentation_id_to_route_.find(session.presentation_id); |
315 if (it == presentation_id_to_route_id_.end()) { | 331 if (it == presentation_id_to_route_.end()) { |
316 DVLOG(2) << "ListenForSessionMessages: no route for " | 332 DVLOG(2) << "ListenForSessionMessages: no route for " |
317 << session.presentation_id; | 333 << session.presentation_id; |
318 return; | 334 return; |
319 } | 335 } |
320 | 336 |
321 const MediaRoute::Id& route_id = it->second; | 337 if (it->second.is_offscreen_presentation()) { |
338 DVLOG(2) << "ListenForSessionMessages: do not listen for offscreen " | |
339 << "presentation [id]: " << session.presentation_id; | |
340 return; | |
341 } | |
342 | |
343 const MediaRoute::Id& route_id = it->second.media_route_id(); | |
322 if (session_messages_observers_.find(route_id) != | 344 if (session_messages_observers_.find(route_id) != |
323 session_messages_observers_.end()) { | 345 session_messages_observers_.end()) { |
324 DLOG(ERROR) << __func__ | 346 DLOG(ERROR) << __func__ |
325 << "Already listening for session messages for route: " | 347 << "Already listening for session messages for route: " |
326 << route_id; | 348 << route_id; |
327 return; | 349 return; |
328 } | 350 } |
329 | 351 |
330 session_messages_observers_.insert(std::make_pair( | 352 session_messages_observers_.insert(std::make_pair( |
331 route_id, base::MakeUnique<PresentationSessionMessagesObserver>( | 353 route_id, base::MakeUnique<PresentationSessionMessagesObserver>( |
332 router_, it->second, message_cb))); | 354 router_, route_id, message_cb))); |
333 } | 355 } |
334 | 356 |
335 MediaSource PresentationFrame::GetMediaSourceFromListener( | 357 MediaSource PresentationFrame::GetMediaSourceFromListener( |
336 content::PresentationScreenAvailabilityListener* listener) const { | 358 content::PresentationScreenAvailabilityListener* listener) const { |
337 // If the default presentation URL is empty then fall back to tab mirroring. | 359 // If the default presentation URL is empty then fall back to tab mirroring. |
338 return listener->GetAvailabilityUrl().is_empty() | 360 return listener->GetAvailabilityUrl().is_empty() |
339 ? MediaSourceForTab(SessionTabHelper::IdForTab(web_contents_)) | 361 ? MediaSourceForTab(SessionTabHelper::IdForTab(web_contents_)) |
340 : MediaSourceForPresentationUrl(listener->GetAvailabilityUrl()); | 362 : MediaSourceForPresentationUrl(listener->GetAvailabilityUrl()); |
341 } | 363 } |
342 | 364 |
365 bool PresentationFrame::IsOffscreenPresentation( | |
366 const std::string& presentation_id) { | |
367 DCHECK(base::ContainsKey(presentation_id_to_route_, presentation_id)); | |
368 auto it = presentation_id_to_route_.find(presentation_id); | |
369 return it->second.is_offscreen_presentation(); | |
370 } | |
371 | |
372 void PresentationFrame::OnBrowserConnectionAvailable( | |
373 const content::PresentationSessionInfo& session, | |
374 content::PresentationConnectionPtr source_conn, | |
375 content::PresentationConnectionRequest target_conn_request) { | |
376 DCHECK(source_conn); | |
377 DCHECK(base::ContainsKey(presentation_id_to_route_, session.presentation_id)); | |
378 auto it = presentation_id_to_route_.find(session.presentation_id); | |
379 | |
380 std::unique_ptr<BrowserPresentationConnectionProxy> proxy = | |
381 base::MakeUnique<BrowserPresentationConnectionProxy>(session, router_, | |
382 &it->second); | |
383 | |
384 proxy->Bind(std::move(target_conn_request)); | |
385 proxy->SetTargetConnection(std::move(source_conn)); | |
386 | |
387 browser_connection_proxies_.insert(std::move(proxy)); | |
mark a. foltz
2017/01/23 22:29:34
Where are entries removed from browser_connection_
zhaobin
2017/01/24 19:28:46
Should be removed in PresentationFrame::RemoveConn
| |
388 } | |
389 | |
343 // Used by PresentationServiceDelegateImpl to manage PresentationFrames. | 390 // Used by PresentationServiceDelegateImpl to manage PresentationFrames. |
344 class PresentationFrameManager { | 391 class PresentationFrameManager { |
345 public: | 392 public: |
346 PresentationFrameManager(content::WebContents* web_contents, | 393 PresentationFrameManager(content::WebContents* web_contents, |
347 MediaRouter* router); | 394 MediaRouter* router); |
348 ~PresentationFrameManager(); | 395 ~PresentationFrameManager(); |
349 | 396 |
350 // Mirror corresponding APIs in PresentationServiceDelegateImpl. | 397 // Mirror corresponding APIs in PresentationServiceDelegateImpl. |
351 bool SetScreenAvailabilityListener( | 398 bool SetScreenAvailabilityListener( |
352 const RenderFrameHostId& render_frame_host_id, | 399 const RenderFrameHostId& render_frame_host_id, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 | 438 |
392 void OnPresentationSessionStarted( | 439 void OnPresentationSessionStarted( |
393 const RenderFrameHostId& render_frame_host_id, | 440 const RenderFrameHostId& render_frame_host_id, |
394 const content::PresentationSessionInfo& session, | 441 const content::PresentationSessionInfo& session, |
395 const MediaRoute& route); | 442 const MediaRoute& route); |
396 void OnDefaultPresentationSessionStarted( | 443 void OnDefaultPresentationSessionStarted( |
397 const PresentationRequest& request, | 444 const PresentationRequest& request, |
398 const content::PresentationSessionInfo& session, | 445 const content::PresentationSessionInfo& session, |
399 const MediaRoute& route); | 446 const MediaRoute& route); |
400 | 447 |
448 bool IsOffscreenPresentation(const RenderFrameHostId& render_frame_host_id, | |
449 const std::string& presentation_id); | |
450 void OnBrowserConnectionAvailable( | |
451 const RenderFrameHostId& render_frame_host_id, | |
452 const content::PresentationSessionInfo& session, | |
453 content::PresentationConnectionPtr source_conn, | |
454 content::PresentationConnectionRequest target_conn_request); | |
455 | |
401 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id, | 456 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id, |
402 const std::string& presentation_id) const; | 457 const std::string& presentation_id) const; |
403 const std::vector<MediaRoute::Id> GetRouteIds( | 458 const std::vector<MediaRoute::Id> GetRouteIds( |
404 const RenderFrameHostId& render_frame_host_id) const; | 459 const RenderFrameHostId& render_frame_host_id) const; |
405 | 460 |
406 const PresentationRequest* default_presentation_request() const { | 461 const PresentationRequest* default_presentation_request() const { |
407 return default_presentation_request_.get(); | 462 return default_presentation_request_.get(); |
408 } | 463 } |
409 | 464 |
410 private: | 465 private: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 const auto it = presentation_frames_.find(request.render_frame_host_id()); | 527 const auto it = presentation_frames_.find(request.render_frame_host_id()); |
473 if (it != presentation_frames_.end()) | 528 if (it != presentation_frames_.end()) |
474 it->second->OnPresentationSessionStarted(session, route); | 529 it->second->OnPresentationSessionStarted(session, route); |
475 | 530 |
476 if (default_presentation_request_ && | 531 if (default_presentation_request_ && |
477 default_presentation_request_->Equals(request)) { | 532 default_presentation_request_->Equals(request)) { |
478 default_presentation_started_callback_.Run(session); | 533 default_presentation_started_callback_.Run(session); |
479 } | 534 } |
480 } | 535 } |
481 | 536 |
537 bool PresentationFrameManager::IsOffscreenPresentation( | |
538 const RenderFrameHostId& render_frame_host_id, | |
539 const std::string& presentation_id) { | |
540 const auto it = presentation_frames_.find(render_frame_host_id); | |
541 if (it != presentation_frames_.end()) | |
542 return it->second->IsOffscreenPresentation(presentation_id); | |
543 return false; | |
544 } | |
545 | |
546 void PresentationFrameManager::OnBrowserConnectionAvailable( | |
547 const RenderFrameHostId& render_frame_host_id, | |
548 const content::PresentationSessionInfo& session, | |
549 content::PresentationConnectionPtr source_conn, | |
550 content::PresentationConnectionRequest target_conn_request) { | |
551 const auto it = presentation_frames_.find(render_frame_host_id); | |
552 if (it != presentation_frames_.end()) | |
mark a. foltz
2017/01/23 22:29:34
If there is no target presentation frame for the c
zhaobin
2017/01/24 19:28:46
Done.
| |
553 return it->second->OnBrowserConnectionAvailable( | |
554 session, std::move(source_conn), std::move(target_conn_request)); | |
555 } | |
556 | |
482 const MediaRoute::Id PresentationFrameManager::GetRouteId( | 557 const MediaRoute::Id PresentationFrameManager::GetRouteId( |
483 const RenderFrameHostId& render_frame_host_id, | 558 const RenderFrameHostId& render_frame_host_id, |
484 const std::string& presentation_id) const { | 559 const std::string& presentation_id) const { |
485 const auto it = presentation_frames_.find(render_frame_host_id); | 560 const auto it = presentation_frames_.find(render_frame_host_id); |
486 return it != presentation_frames_.end() | 561 return it != presentation_frames_.end() |
487 ? it->second->GetRouteId(presentation_id) : MediaRoute::Id(); | 562 ? it->second->GetRouteId(presentation_id) : MediaRoute::Id(); |
488 } | 563 } |
489 | 564 |
490 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( | 565 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( |
491 const RenderFrameHostId& render_frame_host_id) const { | 566 const RenderFrameHostId& render_frame_host_id) const { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
904 int render_process_id, | 979 int render_process_id, |
905 int render_frame_id, | 980 int render_frame_id, |
906 const content::PresentationSessionInfo& connection, | 981 const content::PresentationSessionInfo& connection, |
907 const content::PresentationConnectionStateChangedCallback& | 982 const content::PresentationConnectionStateChangedCallback& |
908 state_changed_cb) { | 983 state_changed_cb) { |
909 frame_manager_->ListenForConnectionStateChange( | 984 frame_manager_->ListenForConnectionStateChange( |
910 RenderFrameHostId(render_process_id, render_frame_id), connection, | 985 RenderFrameHostId(render_process_id, render_frame_id), connection, |
911 state_changed_cb); | 986 state_changed_cb); |
912 } | 987 } |
913 | 988 |
914 void PresentationServiceDelegateImpl::ConnectToOffscreenPresentation( | 989 void PresentationServiceDelegateImpl::ConnectToPresentation( |
915 int render_process_id, | 990 int render_process_id, |
916 int render_frame_id, | 991 int render_frame_id, |
917 const content::PresentationSessionInfo& session, | 992 const content::PresentationSessionInfo& session, |
918 content::PresentationConnectionPtr controller_connection_ptr, | 993 content::PresentationConnectionPtr controller_connection_ptr, |
919 content::PresentationConnectionRequest receiver_connection_request) { | 994 content::PresentationConnectionRequest receiver_connection_request) { |
920 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 995 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
921 auto* const offscreen_presentation_manager = | 996 |
922 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( | 997 if (frame_manager_->IsOffscreenPresentation(render_frame_host_id, |
923 web_contents_); | 998 session.presentation_id)) { |
924 offscreen_presentation_manager->RegisterOffscreenPresentationController( | 999 auto* const offscreen_presentation_manager = |
925 session.presentation_id, session.presentation_url, render_frame_host_id, | 1000 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( |
926 std::move(controller_connection_ptr), | 1001 web_contents_); |
927 std::move(receiver_connection_request)); | 1002 offscreen_presentation_manager->RegisterOffscreenPresentationController( |
1003 session.presentation_id, session.presentation_url, render_frame_host_id, | |
1004 std::move(controller_connection_ptr), | |
1005 std::move(receiver_connection_request)); | |
1006 } else { | |
1007 frame_manager_->OnBrowserConnectionAvailable( | |
1008 render_frame_host_id, session, std::move(controller_connection_ptr), | |
1009 std::move(receiver_connection_request)); | |
1010 } | |
928 } | 1011 } |
929 | 1012 |
930 void PresentationServiceDelegateImpl::OnRouteResponse( | 1013 void PresentationServiceDelegateImpl::OnRouteResponse( |
931 const PresentationRequest& presentation_request, | 1014 const PresentationRequest& presentation_request, |
932 const RouteRequestResult& result) { | 1015 const RouteRequestResult& result) { |
933 if (!result.route() || | 1016 if (!result.route() || |
934 !base::ContainsValue(presentation_request.presentation_urls(), | 1017 !base::ContainsValue(presentation_request.presentation_urls(), |
935 result.presentation_url())) { | 1018 result.presentation_url())) { |
936 return; | 1019 return; |
937 } | 1020 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
988 const base::ListValue* origins = | 1071 const base::ListValue* origins = |
989 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) | 1072 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) |
990 ->GetPrefs() | 1073 ->GetPrefs() |
991 ->GetList(prefs::kMediaRouterTabMirroringSources); | 1074 ->GetList(prefs::kMediaRouterTabMirroringSources); |
992 return origins && | 1075 return origins && |
993 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); | 1076 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); |
994 } | 1077 } |
995 #endif // !defined(OS_ANDROID) | 1078 #endif // !defined(OS_ANDROID) |
996 | 1079 |
997 } // namespace media_router | 1080 } // namespace media_router |
OLD | NEW |