Chromium Code Reviews| 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 } | |
|
stevenjb
2015/04/01 00:20:47
This early exit isn't necessary and just confuses
| |
| 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 } | |
|
stevenjb
2015/04/01 00:20:48
This shouldn't happen, we check for connected netw
| |
| 223 | |
| 224 if (error_name == NetworkConnectionHandler::kErrorBadPassphrase || | 210 if (error_name == NetworkConnectionHandler::kErrorBadPassphrase || |
| 225 error_name == NetworkConnectionHandler::kErrorPassphraseRequired || | 211 error_name == NetworkConnectionHandler::kErrorPassphraseRequired || |
| 226 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || | 212 error_name == NetworkConnectionHandler::kErrorConfigurationRequired || |
| 227 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { | 213 error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) { |
| 228 HandleUnconfiguredNetwork(service_path); | 214 HandleUnconfiguredNetwork(service_path); |
| 229 return; | 215 return; |
| 230 } | 216 } |
|
stevenjb
2015/04/01 00:20:48
This shouldn't happen, we check the 'Configured' s
| |
| 231 | 217 |
| 232 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { | 218 if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) { |
| 233 if (!delegate_->ShowEnrollNetwork(service_path)) | 219 if (!delegate_->ShowEnrollNetwork(service_path)) |
| 234 HandleUnconfiguredNetwork(service_path); | 220 HandleUnconfiguredNetwork(service_path); |
| 235 return; | 221 return; |
| 236 } | 222 } |
|
stevenjb
2015/04/01 00:20:48
Same here.
| |
| 237 | 223 |
| 238 // Only show a configure dialog if there was a ConnectFailed error. The dialog | 224 // Only show a configure dialog if there was a ConnectFailed error. The dialog |
| 239 // allows the user to request a new connect attempt or cancel. Note: a | 225 // allows the user to request a new connect attempt or cancel. Note: a |
| 240 // notification may also be displayed by NetworkStateNotifier in this case. | 226 // notification may also be displayed by NetworkStateNotifier in this case. |
| 241 if (error_name == NetworkConnectionHandler::kErrorConnectFailed) | 227 if (error_name == NetworkConnectionHandler::kErrorConnectFailed) |
| 242 HandleUnconfiguredNetwork(service_path); | 228 HandleUnconfiguredNetwork(service_path); |
|
stevenjb
2015/04/01 00:20:48
Edge case. The Settings UI will no longer automati
| |
| 243 | 229 |
| 244 // Notifications for other connect failures are handled by | 230 // Notifications for other connect failures are handled by |
| 245 // NetworkStateNotifier, so no need to do anything else here. | 231 // NetworkStateNotifier, so no need to do anything else here. |
| 246 } | 232 } |
| 247 | 233 |
| 248 void NetworkConnectImpl::OnConnectSucceeded(const std::string& service_path) { | 234 void NetworkConnectImpl::OnConnectSucceeded(const std::string& service_path) { |
| 249 NET_LOG_USER("Connect Succeeded", service_path); | 235 NET_LOG_USER("Connect Succeeded", service_path); |
| 250 network_state_notifier_->RemoveConnectNotification(); | 236 network_state_notifier_->RemoveConnectNotification(); |
| 251 } | 237 } |
| 252 | 238 |
| 253 // If |check_error_state| is true, error state for the network is checked, | 239 // If |check_error_state| is true, error state for the network is checked, |
| 254 // otherwise any current error state is ignored (e.g. for recently configured | 240 // otherwise any current error state is ignored (e.g. for recently configured |
| 255 // networks or repeat connect attempts). | 241 // networks or repeat connect attempts). |
| 256 void NetworkConnectImpl::CallConnectToNetwork(const std::string& service_path, | 242 void NetworkConnectImpl::CallConnectToNetwork(const std::string& service_path, |
| 257 bool check_error_state) { | 243 bool check_error_state) { |
| 258 network_state_notifier_->RemoveConnectNotification(); | |
|
stevenjb
2015/04/01 00:20:48
Moved to NetworkStateNotifier any time a new conne
| |
| 259 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( | 244 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( |
| 260 service_path, base::Bind(&NetworkConnectImpl::OnConnectSucceeded, | 245 service_path, base::Bind(&NetworkConnectImpl::OnConnectSucceeded, |
| 261 weak_factory_.GetWeakPtr(), service_path), | 246 weak_factory_.GetWeakPtr(), service_path), |
| 262 base::Bind(&NetworkConnectImpl::OnConnectFailed, | 247 base::Bind(&NetworkConnectImpl::OnConnectFailed, |
| 263 weak_factory_.GetWeakPtr(), service_path), | 248 weak_factory_.GetWeakPtr(), service_path), |
| 264 check_error_state); | 249 check_error_state); |
| 265 } | 250 } |
| 266 | 251 |
| 267 void NetworkConnectImpl::OnActivateFailed( | 252 void NetworkConnectImpl::OnActivateFailed( |
| 268 const std::string& service_path, | 253 const std::string& service_path, |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 return g_network_connect; | 630 return g_network_connect; |
| 646 } | 631 } |
| 647 | 632 |
| 648 NetworkConnect::NetworkConnect() { | 633 NetworkConnect::NetworkConnect() { |
| 649 } | 634 } |
| 650 | 635 |
| 651 NetworkConnect::~NetworkConnect() { | 636 NetworkConnect::~NetworkConnect() { |
| 652 } | 637 } |
| 653 | 638 |
| 654 } // namespace ui | 639 } // namespace ui |
| OLD | NEW |