Yandex still was not the default search engine

This commit is contained in:
Mikhail Novosyolov 2022-06-04 15:55:43 +03:00
parent 9c40a479c6
commit 276c8b0335

View file

@ -1,4 +1,4 @@
From b6bcaa2f6f16d65e0fffaefc6de2e94ad5780f76 Mon Sep 17 00:00:00 2001
From 87a4a1ad7c32138dd2d87066417bddc63cbf7619 Mon Sep 17 00:00:00 2001
From: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Date: Sun, 29 May 2022 22:31:21 +0300
Subject: [PATCH] Yandex as default search engine
@ -8,15 +8,19 @@ Quality of google.ru search results seems to be degradating a bit.
I understand that Google develops Chromium, and so it would be fair if they got some money from adverstisment,
but, firstly, they have themselves stopped all ads in Russia,
secondly, influnce of Google is a bad thing because they take part in the information war.
secondly, influnce of Google is a bad thing because they have to take part in the information war.
The patch "Functional new tab page with non-Google search engines" makes chrome://new-tab-page work.
Yandex's URL which is patched here does not allow to add new items in to the quick access list
and shows advertisment of the proprietary Yandex browser. I do not want users to install it.
A simpler solution would be changing chromium-default-config.json like
http://git.osmesh.ru/MOS/mos-panel-desktop/src/commit/0f02deea4f7da5ee186433cc71a7ba0193a8f52d/kometa-std-desktop-1.1/chromium.json
but it would make Yandex.ru be the default even for not Russian users.
---
components/search_engines/prepopulated_engines.json | 9 +++++----
.../search_engines/template_url_prepopulate_data.cc | 11 ++++++-----
2 files changed, 11 insertions(+), 9 deletions(-)
.../search_engines/prepopulated_engines.json | 9 ++++---
.../template_url_prepopulate_data.cc | 25 ++++++++++++++-----
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json
index 13572d4355..cc449a1ccb 100644
@ -67,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..8efd6fd2c5 100644
index e38343c221..9a421c6313 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -28,6 +28,7 @@ namespace {
@ -130,6 +134,27 @@ index e38343c221..8efd6fd2c5 100644
&yahoo_tr,
&bing,
&duckduckgo,
@@ -1381,7 +1382,19 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
t_urls = GetPrepopulationSetFromCountryID(
country_codes::GetCountryIDFromPrefs(prefs));
}
- if (default_search_provider_index) {
+ /* 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.
+ */
+ 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; });
--
2.35.2