From a7f4daf245fae8cbee949584a3d10d141c221a5a Mon Sep 17 00:00:00 2001 From: tigro Date: Thu, 19 Sep 2024 17:54:08 +0300 Subject: [PATCH] Added Yandex search bar as default on newtab and new-tab-page --- chrome/app/generated_resources.grd | 2 -- chrome/app/resources/generated_resources_be.xtb | 4 ++-- chrome/app/resources/generated_resources_en-GB.xtb | 2 +- chrome/app/resources/generated_resources_ru.xtb | 2 +- chrome/app/resources/generated_resources_uk.xtb | 2 +- chrome/browser/history/top_sites_factory.cc | 4 ++-- .../browser/resources/new_tab_page/lens_form.html | 1 + chrome/browser/resources/new_tab_page/lens_form.ts | 6 +++--- .../resources/new_tab_page/lens_upload_dialog.css | 2 +- .../resources/new_tab_page/lens_upload_dialog.html | 8 ++++---- chrome/browser/resources/new_tab_page/logo.css | 5 +---- chrome/browser/resources/new_tab_page/logo.ts | 2 +- chrome/browser/search/search.cc | 7 +++++++ chrome/browser/search/search.h | 2 ++ .../ui/webui/new_tab_page/new_tab_page_ui.cc | 5 +++++ components/search/search.cc | 14 ++++++++++++++ components/search/search.h | 7 +++++++ components/search_engines/keyword_table.cc | 4 ++++ .../search_engines/prepopulated_engines.json | 11 ++++++----- .../search_engines/search_engine_countries-inc.cc | 9 +++++---- .../search_engines/template_url_data_util.cc | 6 +++++- .../template_url_prepopulate_data.cc | 9 ++++++++- .../cr_components/searchbox/searchbox.html | 7 +++++++ 23 files changed, 88 insertions(+), 33 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 47cecfd278..024a9dc2f6 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7698,10 +7698,8 @@ Keep your key file in a safe place. You will need it to create new versions of y - Search Google or type a URL - Search Google Add to your search diff --git a/chrome/app/resources/generated_resources_be.xtb b/chrome/app/resources/generated_resources_be.xtb index 03dc88027c..1f056930cd 100644 --- a/chrome/app/resources/generated_resources_be.xtb +++ b/chrome/app/resources/generated_resources_be.xtb @@ -9816,7 +9816,7 @@ Стварайце рэзервовыя копіі сваіх даных, каб іх можна было выкарыстоўваць на іншых прыладах Стварыце ярлык на працоўным стале прылады, каб мець прамы доступ да гэтага профілю Падключыце клавіятуру або мыш. Калі вы выкарыстоўваеце прылады з Bluetooth, упэўніцеся, што яны гатовыя да спалучэння. -Шукайце відарысы з дапамогай Google Аб’ектыва +Шукайце відарысы У Google пашырэнне "" абазначана як шкоднае. Яго ўсталяванне было прадухілена Адваротная прагортка сэнсарнай панэллю Камерцыйнае падпісванне кода ў Microsoft @@ -11578,4 +11578,4 @@ Пры наведванні сайтаў яны будуць аўтаматычна ўлічваць гэту наладу. Звычайна сайты адпраўляюць апавяшчэнні, каб паведаміць вам пра экстранныя навіны або новыя паведамленні ў чаце. Каб выкарыстоўваць функцыю сінхранізацыі параметраў Wi-Fi, уключыце Сінхранізацыю Chrome. Даведацца больш Пра&верыць - \ No newline at end of file + diff --git a/chrome/app/resources/generated_resources_en-GB.xtb b/chrome/app/resources/generated_resources_en-GB.xtb index f283ab5ede..5d7368f6e7 100644 --- a/chrome/app/resources/generated_resources_en-GB.xtb +++ b/chrome/app/resources/generated_resources_en-GB.xtb @@ -9827,7 +9827,7 @@ Keep your key file in a safe place. You will need it to create new versions of y Back up your stuff and use it on any device Create a desktop shortcut on your device to access directly to this profile Connect a keyboard or mouse. If you are using Bluetooth devices, make sure that your devices are ready to pair. -Search any image with Google Lens +Search any image Google has flagged '' as malicious, and installation has been prevented Touchpad reverse scrolling Microsoft Commercial Code Signing diff --git a/chrome/app/resources/generated_resources_ru.xtb b/chrome/app/resources/generated_resources_ru.xtb index 2cea179a09..60a3fd18a2 100644 --- a/chrome/app/resources/generated_resources_ru.xtb +++ b/chrome/app/resources/generated_resources_ru.xtb @@ -9820,7 +9820,7 @@ Создайте резервную копию данных и используйте их на любом устройстве. Чтобы быстро переключаться на этот профиль, создайте ярлык на рабочем столе Подключите мышь или клавиатуру. Если вы используете устройства Bluetooth, убедитесь, что они готовы к подключению. -Ищите по изображениям с Google Объективом +Ищите по изображениям Google заблокировал установку потенциально опасной программы (). Обратное направление прокрутки с помощью сенсорной панели Подписывание коммерческого кода Microsoft diff --git a/chrome/app/resources/generated_resources_uk.xtb b/chrome/app/resources/generated_resources_uk.xtb index 2579b09b79..83edc733cb 100644 --- a/chrome/app/resources/generated_resources_uk.xtb +++ b/chrome/app/resources/generated_resources_uk.xtb @@ -9830,7 +9830,7 @@ Створюйте резервні копії даних і використовуйте їх на будь-якому пристрої Створити ярлик на робочому столі, щоб відразу переходити до цього профілю Підключіть клавіатуру або мишу. Якщо ви користуєтеся пристроями з Bluetooth, переконайтеся, що вони готові до підключення. -Шукайте будь-яке зображення через Google Об’єктив +Шукайте будь-яке зображення Система Google позначила розширення як шкідливе та заборонила встановлення Зворотне прокручування на сенсорній панелі Підписування комерційного коду Microsoft diff --git a/chrome/browser/history/top_sites_factory.cc b/chrome/browser/history/top_sites_factory.cc index cd1caf3f41..5f0b99b14f 100644 --- a/chrome/browser/history/top_sites_factory.cc +++ b/chrome/browser/history/top_sites_factory.cc @@ -59,7 +59,7 @@ struct RawPrepopulatedPage { // roughly match favicon). }; -#if !BUILDFLAG(IS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) && 0 // no prepopulated // Android does not use prepopulated pages. const RawPrepopulatedPage kRawPrepopulatedPages[] = { { @@ -74,7 +74,7 @@ const RawPrepopulatedPage kRawPrepopulatedPages[] = { void InitializePrepopulatedPageList( Profile* profile, history::PrepopulatedPageList* prepopulated_pages) { -#if !BUILDFLAG(IS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) && 0 // no prepopulated DCHECK(prepopulated_pages); PrefService* pref_service = profile->GetPrefs(); bool hide_web_store_icon = diff --git a/chrome/browser/resources/new_tab_page/lens_form.html b/chrome/browser/resources/new_tab_page/lens_form.html index 72bd92c5ab..2604d9c0dd 100644 --- a/chrome/browser/resources/new_tab_page/lens_form.html +++ b/chrome/browser/resources/new_tab_page/lens_form.html @@ -11,6 +11,7 @@
+ diff --git a/chrome/browser/resources/new_tab_page/lens_form.ts b/chrome/browser/resources/new_tab_page/lens_form.ts index cc89f05912..020eb1413d 100644 --- a/chrome/browser/resources/new_tab_page/lens_form.ts +++ b/chrome/browser/resources/new_tab_page/lens_form.ts @@ -11,14 +11,14 @@ import {getCss} from './lens_form.css.js'; import {getHtml} from './lens_form.html.js'; /** Lens service endpoint for the Upload by File action. */ -const SCOTTY_UPLOAD_FILE_ACTION: string = 'https://lens.google.com/upload'; -const DIRECT_UPLOAD_FILE_ACTION: string = 'https://lens.google.com/v3/upload'; +const SCOTTY_UPLOAD_FILE_ACTION: string = 'https://yandex.ru/images/search'; +const DIRECT_UPLOAD_FILE_ACTION: string = 'https://yandex.ru/images/search'; /** Entrypoint for the upload by file action. */ const UPLOAD_FILE_ENTRYPOINT: string = 'cntpubb'; /** Lens service endpoint for the Upload by URL action. */ -const UPLOAD_BY_URL_ACTION: string = 'https://lens.google.com/uploadbyurl'; +const UPLOAD_BY_URL_ACTION: string = 'https://yandex.ru/images/search'; /** Entrypoint for the upload by url action. */ const UPLOAD_URL_ENTRYPOINT: string = 'cntpubu'; diff --git a/chrome/browser/resources/new_tab_page/lens_upload_dialog.css b/chrome/browser/resources/new_tab_page/lens_upload_dialog.css index 2f53948285..422291d042 100644 --- a/chrome/browser/resources/new_tab_page/lens_upload_dialog.css +++ b/chrome/browser/resources/new_tab_page/lens_upload_dialog.css @@ -109,7 +109,7 @@ display: flex; flex-direction: column; flex-grow: 1; - height: 280px; + height: 110px; padding: 20px; position: relative; width: 100%; diff --git a/chrome/browser/resources/new_tab_page/lens_upload_dialog.html b/chrome/browser/resources/new_tab_page/lens_upload_dialog.html index 09f613f71a..69ee3a7366 100644 --- a/chrome/browser/resources/new_tab_page/lens_upload_dialog.html +++ b/chrome/browser/resources/new_tab_page/lens_upload_dialog.html @@ -22,7 +22,7 @@ ` : ''} ${this.isNormalOrError_ ? html` -
+
-
+
AddBoolean( + "googleLensForYandex", + search::DefaultSearchProviderIsYandex(profile)); + SearchboxHandler::SetupWebUIDataSource( source, profile, /*enable_voice_search=*/true, diff --git a/components/search/search.cc b/components/search/search.cc index a7167fae92..67d36156c5 100644 --- a/components/search/search.cc +++ b/components/search/search.cc @@ -34,4 +34,18 @@ bool TemplateURLIsGoogle(const TemplateURL* template_url, template_url->GetEngineType(search_terms_data) == SEARCH_ENGINE_GOOGLE; } +bool DefaultSearchProviderIsYandex( + const TemplateURLService* template_url_service) { + if (!template_url_service) + return false; + return TemplateURLIsYandex(template_url_service->GetDefaultSearchProvider(), + template_url_service->search_terms_data()); +} + +bool TemplateURLIsYandex(const TemplateURL* template_url, + const SearchTermsData& search_terms_data) { + return template_url != nullptr && + template_url->GetEngineType(search_terms_data) == SEARCH_ENGINE_YANDEX; +} + } // namespace search diff --git a/components/search/search.h b/components/search/search.h index 98572faa77..cfb6727848 100644 --- a/components/search/search.h +++ b/components/search/search.h @@ -22,6 +22,13 @@ bool DefaultSearchProviderIsGoogle( // Returns whether supplied template URL is Google template URL. bool TemplateURLIsGoogle(const TemplateURL* template_url, const SearchTermsData& search_terms_data); + +bool DefaultSearchProviderIsYandex( + const TemplateURLService* template_url_service); + +// Returns whether supplied template URL is Google template URL. +bool TemplateURLIsYandex(const TemplateURL* template_url, + const SearchTermsData& search_terms_data); } // namespace search #endif // COMPONENTS_SEARCH_SEARCH_H_ diff --git a/components/search_engines/keyword_table.cc b/components/search_engines/keyword_table.cc index c88f019f8d..85afef9757 100644 --- a/components/search_engines/keyword_table.cc +++ b/components/search_engines/keyword_table.cc @@ -173,7 +173,9 @@ void BindURLToStatement(const TemplateURLData& data, s->BindString(starting_column + 16, data.search_url_post_params); s->BindString(starting_column + 17, data.suggestions_url_post_params); s->BindString(starting_column + 18, data.image_url_post_params); +#if 0 // Disable new tab overriding by search engines s->BindString(starting_column + 19, data.new_tab_url); +#endif s->BindTime(starting_column + 20, data.last_visited); s->BindBool(starting_column + 21, data.created_from_play_api); s->BindInt(starting_column + 22, static_cast(data.is_active)); @@ -541,7 +543,9 @@ bool KeywordTable::GetKeywordDataFromStatement(sql::Statement& s, data->SetURL(s.ColumnString(4)); data->suggestions_url = s.ColumnString(10); data->image_url = s.ColumnString(16); +#if 0 // Disable new tab overriding by search engines data->new_tab_url = s.ColumnString(20); +#endif data->search_url_post_params = s.ColumnString(17); data->suggestions_url_post_params = s.ColumnString(18); data->image_url_post_params = s.ColumnString(19); diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json index 2036ba59e6..5236f359f7 100644 --- a/components/search_engines/prepopulated_engines.json +++ b/components/search_engines/prepopulated_engines.json @@ -838,7 +838,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 }, @@ -851,6 +851,7 @@ "suggest_url": "https://suggest.yandex.com/suggest-ff.cgi?part={searchTerms}&{google:cursorPosition}", "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, "regulatory_extensions": [ @@ -876,7 +877,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 }, @@ -890,7 +891,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 }, @@ -903,7 +904,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 }, @@ -917,7 +918,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 a4a0459de0..616430f279 100644 --- a/components/search_engines/search_engine_countries-inc.cc +++ b/components/search_engines/search_engine_countries-inc.cc @@ -38,6 +38,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}, @@ -173,8 +174,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}, @@ -498,9 +499,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}, }; @@ -594,8 +595,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}, @@ -1010,8 +1011,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}, diff --git a/components/search_engines/template_url_data_util.cc b/components/search_engines/template_url_data_util.cc index 18364f4324..6dc09f5e63 100644 --- a/components/search_engines/template_url_data_util.cc +++ b/components/search_engines/template_url_data_util.cc @@ -75,10 +75,12 @@ std::unique_ptr TemplateURLDataFromDictionary( if (string_value) { result->image_translate_url = *string_value; } +#if 0 // Disable new tab overriding by search engines string_value = dict.FindString(DefaultSearchManager::kNewTabURL); if (string_value) { result->new_tab_url = *string_value; } +#endif string_value = dict.FindString(DefaultSearchManager::kContextualSearchURL); if (string_value) { result->contextual_search_url = *string_value; @@ -343,7 +345,7 @@ std::unique_ptr TemplateURLDataFromPrepopulatedEngine( ToU16StringView(engine.name), ToU16StringView(engine.keyword), ToStringView(engine.search_url), ToStringView(engine.suggest_url), ToStringView(engine.image_url), ToStringView(engine.image_translate_url), - ToStringView(engine.new_tab_url), + ToStringView(nullptr), //ToStringView(engine.new_tab_url), ToStringView(engine.contextual_search_url), ToStringView(engine.logo_url), ToStringView(engine.doodle_url), ToStringView(engine.search_url_post_params), @@ -434,10 +436,12 @@ std::unique_ptr TemplateURLDataFromOverrideDictionary( if (string_value) { image_translate_url = *string_value; } +#if 0 // Disable new tab overriding by search engines string_value = engine_dict.FindString("new_tab_url"); if (string_value) { new_tab_url = *string_value; } +#endif string_value = engine_dict.FindString("contextual_search_url"); if (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 index 6c32b0e684..42e0d25e16 100644 --- a/components/search_engines/template_url_prepopulate_data.cc +++ b/components/search_engines/template_url_prepopulate_data.cc @@ -79,6 +79,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; } @@ -318,7 +325,7 @@ std::unique_ptr 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); } diff --git a/ui/webui/resources/cr_components/searchbox/searchbox.html b/ui/webui/resources/cr_components/searchbox/searchbox.html index 0df21dda3f..b0c38b2b8b 100644 --- a/ui/webui/resources/cr_components/searchbox/searchbox.html +++ b/ui/webui/resources/cr_components/searchbox/searchbox.html @@ -1,4 +1,11 @@