OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" | 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/value_conversions.h" | 10 #include "base/value_conversions.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 const ProfileInfoCache& info_cache = | 407 const ProfileInfoCache& info_cache = |
408 g_browser_process->profile_manager()->GetProfileInfoCache(); | 408 g_browser_process->profile_manager()->GetProfileInfoCache(); |
409 size_t profile_index = info_cache.GetIndexOfProfileWithPath(profile_path); | 409 size_t profile_index = info_cache.GetIndexOfProfileWithPath(profile_path); |
410 | 410 |
411 if (profile_index == std::string::npos) { | 411 if (profile_index == std::string::npos) { |
412 NOTREACHED(); | 412 NOTREACHED(); |
413 return; | 413 return; |
414 } | 414 } |
415 | 415 |
416 authenticating_profile_index_ = profile_index; | 416 authenticating_profile_index_ = profile_index; |
417 if (!LocalAuth::ValidateLocalAuthCredentials(profile_index, password)) { | 417 if (!chrome::ValidateLocalAuthCredentials(profile_index, password)) { |
418 // Make a second attempt via an on-line authentication call. This handles | 418 // Make a second attempt via an on-line authentication call. This handles |
419 // profiles that are missing sign-in credentials and also cases where the | 419 // profiles that are missing sign-in credentials and also cases where the |
420 // password has been changed externally. | 420 // password has been changed externally. |
421 client_login_.reset(new GaiaAuthFetcher( | 421 client_login_.reset(new GaiaAuthFetcher( |
422 this, | 422 this, |
423 GaiaConstants::kChromeSource, | 423 GaiaConstants::kChromeSource, |
424 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext())); | 424 web_ui()->GetWebContents()->GetBrowserContext()->GetRequestContext())); |
425 | 425 |
426 client_login_->StartClientLogin( | 426 client_login_->StartClientLogin( |
427 base::UTF16ToUTF8(email_address), | 427 base::UTF16ToUTF8(email_address), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 std::string email; | 518 std::string email; |
519 CHECK(args->GetString(0, &email)); | 519 CHECK(args->GetString(0, &email)); |
520 SetAuthType(email, | 520 SetAuthType(email, |
521 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 521 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, |
522 base::string16()); | 522 base::string16()); |
523 HideUserPodCustomIcon(email); | 523 HideUserPodCustomIcon(email); |
524 } | 524 } |
525 | 525 |
526 void UserManagerScreenHandler::OnClientLoginSuccess( | 526 void UserManagerScreenHandler::OnClientLoginSuccess( |
527 const ClientLoginResult& result) { | 527 const ClientLoginResult& result) { |
528 LocalAuth::SetLocalAuthCredentials(authenticating_profile_index_, | 528 chrome::SetLocalAuthCredentials(authenticating_profile_index_, |
529 password_attempt_); | 529 password_attempt_); |
530 ReportAuthenticationResult(true, ProfileMetrics::AUTH_ONLINE); | 530 ReportAuthenticationResult(true, ProfileMetrics::AUTH_ONLINE); |
531 } | 531 } |
532 | 532 |
533 void UserManagerScreenHandler::OnClientLoginFailure( | 533 void UserManagerScreenHandler::OnClientLoginFailure( |
534 const GoogleServiceAuthError& error) { | 534 const GoogleServiceAuthError& error) { |
535 const GoogleServiceAuthError::State state = error.state(); | 535 const GoogleServiceAuthError::State state = error.state(); |
536 // Some "error" results mean the password was correct but some other action | 536 // Some "error" results mean the password was correct but some other action |
537 // should be taken. For our purposes, we only care that the password was | 537 // should be taken. For our purposes, we only care that the password was |
538 // correct so count those as a success. | 538 // correct so count those as a success. |
539 bool success = (state == GoogleServiceAuthError::NONE || | 539 bool success = (state == GoogleServiceAuthError::NONE || |
540 state == GoogleServiceAuthError::CAPTCHA_REQUIRED || | 540 state == GoogleServiceAuthError::CAPTCHA_REQUIRED || |
541 state == GoogleServiceAuthError::TWO_FACTOR || | 541 state == GoogleServiceAuthError::TWO_FACTOR || |
542 state == GoogleServiceAuthError::ACCOUNT_DELETED || | 542 state == GoogleServiceAuthError::ACCOUNT_DELETED || |
543 state == GoogleServiceAuthError::ACCOUNT_DISABLED || | 543 state == GoogleServiceAuthError::ACCOUNT_DISABLED || |
544 state == GoogleServiceAuthError::WEB_LOGIN_REQUIRED); | 544 state == GoogleServiceAuthError::WEB_LOGIN_REQUIRED); |
545 | 545 |
546 // If the password was correct, the user must have changed it since the | 546 // If the password was correct, the user must have changed it since the |
547 // profile was locked. Save the password to streamline future unlocks. | 547 // profile was locked. Save the password to streamline future unlocks. |
548 if (success) { | 548 if (success) { |
549 DCHECK(!password_attempt_.empty()); | 549 DCHECK(!password_attempt_.empty()); |
550 LocalAuth::SetLocalAuthCredentials(authenticating_profile_index_, | 550 chrome::SetLocalAuthCredentials(authenticating_profile_index_, |
551 password_attempt_); | 551 password_attempt_); |
552 } | 552 } |
553 | 553 |
554 bool offline = (state == GoogleServiceAuthError::CONNECTION_FAILED || | 554 bool offline = (state == GoogleServiceAuthError::CONNECTION_FAILED || |
555 state == GoogleServiceAuthError::SERVICE_UNAVAILABLE || | 555 state == GoogleServiceAuthError::SERVICE_UNAVAILABLE || |
556 state == GoogleServiceAuthError::REQUEST_CANCELED); | 556 state == GoogleServiceAuthError::REQUEST_CANCELED); |
557 ProfileMetrics::ProfileAuth failure_metric = | 557 ProfileMetrics::ProfileAuth failure_metric = |
558 offline ? ProfileMetrics::AUTH_FAILED_OFFLINE : | 558 offline ? ProfileMetrics::AUTH_FAILED_OFFLINE : |
559 ProfileMetrics::AUTH_FAILED; | 559 ProfileMetrics::AUTH_FAILED; |
560 ReportAuthenticationResult( | 560 ReportAuthenticationResult( |
561 success, success ? ProfileMetrics::AUTH_ONLINE : failure_metric); | 561 success, success ? ProfileMetrics::AUTH_ONLINE : failure_metric); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 Profile* profile, Profile::CreateStatus profile_create_status) { | 828 Profile* profile, Profile::CreateStatus profile_create_status) { |
829 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); | 829 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); |
830 if (browser && browser->window()) { | 830 if (browser && browser->window()) { |
831 OnBrowserWindowReady(browser); | 831 OnBrowserWindowReady(browser); |
832 } else { | 832 } else { |
833 registrar_.Add(this, | 833 registrar_.Add(this, |
834 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 834 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
835 content::NotificationService::AllSources()); | 835 content::NotificationService::AllSources()); |
836 } | 836 } |
837 } | 837 } |
OLD | NEW |