Index: components/signin/core/browser/signin_manager.cc |
diff --git a/components/signin/core/browser/signin_manager.cc b/components/signin/core/browser/signin_manager.cc |
index 7856c7855e2414a94fd158f0e901492a60e7c058..5ced320782343e23fffd226d792388bd95516fd4 100644 |
--- a/components/signin/core/browser/signin_manager.cc |
+++ b/components/signin/core/browser/signin_manager.cc |
@@ -54,6 +54,8 @@ std::string SigninManager::SigninTypeToString(SigninManager::SigninType type) { |
return "No Signin"; |
case SIGNIN_TYPE_WITH_REFRESH_TOKEN: |
return "With refresh token"; |
+ case SIGNIN_TYPE_WITHOUT_REFRESH_TOKEN: |
+ return "Without refresh token"; |
} |
NOTREACHED(); |
@@ -101,19 +103,21 @@ void SigninManager::StartSignInWithRefreshToken( |
const std::string& password, |
const OAuthTokenFetchedCallback& callback) { |
DCHECK(!IsAuthenticated()); |
- |
- if (!PrepareForSignin(SIGNIN_TYPE_WITH_REFRESH_TOKEN, gaia_id, username, |
- password)) { |
+ SigninType signin_type = refresh_token.empty() |
+ ? SIGNIN_TYPE_WITHOUT_REFRESH_TOKEN |
+ : SIGNIN_TYPE_WITH_REFRESH_TOKEN; |
+ if (!PrepareForSignin(signin_type, gaia_id, username, password)) { |
return; |
} |
- // Store our token. |
+ // Store the refresh token. |
temp_refresh_token_ = refresh_token; |
- if (!callback.is_null() && !temp_refresh_token_.empty()) { |
+ if (!callback.is_null()) { |
+ // Callback present, let the caller complete the pending sign-in. |
callback.Run(temp_refresh_token_); |
} else { |
- // No oauth token or callback, so just complete our pending signin. |
+ // No callback, so just complete the pending signin. |
CompletePendingSignin(); |
} |
} |
@@ -350,13 +354,13 @@ void SigninManager::CompletePendingSignin() { |
DCHECK(!possibly_invalid_account_id_.empty()); |
OnSignedIn(); |
- DCHECK(!temp_refresh_token_.empty()); |
DCHECK(IsAuthenticated()); |
- std::string account_id = GetAuthenticatedAccountId(); |
- token_service_->UpdateCredentials(account_id, temp_refresh_token_); |
- temp_refresh_token_.clear(); |
- |
+ if (!temp_refresh_token_.empty()) { |
+ std::string account_id = GetAuthenticatedAccountId(); |
+ token_service_->UpdateCredentials(account_id, temp_refresh_token_); |
+ temp_refresh_token_.clear(); |
+ } |
MergeSigninCredentialIntoCookieJar(); |
} |