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

Side by Side Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 11824046: Detect user initiated network connection failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix spelling Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include "base/i18n/icu_encoding_detection.h" 7 #include "base/i18n/icu_encoding_detection.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/json/json_writer.h" // for debug output only. 10 #include "base/json/json_writer.h" // for debug output only.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 //////////////////////////////////////////////////////////////////////////////// 213 ////////////////////////////////////////////////////////////////////////////////
214 // Network 214 // Network
215 215
216 Network::Network(const std::string& service_path, 216 Network::Network(const std::string& service_path,
217 ConnectionType type) 217 ConnectionType type)
218 : state_(STATE_UNKNOWN), 218 : state_(STATE_UNKNOWN),
219 error_(ERROR_NO_ERROR), 219 error_(ERROR_NO_ERROR),
220 connectable_(true), 220 connectable_(true),
221 connection_started_(false), 221 user_connect_state_(USER_CONNECT_NONE),
222 is_active_(false), 222 is_active_(false),
223 priority_(kPriorityNotSet), 223 priority_(kPriorityNotSet),
224 auto_connect_(false), 224 auto_connect_(false),
225 save_credentials_(false), 225 save_credentials_(false),
226 priority_order_(0), 226 priority_order_(0),
227 added_(false), 227 added_(false),
228 notify_failure_(false), 228 notify_failure_(false),
229 profile_type_(PROFILE_NONE), 229 profile_type_(PROFILE_NONE),
230 service_path_(service_path), 230 service_path_(service_path),
231 type_(type) { 231 type_(type) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Transition STATE_IDLE -> STATE_FAILURE sometimes happens on resume 304 // Transition STATE_IDLE -> STATE_FAILURE sometimes happens on resume
305 // but is not an actual failure as network device is not ready yet. 305 // but is not an actual failure as network device is not ready yet.
306 notify_failure_ = true; 306 notify_failure_ = true;
307 // Normally error_ should be set, but if it is not we need to set it to 307 // Normally error_ should be set, but if it is not we need to set it to
308 // something here so that the retry logic will be triggered. 308 // something here so that the retry logic will be triggered.
309 if (error_ == ERROR_NO_ERROR) { 309 if (error_ == ERROR_NO_ERROR) {
310 VLOG(2) << "Detected NO_ERROR error state. Setting to UNKNOWN."; 310 VLOG(2) << "Detected NO_ERROR error state. Setting to UNKNOWN.";
311 error_ = ERROR_UNKNOWN; 311 error_ = ERROR_UNKNOWN;
312 } 312 }
313 } 313 }
314 } else if (new_state == STATE_IDLE && IsConnectingState(old_state) 314 if (user_connect_state() == USER_CONNECT_STARTED)
315 && connection_started()) { 315 set_user_connect_state(USER_CONNECT_FAILED);
316 } else if (new_state == STATE_IDLE && IsConnectingState(old_state) &&
317 user_connect_state() == USER_CONNECT_STARTED) {
316 // If we requested a connect and never went through a connected state, 318 // If we requested a connect and never went through a connected state,
317 // treat it as a failure. 319 // treat it as a failure.
318 VLOG(1) << service_path() << ": Inferring Failure state."; 320 VLOG(1) << service_path() << ": Inferring Failure state.";
319 notify_failure_ = true; 321 notify_failure_ = true;
320 error_ = ERROR_UNKNOWN; 322 error_ = ERROR_UNKNOWN;
323 if (user_connect_state() == USER_CONNECT_STARTED)
324 set_user_connect_state(USER_CONNECT_FAILED);
321 } else if (new_state != STATE_UNKNOWN) { 325 } else if (new_state != STATE_UNKNOWN) {
322 notify_failure_ = false; 326 notify_failure_ = false;
323 // State changed, so refresh IP address. 327 // State changed, so refresh IP address.
324 InitIPAddress(); 328 InitIPAddress();
329 if (user_connect_state() == USER_CONNECT_STARTED) {
330 if (IsConnectedState(new_state)) {
331 set_user_connect_state(USER_CONNECT_CONNECTED);
332 } else if (!IsConnectingState(new_state)) {
333 LOG(WARNING) << "Connection started and State -> " << GetStateString();
334 set_user_connect_state(USER_CONNECT_FAILED);
335 }
336 }
325 } 337 }
326 VLOG(1) << name() << ".State [" << service_path() << "]: " << GetStateString() 338 VLOG(1) << name() << ".State [" << service_path() << "]: " << GetStateString()
327 << " (was: " << ConnectionStateString(old_state) << ")"; 339 << " (was: " << ConnectionStateString(old_state) << ")";
328 if (!IsConnectingState(new_state) && new_state != STATE_UNKNOWN)
329 set_connection_started(false);
330 } 340 }
331 341
332 void Network::SetError(ConnectionError error) { 342 void Network::SetError(ConnectionError error) {
333 error_ = error; 343 error_ = error;
334 if (error == ERROR_NO_ERROR) 344 if (error == ERROR_NO_ERROR)
335 notify_failure_ = false; 345 notify_failure_ = false;
336 } 346 }
337 347
338 void Network::SetName(const std::string& name) { 348 void Network::SetName(const std::string& name) {
339 std::string name_utf8; 349 std::string name_utf8;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 case ERROR_HTTP_GET_FAILED: 495 case ERROR_HTTP_GET_FAILED:
486 return l10n_util::GetStringUTF8( 496 return l10n_util::GetStringUTF8(
487 IDS_CHROMEOS_NETWORK_ERROR_HTTP_GET_FAILED); 497 IDS_CHROMEOS_NETWORK_ERROR_HTTP_GET_FAILED);
488 case ERROR_IPSEC_PSK_AUTH_FAILED: 498 case ERROR_IPSEC_PSK_AUTH_FAILED:
489 return l10n_util::GetStringUTF8( 499 return l10n_util::GetStringUTF8(
490 IDS_CHROMEOS_NETWORK_ERROR_IPSEC_PSK_AUTH_FAILED); 500 IDS_CHROMEOS_NETWORK_ERROR_IPSEC_PSK_AUTH_FAILED);
491 case ERROR_IPSEC_CERT_AUTH_FAILED: 501 case ERROR_IPSEC_CERT_AUTH_FAILED:
492 return l10n_util::GetStringUTF8( 502 return l10n_util::GetStringUTF8(
493 IDS_CHROMEOS_NETWORK_ERROR_IPSEC_CERT_AUTH_FAILED); 503 IDS_CHROMEOS_NETWORK_ERROR_IPSEC_CERT_AUTH_FAILED);
494 case ERROR_PPP_AUTH_FAILED: 504 case ERROR_PPP_AUTH_FAILED:
505 case ERROR_EAP_AUTHENTICATION_FAILED:
506 case ERROR_EAP_LOCAL_TLS_FAILED:
507 case ERROR_EAP_REMOTE_TLS_FAILED:
495 return l10n_util::GetStringUTF8( 508 return l10n_util::GetStringUTF8(
496 IDS_CHROMEOS_NETWORK_ERROR_PPP_AUTH_FAILED); 509 IDS_CHROMEOS_NETWORK_ERROR_PPP_AUTH_FAILED);
497 case ERROR_UNKNOWN: 510 case ERROR_UNKNOWN:
498 return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN); 511 return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN);
499 } 512 }
500 return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED); 513 return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED);
501 } 514 }
502 515
503 void Network::SetProxyConfig(const std::string& proxy_config) { 516 void Network::SetProxyConfig(const std::string& proxy_config) {
504 SetOrClearStringProperty( 517 SetOrClearStringProperty(
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 case SECURITY_PSK: 1228 case SECURITY_PSK:
1216 return "PSK"; 1229 return "PSK";
1217 } 1230 }
1218 return "Unknown"; 1231 return "Unknown";
1219 } 1232 }
1220 1233
1221 bool WifiNetwork::IsPassphraseRequired() const { 1234 bool WifiNetwork::IsPassphraseRequired() const {
1222 if (encryption_ == SECURITY_NONE) 1235 if (encryption_ == SECURITY_NONE)
1223 return false; 1236 return false;
1224 // A connection failure might be due to a bad passphrase. 1237 // A connection failure might be due to a bad passphrase.
1225 if (error() == ERROR_BAD_PASSPHRASE || error() == ERROR_BAD_WEPKEY || 1238 if (error() == ERROR_BAD_PASSPHRASE ||
1226 error() == ERROR_UNKNOWN) 1239 error() == ERROR_BAD_WEPKEY ||
1240 error() == ERROR_PPP_AUTH_FAILED ||
1241 error() == ERROR_EAP_LOCAL_TLS_FAILED ||
1242 error() == ERROR_EAP_REMOTE_TLS_FAILED ||
1243 error() == ERROR_EAP_AUTHENTICATION_FAILED ||
1244 error() == ERROR_CONNECT_FAILED ||
1245 error() == ERROR_UNKNOWN) {
1246 VLOG(1) << "Authentication Error: " << GetErrorString();
1227 return true; 1247 return true;
1228 // For 802.1x networks, configuration is required if connectable is false 1248 }
1229 // unless we're using a certificate pattern. 1249 // If the user initiated a connection and it failed, request credentials in
1230 if (encryption_ == SECURITY_8021X) { 1250 // case it is a credentials error and Shill was unable to detect it.
1231 if (eap_method_ != EAP_METHOD_TLS || 1251 if (user_connect_state() == USER_CONNECT_FAILED)
1232 client_cert_type() != CLIENT_CERT_TYPE_PATTERN) 1252 return true;
1233 return !connectable(); 1253 // WEP/WPA/RSN and PSK networks rely on the PassphraseRequired property.
1254 if (encryption_ != SECURITY_8021X)
1255 return passphrase_required_;
1256 // For 802.1x networks, if we are using a certificate pattern we do not
1257 // need any credentials.
1258 if (eap_method_ == EAP_METHOD_TLS &&
1259 client_cert_type() == CLIENT_CERT_TYPE_PATTERN) {
1234 return false; 1260 return false;
1235 } 1261 }
1236 return passphrase_required_; 1262 // Connectable will be false if 802.1x credentials are not set
1263 return !connectable();
1237 } 1264 }
1238 1265
1239 bool WifiNetwork::RequiresUserProfile() const { 1266 bool WifiNetwork::RequiresUserProfile() const {
1240 // 8021X requires certificates which are only stored for individual users. 1267 // 8021X requires certificates which are only stored for individual users.
1241 if (encryption_ != SECURITY_8021X) 1268 if (encryption_ != SECURITY_8021X)
1242 return false; 1269 return false;
1243 1270
1244 if (eap_method_ != EAP_METHOD_TLS) 1271 if (eap_method_ != EAP_METHOD_TLS)
1245 return false; 1272 return false;
1246 1273
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 NetworkLibrary* impl; 1373 NetworkLibrary* impl;
1347 if (stub) 1374 if (stub)
1348 impl = new NetworkLibraryImplStub(); 1375 impl = new NetworkLibraryImplStub();
1349 else 1376 else
1350 impl = new NetworkLibraryImplCros(); 1377 impl = new NetworkLibraryImplCros();
1351 impl->Init(); 1378 impl->Init();
1352 return impl; 1379 return impl;
1353 } 1380 }
1354 1381
1355 } // namespace chromeos 1382 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/cros/network_library_impl_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698