From 9bb8103f5a330bfa7c676a4373e264301ddc0292 Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Sun, 5 Jun 2022 17:22:16 +0300 Subject: [PATCH] Simplify patch --- 0002-Yandex-as-default-search-engine.patch | 36 ++++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/0002-Yandex-as-default-search-engine.patch b/0002-Yandex-as-default-search-engine.patch index 74f4101..2b48598 100644 --- a/0002-Yandex-as-default-search-engine.patch +++ b/0002-Yandex-as-default-search-engine.patch @@ -1,4 +1,4 @@ -From 87a4a1ad7c32138dd2d87066417bddc63cbf7619 Mon Sep 17 00:00:00 2001 +From 6681497319c9b7f8d5d27912284ca228408e3d9a Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Sun, 29 May 2022 22:31:21 +0300 Subject: [PATCH] Yandex as default search engine @@ -19,8 +19,8 @@ http://git.osmesh.ru/MOS/mos-panel-desktop/src/commit/0f02deea4f7da5ee186433cc71 but it would make Yandex.ru be the default even for not Russian users. --- .../search_engines/prepopulated_engines.json | 9 ++++--- - .../template_url_prepopulate_data.cc | 25 ++++++++++++++----- - 2 files changed, 24 insertions(+), 10 deletions(-) + .../template_url_prepopulate_data.cc | 27 ++++++++++--------- + 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json index 13572d4355..cc449a1ccb 100644 @@ -71,7 +71,7 @@ index 13572d4355..cc449a1ccb 100644 "id": 15 }, diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc -index e38343c221..9a421c6313 100644 +index e38343c221..4759cd6711 100644 --- a/components/search_engines/template_url_prepopulate_data.cc +++ b/components/search_engines/template_url_prepopulate_data.cc @@ -28,6 +28,7 @@ namespace { @@ -134,27 +134,29 @@ index e38343c221..9a421c6313 100644 &yahoo_tr, &bing, &duckduckgo, -@@ -1381,7 +1382,19 @@ std::vector> GetPrepopulatedEngines( +@@ -1381,13 +1382,15 @@ std::vector> GetPrepopulatedEngines( t_urls = GetPrepopulationSetFromCountryID( country_codes::GetCountryIDFromPrefs(prefs)); } - if (default_search_provider_index) { +- const auto itr = std::find_if( +- t_urls.begin(), t_urls.end(), +- [](const auto& t_url) { return t_url->prepopulate_id == google.id; }); +- *default_search_provider_index = +- itr == t_urls.end() ? 0 : std::distance(t_urls.begin(), itr); +- } + /* Making yandex_ru be the first in "const PrepopulatedEngine* const engines_RU[]" + * makes it be the first item in chrome://settings/search, + * but Google is still chosen by default. -+ * I did not understand this code really well, probably it calculates the distance -+ * between 0 and Google's position. So, as a hack, assume that yandex_ru -+ * is the first in that list (this patch made it be the first) to force the first element -+ * of engine_RU[] to become the real default search engine. ++ * Removed code calculated the distance between 0 and Google's position ++ * and assign that position to default_search_provider_index, ++ * so that Google still was the default search engine. ++ * Instead, just use the first search engine as the default one. + */ -+ int is_russian = strcmp(getenv("LANG"), "ru_RU.UTF-8"); -+ if (default_search_provider_index && (is_russian == 0)) { -+ *default_search_provider_index = 0; /* if LANG == ru_RU.UTF-8 */ -+ } -+ if (default_search_provider_index && (is_russian != 0)) { - const auto itr = std::find_if( - t_urls.begin(), t_urls.end(), - [](const auto& t_url) { return t_url->prepopulate_id == google.id; }); ++ if (default_search_provider_index) *default_search_provider_index = 0; + return t_urls; + } + -- 2.35.2