| 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/device_event_log.h" | 9 #include "chromeos/device_event_log.h" |
| 10 #include "chromeos/network/network_profile_handler.h" | 10 #include "chromeos/network/network_profile_handler.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } else if (key == shill::kActivationStateProperty) { | 71 } else if (key == shill::kActivationStateProperty) { |
| 72 return GetStringValue(key, value, &activation_state_); | 72 return GetStringValue(key, value, &activation_state_); |
| 73 } else if (key == shill::kRoamingStateProperty) { | 73 } else if (key == shill::kRoamingStateProperty) { |
| 74 return GetStringValue(key, value, &roaming_); | 74 return GetStringValue(key, value, &roaming_); |
| 75 } else if (key == shill::kPaymentPortalProperty) { | 75 } else if (key == shill::kPaymentPortalProperty) { |
| 76 const base::DictionaryValue* olp; | 76 const base::DictionaryValue* olp; |
| 77 if (!value.GetAsDictionary(&olp)) | 77 if (!value.GetAsDictionary(&olp)) |
| 78 return false; | 78 return false; |
| 79 return olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, | 79 return olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, |
| 80 &payment_url_); | 80 &payment_url_); |
| 81 } else if (key == shill::kSecurityProperty) { | 81 } else if (key == shill::kSecurityClassProperty) { |
| 82 return GetStringValue(key, value, &security_); | 82 return GetStringValue(key, value, &security_class_); |
| 83 } else if (key == shill::kEapMethodProperty) { | 83 } else if (key == shill::kEapMethodProperty) { |
| 84 return GetStringValue(key, value, &eap_method_); | 84 return GetStringValue(key, value, &eap_method_); |
| 85 } else if (key == shill::kNetworkTechnologyProperty) { | 85 } else if (key == shill::kNetworkTechnologyProperty) { |
| 86 return GetStringValue(key, value, &network_technology_); | 86 return GetStringValue(key, value, &network_technology_); |
| 87 } else if (key == shill::kDeviceProperty) { | 87 } else if (key == shill::kDeviceProperty) { |
| 88 return GetStringValue(key, value, &device_path_); | 88 return GetStringValue(key, value, &device_path_); |
| 89 } else if (key == shill::kGuidProperty) { | 89 } else if (key == shill::kGuidProperty) { |
| 90 return GetStringValue(key, value, &guid_); | 90 return GetStringValue(key, value, &guid_); |
| 91 } else if (key == shill::kProfileProperty) { | 91 } else if (key == shill::kProfileProperty) { |
| 92 return GetStringValue(key, value, &profile_path_); | 92 return GetStringValue(key, value, &profile_path_); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 // Ensure that the network has a valid name. | 147 // Ensure that the network has a valid name. |
| 148 return UpdateName(properties); | 148 return UpdateName(properties); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { | 151 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { |
| 152 ManagedState::GetStateProperties(dictionary); | 152 ManagedState::GetStateProperties(dictionary); |
| 153 | 153 |
| 154 // Properties shared by all types. | 154 // Properties shared by all types. |
| 155 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); | 155 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); |
| 156 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty, | 156 dictionary->SetStringWithoutPathExpansion(shill::kSecurityClassProperty, |
| 157 security()); | 157 security_class()); |
| 158 | 158 |
| 159 if (visible()) { | 159 if (visible()) { |
| 160 if (!error().empty()) | 160 if (!error().empty()) |
| 161 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); | 161 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); |
| 162 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, | 162 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, |
| 163 connection_state()); | 163 connection_state()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Wireless properties | 166 // Wireless properties |
| 167 if (!NetworkTypePattern::Wireless().MatchesType(type())) | 167 if (!NetworkTypePattern::Wireless().MatchesType(type())) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 std::string NetworkState::GetNetmask() const { | 278 std::string NetworkState::GetNetmask() const { |
| 279 return network_util::PrefixLengthToNetmask(prefix_length_); | 279 return network_util::PrefixLengthToNetmask(prefix_length_); |
| 280 } | 280 } |
| 281 | 281 |
| 282 std::string NetworkState::GetSpecifier() const { | 282 std::string NetworkState::GetSpecifier() const { |
| 283 if (!update_received()) { | 283 if (!update_received()) { |
| 284 NET_LOG(ERROR) << "GetSpecifier called before update: " << path(); | 284 NET_LOG(ERROR) << "GetSpecifier called before update: " << path(); |
| 285 return std::string(); | 285 return std::string(); |
| 286 } | 286 } |
| 287 if (type() == shill::kTypeWifi) | 287 if (type() == shill::kTypeWifi) |
| 288 return name() + "_" + security_; | 288 return name() + "_" + security_class_; |
| 289 if (!name().empty()) | 289 if (!name().empty()) |
| 290 return name(); | 290 return name(); |
| 291 return type(); // For unnamed networks such as ethernet. | 291 return type(); // For unnamed networks such as ethernet. |
| 292 } | 292 } |
| 293 | 293 |
| 294 void NetworkState::SetGuid(const std::string& guid) { | 294 void NetworkState::SetGuid(const std::string& guid) { |
| 295 guid_ = guid; | 295 guid_ = guid; |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool NetworkState::UpdateName(const base::DictionaryValue& properties) { | 298 bool NetworkState::UpdateName(const base::DictionaryValue& properties) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 319 connection_state == shill::kStateCarrier); | 319 connection_state == shill::kStateCarrier); |
| 320 } | 320 } |
| 321 | 321 |
| 322 // static | 322 // static |
| 323 bool NetworkState::ErrorIsValid(const std::string& error) { | 323 bool NetworkState::ErrorIsValid(const std::string& error) { |
| 324 // Shill uses "Unknown" to indicate an unset or cleared error state. | 324 // Shill uses "Unknown" to indicate an unset or cleared error state. |
| 325 return !error.empty() && error != kErrorUnknown; | 325 return !error.empty() && error != kErrorUnknown; |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace chromeos | 328 } // namespace chromeos |
| OLD | NEW |