| 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/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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 issues_observer_.reset(new UIIssuesObserver(router_, this)); | 362 issues_observer_.reset(new UIIssuesObserver(router_, this)); |
| 363 issues_observer_->RegisterObserver(); | 363 issues_observer_->RegisterObserver(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 bool MediaRouterUI::CreateRoute(const MediaSink::Id& sink_id, | 366 bool MediaRouterUI::CreateRoute(const MediaSink::Id& sink_id, |
| 367 MediaCastMode cast_mode) { | 367 MediaCastMode cast_mode) { |
| 368 MediaSource::Id source_id; | 368 MediaSource::Id source_id; |
| 369 GURL origin; | 369 GURL origin; |
| 370 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 370 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 371 base::TimeDelta timeout; | 371 base::TimeDelta timeout; |
| 372 bool off_the_record; | 372 bool incognito; |
| 373 if (!SetRouteParameters(sink_id, cast_mode, &source_id, &origin, | 373 if (!SetRouteParameters(sink_id, cast_mode, &source_id, &origin, |
| 374 &route_response_callbacks, &timeout, | 374 &route_response_callbacks, &timeout, &incognito)) { |
| 375 &off_the_record)) { | |
| 376 SendIssueForUnableToCast(cast_mode); | 375 SendIssueForUnableToCast(cast_mode); |
| 377 return false; | 376 return false; |
| 378 } | 377 } |
| 379 router_->CreateRoute(source_id, sink_id, origin, initiator_, | 378 router_->CreateRoute(source_id, sink_id, origin, initiator_, |
| 380 route_response_callbacks, timeout, off_the_record); | 379 route_response_callbacks, timeout, incognito); |
| 381 return true; | 380 return true; |
| 382 } | 381 } |
| 383 | 382 |
| 384 bool MediaRouterUI::SetRouteParameters( | 383 bool MediaRouterUI::SetRouteParameters( |
| 385 const MediaSink::Id& sink_id, | 384 const MediaSink::Id& sink_id, |
| 386 MediaCastMode cast_mode, | 385 MediaCastMode cast_mode, |
| 387 MediaSource::Id* source_id, | 386 MediaSource::Id* source_id, |
| 388 GURL* origin, | 387 GURL* origin, |
| 389 std::vector<MediaRouteResponseCallback>* route_response_callbacks, | 388 std::vector<MediaRouteResponseCallback>* route_response_callbacks, |
| 390 base::TimeDelta* timeout, | 389 base::TimeDelta* timeout, |
| 391 bool* off_the_record) { | 390 bool* incognito) { |
| 392 DCHECK(query_result_manager_.get()); | 391 DCHECK(query_result_manager_.get()); |
| 393 DCHECK(initiator_); | 392 DCHECK(initiator_); |
| 394 | 393 |
| 395 // Note that there is a rarely-encountered bug, where the MediaCastMode to | 394 // Note that there is a rarely-encountered bug, where the MediaCastMode to |
| 396 // MediaSource mapping could have been updated, between when the user clicked | 395 // MediaSource mapping could have been updated, between when the user clicked |
| 397 // on the UI to start a create route request, and when this function is | 396 // on the UI to start a create route request, and when this function is |
| 398 // called. However, since the user does not have visibility into the | 397 // called. However, since the user does not have visibility into the |
| 399 // MediaSource, and that it occurs very rarely in practice, we leave it as-is | 398 // MediaSource, and that it occurs very rarely in practice, we leave it as-is |
| 400 // for now. | 399 // for now. |
| 401 MediaSource source = query_result_manager_->GetSourceForCastMode(cast_mode); | 400 MediaSource source = query_result_manager_->GetSourceForCastMode(cast_mode); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 base::Bind(&MediaRouterUI::HandleCreateSessionRequestRouteResponse, | 447 base::Bind(&MediaRouterUI::HandleCreateSessionRequestRouteResponse, |
| 449 weak_factory_.GetWeakPtr())); | 448 weak_factory_.GetWeakPtr())); |
| 450 } else if (presentation_service_delegate_) { | 449 } else if (presentation_service_delegate_) { |
| 451 route_response_callbacks->push_back( | 450 route_response_callbacks->push_back( |
| 452 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse, | 451 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse, |
| 453 presentation_service_delegate_, *presentation_request_)); | 452 presentation_service_delegate_, *presentation_request_)); |
| 454 } | 453 } |
| 455 } | 454 } |
| 456 | 455 |
| 457 *timeout = GetRouteRequestTimeout(cast_mode); | 456 *timeout = GetRouteRequestTimeout(cast_mode); |
| 458 *off_the_record = Profile::FromWebUI(web_ui())->IsOffTheRecord(); | 457 *incognito = Profile::FromWebUI(web_ui())->IsOffTheRecord(); |
| 459 | 458 |
| 460 return true; | 459 return true; |
| 461 } | 460 } |
| 462 | 461 |
| 463 bool MediaRouterUI::ConnectRoute(const MediaSink::Id& sink_id, | 462 bool MediaRouterUI::ConnectRoute(const MediaSink::Id& sink_id, |
| 464 const MediaRoute::Id& route_id) { | 463 const MediaRoute::Id& route_id) { |
| 465 MediaSource::Id source_id; | 464 MediaSource::Id source_id; |
| 466 GURL origin; | 465 GURL origin; |
| 467 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 466 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 468 base::TimeDelta timeout; | 467 base::TimeDelta timeout; |
| 469 bool off_the_record; | 468 bool incognito; |
| 470 if (!SetRouteParameters(sink_id, MediaCastMode::DEFAULT, &source_id, &origin, | 469 if (!SetRouteParameters(sink_id, MediaCastMode::DEFAULT, &source_id, &origin, |
| 471 &route_response_callbacks, &timeout, | 470 &route_response_callbacks, &timeout, &incognito)) { |
| 472 &off_the_record)) { | |
| 473 SendIssueForUnableToCast(MediaCastMode::DEFAULT); | 471 SendIssueForUnableToCast(MediaCastMode::DEFAULT); |
| 474 return false; | 472 return false; |
| 475 } | 473 } |
| 476 router_->ConnectRouteByRouteId(source_id, route_id, origin, initiator_, | 474 router_->ConnectRouteByRouteId(source_id, route_id, origin, initiator_, |
| 477 route_response_callbacks, timeout, | 475 route_response_callbacks, timeout, incognito); |
| 478 off_the_record); | |
| 479 return true; | 476 return true; |
| 480 } | 477 } |
| 481 | 478 |
| 482 void MediaRouterUI::CloseRoute(const MediaRoute::Id& route_id) { | 479 void MediaRouterUI::CloseRoute(const MediaRoute::Id& route_id) { |
| 483 router_->TerminateRoute(route_id); | 480 router_->TerminateRoute(route_id); |
| 484 } | 481 } |
| 485 | 482 |
| 486 void MediaRouterUI::AddIssue(const Issue& issue) { router_->AddIssue(issue); } | 483 void MediaRouterUI::AddIssue(const Issue& issue) { router_->AddIssue(issue); } |
| 487 | 484 |
| 488 void MediaRouterUI::ClearIssue(const std::string& issue_id) { | 485 void MediaRouterUI::ClearIssue(const std::string& issue_id) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 void MediaRouterUI::OnSearchSinkResponseReceived( | 591 void MediaRouterUI::OnSearchSinkResponseReceived( |
| 595 MediaCastMode cast_mode, | 592 MediaCastMode cast_mode, |
| 596 const MediaSink::Id& found_sink_id) { | 593 const MediaSink::Id& found_sink_id) { |
| 597 DVLOG(1) << "OnSearchSinkResponseReceived"; | 594 DVLOG(1) << "OnSearchSinkResponseReceived"; |
| 598 handler_->ReturnSearchResult(found_sink_id); | 595 handler_->ReturnSearchResult(found_sink_id); |
| 599 | 596 |
| 600 MediaSource::Id source_id; | 597 MediaSource::Id source_id; |
| 601 GURL origin; | 598 GURL origin; |
| 602 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 599 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 603 base::TimeDelta timeout; | 600 base::TimeDelta timeout; |
| 604 bool off_the_record; | 601 bool incognito; |
| 605 if (!SetRouteParameters(found_sink_id, cast_mode, &source_id, &origin, | 602 if (!SetRouteParameters(found_sink_id, cast_mode, &source_id, &origin, |
| 606 &route_response_callbacks, &timeout, | 603 &route_response_callbacks, &timeout, &incognito)) { |
| 607 &off_the_record)) { | |
| 608 SendIssueForUnableToCast(cast_mode); | 604 SendIssueForUnableToCast(cast_mode); |
| 609 return; | 605 return; |
| 610 } | 606 } |
| 611 router_->CreateRoute(source_id, found_sink_id, origin, initiator_, | 607 router_->CreateRoute(source_id, found_sink_id, origin, initiator_, |
| 612 route_response_callbacks, timeout, off_the_record); | 608 route_response_callbacks, timeout, incognito); |
| 613 } | 609 } |
| 614 | 610 |
| 615 void MediaRouterUI::SendIssueForRouteTimeout( | 611 void MediaRouterUI::SendIssueForRouteTimeout( |
| 616 MediaCastMode cast_mode, | 612 MediaCastMode cast_mode, |
| 617 const base::string16& presentation_request_source_name) { | 613 const base::string16& presentation_request_source_name) { |
| 618 std::string issue_title; | 614 std::string issue_title; |
| 619 switch (cast_mode) { | 615 switch (cast_mode) { |
| 620 case DEFAULT: | 616 case DEFAULT: |
| 621 DLOG_IF(ERROR, presentation_request_source_name.empty()) | 617 DLOG_IF(ERROR, presentation_request_source_name.empty()) |
| 622 << "Empty presentation request source name."; | 618 << "Empty presentation request source name."; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 base::Time::Now() - start_time_); | 698 base::Time::Now() - start_time_); |
| 703 start_time_ = base::Time(); | 699 start_time_ = base::Time(); |
| 704 } | 700 } |
| 705 } | 701 } |
| 706 | 702 |
| 707 void MediaRouterUI::UpdateMaxDialogHeight(int height) { | 703 void MediaRouterUI::UpdateMaxDialogHeight(int height) { |
| 708 handler_->UpdateMaxDialogHeight(height); | 704 handler_->UpdateMaxDialogHeight(height); |
| 709 } | 705 } |
| 710 | 706 |
| 711 } // namespace media_router | 707 } // namespace media_router |
| OLD | NEW |