OLD | NEW |
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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return "No Signin"; | 298 return "No Signin"; |
299 case SIGNIN_TYPE_CLIENT_LOGIN: | 299 case SIGNIN_TYPE_CLIENT_LOGIN: |
300 return "Client Login"; | 300 return "Client Login"; |
301 case SIGNIN_TYPE_WITH_CREDENTIALS: | 301 case SIGNIN_TYPE_WITH_CREDENTIALS: |
302 return "Signin with credentials"; | 302 return "Signin with credentials"; |
303 case SIGNIN_TYPE_CLIENT_OAUTH: | 303 case SIGNIN_TYPE_CLIENT_OAUTH: |
304 return "Client OAuth"; | 304 return "Client OAuth"; |
305 } | 305 } |
306 | 306 |
307 NOTREACHED(); | 307 NOTREACHED(); |
308 return ""; | 308 return std::string(); |
309 } | 309 } |
310 | 310 |
311 | |
312 bool SigninManager::PrepareForSignin(SigninType type, | 311 bool SigninManager::PrepareForSignin(SigninType type, |
313 const std::string& username, | 312 const std::string& username, |
314 const std::string& password) { | 313 const std::string& password) { |
315 DCHECK(possibly_invalid_username_.empty() || | 314 DCHECK(possibly_invalid_username_.empty() || |
316 possibly_invalid_username_ == username); | 315 possibly_invalid_username_ == username); |
317 DCHECK(!username.empty()); | 316 DCHECK(!username.empty()); |
318 | 317 |
319 if (!IsAllowedUsername(username)) { | 318 if (!IsAllowedUsername(username)) { |
320 // Account is not allowed by admin policy. | 319 // Account is not allowed by admin policy. |
321 HandleAuthError(GoogleServiceAuthError( | 320 HandleAuthError(GoogleServiceAuthError( |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 const std::string& password) { | 460 const std::string& password) { |
462 DCHECK(authenticated_username_.empty()); | 461 DCHECK(authenticated_username_.empty()); |
463 | 462 |
464 if (!PrepareForSignin(SIGNIN_TYPE_CLIENT_OAUTH, username, password)) | 463 if (!PrepareForSignin(SIGNIN_TYPE_CLIENT_OAUTH, username, password)) |
465 return; | 464 return; |
466 | 465 |
467 std::vector<std::string> scopes; | 466 std::vector<std::string> scopes; |
468 scopes.push_back(GaiaUrls::GetInstance()->oauth1_login_scope()); | 467 scopes.push_back(GaiaUrls::GetInstance()->oauth1_login_scope()); |
469 const std::string& locale = g_browser_process->GetApplicationLocale(); | 468 const std::string& locale = g_browser_process->GetApplicationLocale(); |
470 | 469 |
471 client_login_->StartClientOAuth(username, password, scopes, "", locale); | 470 client_login_->StartClientOAuth( |
| 471 username, password, scopes, std::string(), locale); |
472 | 472 |
473 // Register for token availability. The signin manager will pre-login the | 473 // Register for token availability. The signin manager will pre-login the |
474 // user when the GAIA service token is ready for use. Only do this if we | 474 // user when the GAIA service token is ready for use. Only do this if we |
475 // are not running in ChomiumOS, since it handles pre-login itself, and if | 475 // are not running in ChomiumOS, since it handles pre-login itself, and if |
476 // cookies are not disabled for Google accounts. | 476 // cookies are not disabled for Google accounts. |
477 #if !defined(OS_CHROMEOS) | 477 #if !defined(OS_CHROMEOS) |
478 if (AreSigninCookiesAllowed(profile_)) { | 478 if (AreSigninCookiesAllowed(profile_)) { |
479 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 479 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
480 registrar_.Add(this, | 480 registrar_.Add(this, |
481 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 481 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 return; | 542 return; |
543 } | 543 } |
544 | 544 |
545 GoogleServiceSignoutDetails details(authenticated_username_); | 545 GoogleServiceSignoutDetails details(authenticated_username_); |
546 | 546 |
547 ClearTransientSigninData(); | 547 ClearTransientSigninData(); |
548 authenticated_username_.clear(); | 548 authenticated_username_.clear(); |
549 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); | 549 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); |
550 | 550 |
551 // Erase (now) stale information from AboutSigninInternals. | 551 // Erase (now) stale information from AboutSigninInternals. |
552 NotifyDiagnosticsObservers(USERNAME, ""); | 552 NotifyDiagnosticsObservers(USERNAME, std::string()); |
553 NotifyDiagnosticsObservers(LSID, ""); | 553 NotifyDiagnosticsObservers(LSID, std::string()); |
554 NotifyDiagnosticsObservers( | 554 NotifyDiagnosticsObservers(signin_internals_util::SID, std::string()); |
555 signin_internals_util::SID, ""); | |
556 | 555 |
557 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 556 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
558 content::NotificationService::current()->Notify( | 557 content::NotificationService::current()->Notify( |
559 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 558 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
560 content::Source<Profile>(profile_), | 559 content::Source<Profile>(profile_), |
561 content::Details<const GoogleServiceSignoutDetails>(&details)); | 560 content::Details<const GoogleServiceSignoutDetails>(&details)); |
562 RevokeOAuthLoginToken(); | 561 RevokeOAuthLoginToken(); |
563 token_service->ResetCredentialsInMemory(); | 562 token_service->ResetCredentialsInMemory(); |
564 token_service->EraseTokensFromDB(); | 563 token_service->EraseTokensFromDB(); |
565 } | 564 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 NotifySigninValueChanged(field, value)); | 953 NotifySigninValueChanged(field, value)); |
955 } | 954 } |
956 | 955 |
957 void SigninManager::NotifyDiagnosticsObservers( | 956 void SigninManager::NotifyDiagnosticsObservers( |
958 const TimedSigninStatusField& field, | 957 const TimedSigninStatusField& field, |
959 const std::string& value) { | 958 const std::string& value) { |
960 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, | 959 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, |
961 signin_diagnostics_observers_, | 960 signin_diagnostics_observers_, |
962 NotifySigninValueChanged(field, value)); | 961 NotifySigninValueChanged(field, value)); |
963 } | 962 } |
OLD | NEW |