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 "chromeos/network/network_event_log.h" | 8 #include "chromeos/network/network_event_log.h" |
9 #include "chromeos/network/network_profile_handler.h" | 9 #include "chromeos/network/network_profile_handler.h" |
10 #include "chromeos/network/network_type_pattern.h" | 10 #include "chromeos/network/network_type_pattern.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 // SignalStrength > 0. | 167 // SignalStrength > 0. |
168 if ((type() == shill::kTypeWifi || type() == shill::kTypeWimax) && | 168 if ((type() == shill::kTypeWifi || type() == shill::kTypeWimax) && |
169 visible() && signal_strength_ <= 0) { | 169 visible() && signal_strength_ <= 0) { |
170 signal_strength_ = 1; | 170 signal_strength_ = 1; |
171 } | 171 } |
172 | 172 |
173 return changed; | 173 return changed; |
174 } | 174 } |
175 | 175 |
176 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { | 176 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { |
177 ManagedState::GetStateProperties(dictionary); | 177 GetConfigurationStateProperties(dictionary); |
178 | 178 |
pneubeck (no reviews)
2014/11/11 16:09:31
maybe add a comment that the remainder of this fun
| |
179 // Properties shared by all types. | 179 if (!visible()) |
180 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); | 180 return; |
181 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty, | |
182 security()); | |
183 | 181 |
184 if (visible()) { | 182 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, |
185 if (!error().empty()) | 183 connection_state()); |
186 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); | 184 if (!error().empty()) |
187 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, | 185 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); |
188 connection_state()); | |
189 } | |
190 | 186 |
191 // Wireless properties | 187 // Wireless properties |
192 if (!NetworkTypePattern::Wireless().MatchesType(type())) | 188 if (NetworkTypePattern::Wireless().MatchesType(type())) { |
193 return; | |
194 | |
195 if (visible()) { | |
196 dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty, | 189 dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty, |
197 connectable()); | 190 connectable()); |
198 dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty, | 191 dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty, |
199 signal_strength()); | 192 signal_strength()); |
200 } | 193 } |
201 | 194 |
195 // Mobile properties | |
196 if (NetworkTypePattern::Mobile().MatchesType(type())) { | |
197 dictionary->SetStringWithoutPathExpansion(shill::kActivationStateProperty, | |
198 activation_state()); | |
199 dictionary->SetStringWithoutPathExpansion(shill::kRoamingStateProperty, | |
200 roaming()); | |
201 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, | |
202 cellular_out_of_credits()); | |
203 } | |
204 } | |
205 | |
206 void NetworkState::GetConfigurationStateProperties( | |
207 base::DictionaryValue* dictionary) const { | |
208 // Properties shared by all types. | |
209 ManagedState::GetStateProperties(dictionary); | |
pneubeck (no reviews)
2014/11/11 16:09:31
this seems not intuitive.
The function description
stevenjb
2014/11/12 01:23:29
Separated out GetNetworkStateProperties and GetVis
| |
210 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); | |
211 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty, | |
212 security()); | |
213 | |
202 // Wifi properties | 214 // Wifi properties |
203 if (NetworkTypePattern::WiFi().MatchesType(type())) { | 215 if (NetworkTypePattern::WiFi().MatchesType(type())) { |
204 dictionary->SetStringWithoutPathExpansion(shill::kEapMethodProperty, | 216 dictionary->SetStringWithoutPathExpansion(shill::kEapMethodProperty, |
205 eap_method()); | 217 eap_method()); |
206 } | 218 } |
207 | 219 |
208 // Mobile properties | 220 // Mobile properties |
209 if (NetworkTypePattern::Mobile().MatchesType(type())) { | 221 if (NetworkTypePattern::Mobile().MatchesType(type())) { |
210 dictionary->SetStringWithoutPathExpansion( | 222 dictionary->SetStringWithoutPathExpansion( |
211 shill::kNetworkTechnologyProperty, | 223 shill::kNetworkTechnologyProperty, |
212 network_technology()); | 224 network_technology()); |
213 dictionary->SetStringWithoutPathExpansion(shill::kActivationStateProperty, | |
214 activation_state()); | |
215 dictionary->SetStringWithoutPathExpansion(shill::kRoamingStateProperty, | |
216 roaming()); | |
217 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, | |
218 cellular_out_of_credits()); | |
219 } | 225 } |
220 } | 226 } |
221 | 227 |
222 void NetworkState::IPConfigPropertiesChanged( | 228 void NetworkState::IPConfigPropertiesChanged( |
223 const base::DictionaryValue& properties) { | 229 const base::DictionaryValue& properties) { |
224 for (base::DictionaryValue::Iterator iter(properties); | 230 for (base::DictionaryValue::Iterator iter(properties); |
225 !iter.IsAtEnd(); iter.Advance()) { | 231 !iter.IsAtEnd(); iter.Advance()) { |
226 std::string key = iter.key(); | 232 std::string key = iter.key(); |
227 const base::Value& value = iter.value(); | 233 const base::Value& value = iter.value(); |
228 | 234 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 connection_state == shill::kStateCarrier); | 350 connection_state == shill::kStateCarrier); |
345 } | 351 } |
346 | 352 |
347 // static | 353 // static |
348 bool NetworkState::ErrorIsValid(const std::string& error) { | 354 bool NetworkState::ErrorIsValid(const std::string& error) { |
349 // Shill uses "Unknown" to indicate an unset or cleared error state. | 355 // Shill uses "Unknown" to indicate an unset or cleared error state. |
350 return !error.empty() && error != kErrorUnknown; | 356 return !error.empty() && error != kErrorUnknown; |
351 } | 357 } |
352 | 358 |
353 } // namespace chromeos | 359 } // namespace chromeos |
OLD | NEW |