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

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

Issue 1273423004: Shows a launch spinner next to a sink once it is selected to create a route. The launch spinner sur… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Kevin's comments Created 5 years, 4 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 <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/media/router/create_presentation_session_request.h" 10 #include "chrome/browser/media/router/create_presentation_session_request.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 if (ui_initialized_) 276 if (ui_initialized_)
277 handler_->UpdateIssue(issue); 277 handler_->UpdateIssue(issue);
278 } 278 }
279 279
280 void MediaRouterUI::OnRoutesUpdated(const std::vector<MediaRoute>& routes) { 280 void MediaRouterUI::OnRoutesUpdated(const std::vector<MediaRoute>& routes) {
281 routes_ = routes; 281 routes_ = routes;
282 if (ui_initialized_) 282 if (ui_initialized_)
283 handler_->UpdateRoutes(routes_); 283 handler_->UpdateRoutes(routes_);
284 } 284 }
285 285
286 void MediaRouterUI::OnRouteResponseReceived(const MediaRoute* route, 286 void MediaRouterUI::OnRouteResponseReceived(const MediaSink::Id& sink_id,
287 const MediaRoute* route,
287 const std::string& error) { 288 const std::string& error) {
288 DVLOG(1) << "OnRouteResponseReceived"; 289 DVLOG(1) << "OnRouteResponseReceived";
289 // TODO(imcheng): Display error in UI. (crbug.com/490372) 290 // TODO(imcheng): Display error in UI. (crbug.com/490372)
290 if (!route) 291 if (!route) {
apacible 2015/08/10 14:13:27 To simplify, maybe something like this for L291-29
haibinlu 2015/08/11 01:31:47 Done.
292 handler_->OnCreateRouteResponseReceived(sink_id, nullptr);
291 LOG(ERROR) << "MediaRouteResponse returned error: " << error; 293 LOG(ERROR) << "MediaRouteResponse returned error: " << error;
292 else 294 } else {
293 handler_->AddRoute(*route); 295 handler_->OnCreateRouteResponseReceived(sink_id, route);
296 }
294 297
295 has_pending_route_request_ = false; 298 has_pending_route_request_ = false;
296 requesting_route_for_default_source_ = false; 299 requesting_route_for_default_source_ = false;
297 } 300 }
298 301
299 bool MediaRouterUI::DoCreateRoute(const MediaSink::Id& sink_id, 302 bool MediaRouterUI::DoCreateRoute(const MediaSink::Id& sink_id,
300 MediaCastMode cast_mode) { 303 MediaCastMode cast_mode) {
301 DCHECK(query_result_manager_.get()); 304 DCHECK(query_result_manager_.get());
302 DCHECK(initiator_); 305 DCHECK(initiator_);
303 306
(...skipping 28 matching lines...) Expand all
332 // notification necessary. 335 // notification necessary.
333 // (2) Presentation route request for a Presentation API startSession call. 336 // (2) Presentation route request for a Presentation API startSession call.
334 // The startSession (CreatePresentationSessionRequest) will need to be 337 // The startSession (CreatePresentationSessionRequest) will need to be
335 // answered with the 338 // answered with the
336 // route response. 339 // route response.
337 // (3) Browser-initiated presentation route request. If successful, 340 // (3) Browser-initiated presentation route request. If successful,
338 // PresentationServiceDelegateImpl will have to be notified. Note that we 341 // PresentationServiceDelegateImpl will have to be notified. Note that we
339 // treat subsequent route requests from a Presentation API-initiated dialogs 342 // treat subsequent route requests from a Presentation API-initiated dialogs
340 // as browser-initiated. 343 // as browser-initiated.
341 std::vector<MediaRouteResponseCallback> route_response_callbacks; 344 std::vector<MediaRouteResponseCallback> route_response_callbacks;
342 route_response_callbacks.push_back(base::Bind( 345 route_response_callbacks.push_back(
343 &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr())); 346 base::Bind(&MediaRouterUI::OnRouteResponseReceived,
347 weak_factory_.GetWeakPtr(), sink_id));
344 if (requesting_route_for_default_source_) { 348 if (requesting_route_for_default_source_) {
345 if (presentation_request_) { 349 if (presentation_request_) {
346 // |presentation_request_| will be nullptr after this call, as the 350 // |presentation_request_| will be nullptr after this call, as the
347 // object will be transferred to the callback. 351 // object will be transferred to the callback.
348 route_response_callbacks.push_back( 352 route_response_callbacks.push_back(
349 base::Bind(&HandleRouteResponseForPresentationApi, 353 base::Bind(&HandleRouteResponseForPresentationApi,
350 base::Passed(&presentation_request_))); 354 base::Passed(&presentation_request_)));
351 } else if (presentation_service_delegate_) { 355 } else if (presentation_service_delegate_) {
352 route_response_callbacks.push_back( 356 route_response_callbacks.push_back(
353 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse, 357 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse,
354 presentation_service_delegate_)); 358 presentation_service_delegate_));
355 } 359 }
356 } 360 }
357 361
358 router_->CreateRoute(source.id(), sink_id, origin, 362 router_->CreateRoute(source.id(), sink_id, origin,
359 SessionTabHelper::IdForTab(initiator_), 363 SessionTabHelper::IdForTab(initiator_),
360 route_response_callbacks); 364 route_response_callbacks);
361 return true; 365 return true;
362 } 366 }
363 367
364 std::string MediaRouterUI::GetFrameURLHost() const { 368 std::string MediaRouterUI::GetFrameURLHost() const {
365 return GetHostFromURL(frame_url_); 369 return GetHostFromURL(frame_url_);
366 } 370 }
367 371
368 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const { 372 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const {
369 return router_->media_route_provider_extension_id(); 373 return router_->media_route_provider_extension_id();
370 } 374 }
371 375
376 const std::set<MediaSink::Id>& MediaRouterUI::GetSinkIdsInLaunch() const {
377 return router_->sink_ids_in_launch();
378 }
379
372 } // namespace media_router 380 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698