| Index: chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc
|
| diff --git a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc
|
| index a0144c8ae7626d7d0931928ce0e84244db50e336..99209a5c0ca49aba1b65b0114918b11ed5087f33 100644
|
| --- a/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc
|
| +++ b/chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.cc
|
| @@ -280,13 +280,15 @@ void MutableProfileOAuth2TokenServiceDelegate::LoadCredentials(
|
| }
|
|
|
| load_credentials_state_ = LOAD_CREDENTIALS_IN_PROGRESS;
|
| - if (primary_account_id.empty()) {
|
| + if (primary_account_id.empty() &&
|
| + !switches::IsAccountConsistencyDiceEnabled()) {
|
| load_credentials_state_ = LOAD_CREDENTIALS_FINISHED_WITH_SUCCESS;
|
| FireRefreshTokensLoaded();
|
| return;
|
| }
|
|
|
| - ValidateAccountId(primary_account_id);
|
| + if (!primary_account_id.empty())
|
| + ValidateAccountId(primary_account_id);
|
| DCHECK(loading_primary_account_id_.empty());
|
| DCHECK_EQ(0, web_data_service_request_);
|
|
|
| @@ -301,13 +303,15 @@ void MutableProfileOAuth2TokenServiceDelegate::LoadCredentials(
|
| return;
|
| }
|
|
|
| - // If the account_id is an email address, then canonicalize it. This
|
| - // is to support legacy account_ids, and will not be needed after
|
| - // switching to gaia-ids.
|
| - if (primary_account_id.find('@') != std::string::npos) {
|
| - loading_primary_account_id_ = gaia::CanonicalizeEmail(primary_account_id);
|
| - } else {
|
| - loading_primary_account_id_ = primary_account_id;
|
| + if (!primary_account_id.empty()) {
|
| + // If the account_id is an email address, then canonicalize it. This
|
| + // is to support legacy account_ids, and will not be needed after
|
| + // switching to gaia-ids.
|
| + if (primary_account_id.find('@') != std::string::npos) {
|
| + loading_primary_account_id_ = gaia::CanonicalizeEmail(primary_account_id);
|
| + } else {
|
| + loading_primary_account_id_ = primary_account_id;
|
| + }
|
| }
|
|
|
| web_data_service_request_ = token_web_data->GetAllTokens(this);
|
| @@ -343,8 +347,10 @@ void MutableProfileOAuth2TokenServiceDelegate::OnWebDataServiceRequestDone(
|
| // Make sure that we have an entry for |loading_primary_account_id_| in the
|
| // map. The entry could be missing if there is a corruption in the token DB
|
| // while this profile is connected to an account.
|
| - DCHECK(!loading_primary_account_id_.empty());
|
| - if (refresh_tokens_.count(loading_primary_account_id_) == 0) {
|
| + DCHECK(!loading_primary_account_id_.empty() ||
|
| + switches::IsAccountConsistencyDiceEnabled());
|
| + if (!loading_primary_account_id_.empty() &&
|
| + refresh_tokens_.count(loading_primary_account_id_) == 0) {
|
| refresh_tokens_[loading_primary_account_id_].reset(new AccountStatus(
|
| signin_error_controller_, loading_primary_account_id_, std::string()));
|
| }
|
| @@ -428,8 +434,9 @@ void MutableProfileOAuth2TokenServiceDelegate::LoadAllCredentialsIntoMemory(
|
| }
|
|
|
| // Only load secondary accounts when account consistency is enabled.
|
| - if (switches::IsAccountConsistencyMirrorEnabled() ||
|
| - account_id == loading_primary_account_id_) {
|
| + if (account_id == loading_primary_account_id_ ||
|
| + switches::IsAccountConsistencyDiceEnabled() ||
|
| + switches::IsAccountConsistencyMirrorEnabled()) {
|
| refresh_tokens_[account_id].reset(new AccountStatus(
|
| signin_error_controller_, account_id, refresh_token));
|
| FireRefreshTokenAvailable(account_id);
|
|
|