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

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: merge with issue 2471263003 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,
mark a. foltz 2017/01/27 00:44:21 I think you'll have to revert this to use the blin
zhaobin 2017/01/27 05:05:46 Have a using in presentation_service_delegate.h :)
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 "
mark a. foltz 2017/01/27 00:44:21 Do we expect this to happen at all, or is this a b
zhaobin 2017/01/27 05:05:46 Yes, it is a normal code path (log for debugging).
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 DCHECK(base::ContainsKey(presentation_id_to_route_, presentation_id));
mark a. foltz 2017/01/27 00:44:21 Where is presentation_id being passed from? If it
zhaobin 2017/01/27 05:05:46 Done.
371 auto it = presentation_id_to_route_.find(presentation_id);
372 return it->second.is_offscreen_presentation();
373 }
374
375 void PresentationFrame::OnBrowserConnectionAvailable(
376 const content::PresentationSessionInfo& session,
377 content::PresentationConnectionPtr source_connection,
378 content::PresentationConnectionRequest target_connection_request) {
379 DCHECK(source_connection);
380 DCHECK(base::ContainsKey(presentation_id_to_route_, session.presentation_id));
mark a. foltz 2017/01/27 00:44:21 Similar comment about presentation_id.
zhaobin 2017/01/27 05:05:46 Done.
381 auto it = presentation_id_to_route_.find(session.presentation_id);
mark a. foltz 2017/01/27 00:44:21 Can this be const auto?
zhaobin 2017/01/27 05:05:46 Done.
382
383 std::unique_ptr<BrowserPresentationConnectionProxy> proxy =
384 base::MakeUnique<BrowserPresentationConnectionProxy>(session, router_,
385 &it->second);
386
387 proxy->Bind(std::move(target_connection_request));
388 proxy->SetTargetConnection(std::move(source_connection));
389
390 auto route_id = it->second.media_route_id();
391 browser_connection_proxies_.insert(
392 std::make_pair(route_id, std::move(proxy)));
393 }
394
343 // Used by PresentationServiceDelegateImpl to manage PresentationFrames. 395 // Used by PresentationServiceDelegateImpl to manage PresentationFrames.
344 class PresentationFrameManager { 396 class PresentationFrameManager {
345 public: 397 public:
346 PresentationFrameManager(content::WebContents* web_contents, 398 PresentationFrameManager(content::WebContents* web_contents,
347 MediaRouter* router); 399 MediaRouter* router);
348 ~PresentationFrameManager(); 400 ~PresentationFrameManager();
349 401
350 // Mirror corresponding APIs in PresentationServiceDelegateImpl. 402 // Mirror corresponding APIs in PresentationServiceDelegateImpl.
351 bool SetScreenAvailabilityListener( 403 bool SetScreenAvailabilityListener(
352 const RenderFrameHostId& render_frame_host_id, 404 const RenderFrameHostId& render_frame_host_id,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 443
392 void OnPresentationSessionStarted( 444 void OnPresentationSessionStarted(
393 const RenderFrameHostId& render_frame_host_id, 445 const RenderFrameHostId& render_frame_host_id,
394 const content::PresentationSessionInfo& session, 446 const content::PresentationSessionInfo& session,
395 const MediaRoute& route); 447 const MediaRoute& route);
396 void OnDefaultPresentationSessionStarted( 448 void OnDefaultPresentationSessionStarted(
397 const PresentationRequest& request, 449 const PresentationRequest& request,
398 const content::PresentationSessionInfo& session, 450 const content::PresentationSessionInfo& session,
399 const MediaRoute& route); 451 const MediaRoute& route);
400 452
453 bool IsOffscreenPresentation(const RenderFrameHostId& render_frame_host_id,
454 const std::string& presentation_id);
455 void OnBrowserConnectionAvailable(
456 const RenderFrameHostId& render_frame_host_id,
457 const content::PresentationSessionInfo& session,
458 content::PresentationConnectionPtr source_connection,
459 content::PresentationConnectionRequest target_connection_request);
460
401 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id, 461 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id,
402 const std::string& presentation_id) const; 462 const std::string& presentation_id) const;
403 const std::vector<MediaRoute::Id> GetRouteIds( 463 const std::vector<MediaRoute::Id> GetRouteIds(
404 const RenderFrameHostId& render_frame_host_id) const; 464 const RenderFrameHostId& render_frame_host_id) const;
405 465
406 const PresentationRequest* default_presentation_request() const { 466 const PresentationRequest* default_presentation_request() const {
407 return default_presentation_request_.get(); 467 return default_presentation_request_.get();
408 } 468 }
409 469
410 private: 470 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()); 532 const auto it = presentation_frames_.find(request.render_frame_host_id());
473 if (it != presentation_frames_.end()) 533 if (it != presentation_frames_.end())
474 it->second->OnPresentationSessionStarted(session, route); 534 it->second->OnPresentationSessionStarted(session, route);
475 535
476 if (default_presentation_request_ && 536 if (default_presentation_request_ &&
477 default_presentation_request_->Equals(request)) { 537 default_presentation_request_->Equals(request)) {
478 default_presentation_started_callback_.Run(session); 538 default_presentation_started_callback_.Run(session);
479 } 539 }
480 } 540 }
481 541
542 bool PresentationFrameManager::IsOffscreenPresentation(
543 const RenderFrameHostId& render_frame_host_id,
544 const std::string& presentation_id) {
545 const auto it = presentation_frames_.find(render_frame_host_id);
546 if (it != presentation_frames_.end())
547 return it->second->IsOffscreenPresentation(presentation_id);
548 return false;
549 }
550
551 void PresentationFrameManager::OnBrowserConnectionAvailable(
552 const RenderFrameHostId& render_frame_host_id,
553 const content::PresentationSessionInfo& session,
554 content::PresentationConnectionPtr source_connection,
555 content::PresentationConnectionRequest target_connection_request) {
556 auto* presentation_frame = GetOrAddPresentationFrame(render_frame_host_id);
557 return presentation_frame->OnBrowserConnectionAvailable(
558 session, std::move(source_connection),
559 std::move(target_connection_request));
560 }
561
482 const MediaRoute::Id PresentationFrameManager::GetRouteId( 562 const MediaRoute::Id PresentationFrameManager::GetRouteId(
483 const RenderFrameHostId& render_frame_host_id, 563 const RenderFrameHostId& render_frame_host_id,
484 const std::string& presentation_id) const { 564 const std::string& presentation_id) const {
485 const auto it = presentation_frames_.find(render_frame_host_id); 565 const auto it = presentation_frames_.find(render_frame_host_id);
486 return it != presentation_frames_.end() 566 return it != presentation_frames_.end()
487 ? it->second->GetRouteId(presentation_id) : MediaRoute::Id(); 567 ? it->second->GetRouteId(presentation_id) : MediaRoute::Id();
488 } 568 }
489 569
490 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( 570 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds(
491 const RenderFrameHostId& render_frame_host_id) const { 571 const RenderFrameHostId& render_frame_host_id) const {
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 int render_process_id, 984 int render_process_id,
905 int render_frame_id, 985 int render_frame_id,
906 const content::PresentationSessionInfo& connection, 986 const content::PresentationSessionInfo& connection,
907 const content::PresentationConnectionStateChangedCallback& 987 const content::PresentationConnectionStateChangedCallback&
908 state_changed_cb) { 988 state_changed_cb) {
909 frame_manager_->ListenForConnectionStateChange( 989 frame_manager_->ListenForConnectionStateChange(
910 RenderFrameHostId(render_process_id, render_frame_id), connection, 990 RenderFrameHostId(render_process_id, render_frame_id), connection,
911 state_changed_cb); 991 state_changed_cb);
912 } 992 }
913 993
914 void PresentationServiceDelegateImpl::ConnectToOffscreenPresentation( 994 void PresentationServiceDelegateImpl::ConnectToPresentation(
915 int render_process_id, 995 int render_process_id,
916 int render_frame_id, 996 int render_frame_id,
917 const content::PresentationSessionInfo& session, 997 const content::PresentationSessionInfo& session,
918 content::PresentationConnectionPtr controller_connection_ptr, 998 content::PresentationConnectionPtr controller_connection_ptr,
919 content::PresentationConnectionRequest receiver_connection_request) { 999 content::PresentationConnectionRequest receiver_connection_request) {
920 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 1000 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
921 auto* const offscreen_presentation_manager = 1001
922 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( 1002 if (frame_manager_->IsOffscreenPresentation(render_frame_host_id,
923 web_contents_); 1003 session.presentation_id)) {
924 offscreen_presentation_manager->RegisterOffscreenPresentationController( 1004 auto* const offscreen_presentation_manager =
925 session.presentation_id, session.presentation_url, render_frame_host_id, 1005 OffscreenPresentationManagerFactory::GetOrCreateForWebContents(
926 std::move(controller_connection_ptr), 1006 web_contents_);
927 std::move(receiver_connection_request)); 1007 offscreen_presentation_manager->RegisterOffscreenPresentationController(
1008 session.presentation_id, session.presentation_url, render_frame_host_id,
1009 std::move(controller_connection_ptr),
1010 std::move(receiver_connection_request));
1011 } else {
1012 frame_manager_->OnBrowserConnectionAvailable(
1013 render_frame_host_id, session, std::move(controller_connection_ptr),
1014 std::move(receiver_connection_request));
1015 }
928 } 1016 }
929 1017
930 void PresentationServiceDelegateImpl::OnRouteResponse( 1018 void PresentationServiceDelegateImpl::OnRouteResponse(
931 const PresentationRequest& presentation_request, 1019 const PresentationRequest& presentation_request,
932 const RouteRequestResult& result) { 1020 const RouteRequestResult& result) {
933 if (!result.route() || 1021 if (!result.route() ||
934 !base::ContainsValue(presentation_request.presentation_urls(), 1022 !base::ContainsValue(presentation_request.presentation_urls(),
935 result.presentation_url())) { 1023 result.presentation_url())) {
936 return; 1024 return;
937 } 1025 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 const base::ListValue* origins = 1076 const base::ListValue* origins =
989 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) 1077 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
990 ->GetPrefs() 1078 ->GetPrefs()
991 ->GetList(prefs::kMediaRouterTabMirroringSources); 1079 ->GetList(prefs::kMediaRouterTabMirroringSources);
992 return origins && 1080 return origins &&
993 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); 1081 origins->Find(base::StringValue(origin.Serialize())) != origins->end();
994 } 1082 }
995 #endif // !defined(OS_ANDROID) 1083 #endif // !defined(OS_ANDROID)
996 1084
997 } // namespace media_router 1085 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698