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/logging.h" |
| 8 #include "base/values.h" |
| 9 |
| 10 namespace chromeos { |
| 11 |
| 12 NetworkState::NetworkState(const std::string& path) |
| 13 : ManagedState(MANAGED_TYPE_NETWORK, path), |
| 14 strength_(0) { |
| 15 } |
| 16 |
| 17 bool NetworkState::PropertyChanged(const std::string& key, |
| 18 const base::Value& value) { |
| 19 if (key == flimflam::kSignalStrengthProperty) { |
| 20 return value.GetAsInteger(&strength_); |
| 21 } else if (key == flimflam::kStateProperty) { |
| 22 return value.GetAsString(&state_); |
| 23 } else if (key == flimflam::kErrorProperty) { |
| 24 return value.GetAsString(&error_); |
| 25 } else if (key == flimflam::kActivationStateProperty) { |
| 26 return value.GetAsString(&activation_); |
| 27 } else if (key == flimflam::kRoamingStateProperty) { |
| 28 return value.GetAsString(&roaming_); |
| 29 } else if (key == flimflam::kNameProperty) { |
| 30 return value.GetAsString(&name_); |
| 31 } else if (key == flimflam::kTypeProperty) { |
| 32 return value.GetAsString(&type_); |
| 33 } else if (key == flimflam::kSecurityProperty) { |
| 34 return value.GetAsString(&security_); |
| 35 } else if (key == flimflam::kNetworkTechnologyProperty) { |
| 36 return value.GetAsString(&technology_); |
| 37 } else if (key == flimflam::kDeviceProperty) { |
| 38 return value.GetAsString(&device_path_); |
| 39 } |
| 40 return true; |
| 41 } |
| 42 |
| 43 bool NetworkState::IsConnectedState() const { |
| 44 return StateIsConnected(state_); |
| 45 } |
| 46 |
| 47 bool NetworkState::IsConnectingState() const { |
| 48 return StateIsConnecting(state_); |
| 49 } |
| 50 |
| 51 // static |
| 52 bool NetworkState::StateIsConnected(const std::string& state) { |
| 53 return (state == flimflam::kStateReady || |
| 54 state == flimflam::kStateOnline || |
| 55 state == flimflam::kStatePortal); |
| 56 } |
| 57 |
| 58 // static |
| 59 bool NetworkState::StateIsConnecting(const std::string& state) { |
| 60 return (state == flimflam::kStateAssociation || |
| 61 state == flimflam::kStateConfiguration || |
| 62 state == flimflam::kStateCarrier); |
| 63 } |
| 64 |
| 65 } // namespace chromeos |
OLD | NEW |