| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 sink_list_and_identity->Set("sinks", sinks_val.release()); | 135 sink_list_and_identity->Set("sinks", sinks_val.release()); |
| 136 sink_list_and_identity->SetBoolean("showEmail", show_email); | 136 sink_list_and_identity->SetBoolean("showEmail", show_email); |
| 137 sink_list_and_identity->SetBoolean("showDomain", show_domain); | 137 sink_list_and_identity->SetBoolean("showDomain", show_domain); |
| 138 return sink_list_and_identity; | 138 return sink_list_and_identity; |
| 139 } | 139 } |
| 140 | 140 |
| 141 std::unique_ptr<base::DictionaryValue> RouteToValue( | 141 std::unique_ptr<base::DictionaryValue> RouteToValue( |
| 142 const MediaRoute& route, | 142 const MediaRoute& route, |
| 143 bool can_join, | 143 bool can_join, |
| 144 const std::string& extension_id, | 144 const std::string& extension_id, |
| 145 bool off_the_record, | 145 bool incognito, |
| 146 int current_cast_mode) { | 146 int current_cast_mode) { |
| 147 std::unique_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue); | 147 std::unique_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue); |
| 148 dictionary->SetString("id", route.media_route_id()); | 148 dictionary->SetString("id", route.media_route_id()); |
| 149 dictionary->SetString("sinkId", route.media_sink_id()); | 149 dictionary->SetString("sinkId", route.media_sink_id()); |
| 150 dictionary->SetString("description", route.description()); | 150 dictionary->SetString("description", route.description()); |
| 151 dictionary->SetBoolean("isLocal", route.is_local()); | 151 dictionary->SetBoolean("isLocal", route.is_local()); |
| 152 dictionary->SetBoolean("canJoin", can_join); | 152 dictionary->SetBoolean("canJoin", can_join); |
| 153 if (current_cast_mode > 0) { | 153 if (current_cast_mode > 0) { |
| 154 dictionary->SetInteger("currentCastMode", current_cast_mode); | 154 dictionary->SetInteger("currentCastMode", current_cast_mode); |
| 155 } | 155 } |
| 156 | 156 |
| 157 const std::string& custom_path = route.custom_controller_path(); | 157 const std::string& custom_path = route.custom_controller_path(); |
| 158 if (!off_the_record && !custom_path.empty()) { | 158 if (!incognito && !custom_path.empty()) { |
| 159 std::string full_custom_controller_path = base::StringPrintf("%s://%s/%s", | 159 std::string full_custom_controller_path = base::StringPrintf("%s://%s/%s", |
| 160 extensions::kExtensionScheme, extension_id.c_str(), | 160 extensions::kExtensionScheme, extension_id.c_str(), |
| 161 custom_path.c_str()); | 161 custom_path.c_str()); |
| 162 DCHECK(GURL(full_custom_controller_path).is_valid()); | 162 DCHECK(GURL(full_custom_controller_path).is_valid()); |
| 163 dictionary->SetString("customControllerPath", | 163 dictionary->SetString("customControllerPath", |
| 164 full_custom_controller_path); | 164 full_custom_controller_path); |
| 165 } | 165 } |
| 166 | 166 |
| 167 return dictionary; | 167 return dictionary; |
| 168 } | 168 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 DVLOG(1) << "Error: URL is invalid and cannot be opened."; | 226 DVLOG(1) << "Error: URL is invalid and cannot be opened."; |
| 227 return std::string(); | 227 return std::string(); |
| 228 } | 228 } |
| 229 return help_url; | 229 return help_url; |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace | 232 } // namespace |
| 233 | 233 |
| 234 MediaRouterWebUIMessageHandler::MediaRouterWebUIMessageHandler( | 234 MediaRouterWebUIMessageHandler::MediaRouterWebUIMessageHandler( |
| 235 MediaRouterUI* media_router_ui) | 235 MediaRouterUI* media_router_ui) |
| 236 : off_the_record_( | 236 : incognito_( |
| 237 Profile::FromWebUI(media_router_ui->web_ui())->IsOffTheRecord()), | 237 Profile::FromWebUI(media_router_ui->web_ui())->IsOffTheRecord()), |
| 238 dialog_closing_(false), | 238 dialog_closing_(false), |
| 239 media_router_ui_(media_router_ui) {} | 239 media_router_ui_(media_router_ui) {} |
| 240 | 240 |
| 241 MediaRouterWebUIMessageHandler::~MediaRouterWebUIMessageHandler() { | 241 MediaRouterWebUIMessageHandler::~MediaRouterWebUIMessageHandler() { |
| 242 } | 242 } |
| 243 | 243 |
| 244 void MediaRouterWebUIMessageHandler::UpdateSinks( | 244 void MediaRouterWebUIMessageHandler::UpdateSinks( |
| 245 const std::vector<MediaSinkWithCastModes>& sinks) { | 245 const std::vector<MediaSinkWithCastModes>& sinks) { |
| 246 DVLOG(2) << "UpdateSinks"; | 246 DVLOG(2) << "UpdateSinks"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 271 | 271 |
| 272 void MediaRouterWebUIMessageHandler::OnCreateRouteResponseReceived( | 272 void MediaRouterWebUIMessageHandler::OnCreateRouteResponseReceived( |
| 273 const MediaSink::Id& sink_id, | 273 const MediaSink::Id& sink_id, |
| 274 const MediaRoute* route) { | 274 const MediaRoute* route) { |
| 275 DVLOG(2) << "OnCreateRouteResponseReceived"; | 275 DVLOG(2) << "OnCreateRouteResponseReceived"; |
| 276 if (route) { | 276 if (route) { |
| 277 int current_cast_mode = CurrentCastModeForRouteId( | 277 int current_cast_mode = CurrentCastModeForRouteId( |
| 278 route->media_route_id(), media_router_ui_->current_cast_modes()); | 278 route->media_route_id(), media_router_ui_->current_cast_modes()); |
| 279 std::unique_ptr<base::DictionaryValue> route_value(RouteToValue( | 279 std::unique_ptr<base::DictionaryValue> route_value(RouteToValue( |
| 280 *route, false, media_router_ui_->GetRouteProviderExtensionId(), | 280 *route, false, media_router_ui_->GetRouteProviderExtensionId(), |
| 281 off_the_record_, current_cast_mode)); | 281 incognito_, current_cast_mode)); |
| 282 web_ui()->CallJavascriptFunctionUnsafe( | 282 web_ui()->CallJavascriptFunctionUnsafe( |
| 283 kOnCreateRouteResponseReceived, base::StringValue(sink_id), | 283 kOnCreateRouteResponseReceived, base::StringValue(sink_id), |
| 284 *route_value, base::FundamentalValue(route->for_display())); | 284 *route_value, base::FundamentalValue(route->for_display())); |
| 285 } else { | 285 } else { |
| 286 web_ui()->CallJavascriptFunctionUnsafe( | 286 web_ui()->CallJavascriptFunctionUnsafe( |
| 287 kOnCreateRouteResponseReceived, base::StringValue(sink_id), | 287 kOnCreateRouteResponseReceived, base::StringValue(sink_id), |
| 288 *base::Value::CreateNullValue(), base::FundamentalValue(false)); | 288 *base::Value::CreateNullValue(), base::FundamentalValue(false)); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 const { | 877 const { |
| 878 std::unique_ptr<base::ListValue> value(new base::ListValue); | 878 std::unique_ptr<base::ListValue> value(new base::ListValue); |
| 879 const std::string& extension_id = | 879 const std::string& extension_id = |
| 880 media_router_ui_->GetRouteProviderExtensionId(); | 880 media_router_ui_->GetRouteProviderExtensionId(); |
| 881 | 881 |
| 882 for (const MediaRoute& route : routes) { | 882 for (const MediaRoute& route : routes) { |
| 883 bool can_join = ContainsValue(joinable_route_ids, route.media_route_id()); | 883 bool can_join = ContainsValue(joinable_route_ids, route.media_route_id()); |
| 884 int current_cast_mode = CurrentCastModeForRouteId(route.media_route_id(), | 884 int current_cast_mode = CurrentCastModeForRouteId(route.media_route_id(), |
| 885 current_cast_modes); | 885 current_cast_modes); |
| 886 std::unique_ptr<base::DictionaryValue> route_val(RouteToValue( | 886 std::unique_ptr<base::DictionaryValue> route_val(RouteToValue( |
| 887 route, can_join, extension_id, off_the_record_, current_cast_mode)); | 887 route, can_join, extension_id, incognito_, current_cast_mode)); |
| 888 value->Append(std::move(route_val)); | 888 value->Append(std::move(route_val)); |
| 889 } | 889 } |
| 890 | 890 |
| 891 return value; | 891 return value; |
| 892 } | 892 } |
| 893 | 893 |
| 894 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { | 894 void MediaRouterWebUIMessageHandler::SetWebUIForTest(content::WebUI* web_ui) { |
| 895 set_web_ui(web_ui); | 895 set_web_ui(web_ui); |
| 896 } | 896 } |
| 897 | 897 |
| 898 } // namespace media_router | 898 } // namespace media_router |
| OLD | NEW |