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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ManagedState::GetStateProperties(dictionary); |
| 178 GetNetworkStateProperties(dictionary); |
| 179 if (visible()) |
| 180 GetVisibleStateProperties(dictionary); |
| 181 } |
178 | 182 |
179 // Properties shared by all types. | 183 void NetworkState::GetConfigurationStateProperties( |
| 184 base::DictionaryValue* dictionary) const { |
| 185 ManagedState::GetStateProperties(dictionary); |
| 186 GetNetworkStateProperties(dictionary); |
| 187 } |
| 188 |
| 189 void NetworkState::GetNetworkStateProperties( |
| 190 base::DictionaryValue* dictionary) const { |
180 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); | 191 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); |
181 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty, | 192 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty, |
182 security()); | 193 security()); |
183 | 194 |
184 if (visible()) { | |
185 if (!error().empty()) | |
186 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); | |
187 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, | |
188 connection_state()); | |
189 } | |
190 | |
191 // Wireless properties | |
192 if (!NetworkTypePattern::Wireless().MatchesType(type())) | |
193 return; | |
194 | |
195 if (visible()) { | |
196 dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty, | |
197 connectable()); | |
198 dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty, | |
199 signal_strength()); | |
200 } | |
201 | |
202 // Wifi properties | 195 // Wifi properties |
203 if (NetworkTypePattern::WiFi().MatchesType(type())) { | 196 if (NetworkTypePattern::WiFi().MatchesType(type())) { |
204 dictionary->SetStringWithoutPathExpansion(shill::kEapMethodProperty, | 197 dictionary->SetStringWithoutPathExpansion(shill::kEapMethodProperty, |
205 eap_method()); | 198 eap_method()); |
206 } | 199 } |
207 | 200 |
208 // Mobile properties | 201 // Mobile properties |
209 if (NetworkTypePattern::Mobile().MatchesType(type())) { | 202 if (NetworkTypePattern::Mobile().MatchesType(type())) { |
210 dictionary->SetStringWithoutPathExpansion( | 203 dictionary->SetStringWithoutPathExpansion( |
211 shill::kNetworkTechnologyProperty, | 204 shill::kNetworkTechnologyProperty, |
212 network_technology()); | 205 network_technology()); |
| 206 } |
| 207 } |
| 208 |
| 209 void NetworkState::GetVisibleStateProperties( |
| 210 base::DictionaryValue* dictionary) const { |
| 211 dictionary->SetStringWithoutPathExpansion(shill::kStateProperty, |
| 212 connection_state()); |
| 213 if (!error().empty()) |
| 214 dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error()); |
| 215 |
| 216 // Wireless properties |
| 217 if (NetworkTypePattern::Wireless().MatchesType(type())) { |
| 218 dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty, |
| 219 connectable()); |
| 220 dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty, |
| 221 signal_strength()); |
| 222 } |
| 223 |
| 224 // Mobile properties |
| 225 if (NetworkTypePattern::Mobile().MatchesType(type())) { |
213 dictionary->SetStringWithoutPathExpansion(shill::kActivationStateProperty, | 226 dictionary->SetStringWithoutPathExpansion(shill::kActivationStateProperty, |
214 activation_state()); | 227 activation_state()); |
215 dictionary->SetStringWithoutPathExpansion(shill::kRoamingStateProperty, | 228 dictionary->SetStringWithoutPathExpansion(shill::kRoamingStateProperty, |
216 roaming()); | 229 roaming()); |
217 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, | 230 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, |
218 cellular_out_of_credits()); | 231 cellular_out_of_credits()); |
219 } | 232 } |
220 } | 233 } |
221 | 234 |
222 void NetworkState::IPConfigPropertiesChanged( | 235 void NetworkState::IPConfigPropertiesChanged( |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 connection_state == shill::kStateCarrier); | 357 connection_state == shill::kStateCarrier); |
345 } | 358 } |
346 | 359 |
347 // static | 360 // static |
348 bool NetworkState::ErrorIsValid(const std::string& error) { | 361 bool NetworkState::ErrorIsValid(const std::string& error) { |
349 // Shill uses "Unknown" to indicate an unset or cleared error state. | 362 // Shill uses "Unknown" to indicate an unset or cleared error state. |
350 return !error.empty() && error != kErrorUnknown; | 363 return !error.empty() && error != kErrorUnknown; |
351 } | 364 } |
352 | 365 |
353 } // namespace chromeos | 366 } // namespace chromeos |
OLD | NEW |