@ -1,31 +1,31 @@
From e25aad27626b4f623c4da97fff225f6b729eddd0 Mon Sep 17 00:00:00 2001
From e1462e35be07ce56385a274ca4f81812417dcce6 Mon Sep 17 00:00:00 2001
From: alexey <aberezhok@msvsphere-os.ru>
From: Alexey Berezhok <aberezhok@msvsphere-os.ru>
Date: Mon, 4 Dec 2023 15:59:21 +0300
Date: Tue, 5 Dec 2023 21:46:29 +0300
Subject: [PATCH] Added Yandex search bar as default on newtab and new-tab-page
Subject: [PATCH] Added Yandex search bar as default on newtab and new-tab-page
---
---
chrome/app/generated_resources.grd | 3 ---
chrome/app/generated_resources.grd | 3 --
.../app/resources/generated_resources_be.xtb | 2 +-
.../app/resources/generated_resources_be.xtb | 2 +-
.../resources/generated_resources_en-GB.xtb | 2 +-
.../resources/generated_resources_en-GB.xtb | 2 +-
.../app/resources/generated_resources_ru.xtb | 2 +-
.../app/resources/generated_resources_ru.xtb | 2 +-
.../app/resources/generated_resources_uk.xtb | 2 +-
.../app/resources/generated_resources_uk.xtb | 2 +-
chrome/browser/history/top_sites_factory.cc | 4 ++ --
chrome/browser/history/top_sites_factory.cc | 4 +--
.../resources/new_tab_page/lens_form.html | 1 +
.../resources/new_tab_page/lens_form.html | 1 +
.../resources/new_tab_page/lens_form.ts | 19 ++++++++++++++++++ -
.../resources/new_tab_page/lens_form.ts | 19 ++++++++++++-
.../new_tab_page/lens_upload_dialog.html | 10 +++++- ----
.../new_tab_page/lens_upload_dialog.html | 10 +++----
.../browser/resources/new_tab_page/logo.html | 5 +----
.../browser/resources/new_tab_page/logo.html | 5 +---
chrome/browser/resources/new_tab_page/logo.ts | 2 +-
chrome/browser/resources/new_tab_page/logo.ts | 2 +-
.../new_tab_page/realbox/realbox.html | 7 +++++++
.../new_tab_page/realbox/realbox.html | 7 +++++
chrome/browser/search/search.cc | 7 +++++++
chrome/browser/search/search.cc | 7 +++++
chrome/browser/search/search.h | 2 ++
chrome/browser/search/search.h | 2 ++
.../ui/webui/new_tab_page/new_tab_page_ui.cc | 5 +++++
.../ui/webui/new_tab_page/new_tab_page_ui.cc | 5 ++++
components/search/search.cc | 14 ++++++++++++++
components/search/search.cc | 14 ++++++++++
components/search/search.h | 7 +++++++
components/search/search.h | 7 +++++
components/search_engines/keyword_table.cc | 4 ++++
components/search_engines/keyword_table.cc | 4 +++
.../search_engines/prepopulated_engines.json | 10 +++++-----
.../search_engines/prepopulated_engines.json | 2 1 +++++++-- -----
.../search_engines/template_url_data_util.cc | 6 +++++ -
.../search_engines/template_url_data_util.cc | 6 +++-
.../template_url_prepopulate_data.cc | 16 +++++++++++++++ -
.../template_url_prepopulate_data.cc | 28 +++++++++++++++--- -
21 files changed, 103 insertions(+), 27 deletions(-)
21 files changed, 117 insertions(+), 36 deletions(-)
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 0b10daa9ce..3c794026c7 100644
index 0b10daa9ce..3c794026c7 100644
@ -421,10 +421,19 @@ index ad6afc9ee4..d28ac27862 100644
data->suggestions_url_post_params = s.ColumnString(18);
data->suggestions_url_post_params = s.ColumnString(18);
data->image_url_post_params = s.ColumnString(19);
data->image_url_post_params = s.ColumnString(19);
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 eded2b55e1 ..844fd0ce19 100644
index 8ab6a40d2e ..844fd0ce19 100644
--- a/components/search_engines/prepopulated_engines.json
--- a/components/search_engines/prepopulated_engines.json
+++ b/components/search_engines/prepopulated_engines.json
+++ b/components/search_engines/prepopulated_engines.json
@@ -648,7 +648,7 @@
@@ -639,7 +639,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
},
@@ -648,10 +648,11 @@
"name": "Yandex",
"name": "Yandex",
"keyword": "yandex.com",
"keyword": "yandex.com",
"favicon_url": "https://yastatic.net/lego/_/rBTjd6UOPk5913OSn5ZQVYMTQWQ.ico",
"favicon_url": "https://yastatic.net/lego/_/rBTjd6UOPk5913OSn5ZQVYMTQWQ.ico",
@ -433,7 +442,11 @@ index eded2b55e1..844fd0ce19 100644
"suggest_url": "https://suggest.yandex.com/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}&uil=en&v=3&sn=5",
"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": "https://yandex.com/images/search?rpt=imageview",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
@@ -662,7 +662,7 @@
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -661,11 +662,11 @@
"keyword": "yandex.kz",
"keyword": "yandex.kz",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
@ -442,7 +455,12 @@ index eded2b55e1..844fd0ce19 100644
"suggest_url": "https://suggest.yandex.kz/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"suggest_url": "https://suggest.yandex.kz/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.kz/images/search/?rpt=imageview",
"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",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
@@ -676,7 +676,7 @@
- "new_tab_url": "https://www.yandex.kz/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -675,11 +676,11 @@
"keyword": "yandex.ru",
"keyword": "yandex.ru",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
@ -451,7 +469,12 @@ index eded2b55e1..844fd0ce19 100644
"suggest_url": "https://suggest.yandex.ru/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"suggest_url": "https://suggest.yandex.ru/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.ru/images/search/?rpt=imageview",
"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",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
@@ -689,7 +689,7 @@
- "new_tab_url": "https://www.yandex.ru/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -688,11 +689,11 @@
"name": "Yandex",
"name": "Yandex",
"keyword": "yandex.com.tr",
"keyword": "yandex.com.tr",
"favicon_url": "https://yastatic.net/lego/_/rBTjd6UOPk5913OSn5ZQVYMTQWQ.ico",
"favicon_url": "https://yastatic.net/lego/_/rBTjd6UOPk5913OSn5ZQVYMTQWQ.ico",
@ -460,7 +483,12 @@ index eded2b55e1..844fd0ce19 100644
"suggest_url": "https://suggest.yandex.com.tr/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"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": "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",
"image_url_post_params": "upfile={google:imageThumbnail},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight},prg=1",
@@ -703,7 +703,7 @@
- "new_tab_url": "https://www.yandex.com.tr/chrome/newtab",
+ "new_tab_url": "chrome://new-tab-page",
"type": "SEARCH_ENGINE_YANDEX",
"id": 15
},
@@ -702,11 +703,11 @@
"keyword": "yandex.ua",
"keyword": "yandex.ua",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
@ -469,6 +497,11 @@ index eded2b55e1..844fd0ce19 100644
"suggest_url": "https://suggest.yandex.ua/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"suggest_url": "https://suggest.yandex.ua/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}",
"image_url": "https://yandex.ua/images/search/?rpt=imageview",
"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",
"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/template_url_data_util.cc b/components/search_engines/template_url_data_util.cc
diff --git a/components/search_engines/template_url_data_util.cc b/components/search_engines/template_url_data_util.cc
index 82d054944a..13d2aa704e 100644
index 82d054944a..13d2aa704e 100644
--- a/components/search_engines/template_url_data_util.cc
--- a/components/search_engines/template_url_data_util.cc
@ -509,10 +542,59 @@ index 82d054944a..13d2aa704e 100644
if (string_value) {
if (string_value) {
contextual_search_url = *string_value;
contextual_search_url = *string_value;
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 b544a89951 ..3f53afda71 100644
index 492a908ed6 ..3f53afda71 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
@@ -1681,6 +1681,12 @@ GetPrepopulatedEnginesForEeaRegionCountries(int country_id,
@@ -56,6 +56,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},
@@ -209,8 +210,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},
@@ -597,9 +598,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},
};
@@ -702,8 +703,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},
@@ -1172,8 +1173,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},
@@ -1680,6 +1681,12 @@ GetPrepopulatedEnginesForEeaRegionCountries(int country_id,
current_number_of_engines++;
current_number_of_engines++;
}
}
@ -525,26 +607,27 @@ index b544a89951..3f53afda71 100644
return t_urls;
return t_urls;
}
}
@@ -177 5,6 +1781,14 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
@@ -177 4,12 +1781,23 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
}
}
}
}
}
}
+
+
+ if (default_search_provider_index) {
if (default_search_provider_index) {
+ const auto itr =
const auto itr =
- base::ranges::find(t_urls, google.id, &TemplateURLData::prepopulate_id);
+ base::ranges::find(t_urls, yandex_ru.id, &TemplateURLData::prepopulate_id);
+ base::ranges::find(t_urls, yandex_ru.id, &TemplateURLData::prepopulate_id);
+ *default_search_provider_index =
*default_search_provider_index =
+ itr == t_urls.end() ? 0 : std::distance(t_urls.begin(), itr);
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.
@@ -1783,7 +1797,7 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
+ * Removed code calculated the distance between 0 and Google's position
* so that Google still was the default search engine.
+ * and assign that position to default_search_provider_index,
* Instead, just use the first search engine as the default one.
+ * so that Google still was the default search engine.
*/
+ * Instead, just use the first search engine as the default one.
- if (default_search_provider_index) *default_search_provider_index = 0;
+ */
+ //if (default_search_provider_index) *default_search_provider_index = 0;
+ //if (default_search_provider_index) *default_search_provider_index = 0;
return t_urls;
return t_urls;
}
}