Index: chromeos/network/network_state.cc |
diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc |
index c87bdcb4763c9fdef56f09f60e16360a7e83b9d1..4346e5c58f67383321321390a8d66f239e5de73e 100644 |
--- a/chromeos/network/network_state.cc |
+++ b/chromeos/network/network_state.cc |
@@ -9,6 +9,10 @@ |
namespace chromeos { |
+const char NetworkState::kMatchTypeDefault[] = "default"; |
+const char NetworkState::kMatchTypeWireless[] = "wireless"; |
+const char NetworkState::kMatchTypeNonVirtual[] = "non-virtual"; |
+ |
NetworkState::NetworkState(const std::string& path) |
: ManagedState(MANAGED_TYPE_NETWORK, path), |
signal_strength_(0) { |
@@ -24,7 +28,7 @@ bool NetworkState::PropertyChanged(const std::string& key, |
if (key == flimflam::kSignalStrengthProperty) { |
return GetIntegerValue(key, value, &signal_strength_); |
} else if (key == flimflam::kStateProperty) { |
- return GetStringValue(key, value, &state_); |
+ return GetStringValue(key, value, &connection_state_); |
} else if (key == flimflam::kErrorProperty) { |
return GetStringValue(key, value, &error_); |
} else if (key == flimflam::kActivationStateProperty) { |
@@ -42,25 +46,34 @@ bool NetworkState::PropertyChanged(const std::string& key, |
} |
bool NetworkState::IsConnectedState() const { |
- return StateIsConnected(state_); |
+ return StateIsConnected(connection_state_); |
} |
bool NetworkState::IsConnectingState() const { |
- return StateIsConnecting(state_); |
+ return StateIsConnecting(connection_state_); |
+} |
+ |
+bool NetworkState::MatchesType(const std::string& match_type) const { |
+ return ((match_type == kMatchTypeDefault) || |
+ (match_type == type()) || |
+ (match_type == kMatchTypeNonVirtual && |
+ type() != flimflam::kTypeVPN) || |
+ (match_type == kMatchTypeWireless && |
+ type() != flimflam::kTypeEthernet && type() != flimflam::kTypeVPN)); |
} |
// static |
-bool NetworkState::StateIsConnected(const std::string& state) { |
- return (state == flimflam::kStateReady || |
- state == flimflam::kStateOnline || |
- state == flimflam::kStatePortal); |
+bool NetworkState::StateIsConnected(const std::string& connection_state) { |
+ return (connection_state == flimflam::kStateReady || |
+ connection_state == flimflam::kStateOnline || |
+ connection_state == flimflam::kStatePortal); |
} |
// static |
-bool NetworkState::StateIsConnecting(const std::string& state) { |
- return (state == flimflam::kStateAssociation || |
- state == flimflam::kStateConfiguration || |
- state == flimflam::kStateCarrier); |
+bool NetworkState::StateIsConnecting(const std::string& connection_state) { |
+ return (connection_state == flimflam::kStateAssociation || |
+ connection_state == flimflam::kStateConfiguration || |
+ connection_state == flimflam::kStateCarrier); |
} |
} // namespace chromeos |