| 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_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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 CastModesToValue(cast_modes, source_host)); | 266 CastModesToValue(cast_modes, source_host)); |
| 267 web_ui()->CallJavascriptFunctionUnsafe(kSetCastModeList, *cast_modes_val); | 267 web_ui()->CallJavascriptFunctionUnsafe(kSetCastModeList, *cast_modes_val); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void MediaRouterWebUIMessageHandler::OnCreateRouteResponseReceived( | 270 void MediaRouterWebUIMessageHandler::OnCreateRouteResponseReceived( |
| 271 const MediaSink::Id& sink_id, | 271 const MediaSink::Id& sink_id, |
| 272 const MediaRoute* route) { | 272 const MediaRoute* route) { |
| 273 DVLOG(2) << "OnCreateRouteResponseReceived"; | 273 DVLOG(2) << "OnCreateRouteResponseReceived"; |
| 274 if (route) { | 274 if (route) { |
| 275 int current_cast_mode = CurrentCastModeForRouteId( | 275 int current_cast_mode = CurrentCastModeForRouteId( |
| 276 route->media_route_id(), media_router_ui_->current_cast_modes()); | 276 route->media_route_id(), media_router_ui_->routes_and_cast_modes()); |
| 277 std::unique_ptr<base::DictionaryValue> route_value(RouteToValue( | 277 std::unique_ptr<base::DictionaryValue> route_value(RouteToValue( |
| 278 *route, false, media_router_ui_->GetRouteProviderExtensionId(), | 278 *route, false, media_router_ui_->GetRouteProviderExtensionId(), |
| 279 incognito_, current_cast_mode)); | 279 incognito_, current_cast_mode)); |
| 280 web_ui()->CallJavascriptFunctionUnsafe( | 280 web_ui()->CallJavascriptFunctionUnsafe( |
| 281 kOnCreateRouteResponseReceived, base::StringValue(sink_id), | 281 kOnCreateRouteResponseReceived, base::StringValue(sink_id), |
| 282 *route_value, base::FundamentalValue(route->for_display())); | 282 *route_value, base::FundamentalValue(route->for_display())); |
| 283 } else { | 283 } else { |
| 284 web_ui()->CallJavascriptFunctionUnsafe( | 284 web_ui()->CallJavascriptFunctionUnsafe( |
| 285 kOnCreateRouteResponseReceived, base::StringValue(sink_id), | 285 kOnCreateRouteResponseReceived, base::StringValue(sink_id), |
| 286 *base::Value::CreateNullValue(), base::FundamentalValue(false)); | 286 *base::Value::CreateNullValue(), base::FundamentalValue(false)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // "No Cast devices found?" Chromecast help center page. | 404 // "No Cast devices found?" Chromecast help center page. |
| 405 initial_data.SetString("deviceMissingUrl", | 405 initial_data.SetString("deviceMissingUrl", |
| 406 base::StringPrintf(kHelpPageUrlPrefix, 3249268)); | 406 base::StringPrintf(kHelpPageUrlPrefix, 3249268)); |
| 407 | 407 |
| 408 std::unique_ptr<base::DictionaryValue> sinks_and_identity( | 408 std::unique_ptr<base::DictionaryValue> sinks_and_identity( |
| 409 SinksAndIdentityToValue(media_router_ui_->sinks(), GetAccountInfo())); | 409 SinksAndIdentityToValue(media_router_ui_->sinks(), GetAccountInfo())); |
| 410 initial_data.Set("sinksAndIdentity", sinks_and_identity.release()); | 410 initial_data.Set("sinksAndIdentity", sinks_and_identity.release()); |
| 411 | 411 |
| 412 std::unique_ptr<base::ListValue> routes(RoutesToValue( | 412 std::unique_ptr<base::ListValue> routes(RoutesToValue( |
| 413 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(), | 413 media_router_ui_->routes(), media_router_ui_->joinable_route_ids(), |
| 414 media_router_ui_->current_cast_modes())); | 414 media_router_ui_->routes_and_cast_modes())); |
| 415 initial_data.Set("routes", routes.release()); | 415 initial_data.Set("routes", routes.release()); |
| 416 | 416 |
| 417 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); | 417 const std::set<MediaCastMode> cast_modes = media_router_ui_->cast_modes(); |
| 418 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue( | 418 std::unique_ptr<base::ListValue> cast_modes_list(CastModesToValue( |
| 419 cast_modes, media_router_ui_->GetPresentationRequestSourceName())); | 419 cast_modes, media_router_ui_->GetPresentationRequestSourceName())); |
| 420 initial_data.Set("castModes", cast_modes_list.release()); | 420 initial_data.Set("castModes", cast_modes_list.release()); |
| 421 | 421 |
| 422 web_ui()->CallJavascriptFunctionUnsafe(kSetInitialData, initial_data); | 422 web_ui()->CallJavascriptFunctionUnsafe(kSetInitialData, initial_data); |
| 423 media_router_ui_->UIInitialized(); | 423 media_router_ui_->UIInitialized(); |
| 424 } | 424 } |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 } | 880 } |
| 881 | 881 |
| 882 return value; | 882 return value; |
| 883 } | 883 } |
| 884 | 884 |
| 885 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { | 885 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { |
| 886 set_web_ui(web_ui); | 886 set_web_ui(web_ui); |
| 887 } | 887 } |
| 888 | 888 |
| 889 } // namespace media_router | 889 } // namespace media_router |
| OLD | NEW |