OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chromeos/network/network_state.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 9 |
| 10 namespace chromeos { |
| 11 |
| 12 NetworkState::NetworkState(const std::string& path) |
| 13 : ManagedState(MANAGED_TYPE_NETWORK, path), |
| 14 signal_strength_(0) { |
| 15 } |
| 16 |
| 17 bool NetworkState::PropertyChanged(const std::string& key, |
| 18 const base::Value& value) { |
| 19 if (ManagedStatePropertyChanged(key, value)) |
| 20 return true; |
| 21 if (key == flimflam::kSignalStrengthProperty) { |
| 22 return GetIntegerValue(key, value, &signal_strength_); |
| 23 } else if (key == flimflam::kStateProperty) { |
| 24 return GetStringValue(key, value, &state_); |
| 25 } else if (key == flimflam::kErrorProperty) { |
| 26 return GetStringValue(key, value, &error_); |
| 27 } else if (key == flimflam::kActivationStateProperty) { |
| 28 return GetStringValue(key, value, &activation_state_); |
| 29 } else if (key == flimflam::kRoamingStateProperty) { |
| 30 return GetStringValue(key, value, &roaming_); |
| 31 } else if (key == flimflam::kSecurityProperty) { |
| 32 return GetStringValue(key, value, &security_); |
| 33 } else if (key == flimflam::kNetworkTechnologyProperty) { |
| 34 return GetStringValue(key, value, &technology_); |
| 35 } else if (key == flimflam::kDeviceProperty) { |
| 36 return GetStringValue(key, value, &device_path_); |
| 37 } |
| 38 return false; |
| 39 } |
| 40 |
| 41 bool NetworkState::IsConnectedState() const { |
| 42 return StateIsConnected(state_); |
| 43 } |
| 44 |
| 45 bool NetworkState::IsConnectingState() const { |
| 46 return StateIsConnecting(state_); |
| 47 } |
| 48 |
| 49 // static |
| 50 bool NetworkState::StateIsConnected(const std::string& state) { |
| 51 return (state == flimflam::kStateReady || |
| 52 state == flimflam::kStateOnline || |
| 53 state == flimflam::kStatePortal); |
| 54 } |
| 55 |
| 56 // static |
| 57 bool NetworkState::StateIsConnecting(const std::string& state) { |
| 58 return (state == flimflam::kStateAssociation || |
| 59 state == flimflam::kStateConfiguration || |
| 60 state == flimflam::kStateCarrier); |
| 61 } |
| 62 |
| 63 } // namespace chromeos |
OLD | NEW |