Commit 23101000 authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] Remove deprecated pref kGoogleServicesUsername

This pref is deprecated since M43 and can now be removed.

TBR=jzw

Change-Id: Ie01b4946af6453f786aa05a348ce51c8e3477f39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787782
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695101}
parent 242ce7d8
......@@ -495,6 +495,9 @@ const char kSameVersionStartupCount[] =
// Deprecated 8/2019
const char kHintLoadedCounts[] = "optimization_guide.hint_loaded_counts";
// Deprecated 9/2019
const char kGoogleServicesUsername[] = "google.services.username";
// Register prefs used only for migration (clearing or moving to a new key).
void RegisterProfilePrefsForMigration(
user_prefs::PrefRegistrySyncable* registry) {
......@@ -571,6 +574,7 @@ void RegisterProfilePrefsForMigration(
registry->RegisterBooleanPref(kInsecureExtensionUpdatesEnabled, false);
registry->RegisterDictionaryPref(kHintLoadedCounts);
registry->RegisterStringPref(kGoogleServicesUsername, std::string());
}
} // namespace
......@@ -1179,4 +1183,7 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
// Added 8/2019
profile_prefs->ClearPref(kInsecureExtensionUpdatesEnabled);
profile_prefs->ClearPref(kHintLoadedCounts);
// Added 9/2019
profile_prefs->ClearPref(kGoogleServicesUsername);
}
......@@ -151,10 +151,6 @@ const prefs::TrackedPreferenceMetadata kTrackedPrefs[] = {
{19, prefs::kSwReporterPromptVersion, EnforcementLevel::ENFORCE_ON_LOAD,
PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL},
#endif
// This pref is deprecated and will be removed a few releases after M43.
// kGoogleServicesAccountId replaces it.
{21, prefs::kGoogleServicesUsername, EnforcementLevel::ENFORCE_ON_LOAD,
PrefTrackingStrategy::ATOMIC, ValueType::PERSONAL},
#if defined(OS_WIN)
{22, prefs::kSwReporterPromptSeed, EnforcementLevel::ENFORCE_ON_LOAD,
PrefTrackingStrategy::ATOMIC, ValueType::IMPERSONAL},
......
......@@ -115,8 +115,6 @@ class MirrorBrowserTest : public InProcessBrowserTest {
// and not because it was on a secure Google domain.
// This is a regression test for crbug.com/588492.
IN_PROC_BROWSER_TEST_F(MirrorBrowserTest, MirrorRequestHeader) {
browser()->profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
"user@gmail.com");
browser()->profile()->GetPrefs()->SetString(
prefs::kGoogleServicesUserAccountId, "account_id");
......
......@@ -59,9 +59,6 @@ void PrimaryAccountManager::RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterListPref(prefs::kReverseAutologinRejectedEmailList);
registry->RegisterBooleanPref(prefs::kSigninAllowed, true);
registry->RegisterBooleanPref(prefs::kSignedInWithCredentialProvider, false);
// Deprecated prefs: will be removed in a future release.
registry->RegisterStringPref(prefs::kGoogleServicesUsername, std::string());
}
// static
......@@ -81,63 +78,12 @@ void PrimaryAccountManager::Initialize(PrefService* local_state) {
base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch(switches::kClearTokenService)) {
client_->GetPrefs()->ClearPref(prefs::kGoogleServicesAccountId);
client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUserAccountId);
}
std::string pref_account_id =
client_->GetPrefs()->GetString(prefs::kGoogleServicesAccountId);
// Handle backward compatibility: if kGoogleServicesAccountId is empty, but
// kGoogleServicesUsername is not, then this is an old profile that needs to
// be updated. kGoogleServicesUserAccountId should not be empty, and contains
// the gaia_id. Use both properties to prime the account tracker before
// proceeding.
if (pref_account_id.empty()) {
std::string pref_account_username =
client_->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
if (!pref_account_username.empty()) {
// This is an old profile connected to a google account. Migrate from
// kGoogleServicesUsername to kGoogleServicesAccountId.
std::string pref_gaia_id =
client_->GetPrefs()->GetString(prefs::kGoogleServicesUserAccountId);
// If kGoogleServicesUserAccountId is empty, then this is either a cros
// machine or a really old profile on one of the other platforms. However
// in this case the account tracker should have the gaia_id so fetch it
// from there.
if (pref_gaia_id.empty()) {
CoreAccountInfo info = account_tracker_service_->FindAccountInfoByEmail(
pref_account_username);
pref_gaia_id = info.gaia;
}
// If |pref_gaia_id| is still empty, this means the profile has been in
// an auth error state for some time (since M39). It could also mean
// a profile that has not been used since M33. Before migration to gaia
// id is complete, the returned value will be the normalized email, which
// is correct. After the migration, the returned value will be empty,
// which means the user is essentially signed out.
// TODO(rogerta): may want to show a toast or something.
pref_account_id =
account_tracker_service_
->SeedAccountInfo(pref_gaia_id, pref_account_username)
.id;
// Set account id before removing obsolete user name in case crash in the
// middle.
client_->GetPrefs()->SetString(prefs::kGoogleServicesAccountId,
pref_account_id);
// Now remove obsolete preferences.
client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
}
// TODO(rogerta): once migration to gaia id is complete, remove
// kGoogleServicesUserAccountId and change all uses of that pref to
// kGoogleServicesAccountId.
}
if (!pref_account_id.empty()) {
if (account_tracker_service_->GetMigrationState() ==
AccountTrackerService::MIGRATION_IN_PROGRESS) {
......
......@@ -328,58 +328,6 @@ TEST_F(PrimaryAccountManagerTest, SigninNotAllowed) {
}
#endif
TEST_F(PrimaryAccountManagerTest, UpgradeToNewPrefs) {
user_prefs_.SetString(prefs::kGoogleServicesUsername, "user@gmail.com");
user_prefs_.SetString(prefs::kGoogleServicesUserAccountId, "account_id");
CreatePrimaryAccountManager();
EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedAccountInfo().email);
if (account_tracker()->GetMigrationState() ==
AccountTrackerService::MIGRATION_NOT_STARTED) {
// TODO(rogerta): until the migration to gaia id, the account id will remain
// the old username.
EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedAccountId());
EXPECT_EQ("user@gmail.com",
user_prefs_.GetString(prefs::kGoogleServicesAccountId));
} else {
EXPECT_EQ("account_id", manager_->GetAuthenticatedAccountId());
EXPECT_EQ("account_id",
user_prefs_.GetString(prefs::kGoogleServicesAccountId));
}
EXPECT_EQ("", user_prefs_.GetString(prefs::kGoogleServicesUsername));
// Make sure account tracker was updated.
AccountInfo info =
account_tracker()->GetAccountInfo(manager_->GetAuthenticatedAccountId());
EXPECT_EQ("user@gmail.com", info.email);
EXPECT_EQ("account_id", info.gaia);
}
TEST_F(PrimaryAccountManagerTest, CanonicalizesPrefs) {
// This unit test is not needed after migrating to gaia id.
if (account_tracker()->GetMigrationState() ==
AccountTrackerService::MIGRATION_NOT_STARTED) {
user_prefs_.SetString(prefs::kGoogleServicesUsername, "user.C@gmail.com");
CreatePrimaryAccountManager();
EXPECT_EQ("user.C@gmail.com",
manager_->GetAuthenticatedAccountInfo().email);
// TODO(rogerta): until the migration to gaia id, the account id will remain
// the old username.
EXPECT_EQ("userc@gmail.com", manager_->GetAuthenticatedAccountId());
EXPECT_EQ("userc@gmail.com",
user_prefs_.GetString(prefs::kGoogleServicesAccountId));
EXPECT_EQ("", user_prefs_.GetString(prefs::kGoogleServicesUsername));
// Make sure account tracker has a canonicalized username.
AccountInfo info = account_tracker()->GetAccountInfo(
manager_->GetAuthenticatedAccountId());
EXPECT_EQ("user.C@gmail.com", info.email);
EXPECT_EQ("userc@gmail.com", info.account_id);
}
}
TEST_F(PrimaryAccountManagerTest, GaiaIdMigration) {
if (account_tracker()->GetMigrationState() !=
AccountTrackerService::MIGRATION_NOT_STARTED) {
......@@ -409,35 +357,6 @@ TEST_F(PrimaryAccountManagerTest, GaiaIdMigration) {
}
}
TEST_F(PrimaryAccountManagerTest, VeryOldProfileGaiaIdMigration) {
if (account_tracker()->GetMigrationState() !=
AccountTrackerService::MIGRATION_NOT_STARTED) {
std::string email = "user@gmail.com";
std::string gaia_id = "account_gaia_id";
PrefService* client_prefs = signin_client()->GetPrefs();
client_prefs->SetInteger(prefs::kAccountIdMigrationState,
AccountTrackerService::MIGRATION_NOT_STARTED);
ListPrefUpdate update(client_prefs, prefs::kAccountInfo);
update->Clear();
auto dict = std::make_unique<base::DictionaryValue>();
dict->SetString("account_id", email);
dict->SetString("email", email);
dict->SetString("gaia", gaia_id);
update->Append(std::move(dict));
account_tracker()->Shutdown();
account_tracker()->Initialize(prefs(), base::FilePath());
client_prefs->ClearPref(prefs::kGoogleServicesAccountId);
client_prefs->SetString(prefs::kGoogleServicesUsername, email);
CreatePrimaryAccountManager();
EXPECT_EQ(gaia_id, manager_->GetAuthenticatedAccountId());
EXPECT_EQ(gaia_id, user_prefs_.GetString(prefs::kGoogleServicesAccountId));
}
}
TEST_F(PrimaryAccountManagerTest, GaiaIdMigrationCrashInTheMiddle) {
if (account_tracker()->GetMigrationState() !=
AccountTrackerService::MIGRATION_NOT_STARTED) {
......
......@@ -56,12 +56,10 @@ const char kGoogleServicesHostedDomain[] = "google.services.hosted_domain";
const char kGoogleServicesLastAccountId[] = "google.services.last_account_id";
// String the identifies the last user that logged into sync and other
// google services. As opposed to kGoogleServicesUsername, this value is not
// cleared on signout, but while the user is signed in the two values will
// be the same. This pref remains in order to pre-fill the sign in page when
// reconnecting a profile, but programmatic checks to see if a given account
// is the same as the last account should use kGoogleServicesLastAccountId
// instead.
// google services. This value is not cleared on signout.
// This pref remains in order to pre-fill the sign in page when reconnecting a
// profile, but programmatic checks to see if a given account is the same as the
// last account should use kGoogleServicesLastAccountId instead.
const char kGoogleServicesLastUsername[] = "google.services.last_username";
// Device id scoped to single signin. This device id will be regenerated if user
......@@ -74,11 +72,6 @@ const char kGoogleServicesSigninScopedDeviceId[] =
// other google services.
const char kGoogleServicesUserAccountId[] = "google.services.user_account_id";
// String that identifies the current user logged into sync and other google
// services.
// DEPRECATED.
const char kGoogleServicesUsername[] = "google.services.username";
// Local state pref containing a string regex that restricts which accounts
// can be used to log in to chrome (e.g. "*@google.com"). If missing or blank,
// all accounts are allowed (no restrictions).
......
......@@ -22,7 +22,6 @@ extern const char kGoogleServicesLastAccountId[];
extern const char kGoogleServicesLastUsername[];
extern const char kGoogleServicesSigninScopedDeviceId[];
extern const char kGoogleServicesUserAccountId[];
extern const char kGoogleServicesUsername[];
extern const char kGoogleServicesUsernamePattern[];
extern const char kReverseAutologinRejectedEmailList[];
extern const char kSignedInWithCredentialProvider[];
......
......@@ -71,6 +71,9 @@ namespace {
const char kReverseAutologinEnabled[] = "reverse_autologin.enabled";
const char kLastKnownGoogleURL[] = "browser.last_known_google_url";
const char kLastPromptedGoogleURL[] = "browser.last_prompted_google_url";
// Deprecated 9/2019
const char kGoogleServicesUsername[] = "google.services.username";
}
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
......@@ -180,6 +183,7 @@ void RegisterBrowserStatePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(kReverseAutologinEnabled, true);
registry->RegisterStringPref(kLastKnownGoogleURL, std::string());
registry->RegisterStringPref(kLastPromptedGoogleURL, std::string());
registry->RegisterStringPref(kGoogleServicesUsername, std::string());
}
// This method should be periodically pruned of year+ old migrations.
......@@ -208,4 +212,7 @@ void MigrateObsoleteBrowserStatePrefs(PrefService* prefs) {
syncer::ClearObsoleteSyncLongPollIntervalSeconds(prefs);
prefs->ClearPref(kLastKnownGoogleURL);
prefs->ClearPref(kLastPromptedGoogleURL);
// Added 09/2019
prefs->ClearPref(kGoogleServicesUsername);
}
......@@ -65,7 +65,6 @@ WebViewIdentityManagerFactory::BuildServiceInstanceFor(
// ChromeWebView's signin state.
PrefService* pref_service = browser_state->GetPrefs();
pref_service->ClearPref(prefs::kGoogleServicesAccountId);
pref_service->ClearPref(prefs::kGoogleServicesUsername);
pref_service->ClearPref(prefs::kGoogleServicesUserAccountId);
IOSWebViewSigninClient* client =
......
......@@ -59858,7 +59858,7 @@ Full version information for the fingerprint enum values:
<int value="18" label="kSafeBrowsingIncidentsSent"/>
<int value="19" label="kSwReporterPromptVersion"/>
<int value="20" label="kSwReporterPromptReason"/>
<int value="21" label="kGoogleServicesUsername"/>
<int value="21" label="kGoogleServicesUsername (Obsolete 9/2019)"/>
<int value="22" label="kSwReporterPromptSeed"/>
<int value="23" label="kGoogleServicesAccountId"/>
<int value="24" label="kGoogleServicesLastAccountId"/>
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