[go: nahoru, domu]

🧇 Create SearchEngineChoiceService

Moves a large chunk of methods from search_engine_choice_utils.h into
a newly created SearchEngineChoiceService which is a KeyedService.
No behavior changes.

Low-Coverage-Reason: LARGE_SCALE_REFACTOR
Bug: b/318801987
Change-Id: I2848e174eced83e2bce3a6af957c36df207a48fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5176941
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: David Roger <droger@chromium.org>
Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1248145}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 424db9fa..56b1c8e 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -1481,6 +1481,8 @@
     "safe_browsing/metrics/safe_browsing_metrics_provider.h",
     "search/search.cc",
     "search/search.h",
+    "search_engine_choice/search_engine_choice_service_factory.cc",
+    "search_engine_choice/search_engine_choice_service_factory.h",
     "search_engines/chrome_template_url_service_client.cc",
     "search_engines/chrome_template_url_service_client.h",
     "search_engines/template_url_fetcher_factory.cc",
diff --git a/chrome/browser/autocomplete/keyword_extensions_delegate_impl_unittest.cc b/chrome/browser/autocomplete/keyword_extensions_delegate_impl_unittest.cc
index 0734b18..66c1468 100644
--- a/chrome/browser/autocomplete/keyword_extensions_delegate_impl_unittest.cc
+++ b/chrome/browser/autocomplete/keyword_extensions_delegate_impl_unittest.cc
@@ -50,8 +50,8 @@
 }
 
 void KeywordExtensionsDelegateImplTest::RunTest(bool incognito) {
-  std::unique_ptr<TemplateURLService> empty_model(
-      new TemplateURLService(nullptr, 0));
+  std::unique_ptr<TemplateURLService> empty_model(new TemplateURLService(
+      /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr));
   MockAutocompleteProviderClient client;
   client.set_template_url_service(std::move(empty_model));
   scoped_refptr<KeywordProvider> keyword_provider =
diff --git a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
index 30952e2..dd8ce22 100644
--- a/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
+++ b/chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc
@@ -5,6 +5,7 @@
 #include "chrome/browser/extensions/api/settings_overrides/settings_overrides_api.h"
 
 #include <stddef.h>
+
 #include <memory>
 #include <utility>
 
@@ -13,9 +14,11 @@
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/prefs/session_startup_pref.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h"
 #include "chrome/common/pref_names.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/template_url.h"
 #include "components/search_engines/template_url_data_util.h"
@@ -51,6 +54,7 @@
 
 std::unique_ptr<TemplateURLData> ConvertSearchProvider(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     const ChromeSettingsOverrides::SearchProvider& search_provider,
     const std::string& install_parameter) {
   std::unique_ptr<TemplateURLData> data;
@@ -58,10 +62,12 @@
     if (base::FeatureList::IsEnabled(
             kPrepopulatedSearchEngineOverrideRollout)) {
       data = TemplateURLPrepopulateData::GetPrepopulatedEngineFromFullList(
-          prefs, *search_provider.prepopulated_id);
+          prefs, search_engine_choice_service,
+          *search_provider.prepopulated_id);
     } else {
       data = TemplateURLPrepopulateData::GetPrepopulatedEngine(
-          prefs, *search_provider.prepopulated_id);
+          prefs, search_engine_choice_service,
+          *search_provider.prepopulated_id);
     }
 
     if (data) {
@@ -259,7 +265,9 @@
   ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
   std::string install_parameter = prefs->GetInstallParam(extension->id());
   std::unique_ptr<TemplateURLData> data = ConvertSearchProvider(
-      profile_->GetPrefs(), *settings->search_engine, install_parameter);
+      profile_->GetPrefs(),
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(profile_),
+      *settings->search_engine, install_parameter);
   auto turl = std::make_unique<TemplateURL>(
       *data, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, extension->id(),
       prefs->GetLastUpdateTime(extension->id()),
@@ -281,6 +289,7 @@
   DependsOn(ExtensionPrefsFactory::GetInstance());
   DependsOn(ExtensionPrefsHelperFactory::GetInstance());
   DependsOn(TemplateURLServiceFactory::GetInstance());
+  DependsOn(search_engines::SearchEngineChoiceServiceFactory::GetInstance());
 }
 
 }  // namespace extensions
diff --git a/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc b/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc
index 4812e48..5caa354 100644
--- a/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc
+++ b/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc
@@ -14,6 +14,7 @@
 #include "chrome/browser/prefs/session_startup_pref.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/search/search.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
 #include "chrome/common/chrome_switches.h"
@@ -21,6 +22,7 @@
 #include "chrome/test/base/search_test_utils.h"
 #include "components/prefs/pref_service.h"
 #include "components/search_engines/default_search_manager.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engines_test_util.h"
 #include "components/search_engines/template_url.h"
 #include "components/search_engines/template_url_prepopulate_data.h"
@@ -49,11 +51,14 @@
 const int kTestExtensionPrepopulatedId = 83;
 // TemplateURLData with search engines settings from test extension manifest.
 // chrome/test/data/extensions/settings_override/manifest.json
-std::unique_ptr<TemplateURLData> TestExtensionSearchEngine(PrefService* prefs) {
+std::unique_ptr<TemplateURLData> TestExtensionSearchEngine(Profile* profile) {
+  PrefService* prefs = profile->GetPrefs();
+  search_engines::SearchEngineChoiceService* search_engine_choice_service =
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(profile);
   // Enforcing that `kTestExtensionPrepopulatedId` is not part of the
   // prepopulated set for the current profile's country.
-  for (auto& data :
-       TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, nullptr)) {
+  for (auto& data : TemplateURLPrepopulateData::GetPrepopulatedEngines(
+           prefs, search_engine_choice_service, nullptr)) {
     EXPECT_NE(data->prepopulate_id, kTestExtensionPrepopulatedId);
   }
 
@@ -74,7 +79,7 @@
   if (base::FeatureList::IsEnabled(kPrepopulatedSearchEngineOverrideRollout)) {
     std::unique_ptr<TemplateURLData> prepopulated =
         TemplateURLPrepopulateData::GetPrepopulatedEngineFromFullList(
-            prefs, kTestExtensionPrepopulatedId);
+            prefs, search_engine_choice_service, kTestExtensionPrepopulatedId);
     EXPECT_TRUE(prepopulated);
     // Values below do not exist in extension manifest and are taken from
     // prepopulated engine with prepopulated_id set in extension manifest.
@@ -84,7 +89,7 @@
     // GetPrepopulatedEngineFromFullList() should not be called. The old method
     // is not expected to find anything.
     EXPECT_FALSE(TemplateURLPrepopulateData::GetPrepopulatedEngine(
-        prefs, kTestExtensionPrepopulatedId));
+        prefs, search_engine_choice_service, kTestExtensionPrepopulatedId));
   }
   return result;
 }
@@ -155,7 +160,7 @@
   EXPECT_EQ(TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, current_dse->type());
 
   std::unique_ptr<TemplateURLData> extension_dse =
-      TestExtensionSearchEngine(prefs);
+      TestExtensionSearchEngine(profile());
   ExpectSimilar(extension_dse.get(), &current_dse->data());
 
   UnloadExtension(extension->id());
@@ -191,7 +196,9 @@
 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, OverridenDSEPersists) {
   Profile* profile = browser()->profile();
   DefaultSearchManager default_manager(
-      profile->GetPrefs(), DefaultSearchManager::ObserverCallback());
+      profile->GetPrefs(),
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(profile),
+      DefaultSearchManager::ObserverCallback());
 
   DefaultSearchManager::Source source;
   const TemplateURLData* current_dse =
@@ -199,7 +206,7 @@
 
   ASSERT_TRUE(current_dse);
   std::unique_ptr<TemplateURLData> extension_dse =
-      TestExtensionSearchEngine(profile->GetPrefs());
+      TestExtensionSearchEngine(profile);
   ExpectSimilar(extension_dse.get(), current_dse);
   EXPECT_EQ(DefaultSearchManager::FROM_EXTENSION, source);
 
@@ -236,8 +243,6 @@
 // This test checks that an extension overriding the default search engine can
 // be correctly loaded before the TemplateURLService is loaded.
 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, BeforeTemplateUrlServiceLoad) {
-  PrefService* prefs = profile()->GetPrefs();
-  ASSERT_TRUE(prefs);
   TemplateURLService* url_service =
       TemplateURLServiceFactory::GetForProfile(profile());
   ASSERT_TRUE(url_service);
@@ -251,7 +256,7 @@
   EXPECT_TRUE(url_service->IsExtensionControlledDefaultSearch());
 
   std::unique_ptr<TemplateURLData> extension_dse =
-      TestExtensionSearchEngine(prefs);
+      TestExtensionSearchEngine(profile());
   ExpectSimilar(extension_dse.get(), &current_dse->data());
 
   UnloadExtension(extension->id());
diff --git a/chrome/browser/notifications/notification_channels_provider_android_unittest.cc b/chrome/browser/notifications/notification_channels_provider_android_unittest.cc
index 75467e43..04b4cee 100644
--- a/chrome/browser/notifications/notification_channels_provider_android_unittest.cc
+++ b/chrome/browser/notifications/notification_channels_provider_android_unittest.cc
@@ -732,7 +732,8 @@
   InitChannelsProvider(true /* should_use_channels */);
 
   // Set up TemplateURLService with a default search engine.
-  TemplateURLService* template_url_service = new TemplateURLService(NULL, 0);
+  TemplateURLService* template_url_service = new TemplateURLService(
+      /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr);
   TemplateURLData data;
   data.SetURL("https://default-search-engine.com/url?bar={searchTerms}");
   TemplateURL* template_url =
diff --git a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc
index 1c35025..5c78528 100644
--- a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc
+++ b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc
@@ -28,6 +28,7 @@
 #include "chrome/browser/prefs/profile_pref_store_manager.h"
 #include "chrome/browser/prefs/session_startup_pref.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/common/chrome_constants.h"
 #include "chrome/common/chrome_paths.h"
@@ -607,9 +608,13 @@
     // Explicitly set the DSE (it's otherwise NULL by default, preventing
     // thorough testing of the PROTECTION_ENABLED_DSE level).
     DefaultSearchManager default_search_manager(
-        profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()
+        profile()->GetPrefs(),
+        search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+            profile()),
+        DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-        , profile()->IsMainProfile()
+            ,
+        profile()->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     );
     DefaultSearchManager::Source dse_source =
@@ -691,9 +696,13 @@
     // Explicitly verify the result of reported resets.
 
     DefaultSearchManager default_search_manager(
-        profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()
+        profile()->GetPrefs(),
+        search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+            profile()),
+        DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-        , profile()->IsMainProfile()
+            ,
+        profile()->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     );
     DefaultSearchManager::Source dse_source =
@@ -1161,9 +1170,13 @@
   void SetupPreferences() override {
     // Set user selected default search engine.
     DefaultSearchManager default_search_manager(
-        profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()
+        profile()->GetPrefs(),
+        search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+            profile()),
+        DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-        , profile()->IsMainProfile()
+            ,
+        profile()->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     );
     DefaultSearchManager::Source dse_source =
@@ -1230,9 +1243,13 @@
 
   void VerifyReactionToPrefAttack() override {
     DefaultSearchManager default_search_manager(
-        profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()
+        profile()->GetPrefs(),
+        search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+            profile()),
+        DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-        , profile()->IsMainProfile()
+            ,
+        profile()->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     );
     DefaultSearchManager::Source dse_source =
diff --git a/chrome/browser/preloading/prefetch/zero_suggest_prefetch/zero_suggest_prefetch_tab_helper_browsertest.cc b/chrome/browser/preloading/prefetch/zero_suggest_prefetch/zero_suggest_prefetch_tab_helper_browsertest.cc
index af65d6b..37a3f21d 100644
--- a/chrome/browser/preloading/prefetch/zero_suggest_prefetch/zero_suggest_prefetch_tab_helper_browsertest.cc
+++ b/chrome/browser/preloading/prefetch/zero_suggest_prefetch/zero_suggest_prefetch_tab_helper_browsertest.cc
@@ -52,11 +52,13 @@
     InProcessBrowserTest::SetUpOnMainThread();
 
     auto template_url_service = std::make_unique<TemplateURLService>(
-        /*prefs=*/nullptr, std::make_unique<SearchTermsData>(),
+        /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr,
+        std::make_unique<SearchTermsData>(),
         /*web_data_service=*/nullptr,
         std::unique_ptr<TemplateURLServiceClient>(), base::RepeatingClosure()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-        , /*for_lacros_main_profile=*/false
+                                                         ,
+        /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     );
 
diff --git a/chrome/browser/profile_resetter/profile_resetter_test_base.cc b/chrome/browser/profile_resetter/profile_resetter_test_base.cc
index 851c926..723dfb4a 100644
--- a/chrome/browser/profile_resetter/profile_resetter_test_base.cc
+++ b/chrome/browser/profile_resetter/profile_resetter_test_base.cc
@@ -12,6 +12,7 @@
 #include "build/chromeos_buildflags.h"
 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
 #include "chrome/browser/web_data_service_factory.h"
 #include "components/keyed_service/core/service_access_type.h"
@@ -65,12 +66,15 @@
     content::BrowserContext* context) {
   Profile* profile = Profile::FromBrowserContext(context);
   return std::make_unique<TemplateURLService>(
-      profile->GetPrefs(), std::make_unique<UIThreadSearchTermsData>(),
+      profile->GetPrefs(),
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(profile),
+      std::make_unique<UIThreadSearchTermsData>(),
       WebDataServiceFactory::GetKeywordWebDataForProfile(
           profile, ServiceAccessType::EXPLICIT_ACCESS),
       nullptr /* TemplateURLServiceClient */, base::RepeatingClosure()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-      , profile->IsMainProfile()
+                                                  ,
+      profile->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
 }
diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
index 8e61d90..b435108 100644
--- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
+++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
@@ -149,6 +149,7 @@
 #include "chrome/browser/safe_browsing/tailored_security/tailored_security_service_factory.h"
 #include "chrome/browser/safe_browsing/url_lookup_service_factory.h"
 #include "chrome/browser/safe_browsing/verdict_cache_manager_factory.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/search_provider_logos/logo_service_factory.h"
@@ -1116,6 +1117,7 @@
   }
 #endif
   SCTReportingServiceFactory::GetInstance();
+  search_engines::SearchEngineChoiceServiceFactory::GetInstance();
 #if BUILDFLAG(IS_ANDROID)
   search_resumption_module::StartSuggestServiceFactory::GetInstance();
 #endif
diff --git a/chrome/browser/profiles/profile_keyed_service_browsertest.cc b/chrome/browser/profiles/profile_keyed_service_browsertest.cc
index 2a89dba..e546ad23 100644
--- a/chrome/browser/profiles/profile_keyed_service_browsertest.cc
+++ b/chrome/browser/profiles/profile_keyed_service_browsertest.cc
@@ -499,6 +499,7 @@
     "SafeBrowsingMetricsCollector",
     "SafeBrowsingPrivateEventRouter",
     "SafeBrowsingTailoredSecurityService",
+    "SearchEngineChoiceServiceFactory",
     "SendTabToSelfClientService",
     "SendTabToSelfSyncService",
     "SerialConnectionManager",
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc b/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc
index 249dde8..c6e4eee 100644
--- a/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc
+++ b/chrome/browser/search_engine_choice/search_engine_choice_dialog_browsertest.cc
@@ -20,6 +20,7 @@
 #include "chrome/browser/profiles/profile_test_util.h"
 #include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h"
 #include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/sessions/session_restore_test_helper.h"
 #include "chrome/browser/sessions/session_service_factory.h"
@@ -82,6 +83,8 @@
   explicit MockSearchEngineChoiceDialogService(Profile* profile)
       : SearchEngineChoiceDialogService(
             *profile,
+            *search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+                profile),
             *TemplateURLServiceFactory::GetForProfile(profile)) {
     ON_CALL(*this, NotifyDialogOpened)
         .WillByDefault([this](Browser* browser, base::OnceClosure callback) {
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 a731447..5b8406d 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
@@ -20,6 +20,7 @@
 #include "chrome/browser/ui/web_applications/app_browser_controller.h"
 #include "components/country_codes/country_codes.h"
 #include "components/prefs/pref_service.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/search_engines_switches.h"
@@ -77,8 +78,11 @@
 
 SearchEngineChoiceDialogService::SearchEngineChoiceDialogService(
     Profile& profile,
+    search_engines::SearchEngineChoiceService& search_engine_choice_service,
     TemplateURLService& template_url_service)
-    : profile_(profile), template_url_service_(template_url_service) {}
+    : profile_(profile),
+      search_engine_choice_service_(search_engine_choice_service),
+      template_url_service_(template_url_service) {}
 
 void SearchEngineChoiceDialogService::NotifyChoiceMade(int prepopulate_id,
                                                        EntryPoint entry_point) {
@@ -91,11 +95,10 @@
   const int kCustomSearchEngineId = 0;
   if (prepopulate_id != kCustomSearchEngineId) {
     std::unique_ptr<TemplateURLData> search_engine =
-        TemplateURLPrepopulateData::GetPrepopulatedEngine(pref_service,
-                                                          prepopulate_id);
+        TemplateURLPrepopulateData::GetPrepopulatedEngine(
+            pref_service, &search_engine_choice_service_.get(), prepopulate_id);
 
-    int country_id =
-        search_engines::GetSearchEngineChoiceCountryId(pref_service);
+    int country_id = search_engine_choice_service_->GetCountryId();
     SCOPED_CRASH_KEY_STRING32(
         "ChoiceService", "choice_country",
         country_codes::CountryIDToCountryString(country_id));
@@ -105,7 +108,8 @@
     if (!search_engine) {
       search_engine =
           TemplateURLPrepopulateData::GetPrepopulatedEngineFromFullList(
-              pref_service, prepopulate_id);
+              pref_service, &search_engine_choice_service_.get(),
+              prepopulate_id);
 
       SCOPED_CRASH_KEY_BOOL("ChoiceService", "engine_found",
                             search_engine != nullptr);
@@ -297,8 +301,8 @@
 
   // Respect common conditions with other platforms.
   search_engines::SearchEngineChoiceScreenConditions dynamic_conditions =
-      search_engines::GetDynamicChoiceScreenConditions(
-          CHECK_DEREF(profile_->GetPrefs()), *template_url_service_);
+      search_engine_choice_service_->GetDynamicChoiceScreenConditions(
+          *template_url_service_);
   if (dynamic_conditions !=
       search_engines::SearchEngineChoiceScreenConditions::kEligible) {
     return dynamic_conditions;
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 3309c12..ea72fcf 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
@@ -16,6 +16,7 @@
 #include "chrome/browser/ui/browser_list_observer.h"
 #include "components/keyed_service/core/keyed_service.h"
 #include "components/prefs/pref_registry_simple.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/template_url_data.h"
 #include "components/search_engines/template_url_service.h"
 
@@ -48,8 +49,10 @@
     kDialog,
   };
 
-  SearchEngineChoiceDialogService(Profile& profile,
-                                  TemplateURLService& template_url_service);
+  SearchEngineChoiceDialogService(
+      Profile& profile,
+      search_engines::SearchEngineChoiceService& search_engine_choice_service,
+      TemplateURLService& template_url_service);
   ~SearchEngineChoiceDialogService() override;
 
   // Informs the service that a Search Engine Choice dialog has been opened
@@ -161,6 +164,8 @@
 
   // The `KeyedService` lifetime is expected to exceed the profile's.
   const raw_ref<Profile> profile_;
+  const raw_ref<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
   const raw_ref<TemplateURLService> template_url_service_;
   base::WeakPtrFactory<SearchEngineChoiceDialogService> weak_ptr_factory_{this};
 };
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 fb4f8c2..e3c45bd 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
@@ -12,7 +12,9 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_selections.h"
 #include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/template_url_service.h"
@@ -52,15 +54,13 @@
       !chromeos::IsKioskSession() && !profiles::IsChromeAppKioskSession();
 #endif
 
+  search_engines::SearchEngineChoiceService* search_engine_choice_service =
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(&profile);
   TemplateURLService* template_url_service =
       TemplateURLServiceFactory::GetForProfile(&profile);
-
-  return search_engines::GetStaticChoiceScreenConditions(
+  return search_engine_choice_service->GetStaticChoiceScreenConditions(
       CHECK_DEREF(g_browser_process->policy_service()),
-      /*profile_properties=*/
-      {.is_regular_profile = is_regular_or_guest_profile,
-       .pref_service = profile.GetPrefs()},
-      CHECK_DEREF(template_url_service));
+      is_regular_or_guest_profile, CHECK_DEREF(template_url_service));
 }
 
 bool IsProfileEligibleForChoiceScreen(Profile& profile) {
@@ -85,6 +85,7 @@
               .WithAshInternals(ProfileSelection::kNone)
               .WithGuest(ProfileSelection::kOffTheRecordOnly)
               .Build()) {
+  DependsOn(search_engines::SearchEngineChoiceServiceFactory::GetInstance());
   DependsOn(TemplateURLServiceFactory::GetInstance());
 }
 
@@ -141,7 +142,11 @@
   }
 
   auto& profile = CHECK_DEREF(Profile::FromBrowserContext(context));
-  search_engines::PreprocessPrefsForReprompt(CHECK_DEREF(profile.GetPrefs()));
+  search_engines::SearchEngineChoiceService& search_engine_choice_service =
+      CHECK_DEREF(
+          search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+              &profile));
+  search_engine_choice_service.PreprocessPrefsForReprompt();
 
   if (!IsProfileEligibleForChoiceScreen(profile)) {
     DVLOG(1) << "Profile not eligible, removing tag for profile "
@@ -153,6 +158,6 @@
   TemplateURLService& template_url_service =
       CHECK_DEREF(TemplateURLServiceFactory::GetForProfile(&profile));
   return std::make_unique<SearchEngineChoiceDialogService>(
-      profile, template_url_service);
+      profile, search_engine_choice_service, template_url_service);
 #endif
 }
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_service_factory.cc b/chrome/browser/search_engine_choice/search_engine_choice_service_factory.cc
new file mode 100644
index 0000000..a2d6482
--- /dev/null
+++ b/chrome/browser/search_engine_choice/search_engine_choice_service_factory.cc
@@ -0,0 +1,59 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
+
+#include "base/check_deref.h"
+#include "base/check_is_test.h"
+#include "chrome/browser/profiles/profile.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
+
+namespace search_engines {
+namespace {
+std::unique_ptr<KeyedService> BuildSearchEngineChoiceService(
+    content::BrowserContext* context) {
+  auto& profile = CHECK_DEREF(Profile::FromBrowserContext(context));
+  return std::make_unique<SearchEngineChoiceService>(*profile.GetPrefs());
+}
+}  // namespace
+
+SearchEngineChoiceServiceFactory::SearchEngineChoiceServiceFactory()
+    : ProfileKeyedServiceFactory(
+          "SearchEngineChoiceServiceFactory",
+          ProfileSelections::Builder()
+              .WithRegular(ProfileSelection::kRedirectedToOriginal)
+              .WithGuest(ProfileSelection::kRedirectedToOriginal)
+              .WithSystem(ProfileSelection::kNone)
+              .Build()) {}
+
+SearchEngineChoiceServiceFactory::~SearchEngineChoiceServiceFactory() = default;
+
+// static
+SearchEngineChoiceService* SearchEngineChoiceServiceFactory::GetForProfile(
+    Profile* profile) {
+  return static_cast<SearchEngineChoiceService*>(
+      GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+// static
+SearchEngineChoiceServiceFactory*
+SearchEngineChoiceServiceFactory::GetInstance() {
+  static base::NoDestructor<SearchEngineChoiceServiceFactory> factory;
+  return factory.get();
+}
+
+// static
+BrowserContextKeyedServiceFactory::TestingFactory
+SearchEngineChoiceServiceFactory::GetDefaultFactory() {
+  CHECK_IS_TEST();
+  return base::BindRepeating(&BuildSearchEngineChoiceService);
+}
+
+std::unique_ptr<KeyedService>
+SearchEngineChoiceServiceFactory::BuildServiceInstanceForBrowserContext(
+    content::BrowserContext* context) const {
+  return BuildSearchEngineChoiceService(context);
+}
+
+}  // namespace search_engines
diff --git a/chrome/browser/search_engine_choice/search_engine_choice_service_factory.h b/chrome/browser/search_engine_choice/search_engine_choice_service_factory.h
new file mode 100644
index 0000000..95f2cc37
--- /dev/null
+++ b/chrome/browser/search_engine_choice/search_engine_choice_service_factory.h
@@ -0,0 +1,46 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SEARCH_ENGINE_CHOICE_SEARCH_ENGINE_CHOICE_SERVICE_FACTORY_H_
+#define CHROME_BROWSER_SEARCH_ENGINE_CHOICE_SEARCH_ENGINE_CHOICE_SERVICE_FACTORY_H_
+
+#include "base/no_destructor.h"
+#include "chrome/browser/profiles/profile_keyed_service_factory.h"
+
+class Profile;
+class KeyedService;
+
+namespace search_engines {
+
+class SearchEngineChoiceService;
+
+class SearchEngineChoiceServiceFactory : public ProfileKeyedServiceFactory {
+ public:
+  SearchEngineChoiceServiceFactory(const SearchEngineChoiceServiceFactory&) =
+      delete;
+  SearchEngineChoiceServiceFactory& operator=(
+      const SearchEngineChoiceServiceFactory&) = delete;
+
+  static SearchEngineChoiceService* GetForProfile(Profile* profile);
+
+  static SearchEngineChoiceServiceFactory* GetInstance();
+
+  // Returns the default factory used to build SearchEngineChoiceService. Can be
+  // registered with SetTestingFactory to use real instances during testing.
+  static TestingFactory GetDefaultFactory();
+
+ private:
+  friend class base::NoDestructor<SearchEngineChoiceServiceFactory>;
+
+  SearchEngineChoiceServiceFactory();
+  ~SearchEngineChoiceServiceFactory() override;
+
+  // ProfileKeyedServiceFactory:
+  std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
+      content::BrowserContext* context) const override;
+};
+
+}  // namespace search_engines
+
+#endif  // CHROME_BROWSER_SEARCH_ENGINE_CHOICE_SEARCH_ENGINE_CHOICE_SERVICE_FACTORY_H_
diff --git a/chrome/browser/search_engines/template_url_scraper_browsertest.cc b/chrome/browser/search_engines/template_url_scraper_browsertest.cc
index fa1abcb..45ba238 100644
--- a/chrome/browser/search_engines/template_url_scraper_browsertest.cc
+++ b/chrome/browser/search_engines/template_url_scraper_browsertest.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include <stddef.h>
+
 #include <utility>
 
 #include "base/files/file_util.h"
@@ -13,12 +14,14 @@
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/bind.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chrome/test/base/ui_test_utils.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/template_url_data.h"
 #include "components/search_engines/template_url_prepopulate_data.h"
 #include "components/search_engines/template_url_service.h"
@@ -83,6 +86,9 @@
       base::BindRepeating(&SendResponse));
   ASSERT_TRUE(embedded_test_server()->Start());
 
+  search_engines::SearchEngineChoiceService* search_engine_choice_service =
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+          browser()->profile());
   TemplateURLService* template_urls =
       TemplateURLServiceFactory::GetInstance()->GetForProfile(
           browser()->profile());
@@ -95,7 +101,8 @@
   // set up with.
   std::vector<std::unique_ptr<TemplateURLData>> prepopulate_urls =
       TemplateURLPrepopulateData::GetPrepopulatedEngines(
-          browser()->profile()->GetPrefs(), nullptr);
+          browser()->profile()->GetPrefs(), search_engine_choice_service,
+          nullptr);
   std::vector<std::unique_ptr<TemplateURLData>> starter_pack_urls =
       TemplateURLStarterPackData::GetStarterPackEngines();
 
diff --git a/chrome/browser/search_engines/template_url_service_factory.cc b/chrome/browser/search_engines/template_url_service_factory.cc
index 1230ac82..b0b827b 100644
--- a/chrome/browser/search_engines/template_url_service_factory.cc
+++ b/chrome/browser/search_engines/template_url_service_factory.cc
@@ -15,6 +15,7 @@
 #include "chrome/browser/history/history_service_factory.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_selections.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/chrome_template_url_service_client.h"
 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
 #include "chrome/browser/web_data_service_factory.h"
@@ -77,7 +78,9 @@
 #endif
   Profile* profile = Profile::FromBrowserContext(context);
   return std::make_unique<TemplateURLService>(
-      profile->GetPrefs(), std::make_unique<UIThreadSearchTermsData>(),
+      profile->GetPrefs(),
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(profile),
+      std::make_unique<UIThreadSearchTermsData>(),
       WebDataServiceFactory::GetKeywordWebDataForProfile(
           profile, ServiceAccessType::EXPLICIT_ACCESS),
       std::unique_ptr<TemplateURLServiceClient>(
@@ -86,7 +89,8 @@
                   profile, ServiceAccessType::EXPLICIT_ACCESS))),
       dsp_change_callback
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-      , profile->IsMainProfile()
+      ,
+      profile->IsMainProfile()
 #endif  // BUIDFLAG(IS_CHROMEOS_LACROS)
   );
 }
@@ -102,6 +106,7 @@
               // It's not possible for the user to search in a system profile.
               .WithSystem(ProfileSelection::kNone)
               .Build()) {
+  DependsOn(search_engines::SearchEngineChoiceServiceFactory::GetInstance());
   DependsOn(HistoryServiceFactory::GetInstance());
   DependsOn(WebDataServiceFactory::GetInstance());
 }
diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
index 3e0af86..63fe208 100644
--- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
@@ -344,7 +344,8 @@
   syncer::SyncChangeList dummy;
   TestTemplateURLServiceClient client;
   return TemplateURLService::CreateTemplateURLFromTemplateURLAndSyncData(
-      &client, nullptr, SearchTermsData(), nullptr, sync_data, &dummy);
+      &client, /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr,
+      SearchTermsData(), /*existing_turl=*/nullptr, sync_data, &dummy);
 }
 
 std::unique_ptr<TemplateURL> TemplateURLServiceSyncTest::CopyTemplateURL(
@@ -1894,7 +1895,8 @@
   // Fetch the prepopulate search engines so we know what they are.
   std::vector<std::unique_ptr<TemplateURLData>> prepop_turls =
       TemplateURLPrepopulateData::GetPrepopulatedEngines(
-          profile_a()->GetTestingPrefService(), nullptr);
+          profile_a()->GetTestingPrefService(),
+          test_util_a_->search_engine_choice_service(), nullptr);
 
   std::vector<std::unique_ptr<TemplateURLData>> starter_pack_turls =
       TemplateURLStarterPackData::GetStarterPackEngines();
@@ -2122,7 +2124,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine) {
   std::unique_ptr<TemplateURLData> default_turl(
-      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr));
+      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr));
 
   // Merge with an initial list containing a prepopulated engine with a wrong
   // URL.
@@ -2145,7 +2149,9 @@
                                     syncer::SyncDataList(), PassProcessor());
 
   std::unique_ptr<TemplateURLData> default_turl(
-      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr));
+      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr));
   std::unique_ptr<TemplateURL> sync_turl = CopyTemplateURL(
       default_turl.get(), "http://wrong.url.com?q={searchTerms}", "default");
 
@@ -2164,7 +2170,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, UpdatePrepopulatedEngine) {
   std::unique_ptr<TemplateURLData> default_turl(
-      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr));
+      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr));
 
   TemplateURLData data = *default_turl;
   data.SetURL("http://old.wrong.url.com?q={searchTerms}");
@@ -2194,7 +2202,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergeEditedPrepopulatedEngine) {
   std::unique_ptr<TemplateURLData> default_turl(
-      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr));
+      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr));
 
   TemplateURLData data(*default_turl);
   data.safe_for_autoreplace = false;
@@ -2222,7 +2232,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergeConflictingPrepopulatedEngine) {
   std::unique_ptr<TemplateURLData> default_turl(
-      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr));
+      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr));
 
   TemplateURLData data(*default_turl);
   data.SetKeyword(u"old_kw");
@@ -2284,7 +2296,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngineWithChangedKeyword) {
   const TemplateURLData default_data =
-      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr);
+      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr);
 
   // Add a prepopulated search engine and mark it as default.
   model()->Add(std::make_unique<TemplateURL>(default_data));
@@ -2334,7 +2348,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Pref_Change_Add) {
   const TemplateURLData default_data =
-      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr);
+      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr);
 
   // Add a prepopulated search engine and mark it as default.
   model()->Add(std::make_unique<TemplateURL>(default_data));
@@ -2403,7 +2419,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Pref_Add_Change) {
   const TemplateURLData default_data =
-      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr);
+      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr);
 
   // Add a prepopulated search engine and mark it as default.
   model()->Add(std::make_unique<TemplateURL>(default_data));
@@ -2472,7 +2490,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Change_Add_Pref) {
   const TemplateURLData default_data =
-      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr);
+      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr);
 
   // Add a prepopulated search engine and mark it as default.
   model()->Add(std::make_unique<TemplateURL>(default_data));
@@ -2541,7 +2561,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Add_Change_Pref) {
   const TemplateURLData default_data =
-      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr);
+      *TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr);
 
   // Add a prepopulated search engine and mark it as default.
   model()->Add(std::make_unique<TemplateURL>(default_data));
@@ -2610,7 +2632,9 @@
 
 TEST_F(TemplateURLServiceSyncTest, MergeNonEditedPrepopulatedEngine) {
   std::unique_ptr<TemplateURLData> default_turl(
-      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(nullptr));
+      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          /*prefs=*/nullptr,
+          /*search_engine_choice_service=*/nullptr));
 
   TemplateURLData data(*default_turl);
   data.safe_for_autoreplace = true;  // Can be replaced with built-in values.
diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc
index 78f9db3..aead959 100644
--- a/chrome/browser/search_engines/template_url_service_test_util.cc
+++ b/chrome/browser/search_engines/template_url_service_test_util.cc
@@ -3,12 +3,12 @@
 // found in the LICENSE file.
 
 #include "chrome/browser/search_engines/template_url_service_test_util.h"
-#include "base/memory/raw_ptr.h"
 
 #include <memory>
 #include <utility>
 
 #include "base/functional/callback_helpers.h"
+#include "base/memory/raw_ptr.h"
 #include "base/run_loop.h"
 #include "base/strings/string_util.h"
 #include "base/task/single_thread_task_runner.h"
@@ -19,6 +19,7 @@
 #include "chrome/test/base/testing_profile.h"
 #include "components/search_engines/keyword_table.h"
 #include "components/search_engines/keyword_web_data_service.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engines_test_util.h"
 #include "components/search_engines/template_url_data_util.h"
 #include "components/search_engines/template_url_service.h"
@@ -144,12 +145,17 @@
       base::SingleThreadTaskRunner::GetCurrentDefault());
   web_data_service_->Init(base::NullCallback());
 
+  search_engine_choice_service_ =
+      std::make_unique<search_engines::SearchEngineChoiceService>(
+          *profile_->GetPrefs());
+
   ResetModel(false);
 }
 
 TemplateURLServiceTestUtil::~TemplateURLServiceTestUtil() {
   ClearModel();
   web_data_service_->ShutdownOnUISequence();
+  search_engine_choice_service_.reset();
   profile_.reset();
 
   // Flush the message loop to make application verifiers happy.
@@ -194,7 +200,7 @@
   if (model_)
     ClearModel();
   model_ = std::make_unique<TemplateURLService>(
-      profile()->GetPrefs(),
+      profile()->GetPrefs(), search_engine_choice_service_.get(),
       std::make_unique<TestingSearchTermsData>("http://www.google.com/"),
       web_data_service_.get(),
       std::unique_ptr<TemplateURLServiceClient>(
@@ -204,7 +210,8 @@
               &search_term_)),
       base::BindLambdaForTesting([&] { ++dsp_set_to_google_callback_count_; })
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-      , profile()->IsMainProfile()
+          ,
+      profile()->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   model()->AddObserver(this);
diff --git a/chrome/browser/search_engines/template_url_service_test_util.h b/chrome/browser/search_engines/template_url_service_test_util.h
index 398377540..2916c1b 100644
--- a/chrome/browser/search_engines/template_url_service_test_util.h
+++ b/chrome/browser/search_engines/template_url_service_test_util.h
@@ -11,6 +11,7 @@
 #include "base/files/scoped_temp_dir.h"
 #include "base/memory/ref_counted.h"
 #include "base/time/time.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/test/base/testing_profile.h"
 #include "components/search_engines/enterprise_site_search_manager.h"
 #include "components/search_engines/template_url.h"
@@ -112,6 +113,9 @@
   KeywordWebDataService* web_data_service() { return web_data_service_.get(); }
   TemplateURLService* model() { return model_.get(); }
   TestingProfile* profile() { return profile_.get(); }
+  search_engines::SearchEngineChoiceService* search_engine_choice_service() {
+    return search_engine_choice_service_.get();
+  }
 
  private:
   std::unique_ptr<TestingProfile> profile_;
@@ -119,6 +123,8 @@
   std::u16string search_term_;
   int dsp_set_to_google_callback_count_ = 0;
   scoped_refptr<KeywordWebDataService> web_data_service_;
+  std::unique_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
   std::unique_ptr<TemplateURLService> model_;
   data_decoder::test::InProcessDataDecoder data_decoder_;
 };
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
index 92229cf1..73160e2 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
@@ -21,6 +21,7 @@
 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
 #include "chrome/browser/favicon/favicon_utils.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/ui/app_list/app_list_util.h"
 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
@@ -39,6 +40,7 @@
 #include "components/bookmarks/common/bookmark_pref_names.h"
 #include "components/bookmarks/test/bookmark_test_helpers.h"
 #include "components/prefs/pref_service.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_terms_data.h"
 #include "components/search_engines/template_url_service.h"
 #include "components/search_engines/template_url_service_client.h"
@@ -65,6 +67,9 @@
 
     TestingProfile::Builder profile_builder;
     profile_builder.AddTestingFactory(
+        search_engines::SearchEngineChoiceServiceFactory::GetInstance(),
+        search_engines::SearchEngineChoiceServiceFactory::GetDefaultFactory());
+    profile_builder.AddTestingFactory(
         TemplateURLServiceFactory::GetInstance(),
         base::BindRepeating(
             &BookmarkBarViewBaseTest::CreateTemplateURLService));
@@ -155,12 +160,17 @@
   static std::unique_ptr<KeyedService> CreateTemplateURLService(
       content::BrowserContext* context) {
     Profile* profile = Profile::FromBrowserContext(context);
+    search_engines::SearchEngineChoiceService* search_engine_choice_service =
+        search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+            profile);
     return std::make_unique<TemplateURLService>(
-        profile->GetPrefs(), std::make_unique<SearchTermsData>(),
+        profile->GetPrefs(), search_engine_choice_service,
+        std::make_unique<SearchTermsData>(),
         nullptr /* KeywordWebDataService */,
         nullptr /* TemplateURLServiceClient */, base::RepeatingClosure()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-        , profile->IsMainProfile()
+                                                    ,
+        profile->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     );
   }
diff --git a/chrome/browser/ui/views/frame/test_with_browser_view.cc b/chrome/browser/ui/views/frame/test_with_browser_view.cc
index eae81f1..1c7078cd 100644
--- a/chrome/browser/ui/views/frame/test_with_browser_view.cc
+++ b/chrome/browser/ui/views/frame/test_with_browser_view.cc
@@ -15,6 +15,7 @@
 #include "chrome/browser/extensions/extension_action_test_util.h"
 #include "chrome/browser/extensions/load_error_reporter.h"
 #include "chrome/browser/history/history_service_factory.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/chrome_template_url_service_client.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
@@ -28,6 +29,7 @@
 #include "components/omnibox/browser/autocomplete_classifier.h"
 #include "components/omnibox/browser/autocomplete_controller.h"
 #include "components/omnibox/browser/test_scheme_classifier.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_terms_data.h"
 #include "components/search_engines/template_url_service.h"
 #include "components/signin/public/base/list_accounts_test_utils.h"
@@ -45,7 +47,9 @@
     content::BrowserContext* context) {
   Profile* profile = Profile::FromBrowserContext(context);
   return std::make_unique<TemplateURLService>(
-      profile->GetPrefs(), std::make_unique<UIThreadSearchTermsData>(),
+      profile->GetPrefs(),
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(profile),
+      std::make_unique<UIThreadSearchTermsData>(),
       WebDataServiceFactory::GetKeywordWebDataForProfile(
           profile, ServiceAccessType::EXPLICIT_ACCESS),
       std::make_unique<ChromeTemplateURLServiceClient>(
@@ -53,7 +57,8 @@
               profile, ServiceAccessType::EXPLICIT_ACCESS)),
       base::RepeatingClosure()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-      , profile->IsMainProfile()
+          ,
+      profile->IsMainProfile()
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
 }
diff --git a/chrome/browser/ui/webui/search_engine_choice/icon_utils_unittest.cc b/chrome/browser/ui/webui/search_engine_choice/icon_utils_unittest.cc
index cf3fbc6..80a4f94 100644
--- a/chrome/browser/ui/webui/search_engine_choice/icon_utils_unittest.cc
+++ b/chrome/browser/ui/webui/search_engine_choice/icon_utils_unittest.cc
@@ -11,6 +11,7 @@
 #include "base/test/scoped_feature_list.h"
 #include "components/country_codes/country_codes.h"
 #include "components/search_engines/eea_countries_ids.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engines_switches.h"
 #include "components/search_engines/template_url_prepopulate_data.h"
 #include "components/search_engines/template_url_service.h"
@@ -23,14 +24,22 @@
   IconUtilsTest() {
     TemplateURLService::RegisterProfilePrefs(pref_service_.registry());
     TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
+    search_engine_choice_service_ =
+        std::make_unique<search_engines::SearchEngineChoiceService>(
+            pref_service_);
   }
 
   ~IconUtilsTest() override = default;
   PrefService* pref_service() { return &pref_service_; }
+  search_engines::SearchEngineChoiceService* search_engine_choice_service() {
+    return search_engine_choice_service_.get();
+  }
 
  private:
   base::test::ScopedFeatureList feature_list_{switches::kSearchEngineChoice};
   sync_preferences::TestingPrefServiceSyncable pref_service_;
+  std::unique_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
 };
 
 TEST_F(IconUtilsTest, GetSearchEngineGeneratedIconPath) {
@@ -41,8 +50,8 @@
   for (int country_id : search_engines::kEeaChoiceCountriesIds) {
     pref_service()->SetInteger(country_codes::kCountryIDAtInstall, country_id);
     std::vector<std::unique_ptr<TemplateURLData>> urls =
-        TemplateURLPrepopulateData::GetPrepopulatedEngines(pref_service(),
-                                                           nullptr);
+        TemplateURLPrepopulateData::GetPrepopulatedEngines(
+            pref_service(), search_engine_choice_service(), nullptr);
     for (const std::unique_ptr<TemplateURLData>& url : urls) {
       EXPECT_FALSE(GetSearchEngineGeneratedIconPath(url->keyword()).empty())
           << "Missing icon for " << url->keyword() << ". Try re-running "
diff --git a/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc b/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc
index cd19ee5..7a49100 100644
--- a/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc
+++ b/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui.cc
@@ -12,6 +12,7 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h"
 #include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/ui/webui/search_engine_choice/icon_utils.h"
 #include "chrome/browser/ui/webui/search_engine_choice/search_engine_choice_handler.h"
 #include "chrome/browser/ui/webui/webui_util.h"
@@ -20,6 +21,7 @@
 #include "chrome/grit/search_engine_choice_resources.h"
 #include "chrome/grit/search_engine_choice_resources_map.h"
 #include "chrome/grit/signin_resources.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/template_url.h"
 #include "components/signin/public/base/signin_switches.h"
diff --git a/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui_browsertest.cc b/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui_browsertest.cc
index a134db6..3fa34f8 100644
--- a/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/search_engine_choice/search_engine_choice_ui_browsertest.cc
@@ -12,6 +12,7 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h"
 #include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/search_engine_choice/search_engine_choice_tab_helper.h"
@@ -47,6 +48,8 @@
   explicit MockSearchEngineChoiceDialogService(Profile* profile)
       : SearchEngineChoiceDialogService(
             *profile,
+            *search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+                profile),
             *TemplateURLServiceFactory::GetForProfile(profile)) {
     ON_CALL(*this, GetSearchEngines).WillByDefault([]() {
       std::vector<std::unique_ptr<TemplateURL>> choices;
diff --git a/chrome/browser/ui/webui/settings/search_engines_handler.cc b/chrome/browser/ui/webui/settings/search_engines_handler.cc
index 6ab849b..e949b96e 100644
--- a/chrome/browser/ui/webui/settings/search_engines_handler.cc
+++ b/chrome/browser/ui/webui/settings/search_engines_handler.cc
@@ -17,6 +17,7 @@
 #include "base/values.h"
 #include "chrome/browser/extensions/extension_util.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
 #include "chrome/browser/ui/search_engines/template_url_table_model.h"
@@ -26,6 +27,7 @@
 #include "chrome/common/webui_url_constants.h"
 #include "chrome/grit/generated_resources.h"
 #include "components/prefs/pref_service.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/template_url.h"
@@ -234,8 +236,10 @@
   // The icons that are used for search engines in the EEA region are bundled
   // with Chrome. We use the favicon service for countries outside the EEA
   // region to guarantee having icons for all search engines.
+  search_engines::SearchEngineChoiceService* search_engine_choice_service =
+      search_engines::SearchEngineChoiceServiceFactory::GetForProfile(profile);
   const bool is_eea_region = search_engines::IsEeaChoiceCountry(
-      search_engines::GetSearchEngineChoiceCountryId(profile_->GetPrefs()));
+      search_engine_choice_service->GetCountryId());
   if (is_search_engine_choice_settings_ui && is_eea_region &&
       template_url->prepopulate_id() != 0) {
     std::string_view icon_path =
diff --git a/chrome/browser/ui/webui/settings/settings_ui.cc b/chrome/browser/ui/webui/settings/settings_ui.cc
index b4e18e88e..f0a747d2 100644
--- a/chrome/browser/ui/webui/settings/settings_ui.cc
+++ b/chrome/browser/ui/webui/settings/settings_ui.cc
@@ -29,6 +29,7 @@
 #include "chrome/browser/privacy_sandbox/tracking_protection_onboarding_factory.h"
 #include "chrome/browser/privacy_sandbox/tracking_protection_settings_factory.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
 #include "chrome/browser/signin/identity_manager_factory.h"
 #include "chrome/browser/signin/signin_features.h"
 #include "chrome/browser/ui/browser_element_identifiers.h"
@@ -97,6 +98,7 @@
 #include "components/privacy_sandbox/tracking_protection_settings.h"
 #include "components/safe_browsing/core/browser/hashprefix_realtime/hash_realtime_utils.h"
 #include "components/safe_browsing/core/common/features.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/signin/public/base/signin_pref_names.h"
 #include "components/sync/base/features.h"
@@ -326,8 +328,12 @@
   html_source->AddBoolean("searchEngineChoiceSettingsUi",
                           is_search_engine_choice_settings_ui);
 
+  search_engines::SearchEngineChoiceService*
+      search_engine_choice_dialog_service =
+          search_engines::SearchEngineChoiceServiceFactory::GetForProfile(
+              profile);
   const bool is_eea_country = search_engines::IsEeaChoiceCountry(
-      search_engines::GetSearchEngineChoiceCountryId(profile->GetPrefs()));
+      search_engine_choice_dialog_service->GetCountryId());
   html_source->AddBoolean("useLargeSearchEngineIcons", is_eea_country);
 
 #if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/components/contextual_search/core/browser/contextual_search_delegate_impl_unittest.cc b/components/contextual_search/core/browser/contextual_search_delegate_impl_unittest.cc
index ce57018..30953a75 100644
--- a/components/contextual_search/core/browser/contextual_search_delegate_impl_unittest.cc
+++ b/components/contextual_search/core/browser/contextual_search_delegate_impl_unittest.cc
@@ -89,7 +89,8 @@
     data.contextual_search_url =
         "https://foobar.com/_/contextualsearch?"
         "{google:contextualSearchVersion}{google:contextualSearchContextData}";
-    TemplateURLService* template_url_service = new TemplateURLService(NULL, 0);
+    TemplateURLService* template_url_service = new TemplateURLService(
+        /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr);
     TemplateURL* template_url =
         template_url_service->Add(std::make_unique<TemplateURL>(data));
     template_url_service->SetUserSelectedDefaultSearchProvider(template_url);
diff --git a/components/omnibox/browser/base_search_provider_unittest.cc b/components/omnibox/browser/base_search_provider_unittest.cc
index 37ffb827..406462c 100644
--- a/components/omnibox/browser/base_search_provider_unittest.cc
+++ b/components/omnibox/browser/base_search_provider_unittest.cc
@@ -111,11 +111,13 @@
  protected:
   void SetUp() {
     auto template_url_service = std::make_unique<TemplateURLService>(
-        nullptr /* PrefService */, std::make_unique<SearchTermsData>(),
-        nullptr /* KeywordWebDataService */,
+        /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr,
+        std::make_unique<SearchTermsData>(),
+        /*web_data_service=*/nullptr,
         std::unique_ptr<TemplateURLServiceClient>(), base::RepeatingClosure()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-        , false /* for_lacros_main_profile */
+                                                         ,
+        /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     );
 
diff --git a/components/omnibox/browser/document_provider_unittest.cc b/components/omnibox/browser/document_provider_unittest.cc
index a802c43..151f6fc 100644
--- a/components/omnibox/browser/document_provider_unittest.cc
+++ b/components/omnibox/browser/document_provider_unittest.cc
@@ -49,7 +49,9 @@
 class FakeAutocompleteProviderClient : public MockAutocompleteProviderClient {
  public:
   FakeAutocompleteProviderClient()
-      : template_url_service_(new TemplateURLService(nullptr, 0)),
+      : template_url_service_(
+            new TemplateURLService(/*prefs=*/nullptr,
+                                   /*search_engine_choice_service=*/nullptr)),
         pref_service_(new TestingPrefServiceSimple()) {
     pref_service_->registry()->RegisterBooleanPref(
         omnibox::kDocumentSuggestEnabled, true);
diff --git a/components/omnibox/browser/remote_suggestions_service_unittest.cc b/components/omnibox/browser/remote_suggestions_service_unittest.cc
index 914cbe20..8d31e9b 100644
--- a/components/omnibox/browser/remote_suggestions_service_unittest.cc
+++ b/components/omnibox/browser/remote_suggestions_service_unittest.cc
@@ -98,7 +98,8 @@
 
   RemoteSuggestionsService service(/*document_suggestions_service_=*/nullptr,
                                    GetUrlLoaderFactory());
-  TemplateURLService template_url_service(nullptr, 0);
+  TemplateURLService template_url_service(
+      /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr);
   TemplateURLRef::SearchTermsArgs search_terms_args;
   search_terms_args.current_page_url = "https://www.google.com/";
   service.StartZeroPrefixSuggestionsRequest(
@@ -126,7 +127,8 @@
 
   RemoteSuggestionsService service(/*document_suggestions_service_=*/nullptr,
                                    GetUrlLoaderFactory());
-  TemplateURLService template_url_service(nullptr, 0);
+  TemplateURLService template_url_service(
+      /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr);
   TemplateURLRef::SearchTermsArgs search_terms_args;
   search_terms_args.current_page_url = "https://www.google.com/";
   search_terms_args.bypass_cache = true;
@@ -148,7 +150,8 @@
 }
 
 TEST_F(RemoteSuggestionsServiceTest, EnsureObservers) {
-  TemplateURLService template_url_service(nullptr, 0);
+  TemplateURLService template_url_service(
+      /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr);
   TemplateURLData template_url_data;
   template_url_data.suggestions_url = "https://www.example.com/suggest";
   template_url_service.SetUserSelectedDefaultSearchProvider(
diff --git a/components/omnibox/browser/test_omnibox_client.cc b/components/omnibox/browser/test_omnibox_client.cc
index 596bc27..8f6b32c 100644
--- a/components/omnibox/browser/test_omnibox_client.cc
+++ b/components/omnibox/browser/test_omnibox_client.cc
@@ -47,11 +47,13 @@
       .WillRepeatedly(testing::Return("en-US"));
 
   auto template_url_service = std::make_unique<TemplateURLService>(
-      nullptr /* PrefService */, std::make_unique<SearchTermsData>(),
-      nullptr /* KeywordWebDataService */,
-      std::unique_ptr<TemplateURLServiceClient>(), base::RepeatingClosure()
+      /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr,
+      std::make_unique<SearchTermsData>(),
+      /*web_data_service=*/nullptr, std::unique_ptr<TemplateURLServiceClient>(),
+      base::RepeatingClosure()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-      , false /* for_lacros_main_profile */
+          ,
+      /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
 
diff --git a/components/omnibox/browser/zero_suggest_provider_unittest.cc b/components/omnibox/browser/zero_suggest_provider_unittest.cc
index 3a6589a..1a9fd23 100644
--- a/components/omnibox/browser/zero_suggest_provider_unittest.cc
+++ b/components/omnibox/browser/zero_suggest_provider_unittest.cc
@@ -51,7 +51,9 @@
 class FakeAutocompleteProviderClient : public MockAutocompleteProviderClient {
  public:
   FakeAutocompleteProviderClient()
-      : template_url_service_(new TemplateURLService(nullptr, 0)),
+      : template_url_service_(std::make_unique<TemplateURLService>(
+            /*prefs=*/nullptr,
+            /*search_engine_choice_service=*/nullptr)),
         pref_service_(new TestingPrefServiceSimple()) {
     ZeroSuggestProvider::RegisterProfilePrefs(pref_service_->registry());
     zero_suggest_cache_service_ = std::make_unique<ZeroSuggestCacheService>(
diff --git a/components/search_engines/BUILD.gn b/components/search_engines/BUILD.gn
index 91281d6..5b284b1 100644
--- a/components/search_engines/BUILD.gn
+++ b/components/search_engines/BUILD.gn
@@ -24,6 +24,8 @@
     "keyword_table.h",
     "keyword_web_data_service.cc",
     "keyword_web_data_service.h",
+    "search_engine_choice/search_engine_choice_service.cc",
+    "search_engine_choice/search_engine_choice_service.h",
     "search_engine_choice_utils.cc",
     "search_engine_choice_utils.h",
     "search_engines_pref_names.cc",
@@ -185,6 +187,7 @@
     "default_search_manager_unittest.cc",
     "enterprise_site_search_manager_unittest.cc",
     "keyword_table_unittest.cc",
+    "search_engine_choice/search_engine_choice_service_unittest.cc",
     "search_engine_choice_utils_unittest.cc",
     "search_host_to_urls_map_unittest.cc",
     "template_url_data_unittest.cc",
diff --git a/components/search_engines/android/template_url_service_android.h b/components/search_engines/android/template_url_service_android.h
index 38d53bb..e3b2df7 100644
--- a/components/search_engines/android/template_url_service_android.h
+++ b/components/search_engines/android/template_url_service_android.h
@@ -7,6 +7,7 @@
 
 #include "base/android/scoped_java_ref.h"
 #include "base/memory/raw_ptr.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/template_url_service.h"
 #include "components/search_engines/template_url_service_observer.h"
 
diff --git a/components/search_engines/android/template_url_service_android_unittest.cc b/components/search_engines/android/template_url_service_android_unittest.cc
index 6eec777e..8dabc5c8 100644
--- a/components/search_engines/android/template_url_service_android_unittest.cc
+++ b/components/search_engines/android/template_url_service_android_unittest.cc
@@ -61,10 +61,15 @@
     TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
     DefaultSearchManager::RegisterProfilePrefs(pref_service_.registry());
 
+    search_engine_choice_service_ =
+        std::make_unique<search_engines::SearchEngineChoiceService>(
+            pref_service_);
+
     env_ = base::android::AttachCurrentThread();
 
     template_url_service_ = std::make_unique<TemplateURLService>(
-        &pref_service_, std::make_unique<SearchTermsData>(),
+        &pref_service_, search_engine_choice_service_.get(),
+        std::make_unique<SearchTermsData>(),
         /*web_data_service=*/nullptr,
         /*client=*/nullptr, base::RepeatingClosure());
 
@@ -104,6 +109,8 @@
  private:
   base::test::ScopedFeatureList feature_list_;
   sync_preferences::TestingPrefServiceSyncable pref_service_;
+  std::unique_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
 
   raw_ptr<JNIEnv> env_ = nullptr;
 
diff --git a/components/search_engines/default_search_manager.cc b/components/search_engines/default_search_manager.cc
index 1771bd78..76fe5bf 100644
--- a/components/search_engines/default_search_manager.cc
+++ b/components/search_engines/default_search_manager.cc
@@ -99,15 +99,19 @@
 
 DefaultSearchManager::DefaultSearchManager(
     PrefService* pref_service,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     const ObserverCallback& change_observer
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-    , bool for_lacros_main_profile
+    ,
+    bool for_lacros_main_profile
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     )
     : pref_service_(pref_service),
+      search_engine_choice_service_(search_engine_choice_service),
       change_observer_(change_observer)
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-      , for_lacros_main_profile_(for_lacros_main_profile)
+      ,
+      for_lacros_main_profile_(for_lacros_main_profile)
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
 {
   if (pref_service_) {
@@ -297,8 +301,8 @@
     return;
 
   std::vector<std::unique_ptr<TemplateURLData>> prepopulated_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(pref_service_,
-                                                         nullptr);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          pref_service_, search_engine_choice_service_, nullptr);
 
   auto default_engine = base::ranges::find(
       prepopulated_urls, prefs_default_search_->prepopulate_id,
@@ -363,7 +367,8 @@
 
 void DefaultSearchManager::LoadPrepopulatedDefaultSearch() {
   std::unique_ptr<TemplateURLData> data =
-      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(pref_service_);
+      TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(
+          pref_service_, search_engine_choice_service_);
   fallback_default_search_ = std::move(data);
   MergePrefsDataWithPrepopulated();
 }
diff --git a/components/search_engines/default_search_manager.h b/components/search_engines/default_search_manager.h
index a69eab51..ac83533 100644
--- a/components/search_engines/default_search_manager.h
+++ b/components/search_engines/default_search_manager.h
@@ -13,6 +13,10 @@
 #include "build/chromeos_buildflags.h"
 #include "components/prefs/pref_change_registrar.h"
 
+namespace search_engines {
+class SearchEngineChoiceService;
+}
+
 namespace user_prefs {
 class PrefRegistrySyncable;
 }
@@ -96,10 +100,13 @@
   using ObserverCallback =
       base::RepeatingCallback<void(const TemplateURLData*, Source)>;
 
-  DefaultSearchManager(PrefService* pref_service,
-                       const ObserverCallback& change_observer
+  DefaultSearchManager(
+      PrefService* pref_service,
+      search_engines::SearchEngineChoiceService* search_engine_choice_service,
+      const ObserverCallback& change_observer
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                       , bool for_lacros_main_profile
+      ,
+      bool for_lacros_main_profile
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
 
@@ -173,7 +180,10 @@
   // Invokes |change_observer_| if it is not NULL.
   void NotifyObserver();
 
-  raw_ptr<PrefService> pref_service_;
+  const raw_ptr<PrefService> pref_service_;
+  const raw_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_ = nullptr;
+
   const ObserverCallback change_observer_;
   PrefChangeRegistrar pref_change_registrar_;
 
diff --git a/components/search_engines/default_search_manager_unittest.cc b/components/search_engines/default_search_manager_unittest.cc
index 44a6ccf9..eeb4fdd 100644
--- a/components/search_engines/default_search_manager_unittest.cc
+++ b/components/search_engines/default_search_manager_unittest.cc
@@ -16,6 +16,7 @@
 #include "base/time/time.h"
 #include "build/chromeos_buildflags.h"
 #include "components/pref_registry/pref_registry_syncable.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/search_engines_test_util.h"
 #include "components/search_engines/template_url_data.h"
@@ -96,6 +97,9 @@
   void SetUp() override {
     pref_service_ =
         std::make_unique<sync_preferences::TestingPrefServiceSyncable>();
+    search_engine_choice_service_ =
+        std::make_unique<search_engines::SearchEngineChoiceService>(
+            *pref_service_);
     DefaultSearchManager::RegisterProfilePrefs(pref_service_->registry());
     TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_->registry());
   }
@@ -103,19 +107,25 @@
   sync_preferences::TestingPrefServiceSyncable* pref_service() {
     return pref_service_.get();
   }
+  search_engines::SearchEngineChoiceService* search_engine_choice_service() {
+    return search_engine_choice_service_.get();
+  }
 
  private:
   variations::ScopedVariationsIdsProvider scoped_variations_ids_provider_{
       variations::VariationsIdsProvider::Mode::kUseSignedInState};
   std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> pref_service_;
+  std::unique_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
 };
 
 // Test that a TemplateURLData object is properly written and read from Prefs.
 TEST_F(DefaultSearchManagerTest, ReadAndWritePref) {
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   TemplateURLData data;
@@ -141,15 +151,17 @@
 // Test DefaultSearchmanager handles user-selected DSEs correctly.
 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByUserPref) {
   size_t default_search_index = 0;
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   std::vector<std::unique_ptr<TemplateURLData>> prepopulated_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(pref_service(),
-                                                         &default_search_index);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          pref_service(), search_engine_choice_service(),
+          &default_search_index);
   DefaultSearchManager::Source source = DefaultSearchManager::FROM_POLICY;
   // If no user pref is set, we should use the pre-populated values.
   ExpectSimilar(prepopulated_urls[default_search_index].get(),
@@ -168,9 +180,11 @@
   std::unique_ptr<TemplateURLData> new_data =
       GenerateDummyTemplateURLData("user2");
   DefaultSearchManager other_manager(pref_service(),
+                                     search_engine_choice_service(),
                                      DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                                     , /*for_lacros_main_proifle=*/false
+                                         ,
+                                     /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   other_manager.SetUserSelectedDefaultSearchEngine(*new_data);
@@ -190,15 +204,17 @@
 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByOverrides) {
   SetOverrides(pref_service(), false);
   size_t default_search_index = 0;
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   std::vector<std::unique_ptr<TemplateURLData>> prepopulated_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(pref_service(),
-                                                         &default_search_index);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          pref_service(), search_engine_choice_service(),
+          &default_search_index);
 
   DefaultSearchManager::Source source = DefaultSearchManager::FROM_POLICY;
   TemplateURLData first_default(*manager.GetDefaultSearchEngine(&source));
@@ -208,7 +224,7 @@
   // Update the overrides:
   SetOverrides(pref_service(), true);
   prepopulated_urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(
-      pref_service(), &default_search_index);
+      pref_service(), search_engine_choice_service(), &default_search_index);
 
   // Make sure DefaultSearchManager updated:
   ExpectSimilar(prepopulated_urls[default_search_index].get(),
@@ -222,10 +238,11 @@
 
 // Test DefaultSearchManager handles policy-enforced DSEs correctly.
 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByEnforcedPolicy) {
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   std::unique_ptr<TemplateURLData> data = GenerateDummyTemplateURLData("user");
@@ -255,10 +272,11 @@
 
 // Policy-recommended DSE is handled correctly when no existing DSE is present.
 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByRecommendedPolicy) {
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   DefaultSearchManager::Source source = DefaultSearchManager::FROM_FALLBACK;
@@ -293,10 +311,11 @@
 
 // Policy-recommended DSE does not override existing DSE set by user.
 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByUserAndRecommendedPolicy) {
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   // Set user-configured DSE.
@@ -324,10 +343,11 @@
 
 // Test DefaultSearchManager handles extension-controlled DSEs correctly.
 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByExtension) {
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   std::unique_ptr<TemplateURLData> data = GenerateDummyTemplateURLData("user");
@@ -375,10 +395,11 @@
 // Verify that DefaultSearchManager preserves search engine parameters for
 // search engine created from Play API data.
 TEST_F(DefaultSearchManagerTest, DefaultSearchSetByPlayAPI) {
-  DefaultSearchManager manager(pref_service(),
+  DefaultSearchManager manager(pref_service(), search_engine_choice_service(),
                                DefaultSearchManager::ObserverCallback()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-                               , /*for_lacros_main_proifle=*/false
+                                   ,
+                               /*for_lacros_main_profile=*/false
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
   const TemplateURLData* prepopulated_data =
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_service.cc b/components/search_engines/search_engine_choice/search_engine_choice_service.cc
new file mode 100644
index 0000000..51214e44
--- /dev/null
+++ b/components/search_engines/search_engine_choice/search_engine_choice_service.cc
@@ -0,0 +1,383 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
+
+#include "base/check_deref.h"
+#include "base/command_line.h"
+#include "base/json/json_reader.h"
+#include "base/metrics/histogram_functions.h"
+#include "base/version.h"
+#include "components/country_codes/country_codes.h"
+#include "components/policy/core/common/policy_service.h"
+#include "components/policy/policy_constants.h"
+#include "components/prefs/pref_service.h"
+#include "components/search_engines/eea_countries_ids.h"
+#include "components/search_engines/search_engine_choice_utils.h"
+#include "components/search_engines/search_engines_pref_names.h"
+#include "components/search_engines/search_engines_switches.h"
+#include "components/search_engines/template_url_service.h"
+#include "components/version_info/version_info.h"
+
+namespace search_engines {
+namespace {
+
+#if !(BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+      BUILDFLAG(CHROME_FOR_TESTING))
+// The choice screen should be shown if the `DefaultSearchProviderEnabled`
+// policy is not set, or set to true and the
+// `DefaultSearchProviderSearchURL` policy is not set.
+bool IsSearchEngineChoiceScreenAllowedByPolicy(
+    const policy::PolicyService& policy_service) {
+  const auto& policies = policy_service.GetPolicies(
+      policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
+
+  const auto* default_search_provider_enabled = policies.GetValue(
+      policy::key::kDefaultSearchProviderEnabled, base::Value::Type::BOOLEAN);
+  // Policy is not set.
+  if (!default_search_provider_enabled) {
+    return true;
+  }
+
+  if (default_search_provider_enabled->GetBool()) {
+    const auto* default_search_provider_search_url =
+        policies.GetValue(policy::key::kDefaultSearchProviderSearchURL,
+                          base::Value::Type::STRING);
+    if (!default_search_provider_search_url) {
+      return true;
+    }
+  }
+  return false;
+}
+#endif
+
+SearchEngineType GetDefaultSearchEngineType(
+    TemplateURLService& template_url_service) {
+  const TemplateURL* default_search_engine =
+      template_url_service.GetDefaultSearchProvider();
+
+  return default_search_engine ? default_search_engine->GetEngineType(
+                                     template_url_service.search_terms_data())
+                               : SEARCH_ENGINE_OTHER;
+}
+
+// Returns true if all search engine choice prefs are set.
+bool IsSearchEngineChoiceCompleted(const PrefService& prefs) {
+  return prefs.HasPrefPath(
+             prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp) &&
+         prefs.HasPrefPath(
+             prefs::kDefaultSearchProviderChoiceScreenCompletionVersion);
+}
+
+// Returns true if the version is valid and can be compared to the current
+// Chrome version.
+bool IsValidVersionFormat(const base::Version& version) {
+  if (!version.IsValid()) {
+    return false;
+  }
+
+  // The version should have the same number of components as the current Chrome
+  // version.
+  if (version.components().size() !=
+      version_info::GetVersion().components().size()) {
+    return false;
+  }
+  return true;
+}
+
+// Logs the outcome of a reprompt attempt for a specific key (either a specific
+// country or the wildcard).
+void LogSearchRepromptKeyHistograms(RepromptResult result, bool is_wildcard) {
+  // `RepromptResult::kInvalidDictionary` is recorded separately.
+  CHECK_NE(result, RepromptResult::kInvalidDictionary);
+
+  base::UmaHistogramEnumeration(kSearchEngineChoiceRepromptHistogram, result);
+  if (is_wildcard) {
+    base::UmaHistogramEnumeration(kSearchEngineChoiceRepromptWildcardHistogram,
+                                  result);
+  } else {
+    base::UmaHistogramEnumeration(
+        kSearchEngineChoiceRepromptSpecificCountryHistogram, result);
+  }
+}
+
+}  // namespace
+
+SearchEngineChoiceService::SearchEngineChoiceService(PrefService& profile_prefs)
+    : profile_prefs_(profile_prefs) {}
+
+SearchEngineChoiceService::~SearchEngineChoiceService() = default;
+
+bool SearchEngineChoiceService::ShouldShowUpdatedSettings() {
+#if BUILDFLAG(IS_IOS)
+  // TODO(b/318820137): There should not be a dependency on the country here.
+  if (!IsEeaChoiceCountry(GetCountryId())) {
+    return false;
+  }
+#endif
+  return IsChoiceScreenFlagEnabled(ChoicePromo::kAny);
+}
+
+#if BUILDFLAG(IS_IOS)
+bool SearchEngineChoiceService::ShouldShowChoiceScreen(
+    const policy::PolicyService& policy_service,
+    bool is_regular_profile,
+    TemplateURLService* template_url_service) {
+  PreprocessPrefsForReprompt();
+  auto condition = GetStaticChoiceScreenConditions(
+      policy_service, is_regular_profile, CHECK_DEREF(template_url_service));
+
+  if (condition == SearchEngineChoiceScreenConditions::kEligible) {
+    condition = GetDynamicChoiceScreenConditions(*template_url_service);
+  }
+
+  RecordChoiceScreenProfileInitCondition(condition);
+  return condition == SearchEngineChoiceScreenConditions::kEligible;
+}
+#endif
+
+SearchEngineChoiceScreenConditions
+SearchEngineChoiceService::GetStaticChoiceScreenConditions(
+    const policy::PolicyService& policy_service,
+    bool is_regular_profile,
+    const TemplateURLService& template_url_service) {
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  // TODO(b/319050536): Remove the function declaration on these platforms.
+  return SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
+#else
+  if (!IsChoiceScreenFlagEnabled(ChoicePromo::kAny)) {
+    return SearchEngineChoiceScreenConditions::kFeatureSuppressed;
+  }
+
+  if (switches::kSearchEngineChoiceTriggerForTaggedProfilesOnly.Get() &&
+      !profile_prefs_->GetBoolean(prefs::kDefaultSearchProviderChoicePending)) {
+    return SearchEngineChoiceScreenConditions::kProfileOutOfScope;
+  }
+
+  if (!is_regular_profile) {
+    // Naming not exactly accurate, but still reflect the fact that incognito,
+    // kiosk, etc. are not supported and belongs in this bucked more than in
+    // `kProfileOutOfScope` for example.
+    return SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
+  }
+
+  base::CommandLine* const command_line =
+      base::CommandLine::ForCurrentProcess();
+  // A command line argument with the option for disabling the choice screen for
+  // testing and automation environments.
+  if (command_line->HasSwitch(switches::kDisableSearchEngineChoiceScreen)) {
+    return SearchEngineChoiceScreenConditions::kFeatureSuppressed;
+  }
+
+  // Force triggering the choice screen for testing the screen itself.
+  if (command_line->HasSwitch(switches::kForceSearchEngineChoiceScreen)) {
+    return SearchEngineChoiceScreenConditions::kEligible;
+  }
+
+  if (IsSearchEngineChoiceCompleted(*profile_prefs_)) {
+    return SearchEngineChoiceScreenConditions::kAlreadyCompleted;
+  }
+
+  int country_id = GetCountryId();
+  DVLOG(1) << "Checking country for choice screen, found: "
+           << country_codes::CountryIDToCountryString(country_id);
+  if (!IsEeaChoiceCountry(country_id)) {
+    return SearchEngineChoiceScreenConditions::kNotInRegionalScope;
+  }
+
+  // Initially exclude users with this type of override. Consult b/302675777 for
+  // next steps.
+  if (profile_prefs_->HasPrefPath(prefs::kSearchProviderOverrides)) {
+    return SearchEngineChoiceScreenConditions::kSearchProviderOverride;
+  }
+
+  if (!IsSearchEngineChoiceScreenAllowedByPolicy(policy_service)) {
+    return SearchEngineChoiceScreenConditions::kControlledByPolicy;
+  }
+
+  return SearchEngineChoiceScreenConditions::kEligible;
+#endif
+}
+
+SearchEngineChoiceScreenConditions
+SearchEngineChoiceService::GetDynamicChoiceScreenConditions(
+    const TemplateURLService& template_url_service) {
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  // TODO(b/319050536): Remove the function declaration on these platforms.
+  return SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
+#else
+  // Don't show the dialog if the default search engine is set by an extension.
+  if (template_url_service.IsExtensionControlledDefaultSearch()) {
+    return SearchEngineChoiceScreenConditions::kExtensionControlled;
+  }
+
+  // Don't show the dialog if the user has a custom search engine set as
+  // default.
+  const TemplateURL* default_search_engine =
+      template_url_service.GetDefaultSearchProvider();
+  if (default_search_engine &&
+      !template_url_service.IsPrepopulatedOrDefaultProviderByPolicy(
+          default_search_engine)) {
+    return SearchEngineChoiceScreenConditions::kHasCustomSearchEngine;
+  }
+
+  // Force triggering the choice screen for testing the screen itself.
+  // Deliberately checked after the conditions overriding the default search
+  // engine with some custom one because they would put the choice screens in
+  // some unstable state and they are rather easy to change if we want to
+  // re-enable the triggering.
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kForceSearchEngineChoiceScreen)) {
+    return SearchEngineChoiceScreenConditions::kEligible;
+  }
+
+  if (IsSearchEngineChoiceCompleted(*profile_prefs_)) {
+    return SearchEngineChoiceScreenConditions::kAlreadyCompleted;
+  }
+
+  return SearchEngineChoiceScreenConditions::kEligible;
+#endif
+}
+
+int SearchEngineChoiceService::GetCountryId() {
+  int command_line_country = country_codes::CountryStringToCountryID(
+      base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+          switches::kSearchEngineChoiceCountry));
+  if (command_line_country != country_codes::kCountryIDUnknown) {
+    return command_line_country;
+  }
+
+  bool force_eea_country =
+      switches::kSearchEngineChoiceTriggerWithForceEeaCountry.Get();
+  if (force_eea_country) {
+    // `kSearchEngineChoiceTriggerWithForceEeaCountry` forces the search engine
+    // choice country to Belgium.
+    return country_codes::CountryStringToCountryID("BE");
+  }
+
+  return country_codes::GetCountryIDFromPrefs(&profile_prefs_.get());
+}
+
+void SearchEngineChoiceService::RecordChoiceMade(
+    ChoiceMadeLocation choice_location,
+    TemplateURLService* template_url_service) {
+  if (choice_location == ChoiceMadeLocation::kOther) {
+    // This is called from a path not resulting from a fully featured search
+    // engine choice screen, so skip recoding associated choice data.
+    return;
+  }
+
+  if (!IsChoiceScreenFlagEnabled(ChoicePromo::kAny)) {
+    return;
+  }
+
+  // Don't modify the pref if the user is not in the EEA region.
+  if (!IsEeaChoiceCountry(GetCountryId())) {
+    return;
+  }
+
+  // Don't modify the prefs if they were already set.
+  if (IsSearchEngineChoiceCompleted(*profile_prefs_)) {
+    return;
+  }
+
+  RecordChoiceScreenDefaultSearchProviderType(
+      GetDefaultSearchEngineType(CHECK_DEREF(template_url_service)));
+  profile_prefs_->SetInt64(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
+      base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds());
+  profile_prefs_->SetString(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion,
+      version_info::GetVersionNumber());
+
+  if (profile_prefs_->HasPrefPath(prefs::kDefaultSearchProviderChoicePending)) {
+    DVLOG(1) << "Choice made, removing profile tag.";
+    profile_prefs_->ClearPref(prefs::kDefaultSearchProviderChoicePending);
+  }
+}
+
+void SearchEngineChoiceService::PreprocessPrefsForReprompt() {
+  if (!IsChoiceScreenFlagEnabled(ChoicePromo::kAny)) {
+    return;
+  }
+
+  // If existing prefs are missing or have a wrong format, force a reprompt.
+  if (!profile_prefs_->HasPrefPath(
+          prefs::kDefaultSearchProviderChoiceScreenCompletionVersion)) {
+    WipeSearchEngineChoicePrefs(
+        profile_prefs_.get(),
+        WipeSearchEngineChoiceReason::kMissingChoiceVersion);
+    return;
+  }
+
+  base::Version choice_version(profile_prefs_->GetString(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
+  if (!IsValidVersionFormat(choice_version)) {
+    WipeSearchEngineChoicePrefs(
+        profile_prefs_.get(),
+        WipeSearchEngineChoiceReason::kInvalidChoiceVersion);
+    return;
+  }
+
+  // Check parameters from `switches::kSearchEngineChoiceTriggerRepromptParams`.
+  absl::optional<base::Value::Dict> reprompt_params =
+      base::JSONReader::ReadDict(
+          switches::kSearchEngineChoiceTriggerRepromptParams.Get());
+  if (!reprompt_params) {
+    // No valid reprompt parameters.
+    base::UmaHistogramEnumeration(kSearchEngineChoiceRepromptHistogram,
+                                  RepromptResult::kInvalidDictionary);
+    return;
+  }
+
+  const base::Version& current_version = version_info::GetVersion();
+  int country_id = GetCountryId();
+  const std::string wildcard_string("*");
+  // Explicit country key takes precedence over the wildcard.
+  for (const std::string& key :
+       {country_codes::CountryIDToCountryString(country_id), wildcard_string}) {
+    bool is_wildcard = key == wildcard_string;
+    const std::string* reprompt_version_string =
+        reprompt_params->FindString(key);
+    if (!reprompt_version_string) {
+      // No version string for this country. Fallback to the wildcard.
+      LogSearchRepromptKeyHistograms(RepromptResult::kNoDictionaryKey,
+                                     is_wildcard);
+      continue;
+    }
+
+    base::Version reprompt_version(*reprompt_version_string);
+    if (!IsValidVersionFormat(reprompt_version)) {
+      // The version is ill-formatted.
+      LogSearchRepromptKeyHistograms(RepromptResult::kInvalidVersion,
+                                     is_wildcard);
+      break;
+    }
+
+    // Do not reprompt if the current version is too old, to avoid endless
+    // reprompts.
+    if (current_version < reprompt_version) {
+      LogSearchRepromptKeyHistograms(RepromptResult::kChromeTooOld,
+                                     is_wildcard);
+      break;
+    }
+
+    if (choice_version >= reprompt_version) {
+      // No need to reprompt, the choice is recent enough.
+      LogSearchRepromptKeyHistograms(RepromptResult::kRecentChoice,
+                                     is_wildcard);
+      break;
+    }
+
+    // Wipe the choice to force a reprompt.
+    LogSearchRepromptKeyHistograms(RepromptResult::kReprompt, is_wildcard);
+    WipeSearchEngineChoicePrefs(profile_prefs_.get(),
+                                WipeSearchEngineChoiceReason::kReprompt);
+    return;
+  }
+}
+
+}  // namespace search_engines
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_service.h b/components/search_engines/search_engine_choice/search_engine_choice_service.h
new file mode 100644
index 0000000..d8a4e64
--- /dev/null
+++ b/components/search_engines/search_engine_choice/search_engine_choice_service.h
@@ -0,0 +1,85 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINE_CHOICE_SEARCH_ENGINE_CHOICE_SERVICE_H_
+#define COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINE_CHOICE_SEARCH_ENGINE_CHOICE_SERVICE_H_
+
+#include "base/memory/raw_ref.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "components/search_engines/search_engine_choice_utils.h"
+
+namespace policy {
+class PolicyService;
+}
+
+class PrefService;
+class TemplateURLService;
+
+namespace search_engines {
+
+// `KeyedService` for managing the state related to Search Engine Choice (mostly
+// for the country information).
+class SearchEngineChoiceService : public KeyedService {
+ public:
+  explicit SearchEngineChoiceService(PrefService& profile_prefs);
+  ~SearchEngineChoiceService() override;
+
+  // Returns whether the version of the search engines settings screen showing
+  // additional search engine info should be shown.
+  // TODO(b/318824817): To be removed post-launch.
+  bool ShouldShowUpdatedSettings();
+
+#if BUILDFLAG(IS_IOS)
+  // Returns whether the search engine choice screen can be displayed or not
+  // based on device policies and profile properties.
+  // TODO(b/318801987): Move the function to some iOS-specific location and
+  //                    consider removing `is_regular_profile`.
+  bool ShouldShowChoiceScreen(const policy::PolicyService& policy_service,
+                              bool is_regular_profile,
+                              TemplateURLService* template_url_service);
+#endif
+
+  // Returns the choice screen eligibility condition most relevant for the
+  // profile associated with `profile_prefs` and `template_url_service`. Only
+  // checks dynamic conditions, that can change from one call to the other
+  // during a profile's lifetime. Should be checked right before showing a
+  // choice screen.
+  SearchEngineChoiceScreenConditions GetDynamicChoiceScreenConditions(
+      const TemplateURLService& template_url_service);
+
+  // Returns the choice screen eligibility condition most relevant for the
+  // profile described by `profile_properties`. Only checks static conditions,
+  // such that if a non-eligible condition is returned, it would take at least a
+  // restart for the state to change. So this state can be checked and cached
+  // ahead of showing a choice screen.
+  // TODO(b/318801987): Remove `is_regular_profile` after fixing tests.
+  SearchEngineChoiceScreenConditions GetStaticChoiceScreenConditions(
+      const policy::PolicyService& policy_service,
+      bool is_regular_profile,
+      const TemplateURLService& template_url_service);
+
+  // Returns the country ID to use in the context of any search engine choice
+  // logic. Can be overridden using `switches::kSearchEngineChoiceCountry`.
+  // See `//components/country_codes` for the Country ID format.
+  int GetCountryId();
+
+  // Records that the choice was made by settings the timestamp if applicable.
+  // Records the location from which the choice was made and the search engine
+  // that was chosen.
+  // The function should be called after the default search engine has been set.
+  void RecordChoiceMade(ChoiceMadeLocation choice_location,
+                        TemplateURLService* template_url_service);
+
+  // Checks if the search engine choice should be prompted again, based on
+  // experiment parameters. If a reprompt is needed, some preferences related to
+  // the choice are cleared, which triggers a reprompt on the next page load.
+  void PreprocessPrefsForReprompt();
+
+ private:
+  const raw_ref<PrefService> profile_prefs_;
+};
+
+}  // namespace search_engines
+
+#endif  // COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINE_CHOICE_SEARCH_ENGINE_CHOICE_SERVICE_H_
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_service_unittest.cc b/components/search_engines/search_engine_choice/search_engine_choice_service_unittest.cc
new file mode 100644
index 0000000..6f7abc73
--- /dev/null
+++ b/components/search_engines/search_engine_choice/search_engine_choice_service_unittest.cc
@@ -0,0 +1,909 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
+
+#include <memory>
+#include <vector>
+
+#include "base/check_deref.h"
+#include "base/command_line.h"
+#include "base/feature_list.h"
+#include "base/metrics/field_trial_params.h"
+#include "base/strings/string_util.h"
+#include "base/test/metrics/histogram_tester.h"
+#include "base/test/scoped_feature_list.h"
+#include "base/version.h"
+#include "build/build_config.h"
+#include "components/country_codes/country_codes.h"
+#include "components/policy/core/common/mock_policy_service.h"
+#include "components/policy/core/common/policy_namespace.h"
+#include "components/policy/core/common/policy_types.h"
+#include "components/policy/policy_constants.h"
+#include "components/prefs/testing_pref_service.h"
+#include "components/search_engines/eea_countries_ids.h"
+#include "components/search_engines/prepopulated_engines.h"
+#include "components/search_engines/search_engine_type.h"
+#include "components/search_engines/search_engines_pref_names.h"
+#include "components/search_engines/search_engines_switches.h"
+#include "components/search_engines/template_url_data_util.h"
+#include "components/search_engines/template_url_prepopulate_data.h"
+#include "components/search_engines/template_url_service.h"
+#include "components/signin/public/base/signin_switches.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
+#include "components/version_info/version_info.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using search_engines::RepromptResult;
+using search_engines::WipeSearchEngineChoiceReason;
+using ::testing::NiceMock;
+
+namespace search_engines {
+
+class SearchEngineChoiceServiceTest : public ::testing::Test {
+ public:
+  SearchEngineChoiceServiceTest() {
+    feature_list_.InitAndEnableFeature(switches::kSearchEngineChoice);
+    TemplateURLService::RegisterProfilePrefs(pref_service_.registry());
+    DefaultSearchManager::RegisterProfilePrefs(pref_service_.registry());
+    TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
+
+    search_engine_choice_service_ =
+        std::make_unique<SearchEngineChoiceService>(pref_service_);
+
+    // Override the country checks to simulate being in Belgium.
+    base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+        switches::kSearchEngineChoiceCountry, "BE");
+
+    template_url_service_ = std::make_unique<TemplateURLService>(
+        &pref_service_, search_engine_choice_service_.get());
+
+    InitMockPolicyService();
+    CheckPoliciesInitialState();
+  }
+
+  ~SearchEngineChoiceServiceTest() override = default;
+
+  policy::MockPolicyService& policy_service() { return policy_service_; }
+  policy::PolicyMap& policy_map() { return policy_map_; }
+  PrefService* pref_service() { return &pref_service_; }
+  base::test::ScopedFeatureList* feature_list() { return &feature_list_; }
+  TemplateURLService& template_url_service() {
+    return CHECK_DEREF(template_url_service_.get());
+  }
+  search_engines::SearchEngineChoiceService& search_engine_choice_service() {
+    return CHECK_DEREF(search_engine_choice_service_.get());
+  }
+  base::HistogramTester histogram_tester_;
+
+ private:
+  void InitMockPolicyService() {
+    ON_CALL(policy_service_, GetPolicies(::testing::Eq(policy::PolicyNamespace(
+                                 policy::POLICY_DOMAIN_CHROME, std::string()))))
+        .WillByDefault(::testing::ReturnRef(policy_map_));
+  }
+
+  // Test that the `DefaultSearchProviderEnabled` and
+  // `DefaultSearchProviderSearchURL` policies are not initially set.
+  void CheckPoliciesInitialState() {
+    const auto& policies = policy_service().GetPolicies(
+        policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
+
+    const auto* default_search_provider_enabled = policies.GetValue(
+        policy::key::kDefaultSearchProviderEnabled, base::Value::Type::BOOLEAN);
+    const auto* default_search_provider_search_url =
+        policies.GetValue(policy::key::kDefaultSearchProviderSearchURL,
+                          base::Value::Type::STRING);
+
+    ASSERT_FALSE(default_search_provider_enabled);
+    ASSERT_FALSE(default_search_provider_search_url);
+  }
+
+  base::test::ScopedFeatureList feature_list_;
+  sync_preferences::TestingPrefServiceSyncable pref_service_;
+  std::unique_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
+  NiceMock<policy::MockPolicyService> policy_service_;
+  policy::PolicyMap policy_map_;
+  std::unique_ptr<TemplateURLService> template_url_service_;
+};
+
+// Test that the choice screen doesn't get displayed if the profile is not
+// regular.
+TEST_F(SearchEngineChoiceServiceTest,
+       DoNotShowChoiceScreenWithNotRegularProfile) {
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/false,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+}
+
+// Test that the choice screen gets displayed if the
+// `DefaultSearchProviderEnabled` policy is not set.
+TEST_F(SearchEngineChoiceServiceTest, ShowChoiceScreenIfPoliciesAreNotSet) {
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+
+  SearchEngineChoiceScreenConditions expected_choice_screen_condition =
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+      SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
+#else
+      SearchEngineChoiceScreenConditions::kEligible;
+#endif
+
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            expected_choice_screen_condition);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            expected_choice_screen_condition);
+
+#if BUILDFLAG(IS_IOS)
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowChoiceScreen(
+      policy_service(), /*is_regular_profile=*/true, &template_url_service()));
+  histogram_tester_.ExpectBucketCount(
+      kSearchEngineChoiceScreenProfileInitConditionsHistogram,
+      SearchEngineChoiceScreenConditions::kEligible, 1);
+#endif
+}
+
+// Test that the choice screen does not get displayed if the provider list is
+// overridden in the intial_preferences file.
+TEST_F(SearchEngineChoiceServiceTest,
+       DoNotShowChoiceScreenWithProviderListOverride) {
+  base::Value::List override_list;
+  pref_service()->SetList(prefs::kSearchProviderOverrides,
+                          override_list.Clone());
+
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
+#else
+            SearchEngineChoiceScreenConditions::kSearchProviderOverride
+#endif
+  );
+}
+
+// Test that the choice screen doesn't get displayed if the
+// 'DefaultSearchProviderEnabled' policy is set to false.
+TEST_F(SearchEngineChoiceServiceTest, DoNotShowChoiceScreenIfPolicySetToFalse) {
+  policy_map().Set(policy::key::kDefaultSearchProviderEnabled,
+                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
+                   policy::POLICY_SOURCE_CLOUD, base::Value(false), nullptr);
+
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
+#else
+            SearchEngineChoiceScreenConditions::kControlledByPolicy
+#endif
+  );
+}
+
+// Test that the choice screen gets displayed if the
+// 'DefaultSearchProviderEnabled' policy is set to true but the
+// 'DefaultSearchProviderSearchURL' policy is not set.
+TEST_F(SearchEngineChoiceServiceTest,
+       ShowChoiceScreenIfPolicySetToTrueWithoutUrlSet) {
+  policy_map().Set(policy::key::kDefaultSearchProviderEnabled,
+                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
+                   policy::POLICY_SOURCE_CLOUD, base::Value(true), nullptr);
+
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+#endif
+}
+
+// Test that the choice screen doesn't get displayed if the
+// 'DefaultSearchProviderEnabled' policy is set to true and the
+// DefaultSearchProviderSearchURL' is set.
+TEST_F(SearchEngineChoiceServiceTest,
+       DoNotShowChoiceScreenIfPolicySetToTrueWithUrlSet) {
+  policy_map().Set(policy::key::kDefaultSearchProviderEnabled,
+                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
+                   policy::POLICY_SOURCE_CLOUD, base::Value(true), nullptr);
+  policy_map().Set(policy::key::kDefaultSearchProviderSearchURL,
+                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
+                   policy::POLICY_SOURCE_CLOUD, base::Value("test"), nullptr);
+
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
+#else
+            SearchEngineChoiceScreenConditions::kControlledByPolicy
+#endif
+  );
+}
+
+// Test that the choice screen gets displayed if and only if the
+// `kDefaultSearchProviderChoiceScreenTimestamp` pref is not set. Setting this
+// pref means that the user has made a search engine choice in the choice
+// screen.
+TEST_F(SearchEngineChoiceServiceTest,
+       ShowChoiceScreenIfTheTimestampPrefIsNotSet) {
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+#endif
+
+  search_engine_choice_service().RecordChoiceMade(
+      search_engines::ChoiceMadeLocation::kChoiceScreen,
+      &template_url_service());
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kAlreadyCompleted);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kAlreadyCompleted);
+#endif
+}
+
+// Test that there is a regional condition controlling eligibility.
+TEST_F(SearchEngineChoiceServiceTest,
+       DoNotShowChoiceScreenIfCountryOutOfScope) {
+  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+      switches::kSearchEngineChoiceCountry, "US");
+#if BUILDFLAG(IS_IOS)
+  // TODO(b/318820137): There should not be a dependency on the country here.
+  EXPECT_FALSE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#else
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#endif
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
+#else
+            SearchEngineChoiceScreenConditions::kNotInRegionalScope
+#endif
+  );
+}
+
+// Test that the choice screen does get displayed even if completed if the
+// command line argument for forcing it is set.
+TEST_F(SearchEngineChoiceServiceTest,
+       ShowChoiceScreenWithForceCommandLineFlag) {
+  base::CommandLine::ForCurrentProcess()->AppendSwitch(
+      switches::kForceSearchEngineChoiceScreen);
+  search_engine_choice_service().RecordChoiceMade(
+      search_engines::ChoiceMadeLocation::kChoiceScreen,
+      &template_url_service());
+
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+#endif
+}
+
+// Ensure that the choice screen doesn't get displayed if the flag is disabled.
+TEST_F(SearchEngineChoiceServiceTest, DoNotShowChoiceScreenIfFlagIsDisabled) {
+  feature_list()->Reset();
+  feature_list()->InitWithFeatures({}, {switches::kSearchEngineChoiceTrigger});
+  EXPECT_FALSE(search_engine_choice_service().ShouldShowUpdatedSettings());
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
+#else
+            SearchEngineChoiceScreenConditions::kFeatureSuppressed
+#endif
+  );
+}
+
+TEST_F(SearchEngineChoiceServiceTest, ShowChoiceScreenWithTriggerFeature) {
+  // SearchEngineChoiceTrigger is enabled and not set to trigger only for
+  // tagged profiles: the dialog should trigger, regardless of the state of
+  // the other feature flags.
+  feature_list()->Reset();
+  feature_list()->InitWithFeatures({switches::kSearchEngineChoiceTrigger},
+                                   {switches::kSearchEngineChoice});
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+#endif
+
+  // When the param is set and the profile untagged, the dialog will not be
+  // displayed.
+  base::FieldTrialParams tagged_only_params{
+      {switches::kSearchEngineChoiceTriggerForTaggedProfilesOnly.name, "true"}};
+  feature_list()->Reset();
+  feature_list()->InitWithFeaturesAndParameters(
+      {{switches::kSearchEngineChoiceTrigger, tagged_only_params}},
+      {switches::kSearchEngineChoice});
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kProfileOutOfScope);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+#endif
+
+  // When the profile is tagged, the dialog can also be displayed.
+  pref_service()->SetBoolean(prefs::kDefaultSearchProviderChoicePending, true);
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+#endif
+}
+
+// Test that the choice screen does not get displayed if the command line
+// argument for disabling it is set.
+TEST_F(SearchEngineChoiceServiceTest,
+       DoNotShowChoiceScreenWithDisableCommandLineFlag) {
+  base::CommandLine::ForCurrentProcess()->AppendSwitch(
+      switches::kDisableSearchEngineChoiceScreen);
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(),
+                /*is_regular_profile=*/true, template_url_service()),
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
+#else
+
+            SearchEngineChoiceScreenConditions::kFeatureSuppressed
+#endif
+  );
+}
+
+TEST_F(SearchEngineChoiceServiceTest, GetSearchEngineChoiceCountryId) {
+  const int kBelgiumCountryId =
+      country_codes::CountryCharsToCountryID('B', 'E');
+
+  // The test is set up to use the command line to simulate the country as being
+  // Belgium.
+  EXPECT_EQ(search_engine_choice_service().GetCountryId(), kBelgiumCountryId);
+
+  // When removing the command line flag, the default value is based on the
+  // device locale.
+  base::CommandLine::ForCurrentProcess()->RemoveSwitch(
+      switches::kSearchEngineChoiceCountry);
+  EXPECT_EQ(search_engine_choice_service().GetCountryId(),
+            country_codes::GetCurrentCountryID());
+
+  // When the command line value is invalid, it is ignored.
+  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+      switches::kSearchEngineChoiceCountry, "USA");
+  EXPECT_EQ(search_engine_choice_service().GetCountryId(),
+            country_codes::GetCurrentCountryID());
+
+  // Note that if the format matches (2-character strings), we might get a
+  // country ID that is not valid/supported.
+  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+      switches::kSearchEngineChoiceCountry, "??");
+  EXPECT_EQ(search_engine_choice_service().GetCountryId(),
+            country_codes::CountryCharsToCountryID('?', '?'));
+
+  // The value set from the pref is reflected otherwise.
+  pref_service()->SetInteger(country_codes::kCountryIDAtInstall,
+                             kBelgiumCountryId);
+  base::CommandLine::ForCurrentProcess()->RemoveSwitch(
+      switches::kSearchEngineChoiceCountry);
+  EXPECT_EQ(search_engine_choice_service().GetCountryId(), kBelgiumCountryId);
+}
+
+TEST_F(SearchEngineChoiceServiceTest,
+       DoNotShowChoiceScreenIfUserHasCustomSearchEngineSetAsDefault) {
+  // A custom search engine will have a `prepopulate_id` of 0.
+  const int kCustomSearchEnginePrepopulateId = 0;
+  TemplateURLData template_url_data;
+  template_url_data.prepopulate_id = kCustomSearchEnginePrepopulateId;
+  template_url_data.SetURL("https://www.example.com/?q={searchTerms}");
+  template_url_service().SetUserSelectedDefaultSearchProvider(
+      template_url_service().Add(
+          std::make_unique<TemplateURL>(template_url_data)));
+
+  EXPECT_TRUE(search_engine_choice_service().ShouldShowUpdatedSettings());
+#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
+#else
+  EXPECT_EQ(search_engine_choice_service().GetStaticChoiceScreenConditions(
+                policy_service(), /*is_regular_profile=*/true,
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kEligible);
+  EXPECT_EQ(search_engine_choice_service().GetDynamicChoiceScreenConditions(
+                template_url_service()),
+            SearchEngineChoiceScreenConditions::kHasCustomSearchEngine);
+#endif
+
+#if BUILDFLAG(IS_IOS)
+  EXPECT_FALSE(search_engine_choice_service().ShouldShowChoiceScreen(
+      policy_service(), /*is_regular_profile=*/true, &template_url_service()));
+  histogram_tester_.ExpectBucketCount(
+      kSearchEngineChoiceScreenProfileInitConditionsHistogram,
+      SearchEngineChoiceScreenConditions::kHasCustomSearchEngine, 1);
+#endif
+}
+
+TEST_F(SearchEngineChoiceServiceTest, RecordChoiceMade) {
+  base::CommandLine::ForCurrentProcess()->RemoveSwitch(
+      switches::kSearchEngineChoiceCountry);
+
+  // Test that the choice is not recorded for countries outside the EEA region.
+  const int kUnitedStatesCountryId =
+      country_codes::CountryCharsToCountryID('U', 'S');
+  pref_service()->SetInteger(country_codes::kCountryIDAtInstall,
+                             kUnitedStatesCountryId);
+
+  const TemplateURL* default_search_engine =
+      template_url_service().GetDefaultSearchProvider();
+  EXPECT_EQ(default_search_engine->prepopulate_id(),
+            TemplateURLPrepopulateData::google.id);
+
+  search_engine_choice_service().RecordChoiceMade(
+      search_engines::ChoiceMadeLocation::kChoiceScreen,
+      &template_url_service());
+
+  histogram_tester_.ExpectUniqueSample(
+      search_engines::kSearchEngineChoiceScreenDefaultSearchEngineTypeHistogram,
+      SearchEngineType::SEARCH_ENGINE_GOOGLE, 0);
+  EXPECT_FALSE(pref_service()->HasPrefPath(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
+  EXPECT_FALSE(pref_service()->HasPrefPath(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
+
+  // Revert to an EEA region country.
+  const int kBelgiumCountryId =
+      country_codes::CountryCharsToCountryID('B', 'E');
+  pref_service()->SetInteger(country_codes::kCountryIDAtInstall,
+                             kBelgiumCountryId);
+
+  // Test that the choice is recorded if it wasn't previously done.
+  search_engine_choice_service().RecordChoiceMade(
+      search_engines::ChoiceMadeLocation::kChoiceScreen,
+      &template_url_service());
+  histogram_tester_.ExpectUniqueSample(
+      search_engines::kSearchEngineChoiceScreenDefaultSearchEngineTypeHistogram,
+      SearchEngineType::SEARCH_ENGINE_GOOGLE, 1);
+
+  EXPECT_NEAR(pref_service()->GetInt64(
+                  prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp),
+              base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds(),
+              /*abs_error=*/2);
+  EXPECT_EQ(pref_service()->GetString(
+                prefs::kDefaultSearchProviderChoiceScreenCompletionVersion),
+            version_info::GetVersionNumber());
+
+  // Set the pref to 5 so that we can know if it gets modified.
+  const int kModifiedTimestamp = 5;
+  pref_service()->SetInt64(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
+      kModifiedTimestamp);
+
+  // Test that the choice is not recorded if it was previously done.
+  search_engine_choice_service().RecordChoiceMade(
+      search_engines::ChoiceMadeLocation::kChoiceScreen,
+      &template_url_service());
+  EXPECT_EQ(pref_service()->GetInt64(
+                prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp),
+            kModifiedTimestamp);
+
+  histogram_tester_.ExpectUniqueSample(
+      search_engines::kSearchEngineChoiceScreenDefaultSearchEngineTypeHistogram,
+      SearchEngineType::SEARCH_ENGINE_GOOGLE, 1);
+}
+
+// Test that the user is not reprompted is the reprompt parameter is not a valid
+// JSON string.
+TEST_F(SearchEngineChoiceServiceTest, NoRepromptForSyntaxError) {
+  // Set the reprompt parameters with invalid syntax.
+  base::test::ScopedFeatureList scoped_feature_list;
+  scoped_feature_list.InitAndEnableFeatureWithParameters(
+      switches::kSearchEngineChoiceTrigger,
+      {{switches::kSearchEngineChoiceTriggerRepromptParams.name, "Foo"}});
+  ASSERT_EQ("Foo", switches::kSearchEngineChoiceTriggerRepromptParams.Get());
+
+  // Initialize the preference with some previous choice.
+  int64_t kPreviousTimestamp = 1;
+  pref_service()->SetInt64(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
+      kPreviousTimestamp);
+  base::Version choice_version({1, 2, 3, 4});
+  pref_service()->SetString(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion,
+      choice_version.GetString());
+
+  // The user should not be reprompted.
+  search_engine_choice_service().PreprocessPrefsForReprompt();
+
+  EXPECT_EQ(kPreviousTimestamp,
+            pref_service()->GetInt64(
+                prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
+  EXPECT_EQ(choice_version.GetString(),
+            pref_service()->GetString(
+                prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
+  histogram_tester_.ExpectTotalCount(
+      search_engines::kSearchEngineChoiceWipeReasonHistogram, 0);
+  histogram_tester_.ExpectTotalCount(
+      search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram, 0);
+  histogram_tester_.ExpectTotalCount(
+      search_engines::kSearchEngineChoiceRepromptWildcardHistogram, 0);
+  histogram_tester_.ExpectUniqueSample(
+      search_engines::kSearchEngineChoiceRepromptHistogram,
+      RepromptResult::kInvalidDictionary, 1);
+}
+
+// The user is reprompted if the version preference is missing.
+TEST_F(SearchEngineChoiceServiceTest, RepromptForMissingChoiceVersion) {
+  base::test::ScopedFeatureList scoped_feature_list{
+      switches::kSearchEngineChoiceTrigger};
+
+  // Initialize the timestamp, but not the version.
+  int64_t kPreviousTimestamp = 1;
+  pref_service()->SetInt64(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
+      kPreviousTimestamp);
+
+  // The user should be reprompted.
+  search_engine_choice_service().PreprocessPrefsForReprompt();
+
+  EXPECT_FALSE(pref_service()->HasPrefPath(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
+  EXPECT_FALSE(pref_service()->HasPrefPath(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
+  histogram_tester_.ExpectUniqueSample(
+      search_engines::kSearchEngineChoiceWipeReasonHistogram,
+      WipeSearchEngineChoiceReason::kMissingChoiceVersion, 1);
+  histogram_tester_.ExpectTotalCount(
+      search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram, 0);
+  histogram_tester_.ExpectTotalCount(
+      search_engines::kSearchEngineChoiceRepromptWildcardHistogram, 0);
+  histogram_tester_.ExpectTotalCount(
+      search_engines::kSearchEngineChoiceRepromptHistogram, 0);
+}
+
+struct RepromptTestParam {
+  // Whether the user should be reprompted or not.
+  absl::optional<WipeSearchEngineChoiceReason> wipe_reason;
+  // Internal results of the reprompt computation.
+  absl::optional<RepromptResult> wildcard_result;
+  absl::optional<RepromptResult> country_result;
+  // Version of the choice.
+  const base::StringPiece choice_version;
+  // The reprompt params, as sent by the server.  Use `CURRENT_VERSION` for the
+  // current Chrome version, and `FUTURE_VERSION` for a future version.
+  const char* param_dict;
+};
+
+class SearchEngineChoiceUtilsParamTest
+    : public SearchEngineChoiceServiceTest,
+      public testing::WithParamInterface<RepromptTestParam> {};
+
+TEST_P(SearchEngineChoiceUtilsParamTest, Reprompt) {
+  // Set the reprompt parameters.
+  std::string param_dict = base::CollapseWhitespaceASCII(
+      GetParam().param_dict, /*trim_sequences_with_line_breaks=*/true);
+  base::ReplaceFirstSubstringAfterOffset(&param_dict, /*start_offset=*/0,
+                                         "CURRENT_VERSION",
+                                         version_info::GetVersionNumber());
+  base::Version future_version(
+      {version_info::GetMajorVersionNumberAsInt() + 5u, 2, 3, 4});
+  ASSERT_TRUE(future_version.IsValid());
+  base::ReplaceFirstSubstringAfterOffset(&param_dict, /*start_offset=*/0,
+                                         "FUTURE_VERSION",
+                                         future_version.GetString());
+
+  std::string feature_param_value = param_dict.empty() ? "{}" : param_dict;
+
+  base::test::ScopedFeatureList scoped_feature_list;
+  scoped_feature_list.InitAndEnableFeatureWithParameters(
+      switches::kSearchEngineChoiceTrigger,
+      {{switches::kSearchEngineChoiceTriggerRepromptParams.name,
+        feature_param_value}});
+  ASSERT_EQ(feature_param_value,
+            switches::kSearchEngineChoiceTriggerRepromptParams.Get());
+
+  // Initialize the preference with some previous choice.
+  int64_t kPreviousTimestamp = 1;
+  pref_service()->SetInt64(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
+      kPreviousTimestamp);
+  pref_service()->SetString(
+      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion,
+      GetParam().choice_version);
+
+  // Check whether the user is reprompted.
+  search_engine_choice_service().PreprocessPrefsForReprompt();
+
+  if (GetParam().wipe_reason) {
+    // User is reprompted, prefs were wiped.
+    EXPECT_FALSE(pref_service()->HasPrefPath(
+        prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
+    EXPECT_FALSE(pref_service()->HasPrefPath(
+        prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
+    histogram_tester_.ExpectUniqueSample(
+        search_engines::kSearchEngineChoiceWipeReasonHistogram,
+        *GetParam().wipe_reason, 1);
+  } else {
+    // User is not reprompted, prefs were not wiped.
+    EXPECT_EQ(
+        kPreviousTimestamp,
+        pref_service()->GetInt64(
+            prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
+    EXPECT_EQ(GetParam().choice_version,
+              pref_service()->GetString(
+                  prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
+    histogram_tester_.ExpectTotalCount(
+        search_engines::kSearchEngineChoiceWipeReasonHistogram, 0);
+  }
+
+  int total_reprompt_record_count = 0;
+  if (GetParam().wildcard_result) {
+    ++total_reprompt_record_count;
+    histogram_tester_.ExpectUniqueSample(
+        search_engines::kSearchEngineChoiceRepromptWildcardHistogram,
+        *GetParam().wildcard_result, 1);
+    EXPECT_GE(histogram_tester_.GetBucketCount(
+                  search_engines::kSearchEngineChoiceRepromptHistogram,
+                  *GetParam().wildcard_result),
+              1);
+  } else {
+    histogram_tester_.ExpectTotalCount(
+        search_engines::kSearchEngineChoiceRepromptWildcardHistogram, 0);
+  }
+  if (GetParam().country_result) {
+    ++total_reprompt_record_count;
+    histogram_tester_.ExpectUniqueSample(
+        search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram,
+        *GetParam().country_result, 1);
+    EXPECT_GE(histogram_tester_.GetBucketCount(
+                  search_engines::kSearchEngineChoiceRepromptHistogram,
+                  *GetParam().country_result),
+              1);
+  } else {
+    histogram_tester_.ExpectTotalCount(
+        search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram, 0);
+  }
+  histogram_tester_.ExpectTotalCount(
+      search_engines::kSearchEngineChoiceRepromptHistogram,
+      total_reprompt_record_count);
+}
+
+constexpr RepromptTestParam kRepromptTestParams[] = {
+    // Reprompt all countries with the wildcard.
+    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"*":"1.0.0.1"} )"},
+    // Reprompt works with all version components.
+    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
+     RepromptResult::kNoDictionaryKey, "1.0.0.100", R"( {"*":"1.0.1.0"} )"},
+    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
+     RepromptResult::kNoDictionaryKey, "1.0.200.0", R"( {"*":"1.1.0.0"} )"},
+    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
+     RepromptResult::kNoDictionaryKey, "1.300.0.0", R"( {"*":"2.0.0.0"} )"},
+    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
+     RepromptResult::kNoDictionaryKey, "10.10.1.1",
+     R"( {"*":"30.45.678.9100"} )"},
+    // Reprompt a specific country.
+    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
+     RepromptResult::kReprompt, "1.0.0.0", R"( {"BE":"1.0.0.1"} )"},
+    // Reprompt for params inclusive of current version
+    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
+     RepromptResult::kReprompt, "1.0.0.0", R"( {"BE":"CURRENT_VERSION"} )"},
+    // Reprompt when the choice version is malformed.
+    {WipeSearchEngineChoiceReason::kInvalidChoiceVersion, absl::nullopt,
+     absl::nullopt, "Blah", ""},
+    // Reprompt when both the country and the wild card are specified, as long
+    // as one of them qualifies.
+    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
+     RepromptResult::kReprompt, "1.0.0.0",
+     R"( {"*":"1.0.0.1","BE":"1.0.0.1"} )"},
+    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
+     RepromptResult::kReprompt, "1.0.0.0",
+     R"( {"*":"FUTURE_VERSION","BE":"1.0.0.1"} )"},
+    // Still works with irrelevant parameters for other countries.
+    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
+     RepromptResult::kReprompt, "1.0.0.0",
+     R"(
+       {
+         "FR":"FUTURE_VERSION",
+         "INVALID_COUNTRY":"INVALID_VERSION",
+         "US":"FUTURE_VERSION",
+         "BE":"1.0.0.1"
+       } )"},
+
+    // Don't reprompt when the choice was made in the current version.
+    {absl::nullopt, RepromptResult::kRecentChoice,
+     RepromptResult::kNoDictionaryKey, version_info::GetVersionNumber(),
+     "{\"*\":\"CURRENT_VERSION\"}"},
+    // Don't reprompt when the choice was recent enough.
+    {absl::nullopt, RepromptResult::kRecentChoice,
+     RepromptResult::kNoDictionaryKey, "2.0.0.0", R"( {"*":"1.0.0.1"} )"},
+    // Don't reprompt for another country.
+    {absl::nullopt, RepromptResult::kNoDictionaryKey,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"FR":"1.0.0.1"} )"},
+    {absl::nullopt, RepromptResult::kNoDictionaryKey,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"US":"1.0.0.1"} )"},
+    {absl::nullopt, RepromptResult::kNoDictionaryKey,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"XX":"1.0.0.1"} )"},
+    {absl::nullopt, RepromptResult::kNoDictionaryKey,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0",
+     R"( {"INVALID_COUNTRY":"1.0.0.1"} )"},
+    {absl::nullopt, absl::nullopt, RepromptResult::kChromeTooOld, "1.0.0.0",
+     R"( {"FR":"1.0.0.1","BE":"FUTURE_VERSION"} )"},
+    // Don't reprompt for future versions.
+    {absl::nullopt, RepromptResult::kChromeTooOld,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0",
+     R"( {"*":"FUTURE_VERSION"} )"},
+    // Wildcard is overridden by specific country.
+    {absl::nullopt, absl::nullopt, RepromptResult::kChromeTooOld, "1.0.0.0",
+     R"( {"*":"1.0.0.1","BE":"FUTURE_VERSION"} )"},
+    // Combination of right version for wrong country and wrong version for
+    // right country.
+    {absl::nullopt, absl::nullopt, RepromptResult::kChromeTooOld, "2.0.0.0",
+     R"(
+       {
+          "*":"1.1.0.0",
+          "BE":"FUTURE_VERSION",
+          "FR":"2.0.0.1"
+        } )"},
+    // Empty dictionary.
+    {absl::nullopt, RepromptResult::kNoDictionaryKey,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", "{}"},
+    // Empty parameter.
+    {absl::nullopt, RepromptResult::kNoDictionaryKey,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", ""},
+    // Wrong number of components.
+    {absl::nullopt, RepromptResult::kInvalidVersion,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"*":"2.0"} )"},
+    // Wildcard in version.
+    {absl::nullopt, RepromptResult::kInvalidVersion,
+     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"*":"2.0.0.*"} )"},
+};
+
+INSTANTIATE_TEST_SUITE_P(,
+                         SearchEngineChoiceUtilsParamTest,
+                         ::testing::ValuesIn(kRepromptTestParams));
+
+#if !BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
+    BUILDFLAG(CHROME_FOR_TESTING)
+
+class SearchEngineChoiceUtilsResourceIdsTest : public ::testing::Test {
+ public:
+  SearchEngineChoiceUtilsResourceIdsTest() {
+    TemplateURLService::RegisterProfilePrefs(pref_service_.registry());
+    TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
+
+    search_engine_choice_service_ =
+        std::make_unique<SearchEngineChoiceService>(pref_service_);
+  }
+
+  ~SearchEngineChoiceUtilsResourceIdsTest() override = default;
+
+  PrefService* pref_service() { return &pref_service_; }
+  search_engines::SearchEngineChoiceService& search_engine_choice_service() {
+    return CHECK_DEREF(search_engine_choice_service_.get());
+  }
+
+ private:
+  base::test::ScopedFeatureList feature_list_{switches::kSearchEngineChoice};
+  sync_preferences::TestingPrefServiceSyncable pref_service_;
+  std::unique_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
+};
+
+// Verifies that all prepopulated search engines associated with EEA countries
+// have an icon.
+TEST_F(SearchEngineChoiceUtilsResourceIdsTest, GetIconResourceId) {
+  // Make sure the country is not forced.
+  ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
+      switches::kSearchEngineChoiceCountry));
+
+  for (int country_id : search_engines::kEeaChoiceCountriesIds) {
+    pref_service()->SetInteger(country_codes::kCountryIDAtInstall, country_id);
+    std::vector<std::unique_ptr<TemplateURLData>> urls =
+        TemplateURLPrepopulateData::GetPrepopulatedEngines(
+            pref_service(), &search_engine_choice_service(), nullptr);
+    for (const std::unique_ptr<TemplateURLData>& url : urls) {
+      EXPECT_GE(search_engines::GetIconResourceId(url->keyword()), 0)
+          << "Missing icon for " << url->keyword() << ". Try re-running "
+          << "`tools/search_engine_choice/generate_search_engine_icons.py`.";
+    }
+  }
+}
+
+#endif  // !BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) ||
+        // BUILDFLAG(CHROME_FOR_TESTING)
+
+}  // namespace search_engines
diff --git a/components/search_engines/search_engine_choice_utils.cc b/components/search_engines/search_engine_choice_utils.cc
index 07e1dc72..3d1b97e 100644
--- a/components/search_engines/search_engine_choice_utils.cc
+++ b/components/search_engines/search_engine_choice_utils.cc
@@ -23,92 +23,9 @@
 #include "components/search_engines/template_url_service.h"
 #include "components/signin/public/base/signin_switches.h"
 #include "components/strings/grit/components_strings.h"
-#include "components/version_info/version_info.h"
 #include "ui/base/l10n/l10n_util.h"
 
 namespace search_engines {
-namespace {
-
-// Logs the outcome of a reprompt attempt for a specific key (either a specific
-// country or the wildcard).
-void LogSearchRepromptKeyHistograms(RepromptResult result, bool is_wildcard) {
-  // `RepromptResult::kInvalidDictionary` is recorded separately.
-  CHECK_NE(result, RepromptResult::kInvalidDictionary);
-
-  base::UmaHistogramEnumeration(kSearchEngineChoiceRepromptHistogram, result);
-  if (is_wildcard) {
-    base::UmaHistogramEnumeration(kSearchEngineChoiceRepromptWildcardHistogram,
-                                  result);
-  } else {
-    base::UmaHistogramEnumeration(
-        kSearchEngineChoiceRepromptSpecificCountryHistogram, result);
-  }
-}
-
-#if !(BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-      BUILDFLAG(CHROME_FOR_TESTING))
-// The choice screen should be shown if the `DefaultSearchProviderEnabled`
-// policy is not set, or set to true and the
-// `DefaultSearchProviderSearchURL` policy is not set.
-bool IsSearchEngineChoiceScreenAllowedByPolicy(
-    const policy::PolicyService& policy_service) {
-  const auto& policies = policy_service.GetPolicies(
-      policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
-
-  const auto* default_search_provider_enabled = policies.GetValue(
-      policy::key::kDefaultSearchProviderEnabled, base::Value::Type::BOOLEAN);
-  // Policy is not set.
-  if (!default_search_provider_enabled) {
-    return true;
-  }
-
-  if (default_search_provider_enabled->GetBool()) {
-    const auto* default_search_provider_search_url =
-        policies.GetValue(policy::key::kDefaultSearchProviderSearchURL,
-                          base::Value::Type::STRING);
-    if (!default_search_provider_search_url) {
-      return true;
-    }
-  }
-  return false;
-}
-#endif
-
-SearchEngineType GetDefaultSearchEngineType(
-    TemplateURLService& template_url_service) {
-  const TemplateURL* default_search_engine =
-      template_url_service.GetDefaultSearchProvider();
-
-  return default_search_engine ? default_search_engine->GetEngineType(
-                                     template_url_service.search_terms_data())
-                               : SEARCH_ENGINE_OTHER;
-}
-
-// Returns true if all search engine choice prefs are set.
-bool IsSearchEngineChoiceCompleted(const PrefService& prefs) {
-  return prefs.HasPrefPath(
-             prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp) &&
-         prefs.HasPrefPath(
-             prefs::kDefaultSearchProviderChoiceScreenCompletionVersion);
-}
-
-// Returns true if the version is valid and can be compared to the current
-// Chrome version.
-bool IsValidVersionFormat(const base::Version& version) {
-  if (!version.IsValid()) {
-    return false;
-  }
-
-  // The version should have the same number of components as the current Chrome
-  // version.
-  if (version.components().size() !=
-      version_info::GetVersion().components().size()) {
-    return false;
-  }
-  return true;
-}
-
-}  // namespace
 
 const char kSearchEngineChoiceScreenNavigationConditionsHistogram[] =
     "Search.ChoiceScreenNavigationConditions";
@@ -162,158 +79,6 @@
   }
 }
 
-bool ShouldShowUpdatedSettings(PrefService& profile_prefs) {
-#if BUILDFLAG(IS_IOS)
-  // TODO(b/318820137): There should not be a dependency on the country here.
-  if (!IsEeaChoiceCountry(GetSearchEngineChoiceCountryId(&profile_prefs))) {
-    return false;
-  }
-#endif
-  return IsChoiceScreenFlagEnabled(ChoicePromo::kAny);
-}
-
-#if BUILDFLAG(IS_IOS)
-bool ShouldShowChoiceScreen(const policy::PolicyService& policy_service,
-                            const ProfileProperties& profile_properties,
-                            TemplateURLService* template_url_service) {
-  PreprocessPrefsForReprompt(*profile_properties.pref_service);
-  auto condition = GetStaticChoiceScreenConditions(
-      policy_service, profile_properties, CHECK_DEREF(template_url_service));
-
-  if (condition == SearchEngineChoiceScreenConditions::kEligible) {
-    condition = GetDynamicChoiceScreenConditions(
-        *profile_properties.pref_service, *template_url_service);
-  }
-
-  RecordChoiceScreenProfileInitCondition(condition);
-  return condition == SearchEngineChoiceScreenConditions::kEligible;
-}
-#endif
-
-SearchEngineChoiceScreenConditions GetStaticChoiceScreenConditions(
-    const policy::PolicyService& policy_service,
-    const ProfileProperties& profile_properties,
-    const TemplateURLService& template_url_service) {
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  // TODO(b/319050536): Remove the function declaration on these platforms.
-  return SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
-#else
-  if (!IsChoiceScreenFlagEnabled(ChoicePromo::kAny)) {
-    return SearchEngineChoiceScreenConditions::kFeatureSuppressed;
-  }
-
-  PrefService& prefs = CHECK_DEREF(profile_properties.pref_service.get());
-  if (switches::kSearchEngineChoiceTriggerForTaggedProfilesOnly.Get() &&
-      !prefs.GetBoolean(prefs::kDefaultSearchProviderChoicePending)) {
-    return SearchEngineChoiceScreenConditions::kProfileOutOfScope;
-  }
-
-  if (!profile_properties.is_regular_profile) {
-    // Naming not exactly accurate, but still reflect the fact that incognito,
-    // kiosk, etc. are not supported and belongs in this bucked more than in
-    // `kProfileOutOfScope` for example.
-    return SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
-  }
-
-  base::CommandLine* const command_line =
-      base::CommandLine::ForCurrentProcess();
-  // A command line argument with the option for disabling the choice screen for
-  // testing and automation environments.
-  if (command_line->HasSwitch(switches::kDisableSearchEngineChoiceScreen)) {
-    return SearchEngineChoiceScreenConditions::kFeatureSuppressed;
-  }
-
-  // Force triggering the choice screen for testing the screen itself.
-  if (command_line->HasSwitch(switches::kForceSearchEngineChoiceScreen)) {
-    return SearchEngineChoiceScreenConditions::kEligible;
-  }
-
-  if (IsSearchEngineChoiceCompleted(prefs)) {
-    return SearchEngineChoiceScreenConditions::kAlreadyCompleted;
-  }
-
-  int country_id = GetSearchEngineChoiceCountryId(&prefs);
-  DVLOG(1) << "Checking country for choice screen, found: "
-           << country_codes::CountryIDToCountryString(country_id);
-  if (!IsEeaChoiceCountry(country_id)) {
-    return SearchEngineChoiceScreenConditions::kNotInRegionalScope;
-  }
-
-  // Initially exclude users with this type of override. Consult b/302675777 for
-  // next steps.
-  if (prefs.HasPrefPath(prefs::kSearchProviderOverrides)) {
-    return SearchEngineChoiceScreenConditions::kSearchProviderOverride;
-  }
-
-  if (!IsSearchEngineChoiceScreenAllowedByPolicy(policy_service)) {
-    return SearchEngineChoiceScreenConditions::kControlledByPolicy;
-  }
-
-  return SearchEngineChoiceScreenConditions::kEligible;
-#endif
-}
-
-SearchEngineChoiceScreenConditions GetDynamicChoiceScreenConditions(
-    const PrefService& profile_prefs,
-    const TemplateURLService& template_url_service) {
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  // TODO(b/319050536): Remove the function declaration on these platforms.
-  return SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
-#else
-  // Don't show the dialog if the default search engine is set by an extension.
-  if (template_url_service.IsExtensionControlledDefaultSearch()) {
-    return SearchEngineChoiceScreenConditions::kExtensionControlled;
-  }
-
-  // Don't show the dialog if the user has a custom search engine set as
-  // default.
-  const TemplateURL* default_search_engine =
-      template_url_service.GetDefaultSearchProvider();
-  if (default_search_engine &&
-      !template_url_service.IsPrepopulatedOrDefaultProviderByPolicy(
-          default_search_engine)) {
-    return SearchEngineChoiceScreenConditions::kHasCustomSearchEngine;
-  }
-
-  // Force triggering the choice screen for testing the screen itself.
-  // Deliberately checked after the conditions overriding the default search
-  // engine with some custom one because they would put the choice screens in
-  // some unstable state and they are rather easy to change if we want to
-  // re-enable the triggering.
-  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kForceSearchEngineChoiceScreen)) {
-    return SearchEngineChoiceScreenConditions::kEligible;
-  }
-
-  if (IsSearchEngineChoiceCompleted(profile_prefs)) {
-    return SearchEngineChoiceScreenConditions::kAlreadyCompleted;
-  }
-
-  return SearchEngineChoiceScreenConditions::kEligible;
-#endif
-}
-
-int GetSearchEngineChoiceCountryId(PrefService* profile_prefs) {
-  int command_line_country = country_codes::CountryStringToCountryID(
-      base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
-          switches::kSearchEngineChoiceCountry));
-  if (command_line_country != country_codes::kCountryIDUnknown) {
-    return command_line_country;
-  }
-
-  bool force_eea_country =
-      switches::kSearchEngineChoiceTriggerWithForceEeaCountry.Get();
-  if (force_eea_country) {
-    // `kSearchEngineChoiceTriggerWithForceEeaCountry` forces the search engine
-    // choice country to Belgium.
-    return country_codes::CountryStringToCountryID("BE");
-  }
-
-  return country_codes::GetCountryIDFromPrefs(profile_prefs);
-}
-
 bool IsEeaChoiceCountry(int country_id) {
   return kEeaChoiceCountriesIds.contains(country_id);
 }
@@ -335,44 +100,6 @@
       SEARCH_ENGINE_MAX);
 }
 
-void RecordChoiceMade(PrefService* profile_prefs,
-                      ChoiceMadeLocation choice_location,
-                      TemplateURLService* template_url_service) {
-  if (choice_location == ChoiceMadeLocation::kOther) {
-    // This is called from a path not resulting from a fully featured search
-    // engine choice screen, so skip recoding associated choice data.
-    return;
-  }
-
-  if (!IsChoiceScreenFlagEnabled(ChoicePromo::kAny)) {
-    return;
-  }
-
-  // Don't modify the pref if the user is not in the EEA region.
-  if (!IsEeaChoiceCountry(GetSearchEngineChoiceCountryId(profile_prefs))) {
-    return;
-  }
-
-  // Don't modify the prefs if they were already set.
-  if (IsSearchEngineChoiceCompleted(*profile_prefs)) {
-    return;
-  }
-
-  RecordChoiceScreenDefaultSearchProviderType(
-      GetDefaultSearchEngineType(CHECK_DEREF(template_url_service)));
-  profile_prefs->SetInt64(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
-      base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds());
-  profile_prefs->SetString(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion,
-      version_info::GetVersionNumber());
-
-  if (profile_prefs->HasPrefPath(prefs::kDefaultSearchProviderChoicePending)) {
-    DVLOG(1) << "Choice made, removing profile tag.";
-    profile_prefs->ClearPref(prefs::kDefaultSearchProviderChoicePending);
-  }
-}
-
 void WipeSearchEngineChoicePrefs(PrefService& profile_prefs,
                                  WipeSearchEngineChoiceReason reason) {
   if (IsChoiceScreenFlagEnabled(ChoicePromo::kAny)) {
@@ -399,83 +126,4 @@
 }
 #endif
 
-void PreprocessPrefsForReprompt(PrefService& profile_prefs) {
-  if (!IsChoiceScreenFlagEnabled(ChoicePromo::kAny)) {
-    return;
-  }
-
-  // If existing prefs are missing or have a wrong format, force a reprompt.
-  if (!profile_prefs.HasPrefPath(
-          prefs::kDefaultSearchProviderChoiceScreenCompletionVersion)) {
-    WipeSearchEngineChoicePrefs(
-        profile_prefs, WipeSearchEngineChoiceReason::kMissingChoiceVersion);
-    return;
-  }
-
-  base::Version choice_version(profile_prefs.GetString(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
-  if (!IsValidVersionFormat(choice_version)) {
-    WipeSearchEngineChoicePrefs(
-        profile_prefs, WipeSearchEngineChoiceReason::kInvalidChoiceVersion);
-    return;
-  }
-
-  // Check parameters from `switches::kSearchEngineChoiceTriggerRepromptParams`.
-  absl::optional<base::Value::Dict> reprompt_params =
-      base::JSONReader::ReadDict(
-          switches::kSearchEngineChoiceTriggerRepromptParams.Get());
-  if (!reprompt_params) {
-    // No valid reprompt parameters.
-    base::UmaHistogramEnumeration(kSearchEngineChoiceRepromptHistogram,
-                                  RepromptResult::kInvalidDictionary);
-    return;
-  }
-
-  const base::Version& current_version = version_info::GetVersion();
-  int country_id = GetSearchEngineChoiceCountryId(&profile_prefs);
-  const std::string wildcard_string("*");
-  // Explicit country key takes precedence over the wildcard.
-  for (const std::string& key :
-       {country_codes::CountryIDToCountryString(country_id), wildcard_string}) {
-    bool is_wildcard = key == wildcard_string;
-    const std::string* reprompt_version_string =
-        reprompt_params->FindString(key);
-    if (!reprompt_version_string) {
-      // No version string for this country. Fallback to the wildcard.
-      LogSearchRepromptKeyHistograms(RepromptResult::kNoDictionaryKey,
-                                     is_wildcard);
-      continue;
-    }
-
-    base::Version reprompt_version(*reprompt_version_string);
-    if (!IsValidVersionFormat(reprompt_version)) {
-      // The version is ill-formatted.
-      LogSearchRepromptKeyHistograms(RepromptResult::kInvalidVersion,
-                                     is_wildcard);
-      break;
-    }
-
-    // Do not reprompt if the current version is too old, to avoid endless
-    // reprompts.
-    if (current_version < reprompt_version) {
-      LogSearchRepromptKeyHistograms(RepromptResult::kChromeTooOld,
-                                     is_wildcard);
-      break;
-    }
-
-    if (choice_version >= reprompt_version) {
-      // No need to reprompt, the choice is recent enough.
-      LogSearchRepromptKeyHistograms(RepromptResult::kRecentChoice,
-                                     is_wildcard);
-      break;
-    }
-
-    // Wipe the choice to force a reprompt.
-    LogSearchRepromptKeyHistograms(RepromptResult::kReprompt, is_wildcard);
-    WipeSearchEngineChoicePrefs(profile_prefs,
-                                WipeSearchEngineChoiceReason::kReprompt);
-    return;
-  }
-}
-
 }  // namespace search_engines
diff --git a/components/search_engines/search_engine_choice_utils.h b/components/search_engines/search_engine_choice_utils.h
index ef0db47..072a44de 100644
--- a/components/search_engines/search_engine_choice_utils.h
+++ b/components/search_engines/search_engine_choice_utils.h
@@ -12,13 +12,8 @@
 #include "components/search_engines/choice_made_location.h"
 #include "components/search_engines/search_engine_type.h"
 
-namespace policy {
-class PolicyService;
-}
-
 class PrefService;
 struct TemplateURLData;
-class TemplateURLService;
 
 namespace search_engines {
 
@@ -148,58 +143,11 @@
 // TODO(b/318824817): To be removed post-launch.
 bool IsChoiceScreenFlagEnabled(ChoicePromo promo);
 
-// Returns whether the version of the search engines settings screen showing
-// additional search engine info should be shown.
-// TODO(b/318824817): To be removed post-launch.
-bool ShouldShowUpdatedSettings(PrefService& profile_prefs);
-
-#if BUILDFLAG(IS_IOS)
-// Returns whether the search engine choice screen can be displayed or not based
-// on device policies and profile properties.
-bool ShouldShowChoiceScreen(const policy::PolicyService& policy_service,
-                            const ProfileProperties& profile_properties,
-                            TemplateURLService* template_url_service);
-#endif
-
-// Returns the choice screen eligibility condition most relevant for the profile
-// associated with `profile_prefs` and `template_url_service`.
-// Only checks dynamic conditions, that can change from one call to the other
-// during a profile's lifetime. Should be checked right before showing a choice
-// screen.
-SearchEngineChoiceScreenConditions GetDynamicChoiceScreenConditions(
-    const PrefService& profile_prefs,
-    const TemplateURLService& template_url_service);
-
-// Returns the choice screen eligibility condition most relevant for the profile
-// described by `profile_properties`.
-// Only checks static conditions, such that if a non-eligible condition is
-// returned, it would take at least a restart for the state to change. So this
-// state can be checked and cached ahead of showing a choice screen.
-SearchEngineChoiceScreenConditions GetStaticChoiceScreenConditions(
-    const policy::PolicyService& policy_service,
-    const ProfileProperties& profile_properties,
-    const TemplateURLService& template_url_service);
-
-// Returns the country ID to use in the context of any search engine choice
-// logic. If `profile_prefs` are null, returns
-// `country_codes::GetCurrentCountryID()`. Can be overridden using
-// `switches::kSearchEngineChoiceCountry`. See `//components/country_codes` for
-// the Country ID format.
-int GetSearchEngineChoiceCountryId(PrefService* profile_prefs);
-
 // Returns whether the provided `country_id` is eligible for the EEA default
 // search engine choice prompt.
 // See `//components/country_codes` for the Country ID format.
 bool IsEeaChoiceCountry(int country_id);
 
-// Records that the choice was made by settings the timestamp if applicable.
-// Records the location from which the choice was made and the search engine
-// that was chosen.
-// The function should be called after the default search engine has been set.
-void RecordChoiceMade(PrefService* profile_prefs,
-                      ChoiceMadeLocation choice_location,
-                      TemplateURLService* template_url_service);
-
 // Records the specified choice screen condition at profile initialization.
 void RecordChoiceScreenProfileInitCondition(
     SearchEngineChoiceScreenConditions event);
@@ -237,11 +185,6 @@
 
 #endif
 
-// Checks if the search engine choice should be prompted again, based on
-// experiment parameters. If a reprompt is needed, some preferences related to
-// the choice are cleared, which triggers a reprompt on the next page load.
-void PreprocessPrefsForReprompt(PrefService& profile_prefs);
-
 }  // namespace search_engines
 
 #endif  // COMPONENTS_SEARCH_ENGINES_SEARCH_ENGINE_CHOICE_UTILS_H_
diff --git a/components/search_engines/search_engine_choice_utils_unittest.cc b/components/search_engines/search_engine_choice_utils_unittest.cc
index 40c76e4..e5de900 100644
--- a/components/search_engines/search_engine_choice_utils_unittest.cc
+++ b/components/search_engines/search_engine_choice_utils_unittest.cc
@@ -35,449 +35,27 @@
 #include "components/version_info/version_info.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
-using search_engines::RepromptResult;
-using search_engines::WipeSearchEngineChoiceReason;
-using ::testing::NiceMock;
-
 namespace search_engines {
 
 class SearchEngineChoiceUtilsTest : public ::testing::Test {
  public:
   SearchEngineChoiceUtilsTest() {
     feature_list_.InitAndEnableFeature(switches::kSearchEngineChoice);
-    TemplateURLService::RegisterProfilePrefs(pref_service_.registry());
-    DefaultSearchManager::RegisterProfilePrefs(pref_service_.registry());
     TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
-
-    // Override the country checks to simulate being in Belgium.
-    base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-        switches::kSearchEngineChoiceCountry, "BE");
-
-    template_url_service_ =
-        std::make_unique<TemplateURLService>(&pref_service_);
-
-    InitMockPolicyService();
-    CheckPoliciesInitialState();
   }
 
   ~SearchEngineChoiceUtilsTest() override = default;
 
-  policy::MockPolicyService& policy_service() { return policy_service_; }
-  policy::PolicyMap& policy_map() { return policy_map_; }
   PrefService* pref_service() { return &pref_service_; }
   base::test::ScopedFeatureList* feature_list() { return &feature_list_; }
-  TemplateURLService& template_url_service() {
-    return CHECK_DEREF(template_url_service_.get());
-  }
   base::HistogramTester histogram_tester_;
 
  private:
-  void InitMockPolicyService() {
-    ON_CALL(policy_service_, GetPolicies(::testing::Eq(policy::PolicyNamespace(
-                                 policy::POLICY_DOMAIN_CHROME, std::string()))))
-        .WillByDefault(::testing::ReturnRef(policy_map_));
-  }
-
-  // Test that the `DefaultSearchProviderEnabled` and
-  // `DefaultSearchProviderSearchURL` policies are not initially set.
-  void CheckPoliciesInitialState() {
-    const auto& policies = policy_service().GetPolicies(
-        policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
-
-    const auto* default_search_provider_enabled = policies.GetValue(
-        policy::key::kDefaultSearchProviderEnabled, base::Value::Type::BOOLEAN);
-    const auto* default_search_provider_search_url =
-        policies.GetValue(policy::key::kDefaultSearchProviderSearchURL,
-                          base::Value::Type::STRING);
-
-    ASSERT_FALSE(default_search_provider_enabled);
-    ASSERT_FALSE(default_search_provider_search_url);
-  }
-
-  NiceMock<policy::MockPolicyService> policy_service_;
-  policy::PolicyMap policy_map_;
   sync_preferences::TestingPrefServiceSyncable pref_service_;
   base::test::ScopedFeatureList feature_list_;
   std::unique_ptr<TemplateURLService> template_url_service_;
 };
 
-// Test that the choice screen doesn't get displayed if the profile is not
-// regular.
-TEST_F(SearchEngineChoiceUtilsTest,
-       DoNotShowChoiceScreenWithNotRegularProfile) {
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), /*profile_properties=*/
-                {.is_regular_profile = false, .pref_service = pref_service()},
-                template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-}
-
-// Test that the choice screen gets displayed if the
-// `DefaultSearchProviderEnabled` policy is not set.
-TEST_F(SearchEngineChoiceUtilsTest, ShowChoiceScreenIfPoliciesAreNotSet) {
-  search_engines::ProfileProperties profile_properties{
-      .is_regular_profile = true, .pref_service = pref_service()};
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-
-  SearchEngineChoiceScreenConditions expected_choice_screen_condition =
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-      SearchEngineChoiceScreenConditions::kUnsupportedBrowserType;
-#else
-      SearchEngineChoiceScreenConditions::kEligible;
-#endif
-
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            expected_choice_screen_condition);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      expected_choice_screen_condition);
-
-#if BUILDFLAG(IS_IOS)
-  EXPECT_TRUE(ShouldShowChoiceScreen(policy_service(), profile_properties,
-                                     &template_url_service()));
-  histogram_tester_.ExpectBucketCount(
-      kSearchEngineChoiceScreenProfileInitConditionsHistogram,
-      SearchEngineChoiceScreenConditions::kEligible, 1);
-#endif
-}
-
-// Test that the choice screen does not get displayed if the provider list is
-// overridden in the intial_preferences file.
-TEST_F(SearchEngineChoiceUtilsTest,
-       DoNotShowChoiceScreenWithProviderListOverride) {
-  base::Value::List override_list;
-  pref_service()->SetList(prefs::kSearchProviderOverrides,
-                          override_list.Clone());
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), /*profile_properties=*/
-                {.is_regular_profile = true, .pref_service = pref_service()},
-                template_url_service()),
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
-#else
-            SearchEngineChoiceScreenConditions::kSearchProviderOverride
-#endif
-  );
-}
-
-// Test that the choice screen doesn't get displayed if the
-// 'DefaultSearchProviderEnabled' policy is set to false.
-TEST_F(SearchEngineChoiceUtilsTest, DoNotShowChoiceScreenIfPolicySetToFalse) {
-  policy_map().Set(policy::key::kDefaultSearchProviderEnabled,
-                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
-                   policy::POLICY_SOURCE_CLOUD, base::Value(false), nullptr);
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), /*profile_properties=*/
-                {.is_regular_profile = true, .pref_service = pref_service()},
-                template_url_service()),
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
-#else
-            SearchEngineChoiceScreenConditions::kControlledByPolicy
-#endif
-  );
-}
-
-// Test that the choice screen gets displayed if the
-// 'DefaultSearchProviderEnabled' policy is set to true but the
-// 'DefaultSearchProviderSearchURL' policy is not set.
-TEST_F(SearchEngineChoiceUtilsTest,
-       ShowChoiceScreenIfPolicySetToTrueWithoutUrlSet) {
-  policy_map().Set(policy::key::kDefaultSearchProviderEnabled,
-                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
-                   policy::POLICY_SOURCE_CLOUD, base::Value(true), nullptr);
-  search_engines::ProfileProperties profile_properties{
-      .is_regular_profile = true, .pref_service = pref_service()};
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kEligible);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kEligible);
-#endif
-}
-
-// Test that the choice screen doesn't get displayed if the
-// 'DefaultSearchProviderEnabled' policy is set to true and the
-// DefaultSearchProviderSearchURL' is set.
-TEST_F(SearchEngineChoiceUtilsTest,
-       DoNotShowChoiceScreenIfPolicySetToTrueWithUrlSet) {
-  policy_map().Set(policy::key::kDefaultSearchProviderEnabled,
-                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
-                   policy::POLICY_SOURCE_CLOUD, base::Value(true), nullptr);
-  policy_map().Set(policy::key::kDefaultSearchProviderSearchURL,
-                   policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
-                   policy::POLICY_SOURCE_CLOUD, base::Value("test"), nullptr);
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), /*profile_properties=*/
-                {.is_regular_profile = true, .pref_service = pref_service()},
-                template_url_service()),
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
-#else
-            SearchEngineChoiceScreenConditions::kControlledByPolicy
-#endif
-  );
-}
-
-// Test that the choice screen gets displayed if and only if the
-// `kDefaultSearchProviderChoiceScreenTimestamp` pref is not set. Setting this
-// pref means that the user has made a search engine choice in the choice
-// screen.
-TEST_F(SearchEngineChoiceUtilsTest,
-       ShowChoiceScreenIfTheTimestampPrefIsNotSet) {
-  search_engines::ProfileProperties profile_properties{
-      .is_regular_profile = true, .pref_service = pref_service()};
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kEligible);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kEligible);
-#endif
-
-  search_engines::RecordChoiceMade(
-      pref_service(), search_engines::ChoiceMadeLocation::kChoiceScreen,
-      &template_url_service());
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kAlreadyCompleted);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kAlreadyCompleted);
-#endif
-}
-
-// Test that there is a regional condition controlling eligibility.
-TEST_F(SearchEngineChoiceUtilsTest, DoNotShowChoiceScreenIfCountryOutOfScope) {
-  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kSearchEngineChoiceCountry, "US");
-#if BUILDFLAG(IS_IOS)
-  // TODO(b/318820137): There should not be a dependency on the country here.
-  EXPECT_FALSE(ShouldShowUpdatedSettings(*pref_service()));
-#else
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#endif
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), /*profile_properties=*/
-                {.is_regular_profile = true, .pref_service = pref_service()},
-                template_url_service()),
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
-#else
-            SearchEngineChoiceScreenConditions::kNotInRegionalScope
-#endif
-  );
-}
-
-// Test that the choice screen does get displayed even if completed if the
-// command line argument for forcing it is set.
-TEST_F(SearchEngineChoiceUtilsTest, ShowChoiceScreenWithForceCommandLineFlag) {
-  base::CommandLine::ForCurrentProcess()->AppendSwitch(
-      switches::kForceSearchEngineChoiceScreen);
-  search_engines::RecordChoiceMade(
-      pref_service(), search_engines::ChoiceMadeLocation::kChoiceScreen,
-      &template_url_service());
-
-  search_engines::ProfileProperties profile_properties{
-      .is_regular_profile = true, .pref_service = pref_service()};
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kEligible);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kEligible);
-#endif
-}
-
-// Ensure that the choice screen doesn't get displayed if the flag is disabled.
-TEST_F(SearchEngineChoiceUtilsTest, DoNotShowChoiceScreenIfFlagIsDisabled) {
-  feature_list()->Reset();
-  feature_list()->InitWithFeatures({}, {switches::kSearchEngineChoiceTrigger});
-  EXPECT_FALSE(ShouldShowUpdatedSettings(*pref_service()));
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), /*profile_properties=*/
-                {.is_regular_profile = true, .pref_service = pref_service()},
-                template_url_service()),
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
-#else
-            SearchEngineChoiceScreenConditions::kFeatureSuppressed
-#endif
-  );
-}
-
-TEST_F(SearchEngineChoiceUtilsTest, ShowChoiceScreenWithTriggerFeature) {
-  search_engines::ProfileProperties profile_properties{
-      .is_regular_profile = true, .pref_service = pref_service()};
-
-  // SearchEngineChoiceTrigger is enabled and not set to trigger only for
-  // tagged profiles: the dialog should trigger, regardless of the state of
-  // the other feature flags.
-  feature_list()->Reset();
-  feature_list()->InitWithFeatures({switches::kSearchEngineChoiceTrigger},
-                                   {switches::kSearchEngineChoice});
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kEligible);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kEligible);
-#endif
-
-  // When the param is set and the profile untagged, the dialog will not be
-  // displayed.
-  base::FieldTrialParams tagged_only_params{
-      {switches::kSearchEngineChoiceTriggerForTaggedProfilesOnly.name, "true"}};
-  feature_list()->Reset();
-  feature_list()->InitWithFeaturesAndParameters(
-      {{switches::kSearchEngineChoiceTrigger, tagged_only_params}},
-      {switches::kSearchEngineChoice});
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kProfileOutOfScope);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kEligible);
-#endif
-
-  // When the profile is tagged, the dialog can also be displayed.
-  pref_service()->SetBoolean(prefs::kDefaultSearchProviderChoicePending, true);
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kEligible);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kEligible);
-#endif
-}
-
-// Test that the choice screen does not get displayed if the command line
-// argument for disabling it is set.
-TEST_F(SearchEngineChoiceUtilsTest,
-       DoNotShowChoiceScreenWithDisableCommandLineFlag) {
-  base::CommandLine::ForCurrentProcess()->AppendSwitch(
-      switches::kDisableSearchEngineChoiceScreen);
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(),
-                {.is_regular_profile = true, .pref_service = pref_service()},
-                template_url_service()),
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType
-#else
-
-            SearchEngineChoiceScreenConditions::kFeatureSuppressed
-#endif
-  );
-}
-
-TEST_F(SearchEngineChoiceUtilsTest, GetSearchEngineChoiceCountryId) {
-  const int kBelgiumCountryId =
-      country_codes::CountryCharsToCountryID('B', 'E');
-
-  // The test is set up to use the command line to simulate the country as being
-  // Belgium.
-  EXPECT_EQ(search_engines::GetSearchEngineChoiceCountryId(pref_service()),
-            kBelgiumCountryId);
-
-  // When removing the command line flag, the default value is based on the
-  // device locale.
-  base::CommandLine::ForCurrentProcess()->RemoveSwitch(
-      switches::kSearchEngineChoiceCountry);
-  EXPECT_EQ(search_engines::GetSearchEngineChoiceCountryId(pref_service()),
-            country_codes::GetCurrentCountryID());
-
-  // When the command line value is invalid, it is ignored.
-  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kSearchEngineChoiceCountry, "USA");
-  EXPECT_EQ(search_engines::GetSearchEngineChoiceCountryId(pref_service()),
-            country_codes::GetCurrentCountryID());
-
-  // Note that if the format matches (2-character strings), we might get a
-  // country ID that is not valid/supported.
-  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kSearchEngineChoiceCountry, "??");
-  EXPECT_EQ(search_engines::GetSearchEngineChoiceCountryId(pref_service()),
-            country_codes::CountryCharsToCountryID('?', '?'));
-
-  // The value set from the pref is reflected otherwise.
-  pref_service()->SetInteger(country_codes::kCountryIDAtInstall,
-                             kBelgiumCountryId);
-  base::CommandLine::ForCurrentProcess()->RemoveSwitch(
-      switches::kSearchEngineChoiceCountry);
-  EXPECT_EQ(search_engines::GetSearchEngineChoiceCountryId(pref_service()),
-            kBelgiumCountryId);
-}
-
 // Sanity check the list.
 TEST_F(SearchEngineChoiceUtilsTest, IsEeaChoiceCountry) {
   using country_codes::CountryCharsToCountryID;
@@ -493,112 +71,6 @@
   EXPECT_FALSE(IsEeaChoiceCountry(CountryCharsToCountryID('U', 'S')));
 }
 
-TEST_F(SearchEngineChoiceUtilsTest,
-       DoNotShowChoiceScreenIfUserHasCustomSearchEngineSetAsDefault) {
-  search_engines::ProfileProperties profile_properties{
-      .is_regular_profile = true, .pref_service = pref_service()};
-
-  // A custom search engine will have a `prepopulate_id` of 0.
-  const int kCustomSearchEnginePrepopulateId = 0;
-  TemplateURLData template_url_data;
-  template_url_data.prepopulate_id = kCustomSearchEnginePrepopulateId;
-  template_url_data.SetURL("https://www.example.com/?q={searchTerms}");
-  template_url_service().SetUserSelectedDefaultSearchProvider(
-      template_url_service().Add(
-          std::make_unique<TemplateURL>(template_url_data)));
-
-  EXPECT_TRUE(ShouldShowUpdatedSettings(*pref_service()));
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kUnsupportedBrowserType);
-#else
-  EXPECT_EQ(GetStaticChoiceScreenConditions(
-                policy_service(), profile_properties, template_url_service()),
-            SearchEngineChoiceScreenConditions::kEligible);
-  EXPECT_EQ(
-      GetDynamicChoiceScreenConditions(*pref_service(), template_url_service()),
-      SearchEngineChoiceScreenConditions::kHasCustomSearchEngine);
-#endif
-
-#if BUILDFLAG(IS_IOS)
-  EXPECT_FALSE(ShouldShowChoiceScreen(policy_service(), profile_properties,
-                                      &template_url_service()));
-  histogram_tester_.ExpectBucketCount(
-      kSearchEngineChoiceScreenProfileInitConditionsHistogram,
-      SearchEngineChoiceScreenConditions::kHasCustomSearchEngine, 1);
-#endif
-}
-
-TEST_F(SearchEngineChoiceUtilsTest, RecordChoiceMade) {
-  base::CommandLine::ForCurrentProcess()->RemoveSwitch(
-      switches::kSearchEngineChoiceCountry);
-
-  // Test that the choice is not recorded for countries outside the EEA region.
-  const int kUnitedStatesCountryId =
-      country_codes::CountryCharsToCountryID('U', 'S');
-  pref_service()->SetInteger(country_codes::kCountryIDAtInstall,
-                             kUnitedStatesCountryId);
-
-  const TemplateURL* default_search_engine =
-      template_url_service().GetDefaultSearchProvider();
-  EXPECT_EQ(default_search_engine->prepopulate_id(),
-            TemplateURLPrepopulateData::google.id);
-
-  search_engines::RecordChoiceMade(
-      pref_service(), search_engines::ChoiceMadeLocation::kChoiceScreen,
-      &template_url_service());
-
-  histogram_tester_.ExpectUniqueSample(
-      search_engines::kSearchEngineChoiceScreenDefaultSearchEngineTypeHistogram,
-      SearchEngineType::SEARCH_ENGINE_GOOGLE, 0);
-  EXPECT_FALSE(pref_service()->HasPrefPath(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
-  EXPECT_FALSE(pref_service()->HasPrefPath(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
-
-  // Revert to an EEA region country.
-  const int kBelgiumCountryId =
-      country_codes::CountryCharsToCountryID('B', 'E');
-  pref_service()->SetInteger(country_codes::kCountryIDAtInstall,
-                             kBelgiumCountryId);
-
-  // Test that the choice is recorded if it wasn't previously done.
-  search_engines::RecordChoiceMade(
-      pref_service(), search_engines::ChoiceMadeLocation::kChoiceScreen,
-      &template_url_service());
-  histogram_tester_.ExpectUniqueSample(
-      search_engines::kSearchEngineChoiceScreenDefaultSearchEngineTypeHistogram,
-      SearchEngineType::SEARCH_ENGINE_GOOGLE, 1);
-
-  EXPECT_NEAR(pref_service()->GetInt64(
-                  prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp),
-              base::Time::Now().ToDeltaSinceWindowsEpoch().InSeconds(),
-              /*abs_error=*/2);
-  EXPECT_EQ(pref_service()->GetString(
-                prefs::kDefaultSearchProviderChoiceScreenCompletionVersion),
-            version_info::GetVersionNumber());
-
-  // Set the pref to 5 so that we can know if it gets modified.
-  const int kModifiedTimestamp = 5;
-  pref_service()->SetInt64(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
-      kModifiedTimestamp);
-
-  // Test that the choice is not recorded if it was previously done.
-  search_engines::RecordChoiceMade(
-      pref_service(), search_engines::ChoiceMadeLocation::kChoiceScreen,
-      &template_url_service());
-  EXPECT_EQ(pref_service()->GetInt64(
-                prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp),
-            kModifiedTimestamp);
-
-  histogram_tester_.ExpectUniqueSample(
-      search_engines::kSearchEngineChoiceScreenDefaultSearchEngineTypeHistogram,
-      SearchEngineType::SEARCH_ENGINE_GOOGLE, 1);
-}
-
 TEST_F(SearchEngineChoiceUtilsTest, IsChoiceScreenFlagEnabled) {
   feature_list()->Reset();
   feature_list()->InitWithFeaturesAndParameters(
@@ -651,316 +123,4 @@
 #endif
 }
 
-// Test that the user is not reprompted is the reprompt parameter is not a valid
-// JSON string.
-TEST_F(SearchEngineChoiceUtilsTest, NoRepromptForSyntaxError) {
-  // Set the reprompt parameters with invalid syntax.
-  base::test::ScopedFeatureList scoped_feature_list;
-  scoped_feature_list.InitAndEnableFeatureWithParameters(
-      switches::kSearchEngineChoiceTrigger,
-      {{switches::kSearchEngineChoiceTriggerRepromptParams.name, "Foo"}});
-  ASSERT_EQ("Foo", switches::kSearchEngineChoiceTriggerRepromptParams.Get());
-
-  // Initialize the preference with some previous choice.
-  int64_t kPreviousTimestamp = 1;
-  pref_service()->SetInt64(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
-      kPreviousTimestamp);
-  base::Version choice_version({1, 2, 3, 4});
-  pref_service()->SetString(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion,
-      choice_version.GetString());
-
-  // The user should not be reprompted.
-  search_engines::PreprocessPrefsForReprompt(*pref_service());
-
-  EXPECT_EQ(kPreviousTimestamp,
-            pref_service()->GetInt64(
-                prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
-  EXPECT_EQ(choice_version.GetString(),
-            pref_service()->GetString(
-                prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
-  histogram_tester_.ExpectTotalCount(
-      search_engines::kSearchEngineChoiceWipeReasonHistogram, 0);
-  histogram_tester_.ExpectTotalCount(
-      search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram, 0);
-  histogram_tester_.ExpectTotalCount(
-      search_engines::kSearchEngineChoiceRepromptWildcardHistogram, 0);
-  histogram_tester_.ExpectUniqueSample(
-      search_engines::kSearchEngineChoiceRepromptHistogram,
-      RepromptResult::kInvalidDictionary, 1);
-}
-
-// The user is reprompted if the version preference is missing.
-TEST_F(SearchEngineChoiceUtilsTest, RepromptForMissingChoiceVersion) {
-  base::test::ScopedFeatureList scoped_feature_list{
-      switches::kSearchEngineChoiceTrigger};
-
-  // Initialize the timestamp, but not the version.
-  int64_t kPreviousTimestamp = 1;
-  pref_service()->SetInt64(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
-      kPreviousTimestamp);
-
-  // The user should be reprompted.
-  search_engines::PreprocessPrefsForReprompt(*pref_service());
-
-  EXPECT_FALSE(pref_service()->HasPrefPath(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
-  EXPECT_FALSE(pref_service()->HasPrefPath(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
-  histogram_tester_.ExpectUniqueSample(
-      search_engines::kSearchEngineChoiceWipeReasonHistogram,
-      WipeSearchEngineChoiceReason::kMissingChoiceVersion, 1);
-  histogram_tester_.ExpectTotalCount(
-      search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram, 0);
-  histogram_tester_.ExpectTotalCount(
-      search_engines::kSearchEngineChoiceRepromptWildcardHistogram, 0);
-  histogram_tester_.ExpectTotalCount(
-      search_engines::kSearchEngineChoiceRepromptHistogram, 0);
-}
-
-struct RepromptTestParam {
-  // Whether the user should be reprompted or not.
-  absl::optional<WipeSearchEngineChoiceReason> wipe_reason;
-  // Internal results of the reprompt computation.
-  absl::optional<RepromptResult> wildcard_result;
-  absl::optional<RepromptResult> country_result;
-  // Version of the choice.
-  const base::StringPiece choice_version;
-  // The reprompt params, as sent by the server.  Use `CURRENT_VERSION` for the
-  // current Chrome version, and `FUTURE_VERSION` for a future version.
-  const char* param_dict;
-};
-
-class SearchEngineChoiceUtilsParamTest
-    : public SearchEngineChoiceUtilsTest,
-      public testing::WithParamInterface<RepromptTestParam> {};
-
-TEST_P(SearchEngineChoiceUtilsParamTest, Reprompt) {
-  // Set the reprompt parameters.
-  std::string param_dict = base::CollapseWhitespaceASCII(
-      GetParam().param_dict, /*trim_sequences_with_line_breaks=*/true);
-  base::ReplaceFirstSubstringAfterOffset(&param_dict, /*start_offset=*/0,
-                                         "CURRENT_VERSION",
-                                         version_info::GetVersionNumber());
-  base::Version future_version(
-      {version_info::GetMajorVersionNumberAsInt() + 5u, 2, 3, 4});
-  ASSERT_TRUE(future_version.IsValid());
-  base::ReplaceFirstSubstringAfterOffset(&param_dict, /*start_offset=*/0,
-                                         "FUTURE_VERSION",
-                                         future_version.GetString());
-
-  std::string feature_param_value = param_dict.empty() ? "{}" : param_dict;
-
-  base::test::ScopedFeatureList scoped_feature_list;
-  scoped_feature_list.InitAndEnableFeatureWithParameters(
-      switches::kSearchEngineChoiceTrigger,
-      {{switches::kSearchEngineChoiceTriggerRepromptParams.name,
-        feature_param_value}});
-  ASSERT_EQ(feature_param_value,
-            switches::kSearchEngineChoiceTriggerRepromptParams.Get());
-
-  // Initialize the preference with some previous choice.
-  int64_t kPreviousTimestamp = 1;
-  pref_service()->SetInt64(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp,
-      kPreviousTimestamp);
-  pref_service()->SetString(
-      prefs::kDefaultSearchProviderChoiceScreenCompletionVersion,
-      GetParam().choice_version);
-
-  // Check whether the user is reprompted.
-  search_engines::PreprocessPrefsForReprompt(*pref_service());
-
-  if (GetParam().wipe_reason) {
-    // User is reprompted, prefs were wiped.
-    EXPECT_FALSE(pref_service()->HasPrefPath(
-        prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
-    EXPECT_FALSE(pref_service()->HasPrefPath(
-        prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
-    histogram_tester_.ExpectUniqueSample(
-        search_engines::kSearchEngineChoiceWipeReasonHistogram,
-        *GetParam().wipe_reason, 1);
-  } else {
-    // User is not reprompted, prefs were not wiped.
-    EXPECT_EQ(
-        kPreviousTimestamp,
-        pref_service()->GetInt64(
-            prefs::kDefaultSearchProviderChoiceScreenCompletionTimestamp));
-    EXPECT_EQ(GetParam().choice_version,
-              pref_service()->GetString(
-                  prefs::kDefaultSearchProviderChoiceScreenCompletionVersion));
-    histogram_tester_.ExpectTotalCount(
-        search_engines::kSearchEngineChoiceWipeReasonHistogram, 0);
-  }
-
-  int total_reprompt_record_count = 0;
-  if (GetParam().wildcard_result) {
-    ++total_reprompt_record_count;
-    histogram_tester_.ExpectUniqueSample(
-        search_engines::kSearchEngineChoiceRepromptWildcardHistogram,
-        *GetParam().wildcard_result, 1);
-    EXPECT_GE(histogram_tester_.GetBucketCount(
-                  search_engines::kSearchEngineChoiceRepromptHistogram,
-                  *GetParam().wildcard_result),
-              1);
-  } else {
-    histogram_tester_.ExpectTotalCount(
-        search_engines::kSearchEngineChoiceRepromptWildcardHistogram, 0);
-  }
-  if (GetParam().country_result) {
-    ++total_reprompt_record_count;
-    histogram_tester_.ExpectUniqueSample(
-        search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram,
-        *GetParam().country_result, 1);
-    EXPECT_GE(histogram_tester_.GetBucketCount(
-                  search_engines::kSearchEngineChoiceRepromptHistogram,
-                  *GetParam().country_result),
-              1);
-  } else {
-    histogram_tester_.ExpectTotalCount(
-        search_engines::kSearchEngineChoiceRepromptSpecificCountryHistogram, 0);
-  }
-  histogram_tester_.ExpectTotalCount(
-      search_engines::kSearchEngineChoiceRepromptHistogram,
-      total_reprompt_record_count);
-}
-
-constexpr RepromptTestParam kRepromptTestParams[] = {
-    // Reprompt all countries with the wildcard.
-    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"*":"1.0.0.1"} )"},
-    // Reprompt works with all version components.
-    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
-     RepromptResult::kNoDictionaryKey, "1.0.0.100", R"( {"*":"1.0.1.0"} )"},
-    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
-     RepromptResult::kNoDictionaryKey, "1.0.200.0", R"( {"*":"1.1.0.0"} )"},
-    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
-     RepromptResult::kNoDictionaryKey, "1.300.0.0", R"( {"*":"2.0.0.0"} )"},
-    {WipeSearchEngineChoiceReason::kReprompt, RepromptResult::kReprompt,
-     RepromptResult::kNoDictionaryKey, "10.10.1.1",
-     R"( {"*":"30.45.678.9100"} )"},
-    // Reprompt a specific country.
-    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
-     RepromptResult::kReprompt, "1.0.0.0", R"( {"BE":"1.0.0.1"} )"},
-    // Reprompt for params inclusive of current version
-    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
-     RepromptResult::kReprompt, "1.0.0.0", R"( {"BE":"CURRENT_VERSION"} )"},
-    // Reprompt when the choice version is malformed.
-    {WipeSearchEngineChoiceReason::kInvalidChoiceVersion, absl::nullopt,
-     absl::nullopt, "Blah", ""},
-    // Reprompt when both the country and the wild card are specified, as long
-    // as one of them qualifies.
-    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
-     RepromptResult::kReprompt, "1.0.0.0",
-     R"( {"*":"1.0.0.1","BE":"1.0.0.1"} )"},
-    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
-     RepromptResult::kReprompt, "1.0.0.0",
-     R"( {"*":"FUTURE_VERSION","BE":"1.0.0.1"} )"},
-    // Still works with irrelevant parameters for other countries.
-    {WipeSearchEngineChoiceReason::kReprompt, absl::nullopt,
-     RepromptResult::kReprompt, "1.0.0.0",
-     R"(
-       {
-         "FR":"FUTURE_VERSION",
-         "INVALID_COUNTRY":"INVALID_VERSION",
-         "US":"FUTURE_VERSION",
-         "BE":"1.0.0.1"
-       } )"},
-
-    // Don't reprompt when the choice was made in the current version.
-    {absl::nullopt, RepromptResult::kRecentChoice,
-     RepromptResult::kNoDictionaryKey, version_info::GetVersionNumber(),
-     "{\"*\":\"CURRENT_VERSION\"}"},
-    // Don't reprompt when the choice was recent enough.
-    {absl::nullopt, RepromptResult::kRecentChoice,
-     RepromptResult::kNoDictionaryKey, "2.0.0.0", R"( {"*":"1.0.0.1"} )"},
-    // Don't reprompt for another country.
-    {absl::nullopt, RepromptResult::kNoDictionaryKey,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"FR":"1.0.0.1"} )"},
-    {absl::nullopt, RepromptResult::kNoDictionaryKey,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"US":"1.0.0.1"} )"},
-    {absl::nullopt, RepromptResult::kNoDictionaryKey,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"XX":"1.0.0.1"} )"},
-    {absl::nullopt, RepromptResult::kNoDictionaryKey,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0",
-     R"( {"INVALID_COUNTRY":"1.0.0.1"} )"},
-    {absl::nullopt, absl::nullopt, RepromptResult::kChromeTooOld, "1.0.0.0",
-     R"( {"FR":"1.0.0.1","BE":"FUTURE_VERSION"} )"},
-    // Don't reprompt for future versions.
-    {absl::nullopt, RepromptResult::kChromeTooOld,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0",
-     R"( {"*":"FUTURE_VERSION"} )"},
-    // Wildcard is overridden by specific country.
-    {absl::nullopt, absl::nullopt, RepromptResult::kChromeTooOld, "1.0.0.0",
-     R"( {"*":"1.0.0.1","BE":"FUTURE_VERSION"} )"},
-    // Combination of right version for wrong country and wrong version for
-    // right country.
-    {absl::nullopt, absl::nullopt, RepromptResult::kChromeTooOld, "2.0.0.0",
-     R"(
-       {
-          "*":"1.1.0.0",
-          "BE":"FUTURE_VERSION",
-          "FR":"2.0.0.1"
-        } )"},
-    // Empty dictionary.
-    {absl::nullopt, RepromptResult::kNoDictionaryKey,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", "{}"},
-    // Empty parameter.
-    {absl::nullopt, RepromptResult::kNoDictionaryKey,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", ""},
-    // Wrong number of components.
-    {absl::nullopt, RepromptResult::kInvalidVersion,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"*":"2.0"} )"},
-    // Wildcard in version.
-    {absl::nullopt, RepromptResult::kInvalidVersion,
-     RepromptResult::kNoDictionaryKey, "1.0.0.0", R"( {"*":"2.0.0.*"} )"},
-};
-
-INSTANTIATE_TEST_SUITE_P(,
-                         SearchEngineChoiceUtilsParamTest,
-                         ::testing::ValuesIn(kRepromptTestParams));
-
-#if !BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
-    BUILDFLAG(CHROME_FOR_TESTING)
-
-class SearchEngineChoiceUtilsResourceIdsTest : public ::testing::Test {
- public:
-  SearchEngineChoiceUtilsResourceIdsTest() {
-    TemplateURLService::RegisterProfilePrefs(pref_service_.registry());
-    TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
-  }
-
-  ~SearchEngineChoiceUtilsResourceIdsTest() override = default;
-  PrefService* pref_service() { return &pref_service_; }
-
- private:
-  base::test::ScopedFeatureList feature_list_{switches::kSearchEngineChoice};
-  sync_preferences::TestingPrefServiceSyncable pref_service_;
-};
-
-// Verifies that all prepopulated search engines associated with EEA countries
-// have an icon.
-TEST_F(SearchEngineChoiceUtilsResourceIdsTest, GetIconResourceId) {
-  // Make sure the country is not forced.
-  ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
-      switches::kSearchEngineChoiceCountry));
-
-  for (int country_id : search_engines::kEeaChoiceCountriesIds) {
-    pref_service()->SetInteger(country_codes::kCountryIDAtInstall, country_id);
-    std::vector<std::unique_ptr<TemplateURLData>> urls =
-        TemplateURLPrepopulateData::GetPrepopulatedEngines(pref_service(),
-                                                           nullptr);
-    for (const std::unique_ptr<TemplateURLData>& url : urls) {
-      EXPECT_GE(search_engines::GetIconResourceId(url->keyword()), 0)
-          << "Missing icon for " << url->keyword() << ". Try re-running "
-          << "`tools/search_engine_choice/generate_search_engine_icons.py`.";
-    }
-  }
-}
-
-#endif  // !BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) ||
-        // BUILDFLAG(CHROME_FOR_TESTING)
-
 }  // namespace search_engines
diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc
index 3a7e303..1b85f1ef 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -20,6 +20,7 @@
 #include "components/pref_registry/pref_registry_syncable.h"
 #include "components/prefs/pref_service.h"
 #include "components/search_engines/prepopulated_engines.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/template_url_data.h"
@@ -1801,6 +1802,7 @@
 
 std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     size_t* default_search_provider_index,
     bool include_current_default,
     TemplateURLService* template_url_service) {
@@ -1809,8 +1811,13 @@
   std::vector<std::unique_ptr<TemplateURLData>> t_urls =
       GetOverriddenTemplateURLData(prefs);
   if (t_urls.empty()) {
-    t_urls = GetPrepopulatedTemplateURLData(
-        search_engines::GetSearchEngineChoiceCountryId(prefs), prefs);
+    // `search_engine_choice_service` (and `prefs`) can be null in tests.
+    // TODO(b/318801987): Make sure `prefs` and `search_engine_choice_service`
+    //                    are always not null.
+    int country_id = search_engine_choice_service
+                         ? search_engine_choice_service->GetCountryId()
+                         : country_codes::GetCurrentCountryID();
+    t_urls = GetPrepopulatedTemplateURLData(country_id, prefs);
 
     if (include_current_default && template_url_service) {
       CHECK(search_engines::IsChoiceScreenFlagEnabled(
@@ -1838,10 +1845,12 @@
   return t_urls;
 }
 
-std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs,
-                                                       int prepopulated_id) {
-  auto engines =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, nullptr);
+std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(
+    PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
+    int prepopulated_id) {
+  auto engines = TemplateURLPrepopulateData::GetPrepopulatedEngines(
+      prefs, search_engine_choice_service, nullptr);
   for (auto& engine : engines) {
     if (engine->prepopulate_id == prepopulated_id)
       return std::move(engine);
@@ -1872,6 +1881,7 @@
 
 std::unique_ptr<TemplateURLData> GetPrepopulatedEngineFromFullList(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     int prepopulated_id) {
   // TODO(crbug.com/1500526): Refactor to better share code with
   // `GetPrepopulatedEngine()`.
@@ -1888,7 +1898,7 @@
   // We look in the profile country's prepopulated set first. This is intended
   // to help using the right entry for the case where we have multiple ones in
   // the full list that share a same prepopulated id.
-  const int country = search_engines::GetSearchEngineChoiceCountryId(prefs);
+  const int country = search_engine_choice_service->GetCountryId();
   for (const EngineAndTier& engine_and_tier :
        GetPrepopulationSetFromCountryID(country)) {
     if (engine_and_tier.search_engine->id == prepopulated_id) {
@@ -1920,11 +1930,13 @@
 }
 
 std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
-    PrefService* prefs) {
+    PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service) {
   size_t default_search_index;
   // This could be more efficient.  We load all URLs but keep only the default.
   std::vector<std::unique_ptr<TemplateURLData>> loaded_urls =
-      GetPrepopulatedEngines(prefs, &default_search_index);
+      GetPrepopulatedEngines(prefs, search_engine_choice_service,
+                             &default_search_index);
 
   return (default_search_index < loaded_urls.size())
              ? std::move(loaded_urls[default_search_index])
diff --git a/components/search_engines/template_url_prepopulate_data.h b/components/search_engines/template_url_prepopulate_data.h
index 745a526..ecf64de 100644
--- a/components/search_engines/template_url_prepopulate_data.h
+++ b/components/search_engines/template_url_prepopulate_data.h
@@ -17,6 +17,10 @@
 class TemplateURLService;
 struct TemplateURLData;
 
+namespace search_engines {
+class SearchEngineChoiceService;
+}
+
 namespace user_prefs {
 class PrefRegistrySyncable;
 }
@@ -35,6 +39,8 @@
 int GetDataVersion(PrefService* prefs);
 
 // Returns the prepopulated URLs for the current country.
+// `search_engine_choice_service` is used for obtaining the country code and
+// shouldn't be null outside of tests.
 // If |default_search_provider_index| is non-null, it is set to the index of the
 // default search provider within the returned vector.
 // `include_current_default` should be true and `template_url_service` should be
@@ -42,6 +48,7 @@
 // top of the returned list if it's not already there.
 std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     size_t* default_search_provider_index,
     bool include_current_default = false,
     TemplateURLService* template_url_service = nullptr);
@@ -49,14 +56,21 @@
 // Returns the prepopulated search engine with the given |prepopulated_id|
 // from the profile country's known prepopulated search engines, or `nullptr`
 // if it's not known there.
-std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs,
-                                                       int prepopulated_id);
+// `search_engine_choice_service` is used for obtaining the country code and
+// shouldn't be null outside of tests.
+std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(
+    PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
+    int prepopulated_id);
 
 // Returns the prepopulated search engine with the given |prepopulated_id|
 // from the full list of known prepopulated search engines, or `nullptr` if
 // it's not known there.
+// `search_engine_choice_service` is used for obtaining the country code and
+// shouldn't be null outside of tests.
 std::unique_ptr<TemplateURLData> GetPrepopulatedEngineFromFullList(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     int prepopulated_id);
 
 #if BUILDFLAG(IS_ANDROID)
@@ -78,8 +92,11 @@
 // may be NULL.
 // If |prefs| is NULL, any search provider overrides from the preferences are
 // not used.
+// `search_engine_choice_service` is used for obtaining the country code and
+// shouldn't be null outside of tests.
 std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
-    PrefService* prefs);
+    PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service);
 
 }  // namespace TemplateURLPrepopulateData
 
diff --git a/components/search_engines/template_url_prepopulate_data_unittest.cc b/components/search_engines/template_url_prepopulate_data_unittest.cc
index 469f521be..8e4c163 100644
--- a/components/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/components/search_engines/template_url_prepopulate_data_unittest.cc
@@ -18,6 +18,7 @@
 #include "components/country_codes/country_codes.h"
 #include "components/google/core/common/google_switches.h"
 #include "components/search_engines/prepopulated_engines.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/search_engines_test_util.h"
@@ -151,6 +152,8 @@
 
 class TemplateURLPrepopulateDataTest : public testing::Test {
  public:
+  TemplateURLPrepopulateDataTest() : search_engine_choice_service_(prefs_) {}
+
   void SetUp() override {
     TemplateURLPrepopulateData::RegisterProfilePrefs(prefs_.registry());
   }
@@ -165,8 +168,9 @@
   }
 
  protected:
-  sync_preferences::TestingPrefServiceSyncable prefs_;
   base::test::ScopedFeatureList feature_list_;
+  sync_preferences::TestingPrefServiceSyncable prefs_;
+  search_engines::SearchEngineChoiceService search_engine_choice_service_;
 };
 
 // Verifies the set of prepopulate data doesn't contain entries with duplicate
@@ -175,7 +179,8 @@
   for (int country_id : kAllCountryIds) {
     prefs_.SetInteger(country_codes::kCountryIDAtInstall, country_id);
     std::vector<std::unique_ptr<TemplateURLData>> urls =
-        TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, nullptr);
+        TemplateURLPrepopulateData::GetPrepopulatedEngines(
+            &prefs_, &search_engine_choice_service_, nullptr);
     std::set<int> unique_ids;
     for (const std::unique_ptr<TemplateURLData>& url : urls) {
       ASSERT_TRUE(unique_ids.find(url->prepopulate_id) == unique_ids.end());
@@ -200,7 +205,8 @@
 
     const size_t kNumberOfSearchEngines =
         TemplateURLPrepopulateData::GetPrepopulatedEngines(
-            &prefs_, /*default_search_provider_index=*/nullptr)
+            &prefs_, &search_engine_choice_service_,
+            /*default_search_provider_index=*/nullptr)
             .size();
 
     if (search_engines::IsEeaChoiceCountry(country_id)) {
@@ -231,11 +237,11 @@
   // same.
   std::vector<std::unique_ptr<TemplateURLData>> t_urls_1 =
       TemplateURLPrepopulateData::GetPrepopulatedEngines(
-          &prefs_,
+          &prefs_, &search_engine_choice_service_,
           /*default_search_provider_index=*/nullptr);
   std::vector<std::unique_ptr<TemplateURLData>> t_urls_2 =
       TemplateURLPrepopulateData::GetPrepopulatedEngines(
-          &prefs_,
+          &prefs_, &search_engine_choice_service_,
           /*default_search_provider_index=*/nullptr);
 
   ASSERT_EQ(t_urls_1.size(), t_urls_2.size());
@@ -253,7 +259,7 @@
 
   std::vector<std::unique_ptr<TemplateURLData>> t_urls =
       TemplateURLPrepopulateData::GetPrepopulatedEngines(
-          &prefs_,
+          &prefs_, &search_engine_choice_service_,
           /*default_search_provider_index=*/nullptr);
 
   // Change the saved chrome milestone to something else.
@@ -262,7 +268,7 @@
 
   std::vector<std::unique_ptr<TemplateURLData>> t_urls_after_update =
       TemplateURLPrepopulateData::GetPrepopulatedEngines(
-          &prefs_,
+          &prefs_, &search_engine_choice_service_,
           /*default_search_provider_index=*/nullptr);
 
   ASSERT_EQ(t_urls.size(), t_urls_after_update.size());
@@ -303,8 +309,8 @@
 
   size_t default_index;
   std::vector<std::unique_ptr<TemplateURLData>> t_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_,
-                                                         &default_index);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          &prefs_, &search_engine_choice_service_, &default_index);
 
   ASSERT_EQ(1u, t_urls.size());
   EXPECT_EQ(u"foo", t_urls[0]->short_name());
@@ -328,7 +334,7 @@
   prefs_.SetUserPref(prefs::kSearchProviderOverrides, std::move(overrides));
 
   t_urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(
-      &prefs_, &default_index);
+      &prefs_, &search_engine_choice_service_, &default_index);
   ASSERT_EQ(1u, t_urls.size());
   EXPECT_EQ(u"foo", t_urls[0]->short_name());
   EXPECT_EQ(u"fook", t_urls[0]->keyword());
@@ -357,9 +363,8 @@
   overrides.Append(entry.Clone());
   prefs_.SetUserPref(prefs::kSearchProviderOverrides, std::move(overrides));
 
-  t_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_,
-                                                         &default_index);
+  t_urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(
+      &prefs_, &search_engine_choice_service_, &default_index);
   EXPECT_EQ(2u, t_urls.size());
 }
 
@@ -390,8 +395,8 @@
 
   size_t default_index;
   std::vector<std::unique_ptr<TemplateURLData>> t_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_,
-                                                         &default_index);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          &prefs_, &search_engine_choice_service_, &default_index);
   ASSERT_FALSE(t_urls.empty());
   for (size_t i = 0; i < t_urls.size(); ++i) {
     EXPECT_NE(u"foo", t_urls[i]->short_name());
@@ -417,8 +422,8 @@
   prefs_.SetInteger(country_codes::kCountryIDAtInstall, 'U' << 8 | 'S');
   size_t default_index;
   std::vector<std::unique_ptr<TemplateURLData>> t_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_,
-                                                         &default_index);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          &prefs_, &search_engine_choice_service_, &default_index);
 
   // Ensure all the URLs have the required fields populated.
   ASSERT_FALSE(t_urls.empty());
@@ -457,7 +462,8 @@
     prefs_.SetInteger(country_codes::kCountryIDAtInstall, country_id);
 
     std::vector<std::unique_ptr<TemplateURLData>> t_urls =
-        TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, nullptr);
+        TemplateURLPrepopulateData::GetPrepopulatedEngines(
+            &prefs_, &search_engine_choice_service_, nullptr);
 
     ASSERT_FALSE(t_urls.empty());
     for (const auto& t_url : t_urls) {
@@ -610,7 +616,8 @@
 
   // Google is first in US, so confirm index 0.
   prefs_.SetInteger(country_codes::kCountryIDAtInstall, 'U' << 8 | 'S');
-  urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, &index);
+  urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(
+      &prefs_, &search_engine_choice_service_, &index);
   EXPECT_EQ(index, size_t{0});
   EXPECT_EQ(urls[index]->prepopulate_id, kGoogleId);
 
@@ -619,7 +626,8 @@
   // check template_url_prepopulate_data.cc reference orders (engines_CN, etc.)
   // to find a suitable country and index.
   prefs_.SetInteger(country_codes::kCountryIDAtInstall, 'C' << 8 | 'N');
-  urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, &index);
+  urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(
+      &prefs_, &search_engine_choice_service_, &index);
   EXPECT_GT(index, size_t{0});
   EXPECT_LT(index, urls.size());
   EXPECT_EQ(urls[index]->prepopulate_id, kGoogleId);
@@ -631,19 +639,22 @@
   // bing, yahoo.
   prefs_.SetInteger(country_codes::kCountryIDAtInstall,
                     country_codes::kCountryIDUnknown);
-  ASSERT_EQ(TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, nullptr)
+  ASSERT_EQ(TemplateURLPrepopulateData::GetPrepopulatedEngines(
+                &prefs_, &search_engine_choice_service_, nullptr)
                 .size(),
             3u);
 
   // `GetPrepopulatedEngine()` only looks in the profile country's prepopulated
   // list.
   EXPECT_FALSE(TemplateURLPrepopulateData::GetPrepopulatedEngine(
-      &prefs_, TemplateURLPrepopulateData::ecosia.id));
+      &prefs_, &search_engine_choice_service_,
+      TemplateURLPrepopulateData::ecosia.id));
 
   // Here we look in the full list.
   auto found_engine =
       TemplateURLPrepopulateData::GetPrepopulatedEngineFromFullList(
-          &prefs_, TemplateURLPrepopulateData::ecosia.id);
+          &prefs_, &search_engine_choice_service_,
+          TemplateURLPrepopulateData::ecosia.id);
   EXPECT_TRUE(found_engine);
   auto expected_engine =
       TemplateURLDataFromPrepopulatedEngine(TemplateURLPrepopulateData::ecosia);
@@ -658,8 +669,8 @@
 
   // For a given country, the output from `GetLocalPrepopulatedEngines`
   // should match the template URLs obtained from `GetPrepopulatedEngines`.
-  auto expected_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, nullptr);
+  auto expected_urls = TemplateURLPrepopulateData::GetPrepopulatedEngines(
+      &prefs_, &search_engine_choice_service_, nullptr);
   auto actual_urls = TemplateURLPrepopulateData::GetLocalPrepopulatedEngines(
       sample_country, prefs_);
 
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc
index 162466f..e41e75c 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -41,6 +41,7 @@
 #include "components/prefs/pref_service.h"
 #include "components/search_engines/choice_made_location.h"
 #include "components/search_engines/enterprise_site_search_manager.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/search_engine_type.h"
 #include "components/search_engines/search_engines_pref_names.h"
@@ -374,9 +375,9 @@
 };
 
 // TemplateURLService ---------------------------------------------------------
-
 TemplateURLService::TemplateURLService(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     std::unique_ptr<SearchTermsData> search_terms_data,
     const scoped_refptr<KeywordWebDataService>& web_data_service,
     std::unique_ptr<TemplateURLServiceClient> client,
@@ -387,6 +388,7 @@
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
     )
     : prefs_(prefs),
+      search_engine_choice_service_(search_engine_choice_service),
       search_terms_data_(std::move(search_terms_data)),
       web_data_service_(web_data_service),
       client_(std::move(client)),
@@ -394,6 +396,7 @@
       pre_loading_providers_(std::make_unique<PreLoadingProviders>()),
       default_search_manager_(
           prefs,
+          search_engine_choice_service,
           base::BindRepeating(&TemplateURLService::ApplyDefaultSearchChange,
                               base::Unretained(this))
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -402,15 +405,21 @@
 #endif  //  BUILDFLAG(IS_CHROMEOS_LACROS)
           ),
       enterprise_site_search_manager_(GetEnterpriseSiteSearchManager(prefs)) {
+  if (!search_engine_choice_service_) {
+    CHECK_IS_TEST();
+    CHECK(!prefs);
+  }
   DCHECK(search_terms_data_);
   Init();
 }
 
 TemplateURLService::TemplateURLService(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     base::span<const TemplateURLService::Initializer> initializers)
     : TemplateURLService(
           prefs,
+          search_engine_choice_service,
           /*search_terms_data=*/std::make_unique<SearchTermsData>(),
           /*web_data_service=*/nullptr,
           /*client=*/nullptr,
@@ -422,6 +431,7 @@
       ) {
   // This constructor is not intended to be used outside of tests.
   CHECK_IS_TEST();
+  CHECK(search_engine_choice_service_ || !prefs);
   ApplyInitializersForTesting(initializers);  // IN-TEST
 }
 
@@ -430,6 +440,7 @@
     : pre_loading_providers_(std::make_unique<PreLoadingProviders>()),
       default_search_manager_(
           /*pref_service=*/nullptr,
+          /*search_engine_choice_service=*/nullptr,
           base::BindRepeating(&TemplateURLService::ApplyDefaultSearchChange,
                               base::Unretained(this))
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -795,7 +806,8 @@
   // handled by `generate_search_engine_icons.py`.
   std::vector<std::unique_ptr<TemplateURLData>> engines =
       TemplateURLPrepopulateData::GetPrepopulatedEngines(
-          prefs_, /*default_search_provider_index=*/nullptr,
+          prefs_, search_engine_choice_service_,
+          /*default_search_provider_index=*/nullptr,
           /*include_current_default=*/true, /*template_url_service=*/this);
   for (const auto& engine : engines) {
     result.push_back(std::make_unique<TemplateURL>(*engine));
@@ -988,7 +1000,7 @@
   }
 
   if (selection_added) {
-    search_engines::RecordChoiceMade(prefs_, choice_made_location, this);
+    search_engine_choice_service_->RecordChoiceMade(choice_made_location, this);
   }
 
 #if BUILDFLAG(IS_ANDROID)
@@ -1121,7 +1133,8 @@
   }
 
   std::vector<std::unique_ptr<TemplateURLData>> prepopulated_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs_, nullptr);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          prefs_, search_engine_choice_service_, nullptr);
   DCHECK(!prepopulated_urls.empty());
   ActionsFromCurrentData actions(CreateActionsFromCurrentPrepopulateData(
       &prepopulated_urls, template_urls_, default_search_provider_));
@@ -1274,7 +1287,8 @@
   int new_resource_starter_pack_version = 0;
   {
     GetSearchProvidersUsingKeywordResult(
-        *result, web_data_service_.get(), prefs_, template_urls.get(),
+        *result, web_data_service_.get(), prefs_, search_engine_choice_service_,
+        template_urls.get(),
         (default_search_provider_source_ == DefaultSearchManager::FROM_USER)
             ? pre_loading_providers_->default_search_provider()
             : nullptr,
@@ -1420,8 +1434,9 @@
         iter->sync_data().GetSpecifics().search_engine().sync_guid());
     std::unique_ptr<TemplateURL> turl =
         CreateTemplateURLFromTemplateURLAndSyncData(
-            client_.get(), prefs_, search_terms_data(), existing_turl,
-            iter->sync_data(), &new_changes);
+            client_.get(), prefs_, search_engine_choice_service_,
+            search_terms_data(), existing_turl, iter->sync_data(),
+            &new_changes);
     if (!turl)
       continue;
 
@@ -1537,8 +1552,8 @@
     TemplateURL* local_turl = GetTemplateURLForGUID(iter->first);
     std::unique_ptr<TemplateURL> sync_turl(
         CreateTemplateURLFromTemplateURLAndSyncData(
-            client_.get(), prefs_, search_terms_data(), local_turl,
-            iter->second, &new_changes));
+            client_.get(), prefs_, search_engine_choice_service_,
+            search_terms_data(), local_turl, iter->second, &new_changes));
     if (!sync_turl)
       continue;
 
@@ -1652,12 +1667,12 @@
 
 bool TemplateURLService::IsEeaChoiceCountry() {
   return search_engines::IsEeaChoiceCountry(
-      search_engines::GetSearchEngineChoiceCountryId(prefs_));
+      search_engine_choice_service_->GetCountryId());
 }
 
 #if BUILDFLAG(IS_ANDROID)
 bool TemplateURLService::ShouldShowUpdatedSettings() {
-  return search_engines::ShouldShowUpdatedSettings(*prefs_);
+  return search_engine_choice_service_->ShouldShowUpdatedSettings();
 }
 #endif
 
@@ -1760,6 +1775,7 @@
 TemplateURLService::CreateTemplateURLFromTemplateURLAndSyncData(
     TemplateURLServiceClient* client,
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     const SearchTermsData& search_terms_data,
     const TemplateURL* existing_turl,
     const syncer::SyncData& sync_data,
@@ -1827,7 +1843,8 @@
   // If this TemplateURL matches a built-in prepopulated template URL, it's
   // possible that sync is trying to modify fields that should not be touched.
   // Revert these fields to the built-in values.
-  UpdateTemplateURLIfPrepopulated(turl.get(), prefs);
+  UpdateTemplateURLIfPrepopulated(turl.get(), prefs,
+                                  search_engine_choice_service);
 
   DCHECK_EQ(TemplateURL::NORMAL, turl->type());
   if (reset_keyword || deduped) {
@@ -2091,13 +2108,15 @@
 // static
 void TemplateURLService::UpdateTemplateURLIfPrepopulated(
     TemplateURL* template_url,
-    PrefService* prefs) {
+    PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service) {
   int prepopulate_id = template_url->prepopulate_id();
   if (template_url->prepopulate_id() == 0)
     return;
 
   std::vector<std::unique_ptr<TemplateURLData>> prepopulated_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, nullptr);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          prefs, search_engine_choice_service, nullptr);
 
   for (const auto& url : prepopulated_urls) {
     if (url->prepopulate_id == prepopulate_id) {
diff --git a/components/search_engines/template_url_service.h b/components/search_engines/template_url_service.h
index 30d9a46..9e442aa 100644
--- a/components/search_engines/template_url_service.h
+++ b/components/search_engines/template_url_service.h
@@ -52,6 +52,10 @@
 class TemplateUrlServiceAndroid;
 #endif
 
+namespace search_engines {
+class SearchEngineChoiceService;
+}
+
 namespace syncer {
 class SyncData;
 }
@@ -134,12 +138,14 @@
 
   TemplateURLService(
       PrefService* prefs,
+      search_engines::SearchEngineChoiceService* search_engine_choice_service,
       std::unique_ptr<SearchTermsData> search_terms_data,
       const scoped_refptr<KeywordWebDataService>& web_data_service,
       std::unique_ptr<TemplateURLServiceClient> client,
       const base::RepeatingClosure& dsp_change_callback
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
-      , bool for_lacros_main_profile
+      ,
+      bool for_lacros_main_profile
 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
   );
 
@@ -152,6 +158,7 @@
   // some template URL data.
   explicit TemplateURLService(
       PrefService* prefs,
+      search_engines::SearchEngineChoiceService* search_engine_choice_service,
       base::span<const TemplateURLService::Initializer> initializers = {});
 
   TemplateURLService(const TemplateURLService&) = delete;
@@ -570,10 +577,13 @@
   // data, an appropriate SyncChange is added to |change_list|.  If the sync
   // data is bad for some reason, an ACTION_DELETE change is added and the
   // function returns NULL.
+  // `search_engine_choice_service` is used to obtain the country code (for the
+  // list of prepopulated engines).
   static std::unique_ptr<TemplateURL>
   CreateTemplateURLFromTemplateURLAndSyncData(
       TemplateURLServiceClient* client,
       PrefService* prefs,
+      search_engines::SearchEngineChoiceService* search_engine_choice_service,
       const SearchTermsData& search_terms_data,
       const TemplateURL* existing_turl,
       const syncer::SyncData& sync_data,
@@ -726,8 +736,10 @@
   // country, update all its fields save for the keyword, short name and id so
   // that they match the internal prepopulated URL. TemplateURLs not coming from
   // a prepopulated URL are not modified.
-  static void UpdateTemplateURLIfPrepopulated(TemplateURL* existing_turl,
-                                              PrefService* prefs);
+  static void UpdateTemplateURLIfPrepopulated(
+      TemplateURL* existing_turl,
+      PrefService* prefs,
+      search_engines::SearchEngineChoiceService* search_engine_choice_service);
 
   // If the TemplateURL's sync GUID matches the kSyncedDefaultSearchProviderGUID
   // preference it will be used to update the DSE in prefs.
@@ -869,6 +881,9 @@
   // ---------- Browser state related members ---------------------------------
   raw_ptr<PrefService> prefs_ = nullptr;
 
+  raw_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_ = nullptr;
+
   std::unique_ptr<SearchTermsData> search_terms_data_ =
       std::make_unique<SearchTermsData>();
 
diff --git a/components/search_engines/template_url_service_unittest.cc b/components/search_engines/template_url_service_unittest.cc
index 08719437..9f82cc2 100644
--- a/components/search_engines/template_url_service_unittest.cc
+++ b/components/search_engines/template_url_service_unittest.cc
@@ -9,6 +9,7 @@
 #include <memory>
 
 #include "base/threading/platform_thread.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/template_url_prepopulate_data.h"
 #include "components/search_engines/template_url_service_client.h"
 #include "components/sync_preferences/testing_pref_service_syncable.h"
@@ -21,8 +22,13 @@
     TemplateURLPrepopulateData::RegisterProfilePrefs(pref_service_.registry());
     DefaultSearchManager::RegisterProfilePrefs(pref_service_.registry());
 
+    search_engine_choice_service_ =
+        std::make_unique<search_engines::SearchEngineChoiceService>(
+            pref_service_);
+
     template_url_service_ = std::make_unique<TemplateURLService>(
-        &pref_service_, std::make_unique<SearchTermsData>(),
+        &pref_service_, search_engine_choice_service_.get(),
+        std::make_unique<SearchTermsData>(),
         nullptr /* KeywordWebDataService */,
         nullptr /* TemplateURLServiceClient */, base::RepeatingClosure()
 #if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -38,6 +44,8 @@
 
  private:
   sync_preferences::TestingPrefServiceSyncable pref_service_;
+  std::unique_ptr<search_engines::SearchEngineChoiceService>
+      search_engine_choice_service_;
   std::unique_ptr<TemplateURLService> template_url_service_;
 };
 
diff --git a/components/search_engines/template_url_service_util_unittest.cc b/components/search_engines/template_url_service_util_unittest.cc
index 5243577..aed5ca33 100644
--- a/components/search_engines/template_url_service_util_unittest.cc
+++ b/components/search_engines/template_url_service_util_unittest.cc
@@ -15,6 +15,7 @@
 #include "base/values.h"
 #include "components/country_codes/country_codes.h"
 #include "components/search_engines/prepopulated_engines.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/search_terms_data.h"
 #include "components/search_engines/template_url.h"
@@ -71,6 +72,7 @@
 // prepopulated engines were loaded.
 void CallGetSearchProvidersUsingLoadedEngines(
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     TemplateURLService::OwnedTemplateURLVector* template_urls,
     int* resource_keyword_version) {
   // Setup inspired by `//components/webdata_services/web_data_service_wrapper*`
@@ -99,7 +101,8 @@
     int resource_starter_pack_version = 0;
 
     GetSearchProvidersUsingLoadedEngines(
-        keyword_web_data.get(), prefs, template_urls,
+        keyword_web_data.get(), prefs, search_engine_choice_service,
+        template_urls,
         /*default_search_provider=*/nullptr, search_terms_data,
         resource_keyword_version, &resource_starter_pack_version,
         &removed_keyword_guids);
@@ -247,6 +250,7 @@
   using TemplateURLPrepopulateData::kCurrentDataVersion;
 
   sync_preferences::TestingPrefServiceSyncable prefs;
+  search_engines::SearchEngineChoiceService search_engine_choice_service(prefs);
   size_t starter_pack_engines_count =
       TemplateURLStarterPackData::GetStarterPackEngines().size();
 
@@ -266,8 +270,9 @@
 
     TemplateURLService::OwnedTemplateURLVector template_urls;
     int resource_keyword_version = mocked_current_version;
-    CallGetSearchProvidersUsingLoadedEngines(&prefs, &template_urls,
-                                             &resource_keyword_version);
+    CallGetSearchProvidersUsingLoadedEngines(
+        &prefs, &search_engine_choice_service, &template_urls,
+        &resource_keyword_version);
 
     struct {
       size_t loaded_engines_count;
diff --git a/components/search_engines/util.cc b/components/search_engines/util.cc
index 21d2a6b..7812ca6 100644
--- a/components/search_engines/util.cc
+++ b/components/search_engines/util.cc
@@ -19,6 +19,7 @@
 #include "base/ranges/algorithm.h"
 #include "base/time/time.h"
 #include "components/prefs/pref_service.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/search_engine_choice_utils.h"
 #include "components/search_engines/search_engines_pref_names.h"
 #include "components/search_engines/template_url.h"
@@ -468,6 +469,7 @@
     const WDTypedResult& result,
     KeywordWebDataService* service,
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     TemplateURLService::OwnedTemplateURLVector* template_urls,
     TemplateURL* default_search_provider,
     const SearchTermsData& search_terms_data,
@@ -500,9 +502,9 @@
   *new_resource_keyword_version = keyword_result.builtin_keyword_version;
   *new_resource_starter_pack_version = keyword_result.starter_pack_version;
   GetSearchProvidersUsingLoadedEngines(
-      service, prefs, template_urls, default_search_provider, search_terms_data,
-      new_resource_keyword_version, new_resource_starter_pack_version,
-      removed_keyword_guids);
+      service, prefs, search_engine_choice_service, template_urls,
+      default_search_provider, search_terms_data, new_resource_keyword_version,
+      new_resource_starter_pack_version, removed_keyword_guids);
 
   // If a data change happened (new version != 0), it should not be caused by a
   // version downgrade. Upgrades (builtin > new) or feature-related merges
@@ -515,6 +517,7 @@
 void GetSearchProvidersUsingLoadedEngines(
     KeywordWebDataService* service,
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     TemplateURLService::OwnedTemplateURLVector* template_urls,
     TemplateURL* default_search_provider,
     const SearchTermsData& search_terms_data,
@@ -524,7 +527,8 @@
   DCHECK(template_urls);
   DCHECK(resource_keyword_version);
   std::vector<std::unique_ptr<TemplateURLData>> prepopulated_urls =
-      TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, nullptr);
+      TemplateURLPrepopulateData::GetPrepopulatedEngines(
+          prefs, search_engine_choice_service, nullptr);
   RemoveDuplicatePrepopulateIDs(service, prepopulated_urls,
                                 default_search_provider, template_urls,
                                 search_terms_data, removed_keyword_guids);
diff --git a/components/search_engines/util.h b/components/search_engines/util.h
index db05912..7d8b11f2 100644
--- a/components/search_engines/util.h
+++ b/components/search_engines/util.h
@@ -12,6 +12,7 @@
 #include <string>
 #include <vector>
 
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #include "components/search_engines/template_url_service.h"
 
 class KeywordWebDataService;
@@ -175,6 +176,7 @@
     const WDTypedResult& result,
     KeywordWebDataService* service,
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     TemplateURLService::OwnedTemplateURLVector* template_urls,
     TemplateURL* default_search_provider,
     const SearchTermsData& search_terms_data,
@@ -192,6 +194,7 @@
 void GetSearchProvidersUsingLoadedEngines(
     KeywordWebDataService* service,
     PrefService* prefs,
+    search_engines::SearchEngineChoiceService* search_engine_choice_service,
     TemplateURLService::OwnedTemplateURLVector* template_urls,
     TemplateURL* default_search_provider,
     const SearchTermsData& search_terms_data,
diff --git a/components/search_provider_logos/logo_service_impl_unittest.cc b/components/search_provider_logos/logo_service_impl_unittest.cc
index a1a9cf20e..54fa36c 100644
--- a/components/search_provider_logos/logo_service_impl_unittest.cc
+++ b/components/search_provider_logos/logo_service_impl_unittest.cc
@@ -349,7 +349,8 @@
 class LogoServiceImplTest : public ::testing::Test {
  protected:
   LogoServiceImplTest()
-      : template_url_service_(nullptr, 0),
+      : template_url_service_(/*prefs=*/nullptr,
+                              /*search_engine_choice_service=*/nullptr),
         logo_cache_(new NiceMock<MockLogoCache>()),
         shared_factory_(
             base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
diff --git a/ios/chrome/app/BUILD.gn b/ios/chrome/app/BUILD.gn
index de28254d..13450d7 100644
--- a/ios/chrome/app/BUILD.gn
+++ b/ios/chrome/app/BUILD.gn
@@ -396,6 +396,7 @@
     "//ios/chrome/browser/promos_manager:factory",
     "//ios/chrome/browser/promos_manager:promos_manager",
     "//ios/chrome/browser/search_engine_choice/model",
+    "//ios/chrome/browser/search_engines/model",
     "//ios/chrome/browser/search_engines/model:template_url_service_factory",
     "//ios/chrome/browser/shared/model/application_context",
     "//ios/chrome/browser/shared/model/browser_state",
diff --git a/ios/chrome/app/search_engine_choice_app_agent.mm b/ios/chrome/app/search_engine_choice_app_agent.mm
index 8657b255..c812453 100644
--- a/ios/chrome/app/search_engine_choice_app_agent.mm
+++ b/ios/chrome/app/search_engine_choice_app_agent.mm
@@ -7,8 +7,10 @@
 #import <memory>
 
 #import "base/check.h"
+#import "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #import "ios/chrome/app/application_delegate/app_state.h"
 #import "ios/chrome/browser/search_engine_choice/model/search_engine_choice_util.h"
+#import "ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h"
 #import "ios/chrome/browser/shared/coordinator/scene/scene_state.h"
 #import "ios/chrome/browser/shared/coordinator/scene/scene_state_observer.h"
 #import "ios/chrome/browser/shared/model/browser/browser.h"
diff --git a/ios/chrome/browser/browser_state/model/browser_state_keyed_service_factories.mm b/ios/chrome/browser/browser_state/model/browser_state_keyed_service_factories.mm
index 2647cf2..49258ea 100644
--- a/ios/chrome/browser/browser_state/model/browser_state_keyed_service_factories.mm
+++ b/ios/chrome/browser/browser_state/model/browser_state_keyed_service_factories.mm
@@ -67,6 +67,7 @@
 #import "ios/chrome/browser/safe_browsing/model/verdict_cache_manager_factory.h"
 #import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager_factory.h"
 #import "ios/chrome/browser/screen_time/model/screen_time_buildflags.h"
+#import "ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h"
 #import "ios/chrome/browser/search_engines/model/template_url_service_factory.h"
 #import "ios/chrome/browser/segmentation_platform/model/segmentation_platform_service_factory.h"
 #import "ios/chrome/browser/sessions/session_restoration_service_factory.h"
@@ -137,6 +138,7 @@
   ios::HistoryServiceFactory::GetInstance();
   ios::LocalOrSyncableBookmarkSyncServiceFactory::GetInstance();
   ios::InMemoryURLIndexFactory::GetInstance();
+  ios::SearchEngineChoiceServiceFactory::GetInstance();
   ios::ShortcutsBackendFactory::GetInstance();
   ios::SigninErrorControllerFactory::GetInstance();
   ios::TemplateURLServiceFactory::GetInstance();
diff --git a/ios/chrome/browser/search_engine_choice/model/BUILD.gn b/ios/chrome/browser/search_engine_choice/model/BUILD.gn
index e004a0e4..55864f2 100644
--- a/ios/chrome/browser/search_engine_choice/model/BUILD.gn
+++ b/ios/chrome/browser/search_engine_choice/model/BUILD.gn
@@ -12,7 +12,7 @@
     "//components/search_engines",
     "//ios/chrome/app:tests_hook",
     "//ios/chrome/browser/policy/model",
-    "//ios/chrome/browser/search_engines/model:template_url_service_factory",
+    "//ios/chrome/browser/search_engines/model",
     "//ios/chrome/browser/shared/model/browser",
     "//ios/chrome/browser/shared/model/browser_state",
     "//ios/chrome/browser/shared/public/features:system_flags",
diff --git a/ios/chrome/browser/search_engine_choice/model/DEPS b/ios/chrome/browser/search_engine_choice/model/DEPS
index bda4ac1..5acd7c2 100644
--- a/ios/chrome/browser/search_engine_choice/model/DEPS
+++ b/ios/chrome/browser/search_engine_choice/model/DEPS
@@ -1,4 +1,5 @@
 include_rules = [
   "+ios/chrome/browser/policy/model/browser_state_policy_connector.h",
+  "+ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h",
   "+ios/chrome/browser/search_engines/model/template_url_service_factory.h",
 ]
\ No newline at end of file
diff --git a/ios/chrome/browser/search_engine_choice/model/search_engine_choice_util.mm b/ios/chrome/browser/search_engine_choice/model/search_engine_choice_util.mm
index cee64d5..2707f39 100644
--- a/ios/chrome/browser/search_engine_choice/model/search_engine_choice_util.mm
+++ b/ios/chrome/browser/search_engine_choice/model/search_engine_choice_util.mm
@@ -4,9 +4,11 @@
 
 #import "ios/chrome/browser/search_engine_choice/model/search_engine_choice_util.h"
 
+#import "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #import "components/search_engines/search_engine_choice_utils.h"
 #import "ios/chrome/app/tests_hook.h"
 #import "ios/chrome/browser/policy/model/browser_state_policy_connector.h"
+#import "ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h"
 #import "ios/chrome/browser/search_engines/model/template_url_service_factory.h"
 #import "ios/chrome/browser/shared/model/browser/browser.h"
 #import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
@@ -21,12 +23,13 @@
   if (!browser_state) {
     return false;
   }
+  search_engines::SearchEngineChoiceService* search_engine_choice_service =
+      ios::SearchEngineChoiceServiceFactory::GetForBrowserState(browser_state);
   BrowserStatePolicyConnector* policy_connector =
       browser_state->GetPolicyConnector();
-  return search_engines::ShouldShowChoiceScreen(
+  return search_engine_choice_service->ShouldShowChoiceScreen(
       *policy_connector->GetPolicyService(),
-      /*profile_properties=*/
-      {.is_regular_profile = true, .pref_service = browser_state->GetPrefs()},
+      /*is_regular_profile=*/true,
       ios::TemplateURLServiceFactory::GetForBrowserState(browser_state));
 }
 
diff --git a/ios/chrome/browser/search_engines/model/BUILD.gn b/ios/chrome/browser/search_engines/model/BUILD.gn
index de0b07d..bdfd290 100644
--- a/ios/chrome/browser/search_engines/model/BUILD.gn
+++ b/ios/chrome/browser/search_engines/model/BUILD.gn
@@ -8,6 +8,8 @@
 
 source_set("model") {
   sources = [
+    "search_engine_choice_service_factory.cc",
+    "search_engine_choice_service_factory.h",
     "search_engine_java_script_feature.h",
     "search_engine_java_script_feature.mm",
     "search_engine_observer_bridge.h",
diff --git a/ios/chrome/browser/search_engines/model/extension_search_engine_data_updater_unittest.mm b/ios/chrome/browser/search_engines/model/extension_search_engine_data_updater_unittest.mm
index 50cf009..250ff95 100644
--- a/ios/chrome/browser/search_engines/model/extension_search_engine_data_updater_unittest.mm
+++ b/ios/chrome/browser/search_engines/model/extension_search_engine_data_updater_unittest.mm
@@ -4,6 +4,8 @@
 
 #import "ios/chrome/browser/search_engines/model/extension_search_engine_data_updater.h"
 
+#import <memory>
+
 #import "base/strings/sys_string_conversions.h"
 #import "components/search_engines/template_url.h"
 #import "components/search_engines/template_url_data.h"
@@ -24,10 +26,11 @@
   void SetUp() override {
     PlatformTest::SetUp();
 
-    template_url_service_.reset(new TemplateURLService(nullptr, 0));
+    template_url_service_ = std::make_unique<TemplateURLService>(
+        /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr);
     template_url_service_->Load();
-    observer_.reset(
-        new ExtensionSearchEngineDataUpdater(template_url_service_.get()));
+    observer_ = std::make_unique<ExtensionSearchEngineDataUpdater>(
+        template_url_service_.get());
 
     NSUserDefaults* shared_defaults = app_group::GetGroupUserDefaults();
     [shared_defaults setBool:NO forKey:search_by_image_key_];
diff --git a/ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.cc b/ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.cc
new file mode 100644
index 0000000..babdd5d8
--- /dev/null
+++ b/ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.cc
@@ -0,0 +1,48 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h"
+
+#include <memory>
+
+#include "base/check_deref.h"
+#include "components/keyed_service/ios/browser_state_dependency_manager.h"
+#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
+#include "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
+#include "ios/web/public/browser_state.h"
+
+namespace ios {
+
+SearchEngineChoiceServiceFactory::SearchEngineChoiceServiceFactory()
+    : BrowserStateKeyedServiceFactory(
+          "SearchEngineChoiceServiceFactory",
+          BrowserStateDependencyManager::GetInstance()) {}
+
+SearchEngineChoiceServiceFactory::~SearchEngineChoiceServiceFactory() = default;
+
+// static
+SearchEngineChoiceServiceFactory*
+SearchEngineChoiceServiceFactory::GetInstance() {
+  static base::NoDestructor<SearchEngineChoiceServiceFactory> factory;
+  return factory.get();
+}
+
+// static
+search_engines::SearchEngineChoiceService*
+SearchEngineChoiceServiceFactory::GetForBrowserState(
+    ChromeBrowserState* browser_state) {
+  return static_cast<search_engines::SearchEngineChoiceService*>(
+      GetInstance()->GetServiceForBrowserState(browser_state, true));
+}
+
+std::unique_ptr<KeyedService>
+SearchEngineChoiceServiceFactory::BuildServiceInstanceFor(
+    web::BrowserState* context) const {
+  ChromeBrowserState* browser_state =
+      ChromeBrowserState::FromBrowserState(context);
+  return std::make_unique<search_engines::SearchEngineChoiceService>(
+      CHECK_DEREF(browser_state->GetPrefs()));
+}
+
+}  // namespace ios
diff --git a/ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h b/ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h
new file mode 100644
index 0000000..6760b6b
--- /dev/null
+++ b/ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h
@@ -0,0 +1,45 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_SEARCH_ENGINES_MODEL_SEARCH_ENGINE_CHOICE_SERVICE_FACTORY_H_
+#define IOS_CHROME_BROWSER_SEARCH_ENGINES_MODEL_SEARCH_ENGINE_CHOICE_SERVICE_FACTORY_H_
+
+#include "base/no_destructor.h"
+#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
+
+class ChromeBrowserState;
+
+namespace search_engines {
+class SearchEngineChoiceService;
+}
+
+namespace ios {
+
+class SearchEngineChoiceServiceFactory
+    : public BrowserStateKeyedServiceFactory {
+ public:
+  SearchEngineChoiceServiceFactory(const SearchEngineChoiceServiceFactory&) =
+      delete;
+  SearchEngineChoiceServiceFactory& operator=(
+      const SearchEngineChoiceServiceFactory&) = delete;
+
+  static search_engines::SearchEngineChoiceService* GetForBrowserState(
+      ChromeBrowserState* browser_state);
+
+  static SearchEngineChoiceServiceFactory* GetInstance();
+
+ private:
+  friend class base::NoDestructor<SearchEngineChoiceServiceFactory>;
+
+  SearchEngineChoiceServiceFactory();
+  ~SearchEngineChoiceServiceFactory() override;
+
+  // BrowserStateKeyedServiceFactory:
+  std::unique_ptr<KeyedService> BuildServiceInstanceFor(
+      web::BrowserState* context) const override;
+};
+
+}  // namespace ios
+
+#endif  // IOS_CHROME_BROWSER_SEARCH_ENGINES_MODEL_SEARCH_ENGINE_CHOICE_SERVICE_FACTORY_H_
diff --git a/ios/chrome/browser/search_engines/model/search_engines_util.cc b/ios/chrome/browser/search_engines/model/search_engines_util.cc
index 2bacda0..538f994 100644
--- a/ios/chrome/browser/search_engines/model/search_engines_util.cc
+++ b/ios/chrome/browser/search_engines/model/search_engines_util.cc
@@ -34,10 +34,12 @@
   if (search_engines::IsChoiceScreenFlagEnabled(
           search_engines::ChoicePromo::kAny)) {
     new_engines = TemplateURLPrepopulateData::GetPrepopulatedEngines(
-        preferences, nullptr);
+        preferences, /*search_engine_choice_service=*/nullptr,
+        /*default_search_provider_index=*/nullptr);
   } else {
-    new_engines =
-        TemplateURLPrepopulateData::GetPrepopulatedEngines(nullptr, nullptr);
+    new_engines = TemplateURLPrepopulateData::GetPrepopulatedEngines(
+        /*prefs=*/nullptr, /*search_engine_choice_service=*/nullptr,
+        /*default_search_provider_index=*/nullptr);
   }
   // The aim is to replace the old search engines with the new ones.
   // It is not possible to remove all of them, because removing the current
diff --git a/ios/chrome/browser/search_engines/model/template_url_service_factory.mm b/ios/chrome/browser/search_engines/model/template_url_service_factory.mm
index 398f45f..ebdde47 100644
--- a/ios/chrome/browser/search_engines/model/template_url_service_factory.mm
+++ b/ios/chrome/browser/search_engines/model/template_url_service_factory.mm
@@ -12,6 +12,7 @@
 #import "components/search_engines/default_search_manager.h"
 #import "components/search_engines/template_url_service.h"
 #import "ios/chrome/browser/history/model/history_service_factory.h"
+#import "ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h"
 #import "ios/chrome/browser/search_engines/model/template_url_service_client_impl.h"
 #import "ios/chrome/browser/search_engines/model/ui_thread_search_terms_data.h"
 #import "ios/chrome/browser/shared/model/browser_state/browser_state_otr_helper.h"
@@ -42,6 +43,7 @@
       ChromeBrowserState::FromBrowserState(context);
   return std::make_unique<TemplateURLService>(
       browser_state->GetPrefs(),
+      ios::SearchEngineChoiceServiceFactory::GetForBrowserState(browser_state),
       std::make_unique<ios::UIThreadSearchTermsData>(),
       ios::WebDataServiceFactory::GetKeywordWebDataForBrowserState(
           browser_state, ServiceAccessType::EXPLICIT_ACCESS),
@@ -78,6 +80,7 @@
           BrowserStateDependencyManager::GetInstance()) {
   DependsOn(ios::HistoryServiceFactory::GetInstance());
   DependsOn(ios::WebDataServiceFactory::GetInstance());
+  DependsOn(ios::SearchEngineChoiceServiceFactory::GetInstance());
 }
 
 TemplateURLServiceFactory::~TemplateURLServiceFactory() {}
diff --git a/ios/chrome/browser/ui/first_run/BUILD.gn b/ios/chrome/browser/ui/first_run/BUILD.gn
index e8ece345..3943d7f 100644
--- a/ios/chrome/browser/ui/first_run/BUILD.gn
+++ b/ios/chrome/browser/ui/first_run/BUILD.gn
@@ -113,6 +113,7 @@
     "//components/sync/base:features",
     "//ios/chrome/app:tests_hook",
     "//ios/chrome/browser/policy/model",
+    "//ios/chrome/browser/search_engines/model",
     "//ios/chrome/browser/search_engines/model:template_url_service_factory",
     "//ios/chrome/browser/shared/model/browser_state",
     "//ios/chrome/browser/shared/public/features",
diff --git a/ios/chrome/browser/ui/first_run/first_run_screen_provider.mm b/ios/chrome/browser/ui/first_run/first_run_screen_provider.mm
index 233a8af4..5eb6d6ef 100644
--- a/ios/chrome/browser/ui/first_run/first_run_screen_provider.mm
+++ b/ios/chrome/browser/ui/first_run/first_run_screen_provider.mm
@@ -6,10 +6,12 @@
 
 #import "base/feature_list.h"
 #import "base/notreached.h"
+#import "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #import "components/search_engines/search_engine_choice_utils.h"
 #import "components/sync/base/features.h"
 #import "ios/chrome/app/tests_hook.h"
 #import "ios/chrome/browser/policy/model/browser_state_policy_connector.h"
+#import "ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h"
 #import "ios/chrome/browser/search_engines/model/template_url_service_factory.h"
 #import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
 #import "ios/chrome/browser/shared/public/features/features.h"
@@ -52,14 +54,14 @@
     [screens addObject:@(kTangibleSync)];
   }
 
+  search_engines::SearchEngineChoiceService* search_engine_choice_service =
+      ios::SearchEngineChoiceServiceFactory::GetForBrowserState(browserState);
   BrowserStatePolicyConnector* policyConnector =
       browserState->GetPolicyConnector();
   if (ios::first_run::IsSearchEngineChoiceScreenEnabledFre() &&
-      search_engines::ShouldShowChoiceScreen(
+      search_engine_choice_service->ShouldShowChoiceScreen(
           *policyConnector->GetPolicyService(),
-          /*profile_properties=*/
-          {.is_regular_profile = true,
-           .pref_service = browserState->GetPrefs()},
+          /*is_regular_profile=*/true,
           ios::TemplateURLServiceFactory::GetForBrowserState(browserState))) {
     [screens addObject:@(kChoice)];
   }
diff --git a/ios/chrome/browser/ui/omnibox/fake_suggestions_database_unittest.cc b/ios/chrome/browser/ui/omnibox/fake_suggestions_database_unittest.cc
index 7e37d39..f67cf2e 100644
--- a/ios/chrome/browser/ui/omnibox/fake_suggestions_database_unittest.cc
+++ b/ios/chrome/browser/ui/omnibox/fake_suggestions_database_unittest.cc
@@ -12,7 +12,9 @@
 
 class FakeSuggestionsDatabaseTest : public testing::Test {
  public:
-  FakeSuggestionsDatabaseTest() : template_url_service_(nullptr, 0) {
+  FakeSuggestionsDatabaseTest()
+      : template_url_service_(/*prefs=*/nullptr,
+                              /*search_engine_choice_service=*/nullptr) {
     fake_suggestions_database_ =
         std::make_unique<FakeSuggestionsDatabase>(&template_url_service_);
   }
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator_unittest.mm b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator_unittest.mm
index 2915826..2995ec9a 100644
--- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator_unittest.mm
+++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator_unittest.mm
@@ -115,7 +115,8 @@
 
     // Setup for AutocompleteController.
     auto template_url_service = std::make_unique<TemplateURLService>(
-        /*prefs=*/nullptr, std::make_unique<SearchTermsData>(),
+        /*prefs=*/nullptr, /*search_engine_search_service=*/nullptr,
+        std::make_unique<SearchTermsData>(),
         /*web_data_service=*/nullptr,
         std::unique_ptr<TemplateURLServiceClient>(), base::RepeatingClosure());
     auto client = std::make_unique<MockAutocompleteProviderClient>();
diff --git a/ios/chrome/browser/ui/settings/search_engine_table_view_controller.mm b/ios/chrome/browser/ui/settings/search_engine_table_view_controller.mm
index d9b46b69..70130457 100644
--- a/ios/chrome/browser/ui/settings/search_engine_table_view_controller.mm
+++ b/ios/chrome/browser/ui/settings/search_engine_table_view_controller.mm
@@ -14,6 +14,7 @@
 #import "base/strings/sys_string_conversions.h"
 #import "components/password_manager/core/common/password_manager_features.h"
 #import "components/prefs/pref_service.h"
+#import "components/search_engines/search_engine_choice/search_engine_choice_service.h"
 #import "components/search_engines/search_engine_choice_utils.h"
 #import "components/search_engines/search_engines_pref_names.h"
 #import "components/search_engines/template_url_service.h"
@@ -22,6 +23,7 @@
 #import "components/strings/grit/components_strings.h"
 #import "ios/chrome/browser/favicon/favicon_loader.h"
 #import "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h"
+#import "ios/chrome/browser/search_engines/model/search_engine_choice_service_factory.h"
 #import "ios/chrome/browser/search_engines/model/search_engine_observer_bridge.h"
 #import "ios/chrome/browser/search_engines/model/template_url_service_factory.h"
 #import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
@@ -118,8 +120,11 @@
     _faviconLoader =
         IOSChromeFaviconLoaderFactory::GetForBrowserState(browserState);
     _prefService = browserState->GetPrefs();
+
+    search_engines::SearchEngineChoiceService* search_engine_choice_service =
+        ios::SearchEngineChoiceServiceFactory::GetForBrowserState(browserState);
     _shouldShowUpdatedSettings =
-        search_engines::ShouldShowUpdatedSettings(*_prefService);
+        search_engine_choice_service->ShouldShowUpdatedSettings();
     [self setTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_ENGINE_SETTING_TITLE)];
     self.shouldDisableDoneButtonOnEdit = YES;
   }