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/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/values.h" | 8 #include "base/values.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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 return false; | 123 return false; |
124 } | 124 } |
125 | 125 |
126 bool NetworkState::InitialPropertiesReceived( | 126 bool NetworkState::InitialPropertiesReceived( |
127 const base::DictionaryValue& properties) { | 127 const base::DictionaryValue& properties) { |
128 NET_LOG_DEBUG("InitialPropertiesReceived", path()); | 128 NET_LOG_DEBUG("InitialPropertiesReceived", path()); |
129 bool changed = false; | 129 bool changed = false; |
130 if (!properties.HasKey(shill::kTypeProperty)) { | 130 if (!properties.HasKey(shill::kTypeProperty)) { |
131 NET_LOG_ERROR("NetworkState has no type", | 131 NET_LOG_ERROR("NetworkState has no type", |
132 shill_property_util::GetNetworkIdFromProperties(properties)); | 132 shill_property_util::GetNetworkIdFromProperties(properties)); |
133 } else { | 133 return false; |
134 changed |= UpdateName(properties); | |
135 } | 134 } |
135 // Ensure that the network has a valid name. | |
136 changed |= UpdateName(properties); | |
137 | |
138 // Set the ca_cert_nss_ property. | |
136 bool had_ca_cert_nss = has_ca_cert_nss_; | 139 bool had_ca_cert_nss = has_ca_cert_nss_; |
137 has_ca_cert_nss_ = IsCaCertNssSet(properties); | 140 has_ca_cert_nss_ = IsCaCertNssSet(properties); |
138 changed |= had_ca_cert_nss != has_ca_cert_nss_; | 141 changed |= had_ca_cert_nss != has_ca_cert_nss_; |
142 | |
143 // By convention, all visible WiFi networks have a SignalStrength > 0. | |
pneubeck (no reviews)
2014/05/08 13:25:12
unrelated?
stevenjb
2014/05/08 22:32:26
Yeah, I guess it is. I added this while working on
| |
144 if (type() == shill::kTypeWifi) { | |
145 if (signal_strength_ <= 0) | |
146 signal_strength_ = 1; | |
147 } | |
148 | |
139 return changed; | 149 return changed; |
140 } | 150 } |
141 | 151 |
142 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { | 152 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { |
143 ManagedState::GetStateProperties(dictionary); | 153 ManagedState::GetStateProperties(dictionary); |
144 | 154 |
145 // Properties shared by all types. | 155 // Properties shared by all types. |
146 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); | 156 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); |
147 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, | 157 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, |
148 connection_state()); | 158 connection_state()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 result += ","; | 255 result += ","; |
246 result += dns_servers_[i]; | 256 result += dns_servers_[i]; |
247 } | 257 } |
248 return result; | 258 return result; |
249 } | 259 } |
250 | 260 |
251 std::string NetworkState::GetNetmask() const { | 261 std::string NetworkState::GetNetmask() const { |
252 return network_util::PrefixLengthToNetmask(prefix_length_); | 262 return network_util::PrefixLengthToNetmask(prefix_length_); |
253 } | 263 } |
254 | 264 |
265 void NetworkState::SetGuid(const std::string& guid) { | |
266 guid_ = guid; | |
267 } | |
268 | |
255 bool NetworkState::UpdateName(const base::DictionaryValue& properties) { | 269 bool NetworkState::UpdateName(const base::DictionaryValue& properties) { |
256 std::string updated_name = | 270 std::string updated_name = |
257 shill_property_util::GetNameFromProperties(path(), properties); | 271 shill_property_util::GetNameFromProperties(path(), properties); |
258 if (updated_name != name()) { | 272 if (updated_name != name()) { |
259 set_name(updated_name); | 273 set_name(updated_name); |
260 return true; | 274 return true; |
261 } | 275 } |
262 return false; | 276 return false; |
263 } | 277 } |
264 | 278 |
(...skipping 11 matching lines...) Expand all Loading... | |
276 connection_state == shill::kStateCarrier); | 290 connection_state == shill::kStateCarrier); |
277 } | 291 } |
278 | 292 |
279 // static | 293 // static |
280 bool NetworkState::ErrorIsValid(const std::string& error) { | 294 bool NetworkState::ErrorIsValid(const std::string& error) { |
281 // Shill uses "Unknown" to indicate an unset or cleared error state. | 295 // Shill uses "Unknown" to indicate an unset or cleared error state. |
282 return !error.empty() && error != kErrorUnknown; | 296 return !error.empty() && error != kErrorUnknown; |
283 } | 297 } |
284 | 298 |
285 } // namespace chromeos | 299 } // namespace chromeos |
OLD | NEW |