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

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

Issue 2060433004: [Media Router] Close dialog after resolving presentation request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
« no previous file with comments | « chrome/browser/ui/webui/media_router/media_router_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 return false; 393 return false;
394 } 394 }
395 395
396 current_route_request_id_ = ++route_request_counter_; 396 current_route_request_id_ = ++route_request_counter_;
397 *origin = for_default_source ? presentation_request_->frame_url().GetOrigin() 397 *origin = for_default_source ? presentation_request_->frame_url().GetOrigin()
398 : GURL(chrome::kChromeUIMediaRouterURL); 398 : GURL(chrome::kChromeUIMediaRouterURL);
399 DCHECK(origin->is_valid()); 399 DCHECK(origin->is_valid());
400 400
401 DVLOG(1) << "DoCreateRoute: origin: " << *origin; 401 DVLOG(1) << "DoCreateRoute: origin: " << *origin;
402 402
403 // There are 3 cases. In all cases the MediaRouterUI will need to be notified. 403 // There are 3 cases. In cases (1) and (3) the MediaRouterUI will need to be
404 // notified. In case (2) the dialog will be closed.
404 // (1) Non-presentation route request (e.g., mirroring). No additional 405 // (1) Non-presentation route request (e.g., mirroring). No additional
405 // notification necessary. 406 // notification necessary.
406 // (2) Presentation route request for a Presentation API startSession call. 407 // (2) Presentation route request for a Presentation API startSession call.
407 // The startSession (CreatePresentationConnectionRequest) will need to be 408 // The startSession (CreatePresentationConnectionRequest) will need to be
408 // answered with the 409 // answered with the route response.
409 // route response.
410 // (3) Browser-initiated presentation route request. If successful, 410 // (3) Browser-initiated presentation route request. If successful,
411 // PresentationServiceDelegateImpl will have to be notified. Note that we 411 // PresentationServiceDelegateImpl will have to be notified. Note that we
412 // treat subsequent route requests from a Presentation API-initiated dialogs 412 // treat subsequent route requests from a Presentation API-initiated dialogs
413 // as browser-initiated. 413 // as browser-initiated.
414 route_response_callbacks->push_back(base::Bind( 414 if (!for_default_source || !create_session_request_) {
415 &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(), 415 route_response_callbacks->push_back(base::Bind(
416 current_route_request_id_, sink_id, cast_mode, 416 &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(),
417 base::UTF8ToUTF16(GetTruncatedPresentationRequestSourceName()))); 417 current_route_request_id_, sink_id, cast_mode,
418 base::UTF8ToUTF16(GetTruncatedPresentationRequestSourceName())));
419 }
418 if (for_default_source) { 420 if (for_default_source) {
419 if (create_session_request_) { 421 if (create_session_request_) {
420 // |create_session_request_| will be nullptr after this call, as the 422 // |create_session_request_| will be nullptr after this call, as the
421 // object will be transferred to the callback. 423 // object will be transferred to the callback.
422 route_response_callbacks->push_back( 424 route_response_callbacks->push_back(
423 base::Bind(&CreatePresentationConnectionRequest::HandleRouteResponse, 425 base::Bind(&CreatePresentationConnectionRequest::HandleRouteResponse,
424 base::Passed(&create_session_request_))); 426 base::Passed(&create_session_request_)));
427 route_response_callbacks->push_back(
428 base::Bind(&MediaRouterUI::HandleCreateSessionRequestRouteResponse,
429 weak_factory_.GetWeakPtr()));
425 } else if (presentation_service_delegate_) { 430 } else if (presentation_service_delegate_) {
426 route_response_callbacks->push_back( 431 route_response_callbacks->push_back(
427 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse, 432 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse,
428 presentation_service_delegate_, *presentation_request_)); 433 presentation_service_delegate_, *presentation_request_));
429 } 434 }
430 } 435 }
431 436
432 *timeout = GetRouteRequestTimeout(cast_mode); 437 *timeout = GetRouteRequestTimeout(cast_mode);
433 *off_the_record = Profile::FromWebUI(web_ui())->IsOffTheRecord(); 438 *off_the_record = Profile::FromWebUI(web_ui())->IsOffTheRecord();
434 439
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 DVLOG(1) << "MediaRouteResponse returned error: " << result.error(); 541 DVLOG(1) << "MediaRouteResponse returned error: " << result.error();
537 } 542 }
538 543
539 handler_->OnCreateRouteResponseReceived(sink_id, route); 544 handler_->OnCreateRouteResponseReceived(sink_id, route);
540 current_route_request_id_ = -1; 545 current_route_request_id_ = -1;
541 546
542 if (result.result_code() == RouteRequestResult::TIMED_OUT) 547 if (result.result_code() == RouteRequestResult::TIMED_OUT)
543 SendIssueForRouteTimeout(cast_mode, presentation_request_source_name); 548 SendIssueForRouteTimeout(cast_mode, presentation_request_source_name);
544 } 549 }
545 550
551 void MediaRouterUI::HandleCreateSessionRequestRouteResponse(
552 const RouteRequestResult&) {
553 Close();
554 }
555
546 void MediaRouterUI::OnSearchSinkResponseReceived( 556 void MediaRouterUI::OnSearchSinkResponseReceived(
547 MediaCastMode cast_mode, 557 MediaCastMode cast_mode,
548 const MediaSink::Id& found_sink_id) { 558 const MediaSink::Id& found_sink_id) {
549 DVLOG(1) << "OnSearchSinkResponseReceived"; 559 DVLOG(1) << "OnSearchSinkResponseReceived";
550 handler_->ReturnSearchResult(found_sink_id); 560 handler_->ReturnSearchResult(found_sink_id);
551 561
552 MediaSource::Id source_id; 562 MediaSource::Id source_id;
553 GURL origin; 563 GURL origin;
554 std::vector<MediaRouteResponseCallback> route_response_callbacks; 564 std::vector<MediaRouteResponseCallback> route_response_callbacks;
555 base::TimeDelta timeout; 565 base::TimeDelta timeout;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 base::Time::Now() - start_time_); 664 base::Time::Now() - start_time_);
655 start_time_ = base::Time(); 665 start_time_ = base::Time();
656 } 666 }
657 } 667 }
658 668
659 void MediaRouterUI::UpdateMaxDialogHeight(int height) { 669 void MediaRouterUI::UpdateMaxDialogHeight(int height) {
660 handler_->UpdateMaxDialogHeight(height); 670 handler_->UpdateMaxDialogHeight(height);
661 } 671 }
662 672
663 } // namespace media_router 673 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/media_router/media_router_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698