| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "chromeos/network/network_profile_handler.h" | 13 #include "chromeos/network/network_profile_handler.h" |
| 14 #include "chromeos/network/network_type_pattern.h" | 14 #include "chromeos/network/network_type_pattern.h" |
| 15 #include "chromeos/network/network_util.h" | 15 #include "chromeos/network/network_util.h" |
| 16 #include "chromeos/network/onc/onc_utils.h" | 16 #include "chromeos/network/onc/onc_utils.h" |
| 17 #include "chromeos/network/shill_property_util.h" | 17 #include "chromeos/network/shill_property_util.h" |
| 18 #include "chromeos/network/tether_constants.h" |
| 18 #include "components/device_event_log/device_event_log.h" | 19 #include "components/device_event_log/device_event_log.h" |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" | 20 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const char kErrorUnknown[] = "Unknown"; | 24 const char kErrorUnknown[] = "Unknown"; |
| 24 | 25 |
| 25 bool ConvertListValueToStringVector(const base::ListValue& string_list, | 26 bool ConvertListValueToStringVector(const base::ListValue& string_list, |
| 26 std::vector<std::string>* result) { | 27 std::vector<std::string>* result) { |
| 27 for (size_t i = 0; i < string_list.GetSize(); ++i) { | 28 for (size_t i = 0; i < string_list.GetSize(); ++i) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 provider_property->SetStringWithoutPathExpansion(shill::kTypeProperty, | 255 provider_property->SetStringWithoutPathExpansion(shill::kTypeProperty, |
| 255 vpn_provider_type_); | 256 vpn_provider_type_); |
| 256 if (vpn_provider_type_ == shill::kProviderThirdPartyVpn) { | 257 if (vpn_provider_type_ == shill::kProviderThirdPartyVpn) { |
| 257 provider_property->SetStringWithoutPathExpansion( | 258 provider_property->SetStringWithoutPathExpansion( |
| 258 shill::kHostProperty, third_party_vpn_provider_extension_id_); | 259 shill::kHostProperty, third_party_vpn_provider_extension_id_); |
| 259 } | 260 } |
| 260 dictionary->SetWithoutPathExpansion(shill::kProviderProperty, | 261 dictionary->SetWithoutPathExpansion(shill::kProviderProperty, |
| 261 provider_property.release()); | 262 provider_property.release()); |
| 262 } | 263 } |
| 263 | 264 |
| 265 // Tether properties |
| 266 if (NetworkTypePattern::Tether().MatchesType(type())) { |
| 267 dictionary->SetIntegerWithoutPathExpansion(kTetherBatteryPercentage, |
| 268 battery_percentage()); |
| 269 dictionary->SetStringWithoutPathExpansion(kTetherCarrier, carrier()); |
| 270 dictionary->SetIntegerWithoutPathExpansion(kTetherSignalStrength, |
| 271 signal_strength()); |
| 272 } |
| 273 |
| 264 // Wireless properties | 274 // Wireless properties |
| 265 if (!NetworkTypePattern::Wireless().MatchesType(type())) | 275 if (!NetworkTypePattern::Wireless().MatchesType(type())) |
| 266 return; | 276 return; |
| 267 | 277 |
| 268 if (visible()) { | 278 if (visible()) { |
| 269 dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty, | 279 dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty, |
| 270 connectable()); | 280 connectable()); |
| 271 dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty, | 281 dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty, |
| 272 signal_strength()); | 282 signal_strength()); |
| 273 } | 283 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 return IsCaptivePortalState(shill_properties, false /* log */); | 460 return IsCaptivePortalState(shill_properties, false /* log */); |
| 451 } | 461 } |
| 452 | 462 |
| 453 // static | 463 // static |
| 454 bool NetworkState::ErrorIsValid(const std::string& error) { | 464 bool NetworkState::ErrorIsValid(const std::string& error) { |
| 455 // Shill uses "Unknown" to indicate an unset or cleared error state. | 465 // Shill uses "Unknown" to indicate an unset or cleared error state. |
| 456 return !error.empty() && error != kErrorUnknown; | 466 return !error.empty() && error != kErrorUnknown; |
| 457 } | 467 } |
| 458 | 468 |
| 459 } // namespace chromeos | 469 } // namespace chromeos |
| OLD | NEW |