Commit 27e60f33 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

Migrate device account even when CoreAccountId is built from Gaia ID

We are in the process to migrate from using email as the account
identifier to using the Gaia ID of the account. This CL changes the
AccoutnManagerMigrator to support this migration.

Bug: 1028512
Change-Id: I2c8ddc53e524d3d04a11c6e10ca7a24ae99f5590
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954467
Auto-Submit: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722469}
parent bd08649f
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "components/signin/public/webdata/token_web_data.h" #include "components/signin/public/webdata/token_web_data.h"
#include "components/user_manager/user.h" #include "components/user_manager/user.h"
#include "components/webdata/common/web_data_service_consumer.h" #include "components/webdata/common/web_data_service_consumer.h"
#include "google_apis/gaia/gaia_auth_util.h"
namespace chromeos { namespace chromeos {
...@@ -229,10 +230,17 @@ class DeviceAccountMigration : public AccountMigrationBaseStep, ...@@ -229,10 +230,17 @@ class DeviceAccountMigration : public AccountMigrationBaseStep,
bool is_success = false; bool is_success = false;
for (auto it = token_map.begin(); it != token_map.end(); ++it) { for (auto it = token_map.begin(); it != token_map.end(); ++it) {
const std::string account_id = RemoveAccountIdPrefix(it->first); const std::string token_account_id = RemoveAccountIdPrefix(it->first);
if (identity_manager()->GetPrimaryAccountId().ToString() != account_id) { if (token_account_id.empty()) {
LOG(ERROR) << "Empty account id loaded from token DB.";
continue; continue;
} }
DCHECK(token_account_id.find('@') != std::string::npos)
<< "Expecting an email as the account ID of a token [actual = "
<< token_account_id << "]";
if (!gaia::AreEmailsSame(device_account_raw_email_, token_account_id))
continue;
account_manager()->UpsertAccount( account_manager()->UpsertAccount(
device_account_, device_account_raw_email_ /* raw_email */, device_account_, device_account_raw_email_ /* raw_email */,
......
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