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

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

Issue 2540773005: Add GetCurrentRoutes() to MediaRouter API, ensure dialog has routes at init (Closed)
Patch Set: Address Mark's comment Created 4 years 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_unittest.cc ('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_webui_message_handle r.h" 5 #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handle r.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 CastModesToValue(cast_modes, source_host)); 267 CastModesToValue(cast_modes, source_host));
268 web_ui()->CallJavascriptFunctionUnsafe(kSetCastModeList, *cast_modes_val); 268 web_ui()->CallJavascriptFunctionUnsafe(kSetCastModeList, *cast_modes_val);
269 } 269 }
270 270
271 void MediaRouterWebUIMessageHandler::OnCreateRouteResponseReceived( 271 void MediaRouterWebUIMessageHandler::OnCreateRouteResponseReceived(
272 const MediaSink::Id& sink_id, 272 const MediaSink::Id& sink_id,
273 const MediaRoute* route) { 273 const MediaRoute* route) {
274 DVLOG(2) << "OnCreateRouteResponseReceived"; 274 DVLOG(2) << "OnCreateRouteResponseReceived";
275 if (route) { 275 if (route) {
276 int current_cast_mode = CurrentCastModeForRouteId( 276 int current_cast_mode = CurrentCastModeForRouteId(
277 route->media_route_id(), media_router_ui_->current_cast_modes()); 277 route->media_route_id(), media_router_ui_->routes_and_cast_modes());
278 std::unique_ptr<base::DictionaryValue> route_value(RouteToValue( 278 std::unique_ptr<base::DictionaryValue> route_value(RouteToValue(
279 *route, false, media_router_ui_->GetRouteProviderExtensionId(), 279 *route, false, media_router_ui_->GetRouteProviderExtensionId(),
280 incognito_, current_cast_mode)); 280 incognito_, current_cast_mode));
281 web_ui()->CallJavascriptFunctionUnsafe( 281 web_ui()->CallJavascriptFunctionUnsafe(
282 kOnCreateRouteResponseReceived, base::StringValue(sink_id), 282 kOnCreateRouteResponseReceived, base::StringValue(sink_id),
283 *route_value, base::FundamentalValue(route->for_display())); 283 *route_value, base::FundamentalValue(route->for_display()));
284 } else { 284 } else {
285 web_ui()->CallJavascriptFunctionUnsafe( 285 web_ui()->CallJavascriptFunctionUnsafe(
286 kOnCreateRouteResponseReceived, base::StringValue(sink_id), 286 kOnCreateRouteResponseReceived, base::StringValue(sink_id),
287 *base::Value::CreateNullValue(), base::FundamentalValue(false)); 287 *base::Value::CreateNullValue(), base::FundamentalValue(false));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // "No Cast devices found?" Chromecast help center page. 405 // "No Cast devices found?" Chromecast help center page.
406 initial_data.SetString("deviceMissingUrl", 406 initial_data.SetString("deviceMissingUrl",
407 base::StringPrintf(kHelpPageUrlPrefix, 3249268)); 407 base::StringPrintf(kHelpPageUrlPrefix, 3249268));
408 408
409 std::unique_ptr<base::DictionaryValue> sinks_and_identity( 409 std::unique_ptr<base::DictionaryValue> sinks_and_identity(
410 SinksAndIdentityToValue(media_router_ui_->sinks(), GetAccountInfo())); 410 SinksAndIdentityToValue(media_router_ui_->sinks(), GetAccountInfo()));
411 initial_data.Set("sinksAndIdentity", sinks_and_identity.release()); 411 initial_data.Set("sinksAndIdentity", sinks_and_identity.release());
412 412
413 std::unique_ptr<base::ListValue> routes(RoutesToValue( 413 std::unique_ptr<base::ListValue> routes(RoutesToValue(
414 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(), 414 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(),
415 media_router_ui_->current_cast_modes())); 415 media_router_ui_->routes_and_cast_modes()));
416 initial_data.Set("routes", routes.release()); 416 initial_data.Set("routes", routes.release());
417 417
418 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); 418 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes();
419 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue( 419 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue(
420 cast_modes, media_router_ui_->GetPresentationRequestSourceName())); 420 cast_modes, media_router_ui_->GetPresentationRequestSourceName()));
421 initial_data.Set("castModes", cast_modes_list.release()); 421 initial_data.Set("castModes", cast_modes_list.release());
422 422
423 // If the cast mode last chosen for the current origin is tab mirroring, 423 // If the cast mode last chosen for the current origin is tab mirroring,
424 // that should be the cast mode initially selected in the dialog. Otherwise 424 // that should be the cast mode initially selected in the dialog. Otherwise
425 // the initial cast mode should be chosen automatically by the dialog. 425 // the initial cast mode should be chosen automatically by the dialog.
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 } 892 }
893 893
894 return value; 894 return value;
895 } 895 }
896 896
897 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { 897 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) {
898 set_web_ui(web_ui); 898 set_web_ui(web_ui);
899 } 899 }
900 900
901 } // namespace media_router 901 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698