🧇 Mark for prefs::kSearchEnginesChoiceProfile for deprecation
This pref was not read or written since Nov 2023 (usage removed in
https://crrev.com/c/5018001) but the cleanup had not been done. This
CL now marks it deprecated, cleans up old values, and removes
associated useless codepaths
Bug: 309936758
Change-Id: I342f7dd48ee4a1c87ddc7c88405ecf957a32e8d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5300589
Commit-Queue: Nicolas Dossou-Gbété <[email protected]>
Reviewed-by: David Roger <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1261658}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index c305241f..2ab6e76 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -993,6 +993,9 @@
};
#endif
+// Deprecated 02/2024
+constexpr char kSearchEnginesChoiceProfile[] = "search_engines.choice_profile";
+
// Register local state used only for migration (clearing or moving to a new
// key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -1106,6 +1109,9 @@
#if BUILDFLAG(IS_MAC)
registry->RegisterBooleanPref(kScreenTimeEnabled, true);
#endif
+
+ // Deprecated 02/2024.
+ registry->RegisterFilePathPref(kSearchEnginesChoiceProfile, base::FilePath());
}
// Register prefs used only for migration (clearing or moving to a new key).
@@ -1520,7 +1526,6 @@
metrics::TabStatsTracker::RegisterPrefs(registry);
performance_manager::user_tuning::prefs::RegisterLocalStatePrefs(registry);
RegisterBrowserPrefs(registry);
- SearchEngineChoiceDialogService::RegisterLocalStatePrefs(registry);
SearchEngineChoiceClientSideTrial::RegisterLocalStatePrefs(registry);
speech::SodaInstaller::RegisterLocalStatePrefs(registry);
StartupBrowserCreator::RegisterLocalStatePrefs(registry);
@@ -2263,6 +2268,10 @@
#if BUILDFLAG(IS_MAC)
local_state->ClearPref(kScreenTimeEnabled);
#endif
+
+ // Added 02/2024
+ local_state->ClearPref(kSearchEnginesChoiceProfile);
+
// Please don't delete the following line. It is used by PRESUBMIT.py.
// END_MIGRATE_OBSOLETE_LOCAL_STATE_PREFS
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc
index 0303d64..4edcea6 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.cc
@@ -204,13 +204,6 @@
}
// static
-void SearchEngineChoiceDialogService::RegisterLocalStatePrefs(
- PrefRegistrySimple* registry) {
- registry->RegisterFilePathPref(prefs::kSearchEnginesChoiceProfile,
- base::FilePath());
-}
-
-// static
search_engines::ChoiceData
SearchEngineChoiceDialogService::GetChoiceDataFromProfile(Profile& profile) {
if (!search_engines::IsChoiceScreenFlagEnabled(
@@ -326,15 +319,6 @@
return dynamic_conditions;
}
- // Lastly, we check if this profile can be the selected one for showing the
- // dialogs. We check it last to make sure we don't mark to eagerly this one
- // as the choice profile if one of the other conditions is not met.
- if (!SearchEngineChoiceDialogServiceFactory::IsSelectedChoiceProfile(
- profile_.get(), /*try_claim=*/true)) {
- return search_engines::SearchEngineChoiceScreenConditions::
- kProfileOutOfScope;
- }
-
return search_engines::SearchEngineChoiceScreenConditions::kEligible;
}
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h
index ea72fcf..a9746bdf 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h
@@ -118,10 +118,6 @@
// ensure it is reset at the end of your test.
static void SetDialogDisabledForTests(bool dialog_disabled);
- // Registers the local state preferences used by the search engine choice
- // screen.
- static void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
-
// Returns a copy of the `ChoiceData` specific to `profile`.
static search_engines::ChoiceData GetChoiceDataFromProfile(Profile& profile);
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.cc b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.cc
index 5265e94..b29a591c 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.cc
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.cc
@@ -41,12 +41,6 @@
kFeatureSuppressed;
}
- if (!SearchEngineChoiceDialogServiceFactory::IsSelectedChoiceProfile(
- profile, /*try_claim=*/false)) {
- return search_engines::SearchEngineChoiceScreenConditions::
- kProfileOutOfScope;
- }
-
bool is_regular_or_guest_profile =
profile.IsRegularProfile() || profile.IsGuestSession();
#if BUILDFLAG(IS_CHROMEOS)
@@ -123,15 +117,6 @@
}
// static
-bool SearchEngineChoiceDialogServiceFactory::IsSelectedChoiceProfile(
- Profile& profile,
- bool try_claim) {
- // TODO(b/309936758): Remove this method and deprecate
- // prefs::kSearchEnginesChoiceProfile
- return true;
-}
-
-// static
bool SearchEngineChoiceDialogServiceFactory::
IsProfileEligibleForChoiceScreenForTesting(Profile& profile) {
CHECK_IS_TEST();
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h
index 120ab0e2..eb5a9d0 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h
@@ -28,12 +28,6 @@
static SearchEngineChoiceDialogServiceFactory* GetInstance();
- // Checks that the profile is the chosen one to display the choice dialog.
- // If none is chosen yet and `try_claim` is `true`, then `profile` will be
- // marked as the chosen one.
- // TODO(b/309936758): Deprecated, currently always returns `true`.
- static bool IsSelectedChoiceProfile(Profile& profile, bool try_claim);
-
// Overrides the check for branded build. This allows bots that run on
// non-branded builds to test the code.
static base::AutoReset<bool> ScopedChromeBuildOverrideForTesting(