| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/system/chromeos/network/network_connect.h" | 5 #include "ash/system/chromeos/network/network_connect.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/chromeos/network/network_observer.h" | 8 #include "ash/system/chromeos/network/network_observer.h" |
| 9 #include "ash/system/chromeos/network/network_state_notifier.h" | 9 #include "ash/system/chromeos/network/network_state_notifier.h" |
| 10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 void OnConnectFailed(const std::string& service_path, | 59 void OnConnectFailed(const std::string& service_path, |
| 60 gfx::NativeWindow owning_window, | 60 gfx::NativeWindow owning_window, |
| 61 const std::string& error_name, | 61 const std::string& error_name, |
| 62 scoped_ptr<base::DictionaryValue> error_data) { | 62 scoped_ptr<base::DictionaryValue> error_data) { |
| 63 NET_LOG_ERROR("Connect Failed: " + error_name, service_path); | 63 NET_LOG_ERROR("Connect Failed: " + error_name, service_path); |
| 64 | 64 |
| 65 // If a new connect attempt canceled this connect, no need to notify the user. | 65 // If a new connect attempt canceled this connect, no need to notify the user. |
| 66 if (error_name == NetworkConnectionHandler::kErrorConnectCanceled) | 66 if (error_name == NetworkConnectionHandler::kErrorConnectCanceled) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 if (error_name == NetworkConnectionHandler::kErrorPassphraseRequired || | 69 if (error_name == flimflam::kErrorBadPassphrase || |
| 70 error_name == NetworkConnectionHandler::kErrorPassphraseRequired || |
| 70 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || | 71 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || |
| 71 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { | 72 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { |
| 72 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( | 73 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( |
| 73 service_path); | 74 service_path); |
| 74 return; | 75 return; |
| 75 } | 76 } |
| 76 | 77 |
| 77 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { | 78 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { |
| 78 ash::Shell::GetInstance()->system_tray_delegate()->EnrollOrConfigureNetwork( | 79 ash::Shell::GetInstance()->system_tray_delegate()->EnrollOrConfigureNetwork( |
| 79 service_path, owning_window); | 80 service_path, owning_window); |
| 80 return; | 81 return; |
| 81 } | 82 } |
| 82 | 83 |
| 83 if (error_name == NetworkConnectionHandler::kErrorActivationRequired) { | 84 if (error_name == NetworkConnectionHandler::kErrorActivationRequired) { |
| 84 network_connect::ActivateCellular(service_path); | 85 network_connect::ActivateCellular(service_path); |
| 85 return; | 86 return; |
| 86 } | 87 } |
| 87 | 88 |
| 88 if (error_name == NetworkConnectionHandler::kErrorConnected || | 89 if (error_name == NetworkConnectionHandler::kErrorConnected || |
| 89 error_name == NetworkConnectionHandler::kErrorConnecting) { | 90 error_name == NetworkConnectionHandler::kErrorConnecting) { |
| 90 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings( | 91 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings( |
| 91 service_path); | 92 service_path); |
| 92 return; | 93 return; |
| 93 } | 94 } |
| 94 | 95 |
| 95 // ConnectFailed or unknown error; show a notification. | 96 // ConnectFailed or unknown error; show a notification. |
| 96 ShowErrorNotification(error_name, service_path); | 97 ShowErrorNotification(error_name, service_path); |
| 97 | 98 |
| 98 // Show a configure dialog for ConnectFailed errors. | 99 // Show a configure dialog for ConnectFailed errors. |
| 99 if (error_name != NetworkConnectionHandler::kErrorConnectFailed) | 100 if (error_name != flimflam::kErrorConnectFailed) |
| 100 return; | 101 return; |
| 101 | 102 |
| 102 // If Shill reports an InProgress error, don't try to configure the network. | 103 // If Shill reports an InProgress error, don't try to configure the network. |
| 103 std::string dbus_error_name; | 104 std::string dbus_error_name; |
| 104 error_data.get()->GetString( | 105 error_data.get()->GetString( |
| 105 chromeos::network_handler::kDbusErrorName, &dbus_error_name); | 106 chromeos::network_handler::kDbusErrorName, &dbus_error_name); |
| 106 if (dbus_error_name == kErrorInProgress) | 107 if (dbus_error_name == kErrorInProgress) |
| 107 return; | 108 return; |
| 108 | 109 |
| 109 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( | 110 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 NetworkObserver::ERROR_CONNECT_FAILED); | 131 NetworkObserver::ERROR_CONNECT_FAILED); |
| 131 | 132 |
| 132 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( | 133 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( |
| 133 service_path, | 134 service_path, |
| 134 base::Bind(&OnConnectSucceeded, service_path), | 135 base::Bind(&OnConnectSucceeded, service_path), |
| 135 base::Bind(&OnConnectFailed, service_path, owning_window), | 136 base::Bind(&OnConnectFailed, service_path, owning_window), |
| 136 check_error_state); | 137 check_error_state); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void OnActivateFailed(const std::string& service_path, | 140 void OnActivateFailed(const std::string& service_path, |
| 140 const std::string& error_name, | 141 const std::string& error_name, |
| 141 scoped_ptr<base::DictionaryValue> error_data) { | 142 scoped_ptr<base::DictionaryValue> error_data) { |
| 142 NET_LOG_ERROR("Unable to activate network", service_path); | 143 NET_LOG_ERROR("Unable to activate network", service_path); |
| 143 ShowErrorNotification( | 144 ShowErrorNotification(network_connect::kErrorActivateFailed, service_path); |
| 144 NetworkConnectionHandler::kErrorActivateFailed, service_path); | |
| 145 } | 145 } |
| 146 | 146 |
| 147 void OnActivateSucceeded(const std::string& service_path) { | 147 void OnActivateSucceeded(const std::string& service_path) { |
| 148 NET_LOG_USER("Activation Succeeded", service_path); | 148 NET_LOG_USER("Activation Succeeded", service_path); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void OnConfigureFailed(const std::string& error_name, | 151 void OnConfigureFailed(const std::string& error_name, |
| 152 scoped_ptr<base::DictionaryValue> error_data) { | 152 scoped_ptr<base::DictionaryValue> error_data) { |
| 153 NET_LOG_ERROR("Unable to configure network", ""); | 153 NET_LOG_ERROR("Unable to configure network", ""); |
| 154 ShowErrorNotification(NetworkConnectionHandler::kErrorConfigureFailed, ""); | 154 ShowErrorNotification(NetworkConnectionHandler::kErrorConfigureFailed, ""); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 base::Bind(&ClearPropertiesAndConnect, | 239 base::Bind(&ClearPropertiesAndConnect, |
| 240 service_path, | 240 service_path, |
| 241 properties_to_clear), | 241 properties_to_clear), |
| 242 base::Bind(&SetPropertiesFailed, "SetProperties", service_path)); | 242 base::Bind(&SetPropertiesFailed, "SetProperties", service_path)); |
| 243 } | 243 } |
| 244 | 244 |
| 245 } // namespace | 245 } // namespace |
| 246 | 246 |
| 247 namespace network_connect { | 247 namespace network_connect { |
| 248 | 248 |
| 249 const char kErrorActivateFailed[] = "activate-failed"; |
| 250 |
| 249 void ConnectToNetwork(const std::string& service_path, | 251 void ConnectToNetwork(const std::string& service_path, |
| 250 gfx::NativeWindow owning_window) { | 252 gfx::NativeWindow owning_window) { |
| 251 const bool check_error_state = true; | 253 const bool check_error_state = true; |
| 252 CallConnectToNetwork(service_path, check_error_state, owning_window); | 254 CallConnectToNetwork(service_path, check_error_state, owning_window); |
| 253 } | 255 } |
| 254 | 256 |
| 255 void ActivateCellular(const std::string& service_path) { | 257 void ActivateCellular(const std::string& service_path) { |
| 256 NET_LOG_USER("ActivateCellular", service_path); | 258 NET_LOG_USER("ActivateCellular", service_path); |
| 257 const NetworkState* cellular = | 259 const NetworkState* cellular = |
| 258 NetworkHandler::Get()->network_state_handler()-> | 260 NetworkHandler::Get()->network_state_handler()-> |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 if (StringToLowerASCII(error) == | 392 if (StringToLowerASCII(error) == |
| 391 StringToLowerASCII(std::string(flimflam::kUnknownString))) { | 393 StringToLowerASCII(std::string(flimflam::kUnknownString))) { |
| 392 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN); | 394 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN); |
| 393 } | 395 } |
| 394 return l10n_util::GetStringFUTF16(IDS_NETWORK_UNRECOGNIZED_ERROR, | 396 return l10n_util::GetStringFUTF16(IDS_NETWORK_UNRECOGNIZED_ERROR, |
| 395 UTF8ToUTF16(error)); | 397 UTF8ToUTF16(error)); |
| 396 } | 398 } |
| 397 | 399 |
| 398 } // network_connect | 400 } // network_connect |
| 399 } // ash | 401 } // ash |
| OLD | NEW |