| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/devtools/chrome_devtools_manager_delegate.h" | 5 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/devtools/device/android_device_manager.h" | 10 #include "chrome/browser/devtools/device/android_device_manager.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // Could have been created late. | 247 // Could have been created late. |
| 248 if (host_data_.find(agent_host) == host_data_.end()) | 248 if (host_data_.find(agent_host) == host_data_.end()) |
| 249 DevToolsAgentHostAttached(agent_host); | 249 DevToolsAgentHostAttached(agent_host); |
| 250 | 250 |
| 251 std::set<net::HostPortPair> tcp_locations; | 251 std::set<net::HostPortPair> tcp_locations; |
| 252 base::ListValue* locations; | 252 base::ListValue* locations; |
| 253 if (!params->GetList(kLocationsParam, &locations)) | 253 if (!params->GetList(kLocationsParam, &locations)) |
| 254 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, | 254 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, |
| 255 kLocationsParam); | 255 kLocationsParam); |
| 256 for (const auto& item : *locations) { | 256 for (const auto& item : *locations) { |
| 257 if (!item->IsType(base::Value::Type::DICTIONARY)) { | 257 if (!item.IsType(base::Value::Type::DICTIONARY)) { |
| 258 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, | 258 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, |
| 259 kLocationsParam); | 259 kLocationsParam); |
| 260 } | 260 } |
| 261 base::DictionaryValue* dictionary = | 261 const base::DictionaryValue* dictionary = |
| 262 static_cast<base::DictionaryValue*>(item.get()); | 262 static_cast<const base::DictionaryValue*>(&item); |
| 263 std::string host; | 263 std::string host; |
| 264 if (!dictionary->GetStringWithoutPathExpansion(kHostParam, &host)) { | 264 if (!dictionary->GetStringWithoutPathExpansion(kHostParam, &host)) { |
| 265 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, | 265 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, |
| 266 kLocationsParam); | 266 kLocationsParam); |
| 267 } | 267 } |
| 268 int port = 0; | 268 int port = 0; |
| 269 if (!dictionary->GetIntegerWithoutPathExpansion(kPortParam, &port)) { | 269 if (!dictionary->GetIntegerWithoutPathExpansion(kPortParam, &port)) { |
| 270 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, | 270 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, |
| 271 kLocationsParam); | 271 kLocationsParam); |
| 272 } | 272 } |
| 273 tcp_locations.insert(net::HostPortPair(host, port)); | 273 tcp_locations.insert(net::HostPortPair(host, port)); |
| 274 } | 274 } |
| 275 | 275 |
| 276 host_data_[agent_host]->set_remote_locations(tcp_locations); | 276 host_data_[agent_host]->set_remote_locations(tcp_locations); |
| 277 UpdateDeviceDiscovery(); | 277 UpdateDeviceDiscovery(); |
| 278 | 278 |
| 279 std::unique_ptr<base::DictionaryValue> result( | 279 std::unique_ptr<base::DictionaryValue> result( |
| 280 base::MakeUnique<base::DictionaryValue>()); | 280 base::MakeUnique<base::DictionaryValue>()); |
| 281 return DevToolsProtocol::CreateSuccessResponse(command_id, std::move(result)); | 281 return DevToolsProtocol::CreateSuccessResponse(command_id, std::move(result)); |
| 282 } | 282 } |
| OLD | NEW |