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

Side by Side Diff: ui/chromeos/network/network_connect.cc

Issue 1043343002: Use networkingPrivate.startConnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_430115_internet_options_cellular
Patch Set: Fix tests, add comment Created 5 years, 8 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 unified diff | Download patch
OLDNEW
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
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
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 }
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 }
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);
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();
251 } 236 }
252 237
253 // If |check_error_state| is true, error state for the network is checked, 238 // 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 239 // otherwise any current error state is ignored (e.g. for recently configured
255 // networks or repeat connect attempts). 240 // networks or repeat connect attempts).
256 void NetworkConnectImpl::CallConnectToNetwork(const std::string& service_path, 241 void NetworkConnectImpl::CallConnectToNetwork(const std::string& service_path,
257 bool check_error_state) { 242 bool check_error_state) {
258 network_state_notifier_->RemoveConnectNotification();
259 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( 243 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork(
260 service_path, base::Bind(&NetworkConnectImpl::OnConnectSucceeded, 244 service_path, base::Bind(&NetworkConnectImpl::OnConnectSucceeded,
261 weak_factory_.GetWeakPtr(), service_path), 245 weak_factory_.GetWeakPtr(), service_path),
262 base::Bind(&NetworkConnectImpl::OnConnectFailed, 246 base::Bind(&NetworkConnectImpl::OnConnectFailed,
263 weak_factory_.GetWeakPtr(), service_path), 247 weak_factory_.GetWeakPtr(), service_path),
264 check_error_state); 248 check_error_state);
265 } 249 }
266 250
267 void NetworkConnectImpl::OnActivateFailed( 251 void NetworkConnectImpl::OnActivateFailed(
268 const std::string& service_path, 252 const std::string& service_path,
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 return g_network_connect; 629 return g_network_connect;
646 } 630 }
647 631
648 NetworkConnect::NetworkConnect() { 632 NetworkConnect::NetworkConnect() {
649 } 633 }
650 634
651 NetworkConnect::~NetworkConnect() { 635 NetworkConnect::~NetworkConnect() {
652 } 636 }
653 637
654 } // namespace ui 638 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698