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 "chromeos/network/network_state.h" | 5 #include "chromeos/network/network_state.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chromeos/network/network_event_log.h" | 9 #include "chromeos/network/network_event_log.h" |
10 #include "chromeos/network/network_profile_handler.h" | 10 #include "chromeos/network/network_profile_handler.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } else if (key == shill::kActivationStateProperty) { | 99 } else if (key == shill::kActivationStateProperty) { |
100 return GetStringValue(key, value, &activation_state_); | 100 return GetStringValue(key, value, &activation_state_); |
101 } else if (key == shill::kRoamingStateProperty) { | 101 } else if (key == shill::kRoamingStateProperty) { |
102 return GetStringValue(key, value, &roaming_); | 102 return GetStringValue(key, value, &roaming_); |
103 } else if (key == shill::kPaymentPortalProperty) { | 103 } else if (key == shill::kPaymentPortalProperty) { |
104 const base::DictionaryValue* olp; | 104 const base::DictionaryValue* olp; |
105 if (!value.GetAsDictionary(&olp)) | 105 if (!value.GetAsDictionary(&olp)) |
106 return false; | 106 return false; |
107 return olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, | 107 return olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, |
108 &payment_url_); | 108 &payment_url_); |
109 } else if (key == shill::kSecurityProperty) { | 109 } else if (key == shill::kSecurityClassProperty) { |
110 return GetStringValue(key, value, &security_); | 110 return GetStringValue(key, value, &security_class_); |
111 } else if (key == shill::kEapMethodProperty) { | 111 } else if (key == shill::kEapMethodProperty) { |
112 return GetStringValue(key, value, &eap_method_); | 112 return GetStringValue(key, value, &eap_method_); |
113 } else if (key == shill::kNetworkTechnologyProperty) { | 113 } else if (key == shill::kNetworkTechnologyProperty) { |
114 return GetStringValue(key, value, &network_technology_); | 114 return GetStringValue(key, value, &network_technology_); |
115 } else if (key == shill::kDeviceProperty) { | 115 } else if (key == shill::kDeviceProperty) { |
116 return GetStringValue(key, value, &device_path_); | 116 return GetStringValue(key, value, &device_path_); |
117 } else if (key == shill::kGuidProperty) { | 117 } else if (key == shill::kGuidProperty) { |
118 return GetStringValue(key, value, &guid_); | 118 return GetStringValue(key, value, &guid_); |
119 } else if (key == shill::kProfileProperty) { | 119 } else if (key == shill::kProfileProperty) { |
120 return GetStringValue(key, value, &profile_path_); | 120 return GetStringValue(key, value, &profile_path_); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 | 180 |
181 return changed; | 181 return changed; |
182 } | 182 } |
183 | 183 |
184 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { | 184 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { |
185 ManagedState::GetStateProperties(dictionary); | 185 ManagedState::GetStateProperties(dictionary); |
186 | 186 |
187 // Properties shared by all types. | 187 // Properties shared by all types. |
188 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); | 188 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); |
189 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty, | 189 dictionary->SetStringWithoutPathExpansion(shill::kSecurityClassProperty, |
190 security()); | 190 security_class()); |
191 | 191 |
192 if (visible()) { | 192 if (visible()) { |
193 if (!error().empty()) | 193 if (!error().empty()) |
194 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); | 194 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); |
195 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, | 195 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, |
196 connection_state()); | 196 connection_state()); |
197 } | 197 } |
198 | 198 |
199 // Wireless properties | 199 // Wireless properties |
200 if (!NetworkTypePattern::Wireless().MatchesType(type())) | 200 if (!NetworkTypePattern::Wireless().MatchesType(type())) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 std::string NetworkState::GetNetmask() const { | 311 std::string NetworkState::GetNetmask() const { |
312 return network_util::PrefixLengthToNetmask(prefix_length_); | 312 return network_util::PrefixLengthToNetmask(prefix_length_); |
313 } | 313 } |
314 | 314 |
315 std::string NetworkState::GetSpecifier() const { | 315 std::string NetworkState::GetSpecifier() const { |
316 if (!update_received()) { | 316 if (!update_received()) { |
317 NET_LOG_ERROR("GetSpecifier called before update", path()); | 317 NET_LOG_ERROR("GetSpecifier called before update", path()); |
318 return std::string(); | 318 return std::string(); |
319 } | 319 } |
320 if (type() == shill::kTypeWifi) | 320 if (type() == shill::kTypeWifi) |
321 return name() + "_" + security_; | 321 return name() + "_" + security_class_; |
322 if (!name().empty()) | 322 if (!name().empty()) |
323 return name(); | 323 return name(); |
324 return type(); // For unnamed networks such as ethernet. | 324 return type(); // For unnamed networks such as ethernet. |
325 } | 325 } |
326 | 326 |
327 void NetworkState::SetGuid(const std::string& guid) { | 327 void NetworkState::SetGuid(const std::string& guid) { |
328 guid_ = guid; | 328 guid_ = guid; |
329 } | 329 } |
330 | 330 |
331 bool NetworkState::UpdateName(const base::DictionaryValue& properties) { | 331 bool NetworkState::UpdateName(const base::DictionaryValue& properties) { |
(...skipping 20 matching lines...) Expand all Loading... |
352 connection_state == shill::kStateCarrier); | 352 connection_state == shill::kStateCarrier); |
353 } | 353 } |
354 | 354 |
355 // static | 355 // static |
356 bool NetworkState::ErrorIsValid(const std::string& error) { | 356 bool NetworkState::ErrorIsValid(const std::string& error) { |
357 // Shill uses "Unknown" to indicate an unset or cleared error state. | 357 // Shill uses "Unknown" to indicate an unset or cleared error state. |
358 return !error.empty() && error != kErrorUnknown; | 358 return !error.empty() && error != kErrorUnknown; |
359 } | 359 } |
360 | 360 |
361 } // namespace chromeos | 361 } // namespace chromeos |
OLD | NEW |