From 3561cffa415fecb09df3549578095eef6e07f64f Mon Sep 17 00:00:00 2001 From: tigro Date: Tue, 23 Apr 2024 14:43:39 +0300 Subject: [PATCH] Added Yandex search bar as default on newtab and new-tab-page --- chrome/app/generated_resources.grd | 3 --- .../app/resources/generated_resources_be.xtb | 2 +- .../resources/generated_resources_en-GB.xtb | 2 +- .../app/resources/generated_resources_ru.xtb | 2 +- .../app/resources/generated_resources_uk.xtb | 2 +- chrome/browser/history/top_sites_factory.cc | 4 ++-- .../resources/new_tab_page/lens_form.html | 1 + .../resources/new_tab_page/lens_form.ts | 19 ++++++++++++++++++- .../new_tab_page/lens_upload_dialog.html | 10 +++++----- .../browser/resources/new_tab_page/logo.html | 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_engine_countries-inc.cc | 9 +++++---- .../search_engines/template_url_data_util.cc | 6 +++++- .../template_url_prepopulate_data.cc | 15 +++++++++------ .../cr_components/omnibox/realbox.html | 7 +++++++ 22 files changed, 103 insertions(+), 36 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index ceabbced0f..ae958b0be4 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7609,13 +7609,10 @@ Keep your key file in a safe place. You will need it to create new versions of y - Search Google or type URL - Search Google or type a URL - Search Google Add shortcut diff --git a/chrome/app/resources/generated_resources_be.xtb b/chrome/app/resources/generated_resources_be.xtb index 4459670e32..235c44b353 100644 --- a/chrome/app/resources/generated_resources_be.xtb +++ b/chrome/app/resources/generated_resources_be.xtb @@ -9170,7 +9170,7 @@ Стварайце рэзервовыя копіі сваіх даных, каб іх можна было выкарыстоўваць на іншых прыладах Стварыце ярлык на працоўным стале прылады, каб мець прамы доступ да гэтага профілю Падключыце клавіятуру або мыш. Калі вы выкарыстоўваеце прылады з Bluetooth, упэўніцеся, што яны гатовыя да спалучэння. -Шукайце відарысы з дапамогай Google Аб'ектыва +Шукайце відарысы У Google пашырэнне "" абазначана як шкоднае. Яго ўсталяванне было прадухілена Адваротная прагортка сэнсарнай панэллю Камерцыйнае падпісванне кода ў Microsoft diff --git a/chrome/app/resources/generated_resources_en-GB.xtb b/chrome/app/resources/generated_resources_en-GB.xtb index 8641bff7d6..276fdce88e 100644 --- a/chrome/app/resources/generated_resources_en-GB.xtb +++ b/chrome/app/resources/generated_resources_en-GB.xtb @@ -9186,7 +9186,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 3445b888b2..6858be016c 100644 --- a/chrome/app/resources/generated_resources_ru.xtb +++ b/chrome/app/resources/generated_resources_ru.xtb @@ -9177,7 +9177,7 @@ Создайте резервную копию данных и используйте их на любом устройстве. Чтобы быстро переключаться на этот профиль, создайте ярлык на рабочем столе Подключите мышь или клавиатуру. Если вы используете устройства Bluetooth, убедитесь, что они готовы к подключению. -Ищите по изображениям с Google Объективом +Ищите по изображениям Google заблокировал установку потенциально опасной программы (). Обратное направление прокрутки с помощью сенсорной панели Подписывание коммерческого кода Microsoft diff --git a/chrome/app/resources/generated_resources_uk.xtb b/chrome/app/resources/generated_resources_uk.xtb index 225ec54852..66e1fbe735 100644 --- a/chrome/app/resources/generated_resources_uk.xtb +++ b/chrome/app/resources/generated_resources_uk.xtb @@ -9191,7 +9191,7 @@ Створюйте резервні копії даних і використовуйте їх на будь-якому пристрої Створити ярлик на робочому столі, щоб відразу переходити до цього профілю Підключіть клавіатуру або мишу. Якщо ви користуєтеся пристроями з Bluetooth, переконайтеся, що вони готові до підключення. -Шукайте будь-яке зображення через Google Об’єктив +Шукайте будь-яке зображення Система Google позначила розширення як шкідливе та заборонила встановлення Зворотне прокручування на сенсорній панелі Підписування комерційного коду Microsoft diff --git a/chrome/browser/history/top_sites_factory.cc b/chrome/browser/history/top_sites_factory.cc index 55d07e905b..70c6e15cfb 100644 --- a/chrome/browser/history/top_sites_factory.cc +++ b/chrome/browser/history/top_sites_factory.cc @@ -54,7 +54,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[] = { { @@ -69,7 +69,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 57c6387c7e..0f31a59767 100644 --- a/chrome/browser/resources/new_tab_page/lens_form.html +++ b/chrome/browser/resources/new_tab_page/lens_form.html @@ -18,6 +18,7 @@
+ diff --git a/chrome/browser/resources/new_tab_page/lens_form.ts b/chrome/browser/resources/new_tab_page/lens_form.ts index bf24f4c495..167b57bc5e 100644 --- a/chrome/browser/resources/new_tab_page/lens_form.ts +++ b/chrome/browser/resources/new_tab_page/lens_form.ts @@ -12,11 +12,14 @@ import {getTemplate} 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_YA: string = 'https://yandex.ru/images/search'; +const DIRECT_UPLOAD_FILE_ACTION_YA: 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_YA: string = 'https://yandex.ru/images/search'; const UPLOAD_BY_URL_ACTION: string = 'https://lens.google.com/uploadbyurl'; /** Entrypoint for the upload by url action. */ @@ -74,6 +77,7 @@ export class LensFormElement extends PolymerElement { } static get properties() { + let isYandex = loadTimeData.getBoolean('googleLensForYandex'); return { supportedFileTypes_: { type: String, @@ -99,7 +103,7 @@ export class LensFormElement extends PolymerElement { uploadUrlAction_: { type: String, readOnly: true, - value: UPLOAD_BY_URL_ACTION, + value: ((isYandex == true)?UPLOAD_BY_URL_ACTION_YA:UPLOAD_BY_URL_ACTION), }, uploadUrl_: String, uploadUrlEntrypoint_: { @@ -117,6 +121,11 @@ export class LensFormElement extends PolymerElement { readOnly: true, value: loadTimeData.getString('realboxLensVariations'), }, + useYandexForPics_: { + type: Boolean, + readOnly: true, + value: isYandex, + }, }; } @@ -126,6 +135,7 @@ export class LensFormElement extends PolymerElement { private startTime_: string|null = null; private clientData_: string; private useDirectUpload_: boolean; + private isYandexProp_: boolean = loadTimeData.getBoolean('googleLensForYandex'); openSystemFilePicker() { this.$.fileInput.click(); @@ -153,6 +163,11 @@ export class LensFormElement extends PolymerElement { } private async submitFile_(file: File) { + + if (this.isYandexProp_ == true) { + return; + } else { + if (!SUPPORTED_FILE_TYPES.includes(file.type)) { this.dispatchError_(LensErrorType.FILE_TYPE); return; @@ -194,8 +209,10 @@ export class LensFormElement extends PolymerElement { processedFile.imageWidth ? processedFile.imageWidth.toString() : ''); this.uploadFileAction_ = action.toString(); + this.dispatchLoading_(LensSubmitType.FILE); this.$.fileForm.submit(); + } } submitUrl(urlString: string) { 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 a6eb910711..703311b280 100644 --- a/chrome/browser/resources/new_tab_page/lens_upload_dialog.html +++ b/chrome/browser/resources/new_tab_page/lens_upload_dialog.html @@ -99,7 +99,7 @@ display: flex; flex-direction: column; flex-grow: 1; - height: 280px; + height: 110px; padding: 20px; position: relative; width: 100%; @@ -365,7 +365,7 @@