Commit 3c5cfe2c authored by Andrei Salavei's avatar Andrei Salavei Committed by Commit Bot

Update primary account setup flow during migration

Update IdentityManager initialization flow during the AccountManager
migration. After the offline login the |user_context| has no token,
hence the Primary account could not be setup for the IdentityManager.
Add login account to the AccountManager in case it is not presented
there to properly setup primary account for the IdentityManager.
The primary account with token will be configured later during
the AccountManager migration process.
Remove |DeprecatedSetPrimaryAccountAndUpdateAccountInfo|.

Bug: 987955
Change-Id: Ia1665e8337e26ca05af9a9abc43ab23816fce14d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131912
Commit-Queue: Andrei Salavei <solovey@google.com>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758775}
parent c5cbec6b
......@@ -96,9 +96,10 @@ class AccountMigrationBaseStep : public AccountMigrationRunner::Step {
~AccountMigrationBaseStep() override = default;
protected:
bool IsAccountPresentInAccountManager(
bool IsAccountWithNonDummyTokenPresentInAccountManager(
const AccountManager::AccountKey& account) const {
return base::Contains(account_manager_accounts_, account);
return base::Contains(account_manager_accounts_, account) &&
!account_manager_->HasDummyGaiaToken(account);
}
bool IsAccountManagerEmpty() const {
......@@ -184,7 +185,7 @@ class DeviceAccountMigration : public AccountMigrationBaseStep,
private:
void StartMigration() override {
if (IsAccountPresentInAccountManager(device_account_)) {
if (IsAccountWithNonDummyTokenPresentInAccountManager(device_account_)) {
FinishWithSuccess();
return;
}
......
......@@ -64,14 +64,6 @@ void PrimaryAccountMutatorImpl::SetUnconsentedPrimaryAccount(
AccountInfo account_info = account_tracker_->GetAccountInfo(account_id);
primary_account_manager_->SetUnconsentedPrimaryAccountInfo(account_info);
}
bool PrimaryAccountMutatorImpl::DeprecatedSetPrimaryAccountAndUpdateAccountInfo(
const std::string& gaia_id,
const std::string& email) {
CoreAccountId account_id = account_tracker_->SeedAccountInfo(gaia_id, email);
SetPrimaryAccount(account_id);
return true;
}
#endif
#if !defined(OS_CHROMEOS)
......
......@@ -29,9 +29,6 @@ class PrimaryAccountMutatorImpl : public PrimaryAccountMutator {
#if defined(OS_CHROMEOS)
void RevokeSyncConsent() override;
void SetUnconsentedPrimaryAccount(const CoreAccountId& account_id) override;
bool DeprecatedSetPrimaryAccountAndUpdateAccountInfo(
const std::string& gaia_id,
const std::string& email) override;
#endif
#if !defined(OS_CHROMEOS)
bool ClearPrimaryAccount(
......
......@@ -72,18 +72,6 @@ class PrimaryAccountMutator {
// of "unconsented".
virtual void SetUnconsentedPrimaryAccount(
const CoreAccountId& account_id) = 0;
// Updates the info of the account corresponding to (|gaia_id|, |email|),
// marks it as the primary account, and returns whether the operation
// succeeded or not. Currently, this method is guaranteed to succeed.
// NOTE: Unlike SetPrimaryAccount(), this method does not require that the
// account is known by IdentityManager. The reason is that there are
// contexts on ChromeOS where the primary account is not guaranteed to be
// known by IdentityManager when it is set.
// TODO(https://crbug.com/987955): Remove this API.
virtual bool DeprecatedSetPrimaryAccountAndUpdateAccountInfo(
const std::string& gaia_id,
const std::string& email) = 0;
#endif
#if !defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment