| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/cros/network_parser.h" | 5 #include "chrome/browser/chromeos/cros/network_parser.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" // for debug output only. | 8 #include "base/json/json_writer.h" // for debug output only. |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 VLOG(2) << "Created device for path " << device_path; | 32 VLOG(2) << "Created device for path " << device_path; |
| 33 return device.release(); | 33 return device.release(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool NetworkDeviceParser::UpdateDeviceFromInfo(const DictionaryValue& info, | 36 bool NetworkDeviceParser::UpdateDeviceFromInfo(const DictionaryValue& info, |
| 37 NetworkDevice* device) { | 37 NetworkDevice* device) { |
| 38 for (DictionaryValue::key_iterator iter = info.begin_keys(); | 38 for (DictionaryValue::key_iterator iter = info.begin_keys(); |
| 39 iter != info.end_keys(); ++iter) { | 39 iter != info.end_keys(); ++iter) { |
| 40 const std::string& key = *iter; | 40 const std::string& key = *iter; |
| 41 base::Value* value; | 41 const base::Value* value; |
| 42 bool result = info.GetWithoutPathExpansion(key, &value); | 42 bool result = info.GetWithoutPathExpansion(key, &value); |
| 43 DCHECK(result); | 43 DCHECK(result); |
| 44 if (result) | 44 if (result) |
| 45 UpdateStatus(key, *value, device, NULL); | 45 UpdateStatus(key, *value, device, NULL); |
| 46 } | 46 } |
| 47 if (VLOG_IS_ON(2)) { | 47 if (VLOG_IS_ON(2)) { |
| 48 std::string json; | 48 std::string json; |
| 49 base::JSONWriter::WriteWithOptions(&info, | 49 base::JSONWriter::WriteWithOptions(&info, |
| 50 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 50 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 51 &json); | 51 &json); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 << " Type:" << ConnectionTypeToString(type); | 105 << " Type:" << ConnectionTypeToString(type); |
| 106 return network.release(); | 106 return network.release(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool NetworkParser::UpdateNetworkFromInfo(const DictionaryValue& info, | 109 bool NetworkParser::UpdateNetworkFromInfo(const DictionaryValue& info, |
| 110 Network* network) { | 110 Network* network) { |
| 111 network->set_unique_id(""); | 111 network->set_unique_id(""); |
| 112 for (DictionaryValue::key_iterator iter = info.begin_keys(); | 112 for (DictionaryValue::key_iterator iter = info.begin_keys(); |
| 113 iter != info.end_keys(); ++iter) { | 113 iter != info.end_keys(); ++iter) { |
| 114 const std::string& key = *iter; | 114 const std::string& key = *iter; |
| 115 base::Value* value; | 115 const base::Value* value; |
| 116 bool res = info.GetWithoutPathExpansion(key, &value); | 116 bool res = info.GetWithoutPathExpansion(key, &value); |
| 117 DCHECK(res); | 117 DCHECK(res); |
| 118 if (res) // Use network's parser to update status | 118 if (res) // Use network's parser to update status |
| 119 network->UpdateStatus(key, *value, NULL); | 119 network->UpdateStatus(key, *value, NULL); |
| 120 } | 120 } |
| 121 if (network->unique_id().empty()) | 121 if (network->unique_id().empty()) |
| 122 network->CalculateUniqueId(); | 122 network->CalculateUniqueId(); |
| 123 VLOG(2) << "Updated network '" << network->name() | 123 VLOG(2) << "Updated network '" << network->name() |
| 124 << "' Path:" << network->service_path() << " Type:" | 124 << "' Path:" << network->service_path() << " Type:" |
| 125 << ConnectionTypeToString(network->type()); | 125 << ConnectionTypeToString(network->type()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 network->set_ui_data(NetworkUIData(*ui_data_dict)); | 229 network->set_ui_data(NetworkUIData(*ui_data_dict)); |
| 230 return true; | 230 return true; |
| 231 } | 231 } |
| 232 default: | 232 default: |
| 233 break; | 233 break; |
| 234 } | 234 } |
| 235 return false; | 235 return false; |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace chromeos | 238 } // namespace chromeos |
| OLD | NEW |