Chromium Code Reviews| Index: chromeos/network/network_state.cc |
| diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ff1658d28b182f8f485f05cf68a5b25ca6b7320e |
| --- /dev/null |
| +++ b/chromeos/network/network_state.cc |
| @@ -0,0 +1,65 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chromeos/network/network_state.h" |
| + |
| +#include "base/values.h" |
| +#include "third_party/cros_system_api/dbus/service_constants.h" |
| + |
| +namespace chromeos { |
| + |
| +NetworkState::NetworkState(const std::string& path) |
| + : ManagedState(MANAGED_TYPE_NETWORK, path), |
| + strength_(0) { |
|
gauravsh
2012/10/25 23:41:05
If you explicitly initializing this, I'd explicitl
stevenjb
2012/10/26 21:36:39
I realized this hasn't been implemented yet (it's
|
| +} |
| + |
| +bool NetworkState::PropertyChanged(const std::string& key, |
| + const base::Value& value) { |
| + if (key == flimflam::kSignalStrengthProperty) { |
| + return value.GetAsInteger(&strength_); |
| + } else if (key == flimflam::kStateProperty) { |
| + return value.GetAsString(&state_); |
| + } else if (key == flimflam::kErrorProperty) { |
| + return value.GetAsString(&error_); |
| + } else if (key == flimflam::kActivationStateProperty) { |
| + return value.GetAsString(&activation_); |
| + } else if (key == flimflam::kRoamingStateProperty) { |
| + return value.GetAsString(&roaming_); |
| + } else if (key == flimflam::kNameProperty) { |
| + return value.GetAsString(&name_); |
| + } else if (key == flimflam::kTypeProperty) { |
| + return value.GetAsString(&type_); |
| + } else if (key == flimflam::kSecurityProperty) { |
| + return value.GetAsString(&security_); |
| + } else if (key == flimflam::kNetworkTechnologyProperty) { |
| + return value.GetAsString(&technology_); |
| + } else if (key == flimflam::kDeviceProperty) { |
| + return value.GetAsString(&device_path_); |
| + } |
| + return true; |
| +} |
| + |
| +bool NetworkState::IsConnectedState() const { |
| + return StateIsConnected(state_); |
| +} |
| + |
| +bool NetworkState::IsConnectingState() const { |
| + return StateIsConnecting(state_); |
| +} |
| + |
| +// static |
| +bool NetworkState::StateIsConnected(const std::string& state) { |
| + return (state == flimflam::kStateReady || |
| + state == flimflam::kStateOnline || |
| + state == flimflam::kStatePortal); |
| +} |
| + |
| +// static |
| +bool NetworkState::StateIsConnecting(const std::string& state) { |
| + return (state == flimflam::kStateAssociation || |
| + state == flimflam::kStateConfiguration || |
| + state == flimflam::kStateCarrier); |
| +} |
| + |
| +} // namespace chromeos |