| Index: chrome/browser/devtools/devtools_targets_ui.cc
|
| diff --git a/chrome/browser/devtools/devtools_targets_ui.cc b/chrome/browser/devtools/devtools_targets_ui.cc
|
| index fa0568bf6089044a54fcca4d7d28085078bfafff..d78b3244647b714f18b1cbb06764affc46cdfe5b 100644
|
| --- a/chrome/browser/devtools/devtools_targets_ui.cc
|
| +++ b/chrome/browser/devtools/devtools_targets_ui.cc
|
| @@ -24,6 +24,7 @@
|
| #include "content/public/browser/worker_service_observer.h"
|
| #include "content/public/common/process_type.h"
|
| #include "net/base/escape.h"
|
| +#include "net/base/net_errors.h"
|
|
|
| using content::BrowserThread;
|
|
|
| @@ -244,22 +245,20 @@ void LocalTargetsUIHandler::SendTargets(
|
| std::map<std::string, base::DictionaryValue*> id_to_descriptor;
|
|
|
| STLDeleteValues(&targets_);
|
| - for (DevToolsTargetImpl::List::const_iterator it = targets.begin();
|
| - it != targets.end(); ++it) {
|
| - DevToolsTargetImpl* target = *it;
|
| + for (DevToolsTargetImpl* target : targets) {
|
| targets_[target->GetId()] = target;
|
| id_to_descriptor[target->GetId()] = Serialize(*target);
|
| }
|
|
|
| - for (TargetMap::iterator it(targets_.begin()); it != targets_.end(); ++it) {
|
| - DevToolsTargetImpl* target = it->second;
|
| + for (const auto& pair : targets_) {
|
| + DevToolsTargetImpl* target = pair.second;
|
| base::DictionaryValue* descriptor = id_to_descriptor[target->GetId()];
|
| std::string parent_id = target->GetParentId();
|
| if (parent_id.empty() || id_to_descriptor.count(parent_id) == 0) {
|
| list_value.Append(descriptor);
|
| } else {
|
| base::DictionaryValue* parent = id_to_descriptor[parent_id];
|
| - base::ListValue* guests = NULL;
|
| + base::ListValue* guests = nullptr;
|
| if (!parent->GetList(kGuestList, &guests)) {
|
| guests = new base::ListValue();
|
| parent->Set(kGuestList, guests);
|
| @@ -287,6 +286,10 @@ class AdbTargetsUIHandler
|
| scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost(
|
| const std::string& browser_id) override;
|
|
|
| + void SendJsonRequest(const std::string& browser_id,
|
| + const std::string& url,
|
| + const JsonCallback& callback) override;
|
| +
|
| private:
|
| // DevToolsAndroidBridge::Listener overrides.
|
| void DeviceListChanged(
|
| @@ -342,20 +345,29 @@ AdbTargetsUIHandler::GetBrowserAgentHost(
|
| const std::string& browser_id) {
|
| RemoteBrowsers::iterator it = remote_browsers_.find(browser_id);
|
| if (it == remote_browsers_.end())
|
| - return NULL;
|
| + return nullptr;
|
|
|
| return android_bridge_->GetBrowserAgentHost(it->second);
|
| }
|
|
|
| +void AdbTargetsUIHandler::SendJsonRequest(const std::string& browser_id,
|
| + const std::string& url,
|
| + const JsonCallback& callback) {
|
| + RemoteBrowsers::iterator it = remote_browsers_.find(browser_id);
|
| + if (it == remote_browsers_.end()) {
|
| + callback.Run(net::ERR_FAILED, std::string());
|
| + } else {
|
| + android_bridge_->SendJsonRequest(it->second, url, callback);
|
| + }
|
| +}
|
| +
|
| void AdbTargetsUIHandler::DeviceListChanged(
|
| const DevToolsAndroidBridge::RemoteDevices& devices) {
|
| remote_browsers_.clear();
|
| STLDeleteValues(&targets_);
|
|
|
| base::ListValue device_list;
|
| - for (DevToolsAndroidBridge::RemoteDevices::const_iterator dit =
|
| - devices.begin(); dit != devices.end(); ++dit) {
|
| - DevToolsAndroidBridge::RemoteDevice* device = dit->get();
|
| + for (const auto& device : devices) {
|
| base::DictionaryValue* device_data = new base::DictionaryValue();
|
| device_data->SetString(kAdbModelField, device->model());
|
| device_data->SetString(kAdbSerialField, device->serial());
|
| @@ -368,9 +380,7 @@ void AdbTargetsUIHandler::DeviceListChanged(
|
| device_data->Set(kAdbBrowsersList, browser_list);
|
|
|
| DevToolsAndroidBridge::RemoteBrowsers& browsers = device->browsers();
|
| - for (DevToolsAndroidBridge::RemoteBrowsers::iterator bit =
|
| - browsers.begin(); bit != browsers.end(); ++bit) {
|
| - DevToolsAndroidBridge::RemoteBrowser* browser = bit->get();
|
| + for (const auto& browser : browsers) {
|
| base::DictionaryValue* browser_data = new base::DictionaryValue();
|
| browser_data->SetString(kAdbBrowserNameField, browser->display_name());
|
| browser_data->SetString(kAdbBrowserUserField, browser->user());
|
| @@ -455,20 +465,24 @@ DevToolsTargetsUIHandler::CreateForAdb(
|
| DevToolsTargetImpl* DevToolsTargetsUIHandler::GetTarget(
|
| const std::string& target_id) {
|
| TargetMap::iterator it = targets_.find(target_id);
|
| - if (it != targets_.end())
|
| - return it->second;
|
| - return NULL;
|
| + return it == targets_.end() ? nullptr : it->second;
|
| }
|
|
|
| void DevToolsTargetsUIHandler::Open(const std::string& browser_id,
|
| const std::string& url,
|
| const TargetCallback& callback) {
|
| - callback.Run(NULL);
|
| + callback.Run(nullptr);
|
| }
|
|
|
| scoped_refptr<content::DevToolsAgentHost>
|
| DevToolsTargetsUIHandler::GetBrowserAgentHost(const std::string& browser_id) {
|
| - return NULL;
|
| + return nullptr;
|
| +}
|
| +
|
| +void DevToolsTargetsUIHandler::SendJsonRequest(const std::string& browser_id,
|
| + const std::string& url,
|
| + const JsonCallback& callback) {
|
| + callback.Run(net::ERR_FAILED, std::string());
|
| }
|
|
|
| base::DictionaryValue* DevToolsTargetsUIHandler::Serialize(
|
| @@ -515,24 +529,21 @@ PortForwardingStatusSerializer::~PortForwardingStatusSerializer() {
|
| void PortForwardingStatusSerializer::PortStatusChanged(
|
| const ForwardingStatus& status) {
|
| base::DictionaryValue result;
|
| - for (ForwardingStatus::const_iterator sit = status.begin();
|
| - sit != status.end(); ++sit) {
|
| + for (const auto& device_status : status) {
|
| base::DictionaryValue* port_status_dict = new base::DictionaryValue();
|
| - const PortStatusMap& port_status_map = sit->second;
|
| - for (PortStatusMap::const_iterator it = port_status_map.begin();
|
| - it != port_status_map.end(); ++it) {
|
| + for (const auto& port_status : device_status.second) {
|
| port_status_dict->SetInteger(
|
| - base::StringPrintf("%d", it->first), it->second);
|
| + base::StringPrintf("%d", port_status.first), port_status.second);
|
| }
|
|
|
| base::DictionaryValue* device_status_dict = new base::DictionaryValue();
|
| device_status_dict->Set(kPortForwardingPorts, port_status_dict);
|
| device_status_dict->SetString(kPortForwardingBrowserId,
|
| - SerializeBrowserId(sit->first));
|
| + SerializeBrowserId(device_status.first));
|
|
|
| std::string device_id = base::StringPrintf(
|
| kAdbDeviceIdFormat,
|
| - sit->first->serial().c_str());
|
| + device_status.first->serial().c_str());
|
| result.Set(device_id, device_status_dict);
|
| }
|
| callback_.Run(result);
|
|
|