You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chromium/SOURCES/0001-Yandex-as-default-sear...

162 lines
7.6 KiB

From ea76dbff544332f6d8d4d3b5629edd79269613ec Mon Sep 17 00:00:00 2001
From: tigro <tigro@msvsphere-os.ru>
Date: Thu, 25 Jul 2024 18:32:03 +0300
Subject: [PATCH] Yandex as default search engine
---
components/search_engines/prepopulated_engines.json | 11 ++++++-----
.../search_engines/search_engine_countries-inc.cc | 11 ++++++-----
.../search_engines/template_url_prepopulate_data.cc | 9 ++++++++-
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json
index cdb763081d..d4b06432f2 100644
--- a/components/search_engines/prepopulated_engines.json
+++ b/components/search_engines/prepopulated_engines.json
@@ -665,7 +665,7 @@
"suggest_url": "https://suggest.yandex.by/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.by/images/search/?rpt=imageview",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
- "new_tab_url": "https://www.yandex.by/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -678,6 +678,7 @@
"suggest_url": "https://suggest.yandex.com/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}&uil=en&v=3&sn=5",
"image_url": "https://yandex.com/images/search?rpt=imageview",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -691,7 +692,7 @@
"suggest_url": "https://suggest.yandex.kz/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.kz/images/search/?rpt=imageview",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
- "new_tab_url": "https://www.yandex.kz/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -705,7 +706,7 @@
"suggest_url": "https://suggest.yandex.ru/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.ru/images/search/?rpt=imageview",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
- "new_tab_url": "https://www.yandex.ru/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -718,7 +719,7 @@
"suggest_url": "https://suggest.yandex.com.tr/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.com.tr/gorsel/search?rpt=imageview",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
- "new_tab_url": "https://www.yandex.com.tr/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -732,7 +733,7 @@
"suggest_url": "https://suggest.yandex.ua/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.ua/images/search/?rpt=imageview",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
- "new_tab_url": "https://www.yandex.ua/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
diff --git a/components/search_engines/search_engine_countries-inc.cc b/components/search_engines/search_engine_countries-inc.cc
index 6c8ffb9e7d..4c99be8769 100644
--- a/components/search_engines/search_engine_countries-inc.cc
+++ b/components/search_engines/search_engine_countries-inc.cc
@@ -33,6 +33,7 @@ struct EngineAndTier {
// Default (for countries with no better engine set)
constexpr EngineAndTier engines_default[] = {
+ {SearchEngineTier::kTopEngines, &yandex_com},
{SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &bing},
{SearchEngineTier::kTopEngines, &yahoo},
@@ -169,8 +170,8 @@ constexpr EngineAndTier engines_BR[] = {
// Belarus
constexpr EngineAndTier engines_BY[] = {
- {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &yandex_by},
+ {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &bing},
{SearchEngineTier::kTopEngines, &duckduckgo},
{SearchEngineTier::kTopEngines, &mail_ru},
@@ -494,9 +495,9 @@ constexpr EngineAndTier engines_IN[] = {
// Iraq
constexpr EngineAndTier engines_IQ[] = {
+ {SearchEngineTier::kTopEngines, &yandex_tr},
{SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &bing},
- {SearchEngineTier::kTopEngines, &yandex_tr},
{SearchEngineTier::kTopEngines, &yahoo},
{SearchEngineTier::kTopEngines, &duckduckgo},
};
@@ -590,8 +591,8 @@ constexpr EngineAndTier engines_KW[] = {
// Kazakhstan
constexpr EngineAndTier engines_KZ[] = {
- {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &yandex_kz},
+ {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &bing},
{SearchEngineTier::kTopEngines, &mail_ru},
{SearchEngineTier::kTopEngines, &yahoo},
@@ -1007,8 +1008,8 @@ constexpr EngineAndTier engines_TN[] = {
// Turkey
constexpr EngineAndTier engines_TR[] = {
- {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &yandex_tr},
+ {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &yahoo_tr},
{SearchEngineTier::kTopEngines, &bing},
{SearchEngineTier::kTopEngines, &duckduckgo},
@@ -1043,8 +1044,8 @@ constexpr EngineAndTier engines_TZ[] = {
// Ukraine
constexpr EngineAndTier engines_UA[] = {
- {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &yandex_ru},
+ {SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &bing},
{SearchEngineTier::kTopEngines, &duckduckgo},
{SearchEngineTier::kTopEngines, &yahoo},
diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc
index 3a7798c2d1..60959c3e24 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -81,6 +81,13 @@ GetPrepopulatedEnginesForEeaRegionCountries(int country_id,
std::shuffle(t_urls.begin(), t_urls.end(), generator);
CHECK_LE(t_urls.size(), kMaxEeaPrepopulatedEngines);
+
+ const auto itr =
+ base::ranges::find(t_urls, yandex_ru.id, &TemplateURLData::prepopulate_id);
+ if (itr == t_urls.end()) {
+ t_urls.push_back(TemplateURLDataFromPrepopulatedEngine(yandex_com));
+ }
+
return t_urls;
}
@@ -325,7 +332,7 @@ std::unique_ptr<TemplateURLData> GetPrepopulatedFallbackSearch(
PrefService* prefs,
search_engines::SearchEngineChoiceService* search_engine_choice_service) {
return FindPrepopulatedEngineInternal(prefs, search_engine_choice_service,
- google.id,
+ yandex_ru.id,
/*use_first_as_fallback=*/true);
}
--
2.45.2