Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl.cc

Issue 2471573005: [Presentation API] (5th) (1-UA) integrate controller and receiver side for 1-UA messaging (Closed)
Patch Set: resolve code review comments from Mark Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_connection,
172 content::PresentationConnectionRequest target_connection_request);
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::unordered_map<MediaRoute::Id,
190 std::unique_ptr<BrowserPresentationConnectionProxy>>
191 browser_connection_proxies_;
183 192
184 RenderFrameHostId render_frame_host_id_; 193 RenderFrameHostId render_frame_host_id_;
185 194
186 // References to the owning WebContents, and the corresponding MediaRouter. 195 // References to the owning WebContents, and the corresponding MediaRouter.
187 content::WebContents* web_contents_; 196 content::WebContents* web_contents_;
188 MediaRouter* router_; 197 MediaRouter* router_;
189 198
190 DelegateObserver* delegate_observer_; 199 DelegateObserver* delegate_observer_;
191 }; 200 };
192 201
193 PresentationFrame::PresentationFrame( 202 PresentationFrame::PresentationFrame(
194 const RenderFrameHostId& render_frame_host_id, 203 const RenderFrameHostId& render_frame_host_id,
195 content::WebContents* web_contents, 204 content::WebContents* web_contents,
196 MediaRouter* router) 205 MediaRouter* router)
197 : render_frame_host_id_(render_frame_host_id), 206 : render_frame_host_id_(render_frame_host_id),
198 web_contents_(web_contents), 207 web_contents_(web_contents),
199 router_(router) { 208 router_(router) {
200 DCHECK(web_contents_); 209 DCHECK(web_contents_);
201 DCHECK(router_); 210 DCHECK(router_);
202 } 211 }
203 212
204 PresentationFrame::~PresentationFrame() { 213 PresentationFrame::~PresentationFrame() {
205 } 214 }
206 215
207 void PresentationFrame::OnPresentationSessionStarted( 216 void PresentationFrame::OnPresentationSessionStarted(
208 const content::PresentationSessionInfo& session, 217 const content::PresentationSessionInfo& session,
209 const MediaRoute& route) { 218 const MediaRoute& route) {
210 presentation_id_to_route_id_[session.presentation_id] = 219 presentation_id_to_route_.insert(
211 route.media_route_id(); 220 std::make_pair(session.presentation_id, route));
212 } 221 }
213 222
214 const MediaRoute::Id PresentationFrame::GetRouteId( 223 const MediaRoute::Id PresentationFrame::GetRouteId(
215 const std::string& presentation_id) const { 224 const std::string& presentation_id) const {
216 auto it = presentation_id_to_route_id_.find(presentation_id); 225 auto it = presentation_id_to_route_.find(presentation_id);
217 return it != presentation_id_to_route_id_.end() ? it->second : ""; 226 return it != presentation_id_to_route_.end() ? it->second.media_route_id()
227 : "";
218 } 228 }
219 229
220 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const { 230 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const {
221 std::vector<MediaRoute::Id> route_ids; 231 std::vector<MediaRoute::Id> route_ids;
222 for (const auto& e : presentation_id_to_route_id_) 232 for (const auto& e : presentation_id_to_route_)
223 route_ids.push_back(e.second); 233 route_ids.push_back(e.second.media_route_id());
224 return route_ids; 234 return route_ids;
225 } 235 }
226 236
227 bool PresentationFrame::SetScreenAvailabilityListener( 237 bool PresentationFrame::SetScreenAvailabilityListener(
228 content::PresentationScreenAvailabilityListener* listener) { 238 content::PresentationScreenAvailabilityListener* listener) {
229 MediaSource source(GetMediaSourceFromListener(listener)); 239 MediaSource source(GetMediaSourceFromListener(listener));
230 auto& sinks_observer = url_to_sinks_observer_[source.id()]; 240 auto& sinks_observer = url_to_sinks_observer_[source.id()];
231 if (sinks_observer && sinks_observer->listener() == listener) 241 if (sinks_observer && sinks_observer->listener() == listener)
232 return false; 242 return false;
233 243
(...skipping 21 matching lines...) Expand all
255 } 265 }
256 return false; 266 return false;
257 } 267 }
258 268
259 bool PresentationFrame::HasScreenAvailabilityListenerForTest( 269 bool PresentationFrame::HasScreenAvailabilityListenerForTest(
260 const MediaSource::Id& source_id) const { 270 const MediaSource::Id& source_id) const {
261 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end(); 271 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end();
262 } 272 }
263 273
264 void PresentationFrame::Reset() { 274 void PresentationFrame::Reset() {
265 for (const auto& pid_route_id : presentation_id_to_route_id_) 275 auto offscreen_presentation_manager =
266 router_->DetachRoute(pid_route_id.second); 276 OffscreenPresentationManagerFactory::GetOrCreateForWebContents(
277 web_contents_);
267 278
268 presentation_id_to_route_id_.clear(); 279 for (const auto& pid_route : presentation_id_to_route_) {
280 offscreen_presentation_manager->UnregisterOffscreenPresentationController(
281 pid_route.first, render_frame_host_id_);
282 router_->DetachRoute(pid_route.second.media_route_id());
283 }
284
285 presentation_id_to_route_.clear();
269 url_to_sinks_observer_.clear(); 286 url_to_sinks_observer_.clear();
270 connection_state_subscriptions_.clear(); 287 connection_state_subscriptions_.clear();
271 session_messages_observers_.clear(); 288 session_messages_observers_.clear();
289 browser_connection_proxies_.clear();
272 } 290 }
273 291
274 void PresentationFrame::RemoveConnection(const std::string& presentation_id, 292 void PresentationFrame::RemoveConnection(const std::string& presentation_id,
275 const MediaRoute::Id& route_id) { 293 const MediaRoute::Id& route_id) {
276 // Remove the presentation id mapping so a later call to Reset is a no-op. 294 // Remove the presentation id mapping so a later call to Reset is a no-op.
277 presentation_id_to_route_id_.erase(presentation_id); 295 presentation_id_to_route_.erase(presentation_id);
278 296
279 // We no longer need to observe route messages. 297 // We no longer need to observe route messages.
280 session_messages_observers_.erase(route_id); 298 session_messages_observers_.erase(route_id);
281 299
300 browser_connection_proxies_.erase(route_id);
282 // We keep the PresentationConnectionStateChangedCallback registered with MR 301 // We keep the PresentationConnectionStateChangedCallback registered with MR
283 // so the MRP can tell us when terminate() completed. 302 // so the MRP can tell us when terminate() completed.
284 } 303 }
285 304
286 void PresentationFrame::ListenForConnectionStateChange( 305 void PresentationFrame::ListenForConnectionStateChange(
287 const content::PresentationSessionInfo& connection, 306 const content::PresentationSessionInfo& connection,
288 const content::PresentationConnectionStateChangedCallback& 307 const content::PresentationConnectionStateChangedCallback&
289 state_changed_cb) { 308 state_changed_cb) {
290 auto it = presentation_id_to_route_id_.find(connection.presentation_id); 309 auto it = presentation_id_to_route_.find(connection.presentation_id);
291 if (it == presentation_id_to_route_id_.end()) { 310 if (it == presentation_id_to_route_.end()) {
292 DLOG(ERROR) << __func__ << "route id not found for presentation: " 311 DLOG(ERROR) << __func__ << "route id not found for presentation: "
293 << connection.presentation_id; 312 << connection.presentation_id;
294 return; 313 return;
295 } 314 }
296 315
297 const MediaRoute::Id& route_id = it->second; 316 const MediaRoute::Id& route_id = it->second.media_route_id();
298 if (connection_state_subscriptions_.find(route_id) != 317 if (connection_state_subscriptions_.find(route_id) !=
299 connection_state_subscriptions_.end()) { 318 connection_state_subscriptions_.end()) {
300 DLOG(ERROR) << __func__ 319 DLOG(ERROR) << __func__
301 << "Already listening connection state change for route: " 320 << "Already listening connection state change for route: "
302 << route_id; 321 << route_id;
303 return; 322 return;
304 } 323 }
305 324
306 connection_state_subscriptions_.insert(std::make_pair( 325 connection_state_subscriptions_.insert(std::make_pair(
307 route_id, router_->AddPresentationConnectionStateChangedCallback( 326 route_id, router_->AddPresentationConnectionStateChangedCallback(
308 it->second, state_changed_cb))); 327 route_id, state_changed_cb)));
309 } 328 }
310 329
311 void PresentationFrame::ListenForSessionMessages( 330 void PresentationFrame::ListenForSessionMessages(
312 const content::PresentationSessionInfo& session, 331 const content::PresentationSessionInfo& session,
313 const content::PresentationConnectionMessageCallback& message_cb) { 332 const content::PresentationConnectionMessageCallback& message_cb) {
314 auto it = presentation_id_to_route_id_.find(session.presentation_id); 333 auto it = presentation_id_to_route_.find(session.presentation_id);
315 if (it == presentation_id_to_route_id_.end()) { 334 if (it == presentation_id_to_route_.end()) {
316 DVLOG(2) << "ListenForSessionMessages: no route for " 335 DVLOG(2) << "ListenForSessionMessages: no route for "
317 << session.presentation_id; 336 << session.presentation_id;
318 return; 337 return;
319 } 338 }
320 339
321 const MediaRoute::Id& route_id = it->second; 340 if (it->second.is_offscreen_presentation()) {
341 DVLOG(2) << "ListenForSessionMessages: do not listen for offscreen "
342 << "presentation [id]: " << session.presentation_id;
343 return;
344 }
345
346 const MediaRoute::Id& route_id = it->second.media_route_id();
322 if (session_messages_observers_.find(route_id) != 347 if (session_messages_observers_.find(route_id) !=
323 session_messages_observers_.end()) { 348 session_messages_observers_.end()) {
324 DLOG(ERROR) << __func__ 349 DLOG(ERROR) << __func__
325 << "Already listening for session messages for route: " 350 << "Already listening for session messages for route: "
326 << route_id; 351 << route_id;
327 return; 352 return;
328 } 353 }
329 354
330 session_messages_observers_.insert(std::make_pair( 355 session_messages_observers_.insert(std::make_pair(
331 route_id, base::MakeUnique<PresentationSessionMessagesObserver>( 356 route_id, base::MakeUnique<PresentationSessionMessagesObserver>(
332 router_, it->second, message_cb))); 357 router_, route_id, message_cb)));
333 } 358 }
334 359
335 MediaSource PresentationFrame::GetMediaSourceFromListener( 360 MediaSource PresentationFrame::GetMediaSourceFromListener(
336 content::PresentationScreenAvailabilityListener* listener) const { 361 content::PresentationScreenAvailabilityListener* listener) const {
337 // If the default presentation URL is empty then fall back to tab mirroring. 362 // If the default presentation URL is empty then fall back to tab mirroring.
338 return listener->GetAvailabilityUrl().is_empty() 363 return listener->GetAvailabilityUrl().is_empty()
339 ? MediaSourceForTab(SessionTabHelper::IdForTab(web_contents_)) 364 ? MediaSourceForTab(SessionTabHelper::IdForTab(web_contents_))
340 : MediaSourceForPresentationUrl(listener->GetAvailabilityUrl()); 365 : MediaSourceForPresentationUrl(listener->GetAvailabilityUrl());
341 } 366 }
342 367
368 bool PresentationFrame::IsOffscreenPresentation(
369 const std::string& presentation_id) {
370 if (!base::ContainsKey(presentation_id_to_route_, presentation_id)) {
371 DLOG(WARNING) << "No route for [presentation_id]: " << presentation_id;
372 return false;
373 }
374
375 auto it = presentation_id_to_route_.find(presentation_id);
mark a. foltz 2017/01/27 18:30:06 Nit: const auto
zhaobin 2017/01/27 22:11:40 Done.
376 return it->second.is_offscreen_presentation();
377 }
378
379 void PresentationFrame::OnBrowserConnectionAvailable(
380 const content::PresentationSessionInfo& session,
381 content::PresentationConnectionPtr source_connection,
382 content::PresentationConnectionRequest target_connection_request) {
383 DCHECK(source_connection);
384 if (!base::ContainsKey(presentation_id_to_route_, session.presentation_id)) {
385 DLOG(WARNING) << "No route for [presentation_id]: "
386 << session.presentation_id;
387 return;
388 }
389
390 const auto it = presentation_id_to_route_.find(session.presentation_id);
391 auto* proxy =
392 new BrowserPresentationConnectionProxy(session, router_, &it->second);
393
394 proxy->Bind(std::move(target_connection_request));
395 proxy->SetTargetConnection(std::move(source_connection));
396
397 auto route_id = it->second.media_route_id();
mark a. foltz 2017/01/27 18:30:05 Can this be inlined below?
zhaobin 2017/01/27 22:11:40 Done.
398 browser_connection_proxies_.insert(
399 std::make_pair(route_id, base::WrapUnique(proxy)));
400 }
401
343 // Used by PresentationServiceDelegateImpl to manage PresentationFrames. 402 // Used by PresentationServiceDelegateImpl to manage PresentationFrames.
344 class PresentationFrameManager { 403 class PresentationFrameManager {
345 public: 404 public:
346 PresentationFrameManager(content::WebContents* web_contents, 405 PresentationFrameManager(content::WebContents* web_contents,
347 MediaRouter* router); 406 MediaRouter* router);
348 ~PresentationFrameManager(); 407 ~PresentationFrameManager();
349 408
350 // Mirror corresponding APIs in PresentationServiceDelegateImpl. 409 // Mirror corresponding APIs in PresentationServiceDelegateImpl.
351 bool SetScreenAvailabilityListener( 410 bool SetScreenAvailabilityListener(
352 const RenderFrameHostId& render_frame_host_id, 411 const RenderFrameHostId& render_frame_host_id,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 450
392 void OnPresentationSessionStarted( 451 void OnPresentationSessionStarted(
393 const RenderFrameHostId& render_frame_host_id, 452 const RenderFrameHostId& render_frame_host_id,
394 const content::PresentationSessionInfo& session, 453 const content::PresentationSessionInfo& session,
395 const MediaRoute& route); 454 const MediaRoute& route);
396 void OnDefaultPresentationSessionStarted( 455 void OnDefaultPresentationSessionStarted(
397 const PresentationRequest& request, 456 const PresentationRequest& request,
398 const content::PresentationSessionInfo& session, 457 const content::PresentationSessionInfo& session,
399 const MediaRoute& route); 458 const MediaRoute& route);
400 459
460 bool IsOffscreenPresentation(const RenderFrameHostId& render_frame_host_id,
461 const std::string& presentation_id);
462 void OnBrowserConnectionAvailable(
463 const RenderFrameHostId& render_frame_host_id,
464 const content::PresentationSessionInfo& session,
465 content::PresentationConnectionPtr source_connection,
466 content::PresentationConnectionRequest target_connection_request);
467
401 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id, 468 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id,
402 const std::string& presentation_id) const; 469 const std::string& presentation_id) const;
403 const std::vector<MediaRoute::Id> GetRouteIds( 470 const std::vector<MediaRoute::Id> GetRouteIds(
404 const RenderFrameHostId& render_frame_host_id) const; 471 const RenderFrameHostId& render_frame_host_id) const;
405 472
406 const PresentationRequest* default_presentation_request() const { 473 const PresentationRequest* default_presentation_request() const {
407 return default_presentation_request_.get(); 474 return default_presentation_request_.get();
408 } 475 }
409 476
410 private: 477 private:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 const auto it = presentation_frames_.find(request.render_frame_host_id()); 539 const auto it = presentation_frames_.find(request.render_frame_host_id());
473 if (it != presentation_frames_.end()) 540 if (it != presentation_frames_.end())
474 it->second->OnPresentationSessionStarted(session, route); 541 it->second->OnPresentationSessionStarted(session, route);
475 542
476 if (default_presentation_request_ && 543 if (default_presentation_request_ &&
477 default_presentation_request_->Equals(request)) { 544 default_presentation_request_->Equals(request)) {
478 default_presentation_started_callback_.Run(session); 545 default_presentation_started_callback_.Run(session);
479 } 546 }
480 } 547 }
481 548
549 bool PresentationFrameManager::IsOffscreenPresentation(
550 const RenderFrameHostId& render_frame_host_id,
551 const std::string& presentation_id) {
552 const auto it = presentation_frames_.find(render_frame_host_id);
553 if (it != presentation_frames_.end())
554 return it->second->IsOffscreenPresentation(presentation_id);
555 return false;
556 }
557
558 void PresentationFrameManager::OnBrowserConnectionAvailable(
559 const RenderFrameHostId& render_frame_host_id,
560 const content::PresentationSessionInfo& session,
561 content::PresentationConnectionPtr source_connection,
562 content::PresentationConnectionRequest target_connection_request) {
563 auto* presentation_frame = GetOrAddPresentationFrame(render_frame_host_id);
564 return presentation_frame->OnBrowserConnectionAvailable(
mark a. foltz 2017/01/27 18:30:06 This is returning a value but the function is decl
zhaobin 2017/01/27 22:11:40 Done.
565 session, std::move(source_connection),
566 std::move(target_connection_request));
567 }
568
482 const MediaRoute::Id PresentationFrameManager::GetRouteId( 569 const MediaRoute::Id PresentationFrameManager::GetRouteId(
483 const RenderFrameHostId& render_frame_host_id, 570 const RenderFrameHostId& render_frame_host_id,
484 const std::string& presentation_id) const { 571 const std::string& presentation_id) const {
485 const auto it = presentation_frames_.find(render_frame_host_id); 572 const auto it = presentation_frames_.find(render_frame_host_id);
486 return it != presentation_frames_.end() 573 return it != presentation_frames_.end()
487 ? it->second->GetRouteId(presentation_id) : MediaRoute::Id(); 574 ? it->second->GetRouteId(presentation_id) : MediaRoute::Id();
488 } 575 }
489 576
490 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( 577 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds(
491 const RenderFrameHostId& render_frame_host_id) const { 578 const RenderFrameHostId& render_frame_host_id) const {
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 int render_process_id, 991 int render_process_id,
905 int render_frame_id, 992 int render_frame_id,
906 const content::PresentationSessionInfo& connection, 993 const content::PresentationSessionInfo& connection,
907 const content::PresentationConnectionStateChangedCallback& 994 const content::PresentationConnectionStateChangedCallback&
908 state_changed_cb) { 995 state_changed_cb) {
909 frame_manager_->ListenForConnectionStateChange( 996 frame_manager_->ListenForConnectionStateChange(
910 RenderFrameHostId(render_process_id, render_frame_id), connection, 997 RenderFrameHostId(render_process_id, render_frame_id), connection,
911 state_changed_cb); 998 state_changed_cb);
912 } 999 }
913 1000
914 void PresentationServiceDelegateImpl::ConnectToOffscreenPresentation( 1001 void PresentationServiceDelegateImpl::ConnectToPresentation(
915 int render_process_id, 1002 int render_process_id,
916 int render_frame_id, 1003 int render_frame_id,
917 const content::PresentationSessionInfo& session, 1004 const content::PresentationSessionInfo& session,
918 content::PresentationConnectionPtr controller_connection_ptr, 1005 content::PresentationConnectionPtr controller_connection_ptr,
919 content::PresentationConnectionRequest receiver_connection_request) { 1006 content::PresentationConnectionRequest receiver_connection_request) {
920 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 1007 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
921 auto* const offscreen_presentation_manager = 1008
922 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( 1009 if (frame_manager_->IsOffscreenPresentation(render_frame_host_id,
923 web_contents_); 1010 session.presentation_id)) {
924 offscreen_presentation_manager->RegisterOffscreenPresentationController( 1011 auto* const offscreen_presentation_manager =
925 session.presentation_id, session.presentation_url, render_frame_host_id, 1012 OffscreenPresentationManagerFactory::GetOrCreateForWebContents(
926 std::move(controller_connection_ptr), 1013 web_contents_);
927 std::move(receiver_connection_request)); 1014 offscreen_presentation_manager->RegisterOffscreenPresentationController(
1015 session.presentation_id, session.presentation_url, render_frame_host_id,
1016 std::move(controller_connection_ptr),
1017 std::move(receiver_connection_request));
1018 } else {
1019 frame_manager_->OnBrowserConnectionAvailable(
mark a. foltz 2017/01/27 18:30:06 I feel like we need to handle a presentation_id th
1020 render_frame_host_id, session, std::move(controller_connection_ptr),
1021 std::move(receiver_connection_request));
1022 }
928 } 1023 }
929 1024
930 void PresentationServiceDelegateImpl::OnRouteResponse( 1025 void PresentationServiceDelegateImpl::OnRouteResponse(
931 const PresentationRequest& presentation_request, 1026 const PresentationRequest& presentation_request,
932 const RouteRequestResult& result) { 1027 const RouteRequestResult& result) {
933 if (!result.route() || 1028 if (!result.route() ||
934 !base::ContainsValue(presentation_request.presentation_urls(), 1029 !base::ContainsValue(presentation_request.presentation_urls(),
935 result.presentation_url())) { 1030 result.presentation_url())) {
936 return; 1031 return;
937 } 1032 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 const base::ListValue* origins = 1083 const base::ListValue* origins =
989 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) 1084 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
990 ->GetPrefs() 1085 ->GetPrefs()
991 ->GetList(prefs::kMediaRouterTabMirroringSources); 1086 ->GetList(prefs::kMediaRouterTabMirroringSources);
992 return origins && 1087 return origins &&
993 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); 1088 origins->Find(base::StringValue(origin.Serialize())) != origins->end();
994 } 1089 }
995 #endif // !defined(OS_ANDROID) 1090 #endif // !defined(OS_ANDROID)
996 1091
997 } // namespace media_router 1092 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698