Chromium Code Reviews| Index: chrome/browser/chromeos/login/login_utils.cc |
| diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc |
| index d4e5fc058e4c810683d726c1802404546b51dd59..84d58119533dcccba35c5102723fd1029742423e 100644 |
| --- a/chrome/browser/chromeos/login/login_utils.cc |
| +++ b/chrome/browser/chromeos/login/login_utils.cc |
| @@ -537,6 +537,7 @@ class LoginUtilsImpl : public LoginUtils, |
| // LoginUtils implementation: |
| virtual void PrepareProfile( |
| const std::string& username, |
| + const std::string& display_email, |
| const std::string& password, |
| const GaiaAuthConsumer::ClientLoginResult& credentials, |
| bool pending_requests, |
| @@ -549,8 +550,7 @@ class LoginUtilsImpl : public LoginUtils, |
| virtual scoped_refptr<Authenticator> CreateAuthenticator( |
| LoginStatusConsumer* consumer) OVERRIDE; |
| virtual void PrewarmAuthentication() OVERRIDE; |
| - virtual void RestoreAuthenticationSession(const std::string& user_name, |
| - Profile* profile) OVERRIDE; |
| + virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; |
| virtual void StartTokenServices(Profile* user_profile) OVERRIDE; |
| virtual void StartSync( |
| Profile* profile, |
| @@ -636,7 +636,6 @@ class LoginUtilsImpl : public LoginUtils, |
| // The current background view. |
| chromeos::BackgroundView* background_view_; |
| - std::string username_; |
| std::string password_; |
| GaiaAuthConsumer::ClientLoginResult credentials_; |
| bool pending_requests_; |
| @@ -687,6 +686,7 @@ class LoginUtilsWrapper { |
| void LoginUtilsImpl::PrepareProfile( |
| const std::string& username, |
| + const std::string& display_email, |
| const std::string& password, |
| const GaiaAuthConsumer::ClientLoginResult& credentials, |
| bool pending_requests, |
| @@ -703,13 +703,17 @@ void LoginUtilsImpl::PrepareProfile( |
| btl->AddLoginTimeMarker("StartSession-End", false); |
| btl->AddLoginTimeMarker("UserLoggedIn-Start", false); |
| - UserManager::Get()->UserLoggedIn(username); |
| + UserManager* user_manager = UserManager::Get(); |
| + user_manager->UserLoggedIn(username); |
| btl->AddLoginTimeMarker("UserLoggedIn-End", false); |
| // Switch log file as soon as possible. |
| logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess())); |
| - username_ = username; |
| + // Update user's displayed email. |
| + if (!display_email.empty()) |
| + user_manager->SaveUserDisplayEmail(username, display_email, true); |
| + |
| password_ = password; |
| credentials_ = credentials; |
| @@ -879,12 +883,10 @@ void LoginUtilsImpl::StartSync( |
| // Set the CrOS user by getting this constructor run with the |
| // user's email on first retrieval. |
| + std::string email = UserManager::Get()->logged_in_user().display_email(); |
| // TODO(tim): Tidy this up once cros_user is gone (part of bug 93922). |
| - user_profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, |
| - username_); |
| - user_profile->GetProfileSyncService(username_)->SetPassphrase( |
| - password_, false); |
| - username_ = ""; |
| + user_profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, email); |
| + user_profile->GetProfileSyncService(email)->SetPassphrase(password_, false); |
|
Nikita (slow)
2011/12/05 13:13:04
Please double check how email is used in Sync serv
Ivan Korotkov
2011/12/05 14:12:48
As discussed offline, removed from this CL.
|
| password_ = ""; |
| token_service->Initialize(GaiaConstants::kChromeOSSource, user_profile); |
| @@ -1107,9 +1109,7 @@ void LoginUtilsImpl::PrewarmAuthentication() { |
| } |
| } |
| -void LoginUtilsImpl::RestoreAuthenticationSession(const std::string& username, |
| - Profile* user_profile) { |
| - username_ = username; |
| +void LoginUtilsImpl::RestoreAuthenticationSession(Profile* user_profile) { |
| KickStartAuthentication(user_profile); |
| } |
| @@ -1190,7 +1190,7 @@ bool LoginUtilsImpl::ReadOAuth1AccessToken(Profile* user_profile, |
| std::string* token, |
| std::string* secret) { |
| // Skip reading oauth token if user does not have a valid status. |
| - if (UserManager::Get()->GetUserOAuthStatus(username_) != |
| + if (UserManager::Get()->logged_in_user().oauth_token_status() != |
| User::OAUTH_TOKEN_STATUS_VALID) { |
| return false; |
| } |
| @@ -1224,8 +1224,9 @@ void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile, |
| // ...then record the presence of valid OAuth token for this account in local |
| // state as well. |
| - UserManager::Get()->SaveUserOAuthStatus(username_, |
| - User::OAUTH_TOKEN_STATUS_VALID); |
| + UserManager::Get()->SaveUserOAuthStatus( |
| + UserManager::Get()->logged_in_user().email(), |
| + User::OAUTH_TOKEN_STATUS_VALID); |
| } |
| void LoginUtilsImpl::VerifyOAuth1AccessToken(Profile* user_profile, |
| @@ -1241,11 +1242,9 @@ void LoginUtilsImpl::VerifyOAuth1AccessToken(Profile* user_profile, |
| void LoginUtilsImpl::FetchCredentials(Profile* user_profile, |
| const std::string& token, |
| const std::string& secret) { |
| - oauth_login_verifier_.reset(new OAuthLoginVerifier(this, |
| - user_profile, |
| - token, |
| - secret, |
| - username_)); |
| + oauth_login_verifier_.reset(new OAuthLoginVerifier( |
| + this, user_profile, token, secret, |
| + UserManager::Get()->logged_in_user().email())); |
| oauth_login_verifier_->StartOAuthVerification(); |
| } |