Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: chromeos/network/network_connection_handler.cc

Issue 22340006: Show notifications for Network Config errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + move comment Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/network_connection_handler.h ('k') | chromeos/network/network_handler_callbacks.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_connection_handler.cc
diff --git a/chromeos/network/network_connection_handler.cc b/chromeos/network/network_connection_handler.cc
index f7ec8932948ed9095cd386605c78fb1966af94ef..25e03defdc509e9f05915969de7b70d1cc8b2c24 100644
--- a/chromeos/network/network_connection_handler.cc
+++ b/chromeos/network/network_connection_handler.cc
@@ -119,8 +119,14 @@ const char NetworkConnectionHandler::kErrorAuthenticationRequired[] =
"authentication-required";
const char NetworkConnectionHandler::kErrorShillError[] = "shill-error";
const char NetworkConnectionHandler::kErrorConnectFailed[] = "connect-failed";
+const char NetworkConnectionHandler::kErrorConfigureFailed[] =
+ "configure-failed";
+const char NetworkConnectionHandler::kErrorActivateFailed[] =
+ "activate-failed";
const char NetworkConnectionHandler::kErrorMissingProvider[] =
"missing-provider";
+const char NetworkConnectionHandler::kErrorConnectCanceled[] =
+ "connect-canceled";
const char NetworkConnectionHandler::kErrorUnknown[] = "unknown-error";
struct NetworkConnectionHandler::ConnectRequest {
@@ -244,6 +250,26 @@ void NetworkConnectionHandler::ConnectToNetwork(
return;
}
+ if (check_error_state) {
+ const std::string& error = network->error();
+ if (error == flimflam::kErrorConnectFailed) {
+ InvokeErrorCallback(
+ service_path, error_callback, kErrorPassphraseRequired);
+ return;
+ }
+ if (error == flimflam::kErrorBadPassphrase) {
+ InvokeErrorCallback(
+ service_path, error_callback, kErrorPassphraseRequired);
+ return;
+ }
+
+ if (IsAuthenticationError(error)) {
+ InvokeErrorCallback(
+ service_path, error_callback, kErrorAuthenticationRequired);
+ return;
+ }
+ }
+
// All synchronous checks passed, add |service_path| to connecting list.
pending_requests_.insert(std::make_pair(
service_path,
@@ -340,30 +366,6 @@ void NetworkConnectionHandler::VerifyConfiguredAndConnect(
const base::DictionaryValue& service_properties) {
NET_LOG_EVENT("VerifyConfiguredAndConnect", service_path);
- std::string type;
- service_properties.GetStringWithoutPathExpansion(
- flimflam::kTypeProperty, &type);
-
- if (check_error_state) {
- std::string error;
- service_properties.GetStringWithoutPathExpansion(
- flimflam::kErrorProperty, &error);
- if (error == flimflam::kErrorConnectFailed) {
- ErrorCallbackForPendingRequest(service_path, kErrorPassphraseRequired);
- return;
- }
- if (error == flimflam::kErrorBadPassphrase) {
- ErrorCallbackForPendingRequest(service_path, kErrorPassphraseRequired);
- return;
- }
-
- if (IsAuthenticationError(error)) {
- ErrorCallbackForPendingRequest(service_path,
- kErrorAuthenticationRequired);
- return;
- }
- }
-
// If 'passphrase_required' is still true, then the 'Passphrase' property
// has not been set to a minimum length value.
bool passphrase_required = false;
@@ -374,6 +376,10 @@ void NetworkConnectionHandler::VerifyConfiguredAndConnect(
return;
}
+ std::string type;
+ service_properties.GetStringWithoutPathExpansion(
+ flimflam::kTypeProperty, &type);
+
// Get VPN provider type and host (required for configuration) and ensure
// that required VPN non-cert properties are set.
std::string vpn_provider_type, vpn_provider_host;
@@ -540,7 +546,7 @@ void NetworkConnectionHandler::HandleConfigurationFailure(
network_handler::ErrorCallback error_callback = request->error_callback;
pending_requests_.erase(service_path);
if (!error_callback.is_null())
- error_callback.Run(error_name, error_data.Pass());
+ error_callback.Run(kErrorConfigureFailed, error_data.Pass());
}
void NetworkConnectionHandler::HandleShillConnectSuccess(
@@ -599,13 +605,21 @@ void NetworkConnectionHandler::CheckPendingRequest(
}
// Network is neither connecting or connected; an error occurred.
- std::string error_name = kErrorConnectFailed;
- std::string error_detail = network->error();
- if (error_detail.empty()) {
- if (network->connection_state() == flimflam::kStateFailure)
- error_detail = flimflam::kUnknownString;
- else
- error_detail = "Unexpected State: " + network->connection_state();
+ std::string error_name, error_detail;
+ if (network->connection_state() == flimflam::kStateIdle &&
+ pending_requests_.size() > 1) {
+ // Another connect request canceled this one.
+ error_name = kErrorConnectCanceled;
+ error_detail = "";
+ } else {
+ error_name = kErrorConnectFailed;
+ error_detail = network->error();
+ if (error_detail.empty()) {
+ if (network->connection_state() == flimflam::kStateFailure)
+ error_detail = flimflam::kUnknownString;
+ else
+ error_detail = "Unexpected State: " + network->connection_state();
+ }
}
std::string error_msg = error_name + ": " + error_detail;
NET_LOG_ERROR(error_msg, service_path);
« no previous file with comments | « chromeos/network/network_connection_handler.h ('k') | chromeos/network/network_handler_callbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698