| 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 "components/wifi/network_properties.h" | 5 #include "components/wifi/network_properties.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 10 #include "components/onc/onc_constants.h" | 12 #include "components/onc/onc_constants.h" |
| 11 | 13 |
| 12 namespace wifi { | 14 namespace wifi { |
| 13 | 15 |
| 14 NetworkProperties::NetworkProperties() | 16 NetworkProperties::NetworkProperties() |
| 15 : connection_state(onc::connection_state::kNotConnected), | 17 : connection_state(onc::connection_state::kNotConnected), |
| 16 security(onc::wifi::kSecurityNone), | 18 security(onc::wifi::kSecurityNone), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 45 if (!network_list) { | 47 if (!network_list) { |
| 46 if (frequency != kFrequencyUnknown) | 48 if (frequency != kFrequencyUnknown) |
| 47 wifi->SetInteger(onc::wifi::kFrequency, frequency); | 49 wifi->SetInteger(onc::wifi::kFrequency, frequency); |
| 48 std::unique_ptr<base::ListValue> frequency_list(new base::ListValue()); | 50 std::unique_ptr<base::ListValue> frequency_list(new base::ListValue()); |
| 49 for (FrequencySet::const_iterator it = this->frequency_set.begin(); | 51 for (FrequencySet::const_iterator it = this->frequency_set.begin(); |
| 50 it != this->frequency_set.end(); | 52 it != this->frequency_set.end(); |
| 51 ++it) { | 53 ++it) { |
| 52 frequency_list->AppendInteger(*it); | 54 frequency_list->AppendInteger(*it); |
| 53 } | 55 } |
| 54 if (!frequency_list->empty()) | 56 if (!frequency_list->empty()) |
| 55 wifi->Set(onc::wifi::kFrequencyList, frequency_list.release()); | 57 wifi->Set(onc::wifi::kFrequencyList, std::move(frequency_list)); |
| 56 if (!bssid.empty()) | 58 if (!bssid.empty()) |
| 57 wifi->SetString(onc::wifi::kBSSID, bssid); | 59 wifi->SetString(onc::wifi::kBSSID, bssid); |
| 58 wifi->SetString(onc::wifi::kSSID, ssid); | 60 wifi->SetString(onc::wifi::kSSID, ssid); |
| 59 wifi->SetString(onc::wifi::kHexSSID, | 61 wifi->SetString(onc::wifi::kHexSSID, |
| 60 base::HexEncode(ssid.c_str(), ssid.size())); | 62 base::HexEncode(ssid.c_str(), ssid.size())); |
| 61 } | 63 } |
| 62 value->Set(onc::network_type::kWiFi, wifi.release()); | 64 value->Set(onc::network_type::kWiFi, std::move(wifi)); |
| 63 | 65 |
| 64 return value; | 66 return value; |
| 65 } | 67 } |
| 66 | 68 |
| 67 bool NetworkProperties::UpdateFromValue(const base::DictionaryValue& value) { | 69 bool NetworkProperties::UpdateFromValue(const base::DictionaryValue& value) { |
| 68 const base::DictionaryValue* wifi = NULL; | 70 const base::DictionaryValue* wifi = NULL; |
| 69 std::string network_type; | 71 std::string network_type; |
| 70 // Get network type and make sure that it is WiFi (if specified). | 72 // Get network type and make sure that it is WiFi (if specified). |
| 71 if (value.GetString(onc::network_config::kType, &network_type)) { | 73 if (value.GetString(onc::network_config::kType, &network_type)) { |
| 72 if (network_type != onc::network_type::kWiFi) | 74 if (network_type != onc::network_type::kWiFi) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (l.type == r.type) | 110 if (l.type == r.type) |
| 109 return l.guid < r.guid; | 111 return l.guid < r.guid; |
| 110 if (l.type == onc::network_type::kEthernet) | 112 if (l.type == onc::network_type::kEthernet) |
| 111 return true; | 113 return true; |
| 112 if (r.type == onc::network_type::kEthernet) | 114 if (r.type == onc::network_type::kEthernet) |
| 113 return false; | 115 return false; |
| 114 return l.type > r.type; | 116 return l.type > r.type; |
| 115 } | 117 } |
| 116 | 118 |
| 117 } // namespace wifi | 119 } // namespace wifi |
| OLD | NEW |