From 197a86bd50560694a0cb6336e128136f2fed8ce4 Mon Sep 17 00:00:00 2001 From: tigro Date: Wed, 24 Jan 2024 13:28:09 +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 +- .../new_tab_page/realbox/realbox.html | 7 +++++ 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 | 21 +++++++------- .../search_engines/template_url_data_util.cc | 6 +++- .../template_url_prepopulate_data.cc | 28 +++++++++++++++---- 21 files changed, 117 insertions(+), 36 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 6ac137571b..5eec7833a7 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7544,13 +7544,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 c82dbe7a73..8e7bc894ce 100644 --- a/chrome/app/resources/generated_resources_be.xtb +++ b/chrome/app/resources/generated_resources_be.xtb @@ -9111,7 +9111,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 e160c2b056..5d57515d3c 100644 --- a/chrome/app/resources/generated_resources_en-GB.xtb +++ b/chrome/app/resources/generated_resources_en-GB.xtb @@ -9126,7 +9126,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 ca6e7e7f07..d0efd93524 100644 --- a/chrome/app/resources/generated_resources_ru.xtb +++ b/chrome/app/resources/generated_resources_ru.xtb @@ -9117,7 +9117,7 @@ Создайте резервную копию данных и используйте их на любом устройстве. Чтобы быстро переключаться на этот профиль, создайте ярлык на рабочем столе Подключите мышь или клавиатуру. Если вы используете устройства Bluetooth, убедитесь, что они готовы к подключению. -Ищите по изображениям с Google Объективом +Ищите по изображениям Google заблокировал установку потенциально опасной программы (). Обратное направление прокрутки с помощью сенсорной панели Подписывание коммерческого кода Microsoft diff --git a/chrome/app/resources/generated_resources_uk.xtb b/chrome/app/resources/generated_resources_uk.xtb index 014fe3f9ae..711822ff45 100644 --- a/chrome/app/resources/generated_resources_uk.xtb +++ b/chrome/app/resources/generated_resources_uk.xtb @@ -9131,7 +9131,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 @@