Simplify patch

This commit is contained in:
Mikhail Novosyolov 2022-06-05 17:22:16 +03:00
parent 276c8b0335
commit 9bb8103f5a

View file

@ -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 <m.novosyolov@rosalinux.ru> From: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Date: Sun, 29 May 2022 22:31:21 +0300 Date: Sun, 29 May 2022 22:31:21 +0300
Subject: [PATCH] Yandex as default search engine 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. but it would make Yandex.ru be the default even for not Russian users.
--- ---
.../search_engines/prepopulated_engines.json | 9 ++++--- .../search_engines/prepopulated_engines.json | 9 ++++---
.../template_url_prepopulate_data.cc | 25 ++++++++++++++----- .../template_url_prepopulate_data.cc | 27 ++++++++++---------
2 files changed, 24 insertions(+), 10 deletions(-) 2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json
index 13572d4355..cc449a1ccb 100644 index 13572d4355..cc449a1ccb 100644
@ -71,7 +71,7 @@ index 13572d4355..cc449a1ccb 100644
"id": 15 "id": 15
}, },
diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc 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 --- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc +++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -28,6 +28,7 @@ namespace { @@ -28,6 +28,7 @@ namespace {
@ -134,27 +134,29 @@ index e38343c221..9a421c6313 100644
&yahoo_tr, &yahoo_tr,
&bing, &bing,
&duckduckgo, &duckduckgo,
@@ -1381,7 +1382,19 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines( @@ -1381,13 +1382,15 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
t_urls = GetPrepopulationSetFromCountryID( t_urls = GetPrepopulationSetFromCountryID(
country_codes::GetCountryIDFromPrefs(prefs)); country_codes::GetCountryIDFromPrefs(prefs));
} }
- if (default_search_provider_index) { - 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[]" + /* Making yandex_ru be the first in "const PrepopulatedEngine* const engines_RU[]"
+ * makes it be the first item in chrome://settings/search, + * makes it be the first item in chrome://settings/search,
+ * but Google is still chosen by default. + * but Google is still chosen by default.
+ * I did not understand this code really well, probably it calculates the distance + * Removed code calculated the distance between 0 and Google's position
+ * between 0 and Google's position. So, as a hack, assume that yandex_ru + * and assign that position to default_search_provider_index,
+ * is the first in that list (this patch made it be the first) to force the first element + * so that Google still was the default search engine.
+ * of engine_RU[] to become the real 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) *default_search_provider_index = 0;
+ if (default_search_provider_index && (is_russian == 0)) { return t_urls;
+ *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; });
-- --
2.35.2 2.35.2