| 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 "ui/chromeos/network/network_connect.h" | 5 #include "ui/chromeos/network/network_connect.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 200 |
| 201 // This handles connect failures that are a direct result of a user initiated | 201 // This handles connect failures that are a direct result of a user initiated |
| 202 // connect request and result in a new UI being shown. Note: notifications are | 202 // connect request and result in a new UI being shown. Note: notifications are |
| 203 // handled by NetworkStateNotifier. | 203 // handled by NetworkStateNotifier. |
| 204 void NetworkConnectImpl::OnConnectFailed( | 204 void NetworkConnectImpl::OnConnectFailed( |
| 205 const std::string& service_path, | 205 const std::string& service_path, |
| 206 const std::string& error_name, | 206 const std::string& error_name, |
| 207 scoped_ptr<base::DictionaryValue> error_data) { | 207 scoped_ptr<base::DictionaryValue> error_data) { |
| 208 NET_LOG_ERROR("Connect Failed: " + error_name, service_path); | 208 NET_LOG_ERROR("Connect Failed: " + error_name, service_path); |
| 209 | 209 |
| 210 // If a new connect attempt canceled this connect, or a connect attempt to |
| 211 // the same network is in progress, no need to notify the user here since they |
| 212 // will be notified when the new or existing attempt completes. |
| 213 if (error_name == NetworkConnectionHandler::kErrorConnectCanceled || |
| 214 error_name == NetworkConnectionHandler::kErrorConnecting) { |
| 215 return; |
| 216 } |
| 217 |
| 218 // Already connected to the network, show the settings UI for the network. |
| 219 if (error_name == NetworkConnectionHandler::kErrorConnected) { |
| 220 ShowNetworkSettingsForPath(service_path); |
| 221 return; |
| 222 } |
| 223 |
| 210 if (error_name == NetworkConnectionHandler::kErrorBadPassphrase || | 224 if (error_name == NetworkConnectionHandler::kErrorBadPassphrase || |
| 211 error_name == NetworkConnectionHandler::kErrorPassphraseRequired || | 225 error_name == NetworkConnectionHandler::kErrorPassphraseRequired || |
| 212 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || | 226 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || |
| 213 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { | 227 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { |
| 214 HandleUnconfiguredNetwork(service_path); | 228 HandleUnconfiguredNetwork(service_path); |
| 215 return; | 229 return; |
| 216 } | 230 } |
| 217 | 231 |
| 218 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { | 232 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { |
| 219 if (!delegate_->ShowEnrollNetwork(service_path)) | 233 if (!delegate_->ShowEnrollNetwork(service_path)) |
| 220 HandleUnconfiguredNetwork(service_path); | 234 HandleUnconfiguredNetwork(service_path); |
| 221 return; | 235 return; |
| 222 } | 236 } |
| 223 | 237 |
| 224 // Only show a configure dialog if there was a ConnectFailed error. The dialog | 238 // Only show a configure dialog if there was a ConnectFailed error. The dialog |
| 225 // allows the user to request a new connect attempt or cancel. Note: a | 239 // allows the user to request a new connect attempt or cancel. Note: a |
| 226 // notification may also be displayed by NetworkStateNotifier in this case. | 240 // notification may also be displayed by NetworkStateNotifier in this case. |
| 227 if (error_name == NetworkConnectionHandler::kErrorConnectFailed) | 241 if (error_name == NetworkConnectionHandler::kErrorConnectFailed) |
| 228 HandleUnconfiguredNetwork(service_path); | 242 HandleUnconfiguredNetwork(service_path); |
| 229 | 243 |
| 230 // Notifications for other connect failures are handled by | 244 // Notifications for other connect failures are handled by |
| 231 // NetworkStateNotifier, so no need to do anything else here. | 245 // NetworkStateNotifier, so no need to do anything else here. |
| 232 } | 246 } |
| 233 | 247 |
| 234 void NetworkConnectImpl::OnConnectSucceeded(const std::string& service_path) { | 248 void NetworkConnectImpl::OnConnectSucceeded(const std::string& service_path) { |
| 235 NET_LOG_USER("Connect Succeeded", service_path); | 249 NET_LOG_USER("Connect Succeeded", service_path); |
| 250 network_state_notifier_->RemoveConnectNotification(); |
| 236 } | 251 } |
| 237 | 252 |
| 238 // If |check_error_state| is true, error state for the network is checked, | 253 // If |check_error_state| is true, error state for the network is checked, |
| 239 // otherwise any current error state is ignored (e.g. for recently configured | 254 // otherwise any current error state is ignored (e.g. for recently configured |
| 240 // networks or repeat connect attempts). | 255 // networks or repeat connect attempts). |
| 241 void NetworkConnectImpl::CallConnectToNetwork(const std::string& service_path, | 256 void NetworkConnectImpl::CallConnectToNetwork(const std::string& service_path, |
| 242 bool check_error_state) { | 257 bool check_error_state) { |
| 258 network_state_notifier_->RemoveConnectNotification(); |
| 243 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( | 259 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( |
| 244 service_path, base::Bind(&NetworkConnectImpl::OnConnectSucceeded, | 260 service_path, base::Bind(&NetworkConnectImpl::OnConnectSucceeded, |
| 245 weak_factory_.GetWeakPtr(), service_path), | 261 weak_factory_.GetWeakPtr(), service_path), |
| 246 base::Bind(&NetworkConnectImpl::OnConnectFailed, | 262 base::Bind(&NetworkConnectImpl::OnConnectFailed, |
| 247 weak_factory_.GetWeakPtr(), service_path), | 263 weak_factory_.GetWeakPtr(), service_path), |
| 248 check_error_state); | 264 check_error_state); |
| 249 } | 265 } |
| 250 | 266 |
| 251 void NetworkConnectImpl::OnActivateFailed( | 267 void NetworkConnectImpl::OnActivateFailed( |
| 252 const std::string& service_path, | 268 const std::string& service_path, |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 return g_network_connect; | 645 return g_network_connect; |
| 630 } | 646 } |
| 631 | 647 |
| 632 NetworkConnect::NetworkConnect() { | 648 NetworkConnect::NetworkConnect() { |
| 633 } | 649 } |
| 634 | 650 |
| 635 NetworkConnect::~NetworkConnect() { | 651 NetworkConnect::~NetworkConnect() { |
| 636 } | 652 } |
| 637 | 653 |
| 638 } // namespace ui | 654 } // namespace ui |
| OLD | NEW |