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