Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: components/signin/core/browser/signin_manager.cc

Issue 2953253002: [DICE] Enable sync for an account that is already present in the token service. (Closed)
Patch Set: Address code review Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/signin/core/browser/signin_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « components/signin/core/browser/signin_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698