| Index: chrome/browser/sync/profile_sync_service.cc
|
| diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
|
| index da488e7f7bf5c795ad60e0f1d7ffc7c1b1a1ef73..7f33b180effaede743dbd44abe6b9164db4d97bd 100644
|
| --- a/chrome/browser/sync/profile_sync_service.cc
|
| +++ b/chrome/browser/sync/profile_sync_service.cc
|
| @@ -215,7 +215,8 @@ bool ProfileSyncService::IsOAuthRefreshTokenAvailable() {
|
| ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
|
| if (!token_service)
|
| return false;
|
| - return token_service->RefreshTokenIsAvailable();
|
| + return token_service->RefreshTokenIsAvailable(
|
| + token_service->GetPrimaryAccountId());
|
| } else {
|
| TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
|
| if (!token_service)
|
| @@ -715,12 +716,16 @@ void ProfileSyncService::OnGetTokenFailure(
|
|
|
| void ProfileSyncService::OnRefreshTokenAvailable(
|
| const std::string& account_id) {
|
| - OnRefreshTokensLoaded();
|
| + if (ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
|
| + GetPrimaryAccountId() == account_id) {
|
| + OnRefreshTokensLoaded();
|
| + }
|
| }
|
|
|
| void ProfileSyncService::OnRefreshTokenRevoked(
|
| const std::string& account_id) {
|
| if (!IsOAuthRefreshTokenAvailable()) {
|
| + access_token_.clear();
|
| // The additional check around IsOAuthRefreshTokenAvailable() above
|
| // prevents us sounding the alarm if we actually have a valid token but
|
| // a refresh attempt by TokenService failed for any variety of reasons
|
| @@ -745,10 +750,6 @@ void ProfileSyncService::OnRefreshTokensLoaded() {
|
| }
|
| }
|
|
|
| -void ProfileSyncService::OnRefreshTokensCleared() {
|
| - access_token_.clear();
|
| -}
|
| -
|
| void ProfileSyncService::Shutdown() {
|
| UnregisterAuthNotifications();
|
|
|
| @@ -1886,14 +1887,16 @@ void ProfileSyncService::RequestAccessToken() {
|
| oauth2_scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope);
|
| }
|
|
|
| - OAuth2TokenService* token_service =
|
| + ProfileOAuth2TokenService* token_service =
|
| ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
|
| // Invalidate previous token, otherwise token service will return the same
|
| // token again.
|
| + const std::string& account_id = token_service->GetPrimaryAccountId();
|
| if (!access_token_.empty())
|
| - token_service->InvalidateToken(oauth2_scopes, access_token_);
|
| + token_service->InvalidateToken(account_id, oauth2_scopes, access_token_);
|
| access_token_.clear();
|
| - access_token_request_ = token_service->StartRequest(oauth2_scopes, this);
|
| + access_token_request_ = token_service->StartRequest(
|
| + account_id, oauth2_scopes, this);
|
| }
|
|
|
| void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase,
|
|
|