From e25aad27626b4f623c4da97fff225f6b729eddd0 Mon Sep 17 00:00:00 2001 From: alexey Date: Mon, 4 Dec 2023 15:59:21 +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 | 10 +++++----- .../search_engines/template_url_data_util.cc | 6 +++++- .../template_url_prepopulate_data.cc | 16 +++++++++++++++- 21 files changed, 103 insertions(+), 27 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 0b10daa9ce..3c794026c7 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7370,13 +7370,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 fec3374f62..643daad979 100644 --- a/chrome/app/resources/generated_resources_be.xtb +++ b/chrome/app/resources/generated_resources_be.xtb @@ -8766,7 +8766,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 7605601a0b..ae095dca6d 100644 --- a/chrome/app/resources/generated_resources_en-GB.xtb +++ b/chrome/app/resources/generated_resources_en-GB.xtb @@ -8779,7 +8779,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 a4c91939c8..e4083a4b44 100644 --- a/chrome/app/resources/generated_resources_ru.xtb +++ b/chrome/app/resources/generated_resources_ru.xtb @@ -8770,7 +8770,7 @@ Создайте резервную копию данных и используйте их на любом устройстве. Чтобы быстро переключаться на этот профиль, создайте ярлык на рабочем столе Подключите мышь или клавиатуру. Если вы используете устройства Bluetooth, убедитесь, что они готовы к подключению. -Ищите по изображениям с Google Объективом +Ищите по изображениям Google заблокировал установку потенциально опасной программы (). Обратное направление прокрутки с помощью сенсорной панели Подписывание коммерческого кода Microsoft diff --git a/chrome/app/resources/generated_resources_uk.xtb b/chrome/app/resources/generated_resources_uk.xtb index db17abebfc..8c3bdccd64 100644 --- a/chrome/app/resources/generated_resources_uk.xtb +++ b/chrome/app/resources/generated_resources_uk.xtb @@ -8784,7 +8784,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 b35fd09415..0e92d175b8 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 aaf2da3675..cd71c76b08 100644 --- a/chrome/browser/resources/new_tab_page/lens_form.ts +++ b/chrome/browser/resources/new_tab_page/lens_form.ts @@ -11,11 +11,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. */ @@ -73,6 +76,7 @@ export class LensFormElement extends PolymerElement { } static get properties() { + let isYandex = loadTimeData.getBoolean('googleLensForYandex'); return { supportedFileTypes_: { type: String, @@ -98,7 +102,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_: { @@ -116,6 +120,11 @@ export class LensFormElement extends PolymerElement { readOnly: true, value: loadTimeData.getString('realboxLensVariations'), }, + useYandexForPics_: { + type: Boolean, + readOnly: true, + value: isYandex, + }, }; } @@ -125,6 +134,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(); @@ -152,6 +162,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; @@ -193,8 +208,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 71e6ef74b9..8e787ee6c7 100644 --- a/chrome/browser/resources/new_tab_page/lens_upload_dialog.html +++ b/chrome/browser/resources/new_tab_page/lens_upload_dialog.html @@ -98,7 +98,7 @@ display: flex; flex-direction: column; flex-grow: 1; - height: 280px; + height: 110px; padding: 20px; position: relative; width: 100%; @@ -364,7 +364,7 @@