Add NetworkState::RequiresActivation.

Added a utility function to NetworkState to query if a network
requires activation. All UI code should use this instead of comparing the
Cellular.ActivationState property themselves, as this utility function
handles the "unknown" case as well.

BUG=289470
R=stevenjb@chromium.org

Review URL: https://codereview.chromium.org/23532065

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223472 0039d316-1c4b-4281-b951-d872f2087c98
parent 0fb06ccf
......@@ -270,7 +270,7 @@ void HandleUnconfiguredNetwork(const std::string& service_path,
}
if (network->type() == flimflam::kTypeCellular) {
if (network->activation_state() != flimflam::kActivationStateActivated) {
if (network->RequiresActivation()) {
ash::network_connect::ActivateCellular(service_path);
return;
}
......
......@@ -47,12 +47,6 @@ bool IsAuthenticationError(const std::string& error) {
error == shill::kErrorEapAuthenticationFailed);
}
bool NetworkRequiresActivation(const NetworkState* network) {
return (network->type() == flimflam::kTypeCellular &&
((network->activation_state() != flimflam::kActivationStateActivated &&
network->activation_state() != flimflam::kActivationStateUnknown)));
}
bool VPNIsConfigured(const std::string& service_path,
const std::string& provider_type,
const base::DictionaryValue& provider_properties) {
......@@ -230,7 +224,7 @@ void NetworkConnectionHandler::ConnectToNetwork(
InvokeErrorCallback(service_path, error_callback, kErrorConnecting);
return;
}
if (NetworkRequiresActivation(network)) {
if (network->RequiresActivation()) {
InvokeErrorCallback(service_path, error_callback,
kErrorActivationRequired);
return;
......
......@@ -240,6 +240,12 @@ void NetworkState::GetProperties(base::DictionaryValue* dictionary) const {
cellular_out_of_credits_);
}
bool NetworkState::RequiresActivation() const {
return (type() == flimflam::kTypeCellular &&
activation_state() != flimflam::kActivationStateActivated &&
activation_state() != flimflam::kActivationStateUnknown);
}
bool NetworkState::IsConnectedState() const {
return StateIsConnected(connection_state_);
}
......
......@@ -38,6 +38,9 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
// stored.
void GetProperties(base::DictionaryValue* dictionary) const;
// Returns true, if the network requires a service activation.
bool RequiresActivation() const;
// Accessors
const std::string& security() const { return security_; }
const std::string& device_path() const { return device_path_; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment