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

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_ui.cc

Issue 1838903006: [Media Router] Cherrypick "add sinks to origin list" to beta (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 8 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/ui/webui/media_router/media_router_ui.h" 5 #include "chrome/browser/ui/webui/media_router/media_router_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 collator_.reset( 257 collator_.reset(
258 icu::Collator::createInstance(icu::Locale(locale.c_str()), error)); 258 icu::Collator::createInstance(icu::Locale(locale.c_str()), error));
259 if (U_FAILURE(error)) { 259 if (U_FAILURE(error)) {
260 DLOG(ERROR) << "Failed to create collator for locale " << locale; 260 DLOG(ERROR) << "Failed to create collator for locale " << locale;
261 collator_.reset(); 261 collator_.reset();
262 } 262 }
263 263
264 query_result_manager_.reset(new QueryResultManager(router_)); 264 query_result_manager_.reset(new QueryResultManager(router_));
265 query_result_manager_->AddObserver(this); 265 query_result_manager_->AddObserver(this);
266 266
267 // These modes are always available. 267 // Use a placeholder URL as origin for mirroring.
268 GURL origin(chrome::kChromeUIMediaRouterURL);
269
270 // Desktop mirror mode is always available.
268 query_result_manager_->StartSinksQuery(MediaCastMode::DESKTOP_MIRROR, 271 query_result_manager_->StartSinksQuery(MediaCastMode::DESKTOP_MIRROR,
269 MediaSourceForDesktop()); 272 MediaSourceForDesktop(), origin);
270 initiator_ = initiator; 273 initiator_ = initiator;
271 MediaSource mirroring_source( 274 SessionID::id_type tab_id = SessionTabHelper::IdForTab(initiator);
272 MediaSourceForTab(SessionTabHelper::IdForTab(initiator))); 275 if (tab_id != -1) {
273 query_result_manager_->StartSinksQuery(MediaCastMode::TAB_MIRROR, 276 MediaSource mirroring_source(MediaSourceForTab(tab_id));
274 mirroring_source); 277 query_result_manager_->StartSinksQuery(MediaCastMode::TAB_MIRROR,
278 mirroring_source, origin);
279 }
275 UpdateCastModes(); 280 UpdateCastModes();
276 } 281 }
277 282
278 void MediaRouterUI::InitForTest(MediaRouter* router, 283 void MediaRouterUI::InitForTest(MediaRouter* router,
279 content::WebContents* initiator, 284 content::WebContents* initiator,
280 MediaRouterWebUIMessageHandler* handler) { 285 MediaRouterWebUIMessageHandler* handler) {
281 router_ = router; 286 router_ = router;
282 handler_ = handler; 287 handler_ = handler;
283 InitCommon(initiator); 288 InitCommon(initiator);
284 } 289 }
285 290
286 void MediaRouterUI::OnDefaultPresentationChanged( 291 void MediaRouterUI::OnDefaultPresentationChanged(
287 const PresentationRequest& presentation_request) { 292 const PresentationRequest& presentation_request) {
288 MediaSource source = presentation_request.GetMediaSource(); 293 MediaSource source = presentation_request.GetMediaSource();
289 presentation_request_.reset(new PresentationRequest(presentation_request)); 294 presentation_request_.reset(new PresentationRequest(presentation_request));
290 query_result_manager_->StartSinksQuery(MediaCastMode::DEFAULT, source); 295 query_result_manager_->StartSinksQuery(
296 MediaCastMode::DEFAULT, source,
297 presentation_request_->frame_url().GetOrigin());
291 // Register for MediaRoute updates. 298 // Register for MediaRoute updates.
292 routes_observer_.reset(new UIMediaRoutesObserver( 299 routes_observer_.reset(new UIMediaRoutesObserver(
293 router_, source.id(), 300 router_, source.id(),
294 base::Bind(&MediaRouterUI::OnRoutesUpdated, base::Unretained(this)))); 301 base::Bind(&MediaRouterUI::OnRoutesUpdated, base::Unretained(this))));
295 302
296 UpdateCastModes(); 303 UpdateCastModes();
297 } 304 }
298 305
299 void MediaRouterUI::OnDefaultPresentationRemoved() { 306 void MediaRouterUI::OnDefaultPresentationRemoved() {
300 presentation_request_.reset(); 307 presentation_request_.reset();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 364 }
358 365
359 bool for_default_source = cast_mode == MediaCastMode::DEFAULT; 366 bool for_default_source = cast_mode == MediaCastMode::DEFAULT;
360 if (for_default_source && !presentation_request_) { 367 if (for_default_source && !presentation_request_) {
361 DLOG(ERROR) << "Requested to create a route for presentation, but " 368 DLOG(ERROR) << "Requested to create a route for presentation, but "
362 << "presentation request is missing."; 369 << "presentation request is missing.";
363 return false; 370 return false;
364 } 371 }
365 372
366 current_route_request_id_ = ++route_request_counter_; 373 current_route_request_id_ = ++route_request_counter_;
367 GURL origin; 374 GURL origin = for_default_source
368 if (for_default_source) { 375 ? presentation_request_->frame_url().GetOrigin()
369 origin = presentation_request_->frame_url().GetOrigin(); 376 : GURL(chrome::kChromeUIMediaRouterURL);
370 } else {
371 // Requesting route for mirroring. Use a placeholder URL as origin.
372 origin = GURL(chrome::kChromeUIMediaRouterURL);
373 }
374 DCHECK(origin.is_valid()); 377 DCHECK(origin.is_valid());
375 378
376 DVLOG(1) << "DoCreateRoute: origin: " << origin; 379 DVLOG(1) << "DoCreateRoute: origin: " << origin;
377 380
378 // There are 3 cases. In all cases the MediaRouterUI will need to be notified. 381 // There are 3 cases. In all cases the MediaRouterUI will need to be notified.
379 // (1) Non-presentation route request (e.g., mirroring). No additional 382 // (1) Non-presentation route request (e.g., mirroring). No additional
380 // notification necessary. 383 // notification necessary.
381 // (2) Presentation route request for a Presentation API startSession call. 384 // (2) Presentation route request for a Presentation API startSession call.
382 // The startSession (CreatePresentationConnectionRequest) will need to be 385 // The startSession (CreatePresentationConnectionRequest) will need to be
383 // answered with the 386 // answered with the
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 base::Time::Now() - start_time_); 559 base::Time::Now() - start_time_);
557 start_time_ = base::Time(); 560 start_time_ = base::Time();
558 } 561 }
559 } 562 }
560 563
561 void MediaRouterUI::UpdateMaxDialogHeight(int height) { 564 void MediaRouterUI::UpdateMaxDialogHeight(int height) {
562 handler_->UpdateMaxDialogHeight(height); 565 handler_->UpdateMaxDialogHeight(height);
563 } 566 }
564 567
565 } // namespace media_router 568 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698