From 1f3f641a8935e1782b95a9fdb3c6c77ded2ed76e Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Tue, 8 Oct 2024 12:14:50 +0900 Subject: [PATCH] Set brave search as a default search provider in AU fix https://github.com/brave/brave-browser/issues/41451 --- ..._template_url_prepopulate_data_unittest.cc | 2 +- .../template_url_prepopulate_data.cc | 60 ++++++++++++++++++- .../brave_prepopulated_engines.cc | 2 +- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest.cc b/chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest.cc index be0339ce13eb..6caf3987c5a1 100644 --- a/chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest.cc +++ b/chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest.cc @@ -186,7 +186,7 @@ TEST_F(BraveTemplateURLPrepopulateDataTest, DefaultSearchProvidersForCanada) { TEST_F(BraveTemplateURLPrepopulateDataTest, DefaultSearchProvidersForAustralia) { - CheckForCountry('A', 'U', PREPOPULATED_ENGINE_ID_GOOGLE); + CheckForCountry('A', 'U', PREPOPULATED_ENGINE_ID_BRAVE); } TEST_F(BraveTemplateURLPrepopulateDataTest, diff --git a/chromium_src/components/search_engines/template_url_prepopulate_data.cc b/chromium_src/components/search_engines/template_url_prepopulate_data.cc index 8a2c420f5e76..7f95b19b513d 100644 --- a/chromium_src/components/search_engines/template_url_prepopulate_data.cc +++ b/chromium_src/components/search_engines/template_url_prepopulate_data.cc @@ -521,8 +521,66 @@ BravePrepopulatedEngineID GetDefaultSearchEngine(int country_id, int version) { {country_codes::CountryCharsToCountryID('U', 'Z'), PREPOPULATED_ENGINE_ID_YANDEX}, }); + // Updated default for AU. + static constexpr auto kContentV30 = + base::MakeFixedFlatMap({ + {country_codes::CountryCharsToCountryID('A', 'M'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('A', 'R'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('A', 'T'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('A', 'U'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('A', 'Z'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('B', 'R'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('B', 'Y'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('C', 'A'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('D', 'E'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('E', 'S'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('F', 'R'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('G', 'B'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('I', 'N'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('I', 'T'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('K', 'G'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('K', 'R'), + PREPOPULATED_ENGINE_ID_NAVER}, + {country_codes::CountryCharsToCountryID('K', 'Z'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('M', 'D'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('M', 'X'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('R', 'U'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('T', 'J'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('T', 'M'), + PREPOPULATED_ENGINE_ID_YANDEX}, + {country_codes::CountryCharsToCountryID('U', 'S'), + PREPOPULATED_ENGINE_ID_BRAVE}, + {country_codes::CountryCharsToCountryID('U', 'Z'), + PREPOPULATED_ENGINE_ID_YANDEX}, + }); - if (version > 25) { + if (version > 29) { + const auto it = kContentV30.find(country_id); + if (it == kContentV30.end()) { + return default_v6; + } + return it->second; + } else if (version > 25) { const auto it = kContentV26.find(country_id); if (it == kContentV26.end()) { return default_v6; diff --git a/components/search_engines/brave_prepopulated_engines.cc b/components/search_engines/brave_prepopulated_engines.cc index 659946e7e793..4a0daa7ebf8b 100644 --- a/components/search_engines/brave_prepopulated_engines.cc +++ b/components/search_engines/brave_prepopulated_engines.cc @@ -13,7 +13,7 @@ namespace TemplateURLPrepopulateData { // IMPORTANT! Make sure to bump this value if you make changes to the // engines below or add/remove engines. -const int kBraveCurrentDataVersion = 29; +const int kBraveCurrentDataVersion = 30; // The version is important to increment because Chromium will cache the list // of search engines that are shown. When the version is incremented, Chromium