[UPMLocalSettings] Remove the old settings migration pref

The UPM migration for the syncing users is done.
The migration pref was being written to, but not used for re-enrollment,
so it's no longer useful.

OBSOLETE_HISTOGRAMS[PasswordManager.MigratedSettingsUPMAndroid]= The
histogram is no longer needed because the UPM settings migration
strategy has changed.

Bug: 1486451
Change-Id: I17954d5794de2f5f42c17059d90b9f12993c6972
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4887476
Commit-Queue: Ivana Žužić <[email protected]>
Reviewed-by: Vasilii Sukhanov <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1203212}
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc
index a3b7e39..e5728a7 100644
--- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc
+++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.cc
@@ -192,7 +192,7 @@
 
 void PasswordManagerSettingsServiceAndroidImpl::Init() {
   CHECK(bridge_helper_);
-  MigratePrefsIfNeeded();
+  // TODO(crbug.com/1485556): Copy the pref values to GMSCore for local users.
   bridge_helper_->SetConsumer(weak_ptr_factory_.GetWeakPtr());
 
   lifecycle_helper_->RegisterObserver(base::BindRepeating(
@@ -228,9 +228,39 @@
     return;
   }
 
+  WriteToTheCacheAndRegularPref(setting, value);
+}
+
+void PasswordManagerSettingsServiceAndroidImpl::OnSettingValueAbsent(
+    password_manager::PasswordManagerSetting setting) {
+  CHECK(bridge_helper_);
+  UpdateSettingFetchState(setting);
+
+  if (IsUnenrolledFromUPM(pref_service_))
+    return;
+
+  if (!IsPasswordSyncEnabled(sync_service_))
+    return;
+
+  // This code is currently called only for syncing users. If the setting value
+  // is absent in GMSCore, the cached setting value is set to the default value,
+  // which is true for both of the password-related settings: AutoSingIn and
+  // OfferToSavePasswords.
+  WriteToTheCacheAndRegularPref(setting, absl::nullopt);
+
+  // TODO(crbug.com/1486847): Handle the absent value for local passwords.
+}
+
+void PasswordManagerSettingsServiceAndroidImpl::WriteToTheCacheAndRegularPref(
+    PasswordManagerSetting setting,
+    absl::optional<bool> value) {
   const PrefService::Preference* android_pref =
       GetGMSPrefFromSetting(pref_service_, setting);
-  pref_service_->SetBoolean(android_pref->name(), value);
+  if (value.has_value()) {
+    pref_service_->SetBoolean(android_pref->name(), value.value());
+  } else {
+    pref_service_->ClearPref(android_pref->name());
+  }
 
   // Updating the regular pref now will ensure that if passwods sync turns off
   // the regular pref contains the latest setting value. This can only be done
@@ -240,55 +270,14 @@
   if (!HasChosenToSyncPreferences(sync_service_)) {
     const PrefService::Preference* regular_pref =
         GetRegularPrefFromSetting(pref_service_, setting);
-    pref_service_->SetBoolean(regular_pref->name(), value);
+    if (value.has_value()) {
+      pref_service_->SetBoolean(regular_pref->name(), value.value());
+    } else {
+      pref_service_->ClearPref(regular_pref->name());
+    }
   }
 }
 
-void PasswordManagerSettingsServiceAndroidImpl::OnSettingValueAbsent(
-    password_manager::PasswordManagerSetting setting) {
-  CHECK(bridge_helper_);
-  UpdateSettingFetchState(setting);
-  if (IsUnenrolledFromUPM(pref_service_))
-    return;
-
-  if (!IsPasswordSyncEnabled(sync_service_))
-    return;
-
-  const PrefService::Preference* pref =
-      GetGMSPrefFromSetting(pref_service_, setting);
-
-  // If both GMS and Chrome have default values for the setting, then no update
-  // is needed.
-  if (!pref_service_->GetUserPrefValue(pref->name()))
-    return;
-
-  // If Chrome has an explicitly set value, GMS needs to know about it.
-  // TODO(crbug.com/1289700): Check whether this should be guarded by a
-  // migration pref.
-  bridge_helper_->SetPasswordSettingValue(
-      SyncingAccount(sync_service_->GetAccountInfo().email), setting,
-      pref->GetValue()->GetBool());
-}
-
-void PasswordManagerSettingsServiceAndroidImpl::MigratePrefsIfNeeded() {
-  if (IsUnenrolledFromUPM(pref_service_))
-    return;
-
-  if (pref_service_->GetBoolean(
-          password_manager::prefs::kSettingsMigratedToUPM))
-    return;
-
-  base::UmaHistogramBoolean("PasswordManager.MigratedSettingsUPMAndroid", true);
-  pref_service_->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                            true);
-  // No need to copy the values until sync turns on. When sync turns on, this
-  // will be handled as part of the sync state change rather than migration.
-  if (!IsPasswordSyncEnabled(sync_service_))
-    return;
-
-  DumpChromePrefsIntoGMSPrefs();
-}
-
 void PasswordManagerSettingsServiceAndroidImpl::OnStateChanged(
     syncer::SyncService* sync) {
   if (IsUnenrolledFromUPM(pref_service_))
@@ -300,9 +289,6 @@
 
   is_password_sync_enabled_ = IsPasswordSyncEnabled(sync);
 
-  if (is_password_sync_enabled_)
-    DumpChromePrefsIntoGMSPrefs();
-
   // Fetch settings from the backend to align values stored in GMS Core and
   // Chrome.
   fetch_after_sync_status_change_in_progress_ = true;
@@ -331,32 +317,11 @@
   }
 }
 
-void PasswordManagerSettingsServiceAndroidImpl::DumpChromePrefsIntoGMSPrefs() {
-  for (PasswordManagerSetting setting : kAllPasswordSettings) {
-    const PrefService::Preference* regular_pref =
-        GetRegularPrefFromSetting(pref_service_, setting);
-
-    if (!pref_service_->GetUserPrefValue(regular_pref->name()))
-      continue;
-
-    const PrefService::Preference* gms_pref =
-        GetGMSPrefFromSetting(pref_service_, setting);
-
-    // Make sure the user prefs are consistent. If the settings are set by
-    // policy, the value of the managed pref will still apply in checks, but
-    // the UPM prefs should contain the user set value.
-    pref_service_->SetBoolean(
-        gms_pref->name(),
-        pref_service_->GetUserPrefValue(regular_pref->name())->GetBool());
-  }
-}
-
 void PasswordManagerSettingsServiceAndroidImpl::
     OnUnenrollmentPreferenceChanged() {
   if (!IsUnenrolledFromUPM(pref_service_)) {
     // Perform actions that are usually done on startup, but were skipped
     // for the evicted users.
-    MigratePrefsIfNeeded();
     RequestSettingsFromBackend();
   }
 }
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h
index b0d8c818..6fd9a11 100644
--- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h
+++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl.h
@@ -70,14 +70,12 @@
   void OnSettingValueAbsent(
       password_manager::PasswordManagerSetting setting) override;
 
-  // Updates the non syncable, android-only prefs with the values of the
-  // syncable cross-platform prefs as the latter won't be used when UPM
-  // is up and running. There is no need to migrate the values until sync turns
-  // on, because UPM is not running until then. When sync turns on, this
-  // will be handled as part of the sync state change rather than migration.
-  // If a migration was already performed, there is no need
-  // to migrate again.
-  void MigratePrefsIfNeeded();
+  // Stores the given `value` of the `setting` into the android-only GMS prefs.
+  // Stores the same `value` in the old prefs are not being synced.
+  // If the `value` is not given, the prefs will be set to default.
+  void WriteToTheCacheAndRegularPref(
+      password_manager::PasswordManagerSetting setting,
+      absl::optional<bool> value);
 
   // syncer::SyncServiceObserver implementation
   void OnStateChanged(syncer::SyncService* sync) override;
@@ -90,10 +88,6 @@
   // Asynchronously fetches settings from backend regardless of sync status.
   void FetchSettings();
 
-  // Copies the values of chrome prefs that have user-set values into the
-  // GMS prefs.
-  void DumpChromePrefsIntoGMSPrefs();
-
   // Migrates settings to GMS Core if the user is reenrolled into the UPM
   // in the middle of the browser session.
   void OnUnenrollmentPreferenceChanged();
diff --git a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc
index 2b6addd..df25966a 100644
--- a/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc
+++ b/chrome/browser/password_manager/android/password_manager_settings_service_android_impl_unittest.cc
@@ -207,8 +207,6 @@
   test_pref_service_.registry()->RegisterStringPref(
       ::prefs::kGoogleServicesLastUsername, kTestAccount);
   test_pref_service_.registry()->RegisterBooleanPref(
-      password_manager::prefs::kSettingsMigratedToUPM, false);
-  test_pref_service_.registry()->RegisterBooleanPref(
       password_manager::prefs::kUnenrolledFromGoogleMobileServicesDueToErrors,
       false);
 }
@@ -233,150 +231,6 @@
 }
 
 TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       TestNoAdditionalMigration) {
-  // Imitate the post-migration state by setting the migration pref.
-  pref_service()->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                             true);
-
-  // No additional migration should happen if the migration pref wasn't reset.
-  CreateNewService();
-  histogram_tester()->ExpectTotalCount(
-      "PasswordManager.MigratedSettingsUPMAndroid", 0);
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kOfferToSavePasswordsEnabledGMS),
-            nullptr);
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kAutoSignInEnabledGMS),
-            nullptr);
-}
-
-TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       TestNewMigrationIfPrefUndoneSyncOff) {
-  // Reset the migration pref.
-  pref_service()->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                             false);
-  // Set an explicit value on the "Offer to save passwords" pref.
-  pref_service()->SetBoolean(password_manager::prefs::kCredentialsEnableService,
-                             false);
-
-  // No migration should happen if passwords sync is off, but the migration
-  // should be marked as done. This is because at a later point, when sync
-  // turns on, the GMS prefs will be updated as part of the sync state change
-  // instead of the migration.
-  SetPasswordsSync(false);
-  CreateNewService();
-  histogram_tester()->ExpectUniqueSample(
-      "PasswordManager.MigratedSettingsUPMAndroid", true, 1);
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kOfferToSavePasswordsEnabledGMS),
-            nullptr);
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kAutoSignInEnabledGMS),
-            nullptr);
-  EXPECT_TRUE(pref_service()->GetBoolean(
-      password_manager::prefs::kSettingsMigratedToUPM));
-}
-
-TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       TestNewMigrationIfPrefUndoneSyncOn) {
-  // Reset the migration pref.
-  pref_service()->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                             false);
-  // Set an explicit value on the "Offer to save passwords" pref.
-  pref_service()->SetBoolean(password_manager::prefs::kCredentialsEnableService,
-                             false);
-
-  // Migration changes are expected if sync is on when the service is created.
-  SetPasswordsSync(true);
-  CreateNewService();
-  histogram_tester()->ExpectUniqueSample(
-      "PasswordManager.MigratedSettingsUPMAndroid", true, 1);
-  EXPECT_FALSE(pref_service()->GetBoolean(
-      password_manager::prefs::kOfferToSavePasswordsEnabledGMS));
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kAutoSignInEnabledGMS),
-            nullptr);
-}
-
-TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       TestNewMigrationManagedPrefSetValue) {
-  // Reset the migration pref.
-  pref_service()->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                             false);
-  // Set an explicit value on the "Offer to save passwords" pref.
-  pref_service()->SetBoolean(password_manager::prefs::kCredentialsEnableService,
-                             true);
-  // Saving passwords is disabled by policy.
-  pref_service()->SetManagedPref(
-      password_manager::prefs::kCredentialsEnableService, base::Value(false));
-
-  // Create a new service and expect that the migration stores the user value,
-  // not the one enforced by policy.
-  SetPasswordsSync(true);
-  CreateNewService();
-  histogram_tester()->ExpectUniqueSample(
-      "PasswordManager.MigratedSettingsUPMAndroid", true, 1);
-  EXPECT_TRUE(pref_service()->GetBoolean(
-      password_manager::prefs::kSettingsMigratedToUPM));
-  EXPECT_TRUE(pref_service()->GetBoolean(
-      password_manager::prefs::kOfferToSavePasswordsEnabledGMS));
-  EXPECT_NE(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kOfferToSavePasswordsEnabledGMS),
-            nullptr);
-}
-
-TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       TestNewMigrationManagedPrefDefaultValue) {
-  // Reset the migration pref.
-  pref_service()->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                             false);
-  // Saving passwords is disabled by policy.
-  pref_service()->SetManagedPref(
-      password_manager::prefs::kCredentialsEnableService, base::Value(false));
-
-  // Create a new service and expect that the migration doesn't change the
-  // GMS pref value, because the user hasn't set any value.
-  SetPasswordsSync(true);
-  CreateNewService();
-  histogram_tester()->ExpectUniqueSample(
-      "PasswordManager.MigratedSettingsUPMAndroid", true, 1);
-  EXPECT_TRUE(pref_service()->GetBoolean(
-      password_manager::prefs::kSettingsMigratedToUPM));
-  EXPECT_TRUE(pref_service()->GetBoolean(
-      password_manager::prefs::kOfferToSavePasswordsEnabledGMS));
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kOfferToSavePasswordsEnabledGMS),
-            nullptr);
-}
-
-TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       TestNewMigrationUserUnenrolledFromUPM) {
-  pref_service()->SetBoolean(
-      password_manager::prefs::kUnenrolledFromGoogleMobileServicesDueToErrors,
-      true);
-  ASSERT_FALSE(pref_service()->GetBoolean(
-      password_manager::prefs::kSettingsMigratedToUPM));
-  // Set an explicit value on the "Offer to save passwords" pref.
-  pref_service()->SetBoolean(password_manager::prefs::kCredentialsEnableService,
-                             false);
-
-  // No migration should happen if passwords sync is broken, no prefs should
-  // change and no metrcis should be recorded.
-  InitializeSettingsService(/*password_sync_enabled=*/true,
-                            /*setting_sync_enabled=*/true);
-  histogram_tester()->ExpectTotalCount(
-      "PasswordManager.MigratedSettingsUPMAndroid", 0);
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kOfferToSavePasswordsEnabledGMS),
-            nullptr);
-  EXPECT_EQ(pref_service()->GetUserPrefValue(
-                password_manager::prefs::kAutoSignInEnabledGMS),
-            nullptr);
-  EXPECT_FALSE(pref_service()->GetBoolean(
-      password_manager::prefs::kSettingsMigratedToUPM));
-}
-
-TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
        OnSaveSettingFetchSyncingBoth) {
   InitializeSettingsService(/*password_sync_enabled=*/true,
                             /*setting_sync_enabled=*/true);
@@ -494,16 +348,18 @@
 }
 
 TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       OnSaveSettingAbsentSetValueSyncing) {
+       OnSaveSettingAbsentDoesntSetValueSyncing) {
   InitializeSettingsService(/*password_sync_enabled=*/true,
                             /*setting_sync_enabled=*/true);
   pref_service()->SetUserPref(
       password_manager::prefs::kOfferToSavePasswordsEnabledGMS,
       base::Value(false));
+  // The settings for syncing users should no longer be written to GMSCore.
   EXPECT_CALL(*bridge_helper(),
               SetPasswordSettingValue(
                   Eq(SyncingAccount(kTestAccount)),
-                  Eq(PasswordManagerSetting::kOfferToSavePasswords), false));
+                  Eq(PasswordManagerSetting::kOfferToSavePasswords), false))
+      .Times(0);
   updater_bridge_consumer()->OnSettingValueAbsent(
       PasswordManagerSetting::kOfferToSavePasswords);
 }
@@ -545,15 +401,18 @@
 }
 
 TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       OnAutoSignInAbsentSetValueSyncing) {
+       OnAutoSignInAbsentDontSetValueSyncing) {
   InitializeSettingsService(/*password_sync_enabled=*/true,
                             /*setting_sync_enabled=*/true);
   pref_service()->SetUserPref(password_manager::prefs::kAutoSignInEnabledGMS,
                               base::Value(false));
+
+  // The settings for syncing users should no longer be written to GmsCore.
   EXPECT_CALL(
       *bridge_helper(),
       SetPasswordSettingValue(Eq(SyncingAccount(kTestAccount)),
-                              Eq(PasswordManagerSetting::kAutoSignIn), false));
+                              Eq(PasswordManagerSetting::kAutoSignIn), false))
+      .Times(0);
   updater_bridge_consumer()->OnSettingValueAbsent(
       PasswordManagerSetting::kAutoSignIn);
 }
@@ -586,7 +445,7 @@
 // Checks that general syncable prefs are dumped into the android-only GMS
 // prefs before settings are requested when sync is enabled.
 TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       PasswordSyncEnablingPrefsMoving) {
+       PasswordSyncEnablingDoesntMovePrefs) {
   InitializeSettingsService(/*password_sync_enabled=*/false,
                             /*setting_sync_enabled=*/false);
   pref_service()->SetUserPref(
@@ -602,9 +461,9 @@
   SetPasswordsSync(/*enabled=*/true);
   sync_service()->FireStateChanged();
 
-  EXPECT_FALSE(pref_service()->GetBoolean(
+  EXPECT_TRUE(pref_service()->GetBoolean(
       password_manager::prefs::kOfferToSavePasswordsEnabledGMS));
-  EXPECT_FALSE(pref_service()->GetBoolean(
+  EXPECT_TRUE(pref_service()->GetBoolean(
       password_manager::prefs::kAutoSignInEnabledGMS));
 }
 
@@ -676,18 +535,19 @@
   SetPasswordsSync(/*enabled=*/true);
   sync_service()->FireStateChanged();
 
-  // If there is no user setting stored in GMS Core, Chrome setting should be
-  // set in it.
+  // If there is no user setting stored in GMS Core, Chrome setting should not
+  // be set in it.
   EXPECT_CALL(
       *bridge_helper(),
       SetPasswordSettingValue(Eq(SyncingAccount(kTestAccount)),
-                              Eq(PasswordManagerSetting::kAutoSignIn), false));
+                              Eq(PasswordManagerSetting::kAutoSignIn), false))
+      .Times(0);
   updater_bridge_consumer()->OnSettingValueAbsent(
       PasswordManagerSetting::kAutoSignIn);
 
-  EXPECT_FALSE(pref_service()->GetBoolean(
+  EXPECT_TRUE(pref_service()->GetBoolean(
       password_manager::prefs::kCredentialsEnableAutosignin));
-  EXPECT_FALSE(pref_service()->GetBoolean(
+  EXPECT_TRUE(pref_service()->GetBoolean(
       password_manager::prefs::kAutoSignInEnabledGMS));
 }
 
@@ -1113,16 +973,13 @@
 }
 
 TEST_F(PasswordManagerSettingsServiceAndroidImplTest,
-       TestMigrateSettingsOnReenrollingIntoUPM) {
+       TestDontMigrateSettingsOnReenrollingIntoUPM) {
   SetPasswordsSync(true);
 
   pref_service()->SetBoolean(
       password_manager::prefs::kUnenrolledFromGoogleMobileServicesDueToErrors,
       true);
 
-  // Reset the migration pref.
-  pref_service()->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                             false);
   // Set an explicit value on the "Offer to save passwords" pref.
   pref_service()->SetBoolean(password_manager::prefs::kCredentialsEnableService,
                              false);
@@ -1136,10 +993,7 @@
       password_manager::prefs::kUnenrolledFromGoogleMobileServicesDueToErrors,
       false);
 
-  // Check that Chrome prefs are dumped into GMS prefs.
-  histogram_tester()->ExpectUniqueSample(
-      "PasswordManager.MigratedSettingsUPMAndroid", true, 1);
-  EXPECT_FALSE(pref_service()->GetBoolean(
+  EXPECT_TRUE(pref_service()->GetBoolean(
       password_manager::prefs::kOfferToSavePasswordsEnabledGMS));
   EXPECT_EQ(pref_service()->GetUserPrefValue(
                 password_manager::prefs::kAutoSignInEnabledGMS),
diff --git a/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc b/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc
index 222696c..ec06ae69 100644
--- a/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc
+++ b/chrome/browser/password_manager/android/password_store_android_backend_unittest.cc
@@ -204,7 +204,6 @@
         prefs::kCurrentMigrationVersionToGoogleMobileServices, 1);
     prefs_.registry()->RegisterDoublePref(prefs::kTimeOfLastMigrationAttempt,
                                           20.22);
-    prefs_.registry()->RegisterBooleanPref(prefs::kSettingsMigratedToUPM, true);
 
     backend_ = std::make_unique<PasswordStoreAndroidBackend>(
         base::PassKey<class PasswordStoreAndroidBackendTest>(),
@@ -696,7 +695,6 @@
                 prefs::kCurrentMigrationVersionToGoogleMobileServices),
             0);
   EXPECT_EQ(prefs()->GetDouble(prefs::kTimeOfLastMigrationAttempt), 0.0);
-  EXPECT_FALSE(prefs()->GetBoolean(prefs::kSettingsMigratedToUPM));
 
   const char kErrorCodeMetric[] =
       "PasswordManager.PasswordStoreAndroidBackend.ErrorCode";
@@ -741,7 +739,6 @@
                 prefs::kCurrentMigrationVersionToGoogleMobileServices),
             0);
   EXPECT_NE(prefs()->GetDouble(prefs::kTimeOfLastMigrationAttempt), 0.0);
-  EXPECT_TRUE(prefs()->GetBoolean(prefs::kSettingsMigratedToUPM));
 
   const char kErrorCodeMetric[] =
       "PasswordManager.PasswordStoreAndroidBackend.ErrorCode";
@@ -795,7 +792,6 @@
                 prefs::kCurrentMigrationVersionToGoogleMobileServices),
             0);
   EXPECT_EQ(prefs()->GetDouble(prefs::kTimeOfLastMigrationAttempt), 0.0);
-  EXPECT_FALSE(prefs()->GetBoolean(prefs::kSettingsMigratedToUPM));
 
   const char kErrorCodeMetric[] =
       "PasswordManager.PasswordStoreAndroidBackend.ErrorCode";
@@ -864,7 +860,6 @@
                 prefs::kCurrentMigrationVersionToGoogleMobileServices),
             0);
   EXPECT_NE(prefs()->GetDouble(prefs::kTimeOfLastMigrationAttempt), 0.0);
-  EXPECT_TRUE(prefs()->GetBoolean(prefs::kSettingsMigratedToUPM));
 
   const char kErrorCodeMetric[] =
       "PasswordManager.PasswordStoreAndroidBackend.ErrorCode";
@@ -1046,7 +1041,6 @@
                 prefs::kCurrentMigrationVersionToGoogleMobileServices),
             0);
   EXPECT_EQ(prefs()->GetDouble(prefs::kTimeOfLastMigrationAttempt), 0.0);
-  EXPECT_FALSE(prefs()->GetBoolean(prefs::kSettingsMigratedToUPM));
 
   const char kErrorCodeMetric[] =
       "PasswordManager.PasswordStoreAndroidBackend.ErrorCode";
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 3253e27..0825338 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -949,6 +949,13 @@
 inline constexpr char kPrivacySandboxManuallyControlled[] =
     "privacy_sandbox.manually_controlled";
 
+// Deprecated 09/2023.
+// Boolean value indicating whether the regular prefs were migrated to UPM
+// settings for syncing users.
+#if BUILDFLAG(IS_ANDROID)
+const char kSettingsMigratedToUPM[] = "profile.settings_migrated_to_upm";
+#endif
+
 // Register local state used only for migration (clearing or moving to a new
 // key).
 void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -1330,6 +1337,9 @@
   registry->RegisterBooleanPref(kSyncInitialSyncFeatureSetupCompleteOnAsh,
                                 false);
 #endif
+#if BUILDFLAG(IS_ANDROID)
+  registry->RegisterBooleanPref(kSettingsMigratedToUPM, false);
+#endif
 }
 
 }  // namespace
@@ -2500,6 +2510,9 @@
 #if BUILDFLAG(IS_CHROMEOS_ASH)
   profile_prefs->ClearPref(kSyncInitialSyncFeatureSetupCompleteOnAsh);
 #endif
+#if BUILDFLAG(IS_ANDROID)
+  profile_prefs->ClearPref(kSettingsMigratedToUPM);
+#endif
 
   // Please don't delete the following line. It is used by PRESUBMIT.py.
   // END_MIGRATE_OBSOLETE_PROFILE_PREFS
diff --git a/components/password_manager/core/browser/password_manager.cc b/components/password_manager/core/browser/password_manager.cc
index 3a4e79154..b2e6dc0 100644
--- a/components/password_manager/core/browser/password_manager.cc
+++ b/components/password_manager/core/browser/password_manager.cc
@@ -306,7 +306,6 @@
   registry->RegisterBooleanPref(prefs::kOfferToSavePasswordsEnabledGMS, true);
   registry->RegisterBooleanPref(prefs::kSavePasswordsSuspendedByError, false);
   registry->RegisterBooleanPref(prefs::kAutoSignInEnabledGMS, true);
-  registry->RegisterBooleanPref(prefs::kSettingsMigratedToUPM, false);
   registry->RegisterBooleanPref(prefs::kSettingsMigratedToUPMLocal, false);
   registry->RegisterIntegerPref(
       prefs::kCurrentMigrationVersionToGoogleMobileServices, 0);
diff --git a/components/password_manager/core/browser/password_manager_eviction_util.cc b/components/password_manager/core/browser/password_manager_eviction_util.cc
index c413cd4..f3c1a91 100644
--- a/components/password_manager/core/browser/password_manager_eviction_util.cc
+++ b/components/password_manager/core/browser/password_manager_eviction_util.cc
@@ -42,7 +42,6 @@
       password_manager::prefs::kCurrentMigrationVersionToGoogleMobileServices,
       0);
   prefs->SetDouble(password_manager::prefs::kTimeOfLastMigrationAttempt, 0.0);
-  prefs->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM, false);
 
   base::UmaHistogramBoolean("PasswordManager.UnenrolledFromUPMDueToErrors",
                             true);
diff --git a/components/password_manager/core/browser/password_manager_eviction_util_unittest.cc b/components/password_manager/core/browser/password_manager_eviction_util_unittest.cc
index 88bf4754..fb844dd1 100644
--- a/components/password_manager/core/browser/password_manager_eviction_util_unittest.cc
+++ b/components/password_manager/core/browser/password_manager_eviction_util_unittest.cc
@@ -67,8 +67,6 @@
       0);
   test_pref_service_.registry()->RegisterDoublePref(
       password_manager::prefs::kTimeOfLastMigrationAttempt, 0.0);
-  test_pref_service_.registry()->RegisterBooleanPref(
-      password_manager::prefs::kSettingsMigratedToUPM, false);
 }
 
 PasswordManagerEvictionUtilTest::~PasswordManagerEvictionUtilTest() = default;
@@ -79,8 +77,6 @@
       1);
   pref_service()->SetDouble(
       password_manager::prefs::kTimeOfLastMigrationAttempt, 20.22);
-  pref_service()->SetBoolean(password_manager::prefs::kSettingsMigratedToUPM,
-                             true);
 
   base::HistogramTester histogram_tester;
 
@@ -101,8 +97,6 @@
   EXPECT_EQ(pref_service()->GetDouble(
                 password_manager::prefs::kTimeOfLastMigrationAttempt),
             0.0);
-  EXPECT_FALSE(pref_service()->GetBoolean(
-      password_manager::prefs::kSettingsMigratedToUPM));
 
   histogram_tester.ExpectUniqueSample(kUnenrollmentHistogram, true, 1);
   histogram_tester.ExpectUniqueSample(kUnenrollmentReasonHistogram,
diff --git a/components/password_manager/core/common/password_manager_pref_names.cc b/components/password_manager/core/common/password_manager_pref_names.cc
index cd252119..875e8c0 100644
--- a/components/password_manager/core/common/password_manager_pref_names.cc
+++ b/components/password_manager/core/common/password_manager_pref_names.cc
@@ -23,7 +23,6 @@
     "profile.save_passwords_enabed_gms";
 const char kSavePasswordsSuspendedByError[] =
     "profile.save_passwords_suspended_by_error";
-const char kSettingsMigratedToUPM[] = "profile.settings_migrated_to_upm";
 const char kSettingsMigratedToUPMLocal[] =
     "profile.settings_migrated_to_upm_local";
 
diff --git a/components/password_manager/core/common/password_manager_pref_names.h b/components/password_manager/core/common/password_manager_pref_names.h
index 29cfcf8..63fc982 100644
--- a/components/password_manager/core/common/password_manager_pref_names.h
+++ b/components/password_manager/core/common/password_manager_pref_names.h
@@ -65,10 +65,6 @@
 // can only be stricter than any policy applied
 extern const char kSavePasswordsSuspendedByError[];
 
-// Boolean value indicating whether the regular prefs were migrated to UPM
-// settings for syncing users.
-extern const char kSettingsMigratedToUPM[];
-
 // Boolean value indicating whether the regular prefs that apply to the local
 // password store were migrated to UPM settings. It will be set to true
 // automatically if there is nothing to migrate.
diff --git a/tools/metrics/histograms/metadata/password/histograms.xml b/tools/metrics/histograms/metadata/password/histograms.xml
index 90781c2..95d9245 100644
--- a/tools/metrics/histograms/metadata/password/histograms.xml
+++ b/tools/metrics/histograms/metadata/password/histograms.xml
@@ -2033,19 +2033,6 @@
   </summary>
 </histogram>
 
-<histogram name="PasswordManager.MigratedSettingsUPMAndroid"
-    enum="BooleanEnabled" expires_after="2024-02-04">
-  <owner>[email protected]</owner>
-  <owner>[email protected]</owner>
-  <summary>
-    Records true when a settings migration occurs as part of the UPM transition.
-    It is recorded when the settings service (profile-scoped) is instantiated in
-    a Chrome client with UPM enabled if a migration hasn't already occured. Note
-    that if UPM is disabled, the next time it is enabled a new migration will
-    happen and be recorded.
-  </summary>
-</histogram>
-
 <histogram
     name="PasswordManager.MigrationToOSCrypt.{Store}DeletedPasswordCount"
     units="count" expires_after="2024-03-17">