| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_->current_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::Value(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::Value(false)); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 void MediaRouterWebUIMessageHandler::ReturnSearchResult( | 290 void MediaRouterWebUIMessageHandler::ReturnSearchResult( |
| 291 const std::string& sink_id) { | 291 const std::string& sink_id) { |
| 292 DVLOG(2) << "ReturnSearchResult"; | 292 DVLOG(2) << "ReturnSearchResult"; |
| 293 web_ui()->CallJavascriptFunctionUnsafe(kReceiveSearchResult, | 293 web_ui()->CallJavascriptFunctionUnsafe(kReceiveSearchResult, |
| 294 base::StringValue(sink_id)); | 294 base::StringValue(sink_id)); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void MediaRouterWebUIMessageHandler::UpdateIssue(const Issue* issue) { | 297 void MediaRouterWebUIMessageHandler::UpdateIssue(const Issue* issue) { |
| 298 DVLOG(2) << "UpdateIssue"; | 298 DVLOG(2) << "UpdateIssue"; |
| 299 web_ui()->CallJavascriptFunctionUnsafe( | 299 web_ui()->CallJavascriptFunctionUnsafe( |
| 300 kSetIssue, | 300 kSetIssue, |
| 301 issue ? *IssueToValue(*issue) : *base::Value::CreateNullValue()); | 301 issue ? *IssueToValue(*issue) : *base::Value::CreateNullValue()); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void MediaRouterWebUIMessageHandler::UpdateMaxDialogHeight(int height) { | 304 void MediaRouterWebUIMessageHandler::UpdateMaxDialogHeight(int height) { |
| 305 DVLOG(2) << "UpdateMaxDialogHeight"; | 305 DVLOG(2) << "UpdateMaxDialogHeight"; |
| 306 web_ui()->CallJavascriptFunctionUnsafe(kUpdateMaxHeight, | 306 web_ui()->CallJavascriptFunctionUnsafe(kUpdateMaxHeight, |
| 307 base::FundamentalValue(height)); | 307 base::Value(height)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void MediaRouterWebUIMessageHandler::RegisterMessages() { | 310 void MediaRouterWebUIMessageHandler::RegisterMessages() { |
| 311 web_ui()->RegisterMessageCallback( | 311 web_ui()->RegisterMessageCallback( |
| 312 kRequestInitialData, | 312 kRequestInitialData, |
| 313 base::Bind(&MediaRouterWebUIMessageHandler::OnRequestInitialData, | 313 base::Bind(&MediaRouterWebUIMessageHandler::OnRequestInitialData, |
| 314 base::Unretained(this))); | 314 base::Unretained(this))); |
| 315 web_ui()->RegisterMessageCallback( | 315 web_ui()->RegisterMessageCallback( |
| 316 kCreateRoute, | 316 kCreateRoute, |
| 317 base::Bind(&MediaRouterWebUIMessageHandler::OnCreateRoute, | 317 base::Bind(&MediaRouterWebUIMessageHandler::OnCreateRoute, |
| (...skipping 562 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 |