| 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/signin/profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 break; | 145 break; |
| 146 } | 146 } |
| 147 case chrome::NOTIFICATION_TOKENS_CLEARED: { | 147 case chrome::NOTIFICATION_TOKENS_CLEARED: { |
| 148 CancelAllRequests(); | 148 CancelAllRequests(); |
| 149 ClearCache(); | 149 ClearCache(); |
| 150 UpdateAuthError(GoogleServiceAuthError::AuthErrorNone()); | 150 UpdateAuthError(GoogleServiceAuthError::AuthErrorNone()); |
| 151 FireRefreshTokensCleared(); | 151 FireRefreshTokensCleared(); |
| 152 break; | 152 break; |
| 153 } | 153 } |
| 154 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: | 154 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: |
| 155 // During startup, if the user is signed in and the OAuth2 refresh token |
| 156 // is empty, flag it as an error by badging the menu. Otherwise, if the |
| 157 // user goes on to set up sync, they will have to make two attempts: |
| 158 // One to surface the OAuth2 error, and a second one after signing in. |
| 159 // See crbug.com/276650. |
| 160 if (!GetAccountId(profile_).empty() && GetRefreshToken().empty()) { |
| 161 UpdateAuthError(GoogleServiceAuthError( |
| 162 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); |
| 163 } |
| 155 FireRefreshTokensLoaded(); | 164 FireRefreshTokensLoaded(); |
| 156 break; | 165 break; |
| 157 default: | 166 default: |
| 158 NOTREACHED() << "Invalid notification type=" << type; | 167 NOTREACHED() << "Invalid notification type=" << type; |
| 159 break; | 168 break; |
| 160 } | 169 } |
| 161 } | 170 } |
| 162 | 171 |
| 163 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { | 172 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { |
| 164 return last_auth_error_; | 173 return last_auth_error_; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 324 } |
| 316 } | 325 } |
| 317 | 326 |
| 318 if (!old_login_token.empty() && | 327 if (!old_login_token.empty() && |
| 319 refresh_tokens_.count(GetAccountId(profile_)) == 0) { | 328 refresh_tokens_.count(GetAccountId(profile_)) == 0) { |
| 320 UpdateCredentials(GetAccountId(profile_), old_login_token); | 329 UpdateCredentials(GetAccountId(profile_), old_login_token); |
| 321 } | 330 } |
| 322 | 331 |
| 323 FireRefreshTokensLoaded(); | 332 FireRefreshTokensLoaded(); |
| 324 } | 333 } |
| OLD | NEW |