You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chromium/SOURCES/0001-Added-Yandex-search-ba...

638 lines
32 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

From cd262ed6e5143fde90e0f03d782815f87ad9d168 Mon Sep 17 00:00:00 2001
From: tigro <tigro@msvsphere-os.ru>
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 ef461fb3ce..838886d275 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7514,13 +7514,10 @@ Keep your key file in a safe place. You will need it to create new versions of y
<!-- NTP -->
<message name="IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT" desc="The text displayed in the fakebox (on the New Tab page) when it is empty, and Google is the default search engine.">
- Search Google or type URL
</message>
<message name="IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_MD" desc="The text displayed in the fakebox (on the New Tab page) when it is empty, Google is the default search engine, and the Material Design UI is enabled.">
- Search Google or type a URL
</message>
<message name="IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_SHORT" desc="The text displayed in the fakebox (on the New Tab page) when it is empty, Google is the default search engine, and short hint text is enabled.">
- Search Google
</message>
<message name="IDS_NTP_CUSTOM_LINKS_ADD_SHORTCUT_TOOLTIP" desc="The tooltip for adding a custom link shortcut. (On the New Tab Page)">
Add shortcut
diff --git a/chrome/app/resources/generated_resources_be.xtb b/chrome/app/resources/generated_resources_be.xtb
index 9e28f256f0..4c05572d7e 100644
--- a/chrome/app/resources/generated_resources_be.xtb
+++ b/chrome/app/resources/generated_resources_be.xtb
@@ -8979,7 +8979,7 @@
<translation id="8048728378294435881">Стварайце рэзервовыя копіі сваіх даных, каб іх можна было выкарыстоўваць на іншых прыладах</translation>
<translation id="8048977114738515028">Стварыце ярлык на працоўным стале прылады, каб мець прамы доступ да гэтага профілю</translation>
<translation id="8049029041626250638">Падключыце клавіятуру або мыш. Калі вы выкарыстоўваеце прылады з Bluetooth, упэўніцеся, што яны гатовыя да спалучэння.</translation>
-<translation id="8049122382261047457">Шукайце відарысы з дапамогай Google Аб'ектыва</translation>
+<translation id="8049122382261047457">Шукайце відарысы</translation>
<translation id="8049705080247101012">У Google пашырэнне "<ph name="EXTENSION_NAME" />" абазначана як шкоднае. Яго ўсталяванне было прадухілена</translation>
<translation id="8049948037269924837">Адваротная прагортка сэнсарнай панэллю</translation>
<translation id="8050038245906040378">Камерцыйнае падпісванне кода ў Microsoft</translation>
diff --git a/chrome/app/resources/generated_resources_en-GB.xtb b/chrome/app/resources/generated_resources_en-GB.xtb
index 400a5d3cd6..01925039b9 100644
--- a/chrome/app/resources/generated_resources_en-GB.xtb
+++ b/chrome/app/resources/generated_resources_en-GB.xtb
@@ -8994,7 +8994,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
<translation id="8048728378294435881">Back up your stuff and use it on any device</translation>
<translation id="8048977114738515028">Create a desktop shortcut on your device to access directly to this profile</translation>
<translation id="8049029041626250638">Connect a keyboard or mouse. If you are using Bluetooth devices, make sure that your devices are ready to pair.</translation>
-<translation id="8049122382261047457">Search any image with Google Lens</translation>
+<translation id="8049122382261047457">Search any image</translation>
<translation id="8049705080247101012">Google has flagged '<ph name="EXTENSION_NAME" />' as malicious, and installation has been prevented</translation>
<translation id="8049948037269924837">Touchpad reverse scrolling</translation>
<translation id="8050038245906040378">Microsoft Commercial Code Signing</translation>
diff --git a/chrome/app/resources/generated_resources_ru.xtb b/chrome/app/resources/generated_resources_ru.xtb
index 5a326f9534..6bdd77f1fc 100644
--- a/chrome/app/resources/generated_resources_ru.xtb
+++ b/chrome/app/resources/generated_resources_ru.xtb
@@ -8985,7 +8985,7 @@
<translation id="8048728378294435881">Создайте резервную копию данных и используйте их на любом устройстве.</translation>
<translation id="8048977114738515028">Чтобы быстро переключаться на этот профиль, создайте ярлык на рабочем столе</translation>
<translation id="8049029041626250638">Подключите мышь или клавиатуру. Если вы используете устройства Bluetooth, убедитесь, что они готовы к подключению.</translation>
-<translation id="8049122382261047457">Ищите по изображениям с Google Объективом</translation>
+<translation id="8049122382261047457">Ищите по изображениям</translation>
<translation id="8049705080247101012">Google заблокировал установку потенциально опасной программы (<ph name="EXTENSION_NAME" />).</translation>
<translation id="8049948037269924837">Обратное направление прокрутки с помощью сенсорной панели</translation>
<translation id="8050038245906040378">Подписывание коммерческого кода Microsoft</translation>
diff --git a/chrome/app/resources/generated_resources_uk.xtb b/chrome/app/resources/generated_resources_uk.xtb
index ecc3988cce..8e6e574e6f 100644
--- a/chrome/app/resources/generated_resources_uk.xtb
+++ b/chrome/app/resources/generated_resources_uk.xtb
@@ -8999,7 +8999,7 @@
<translation id="8048728378294435881">Створюйте резервні копії даних і використовуйте їх на будь-якому пристрої</translation>
<translation id="8048977114738515028">Створити ярлик на робочому столі, щоб відразу переходити до цього профілю</translation>
<translation id="8049029041626250638">Підключіть клавіатуру або мишу. Якщо ви користуєтеся пристроями з Bluetooth, переконайтеся, що вони готові до підключення.</translation>
-<translation id="8049122382261047457">Шукайте будь-яке зображення через Google Об’єктив</translation>
+<translation id="8049122382261047457">Шукайте будь-яке зображення</translation>
<translation id="8049705080247101012">Система Google позначила розширення <ph name="EXTENSION_NAME" /> як шкідливе та заборонила встановлення</translation>
<translation id="8049948037269924837">Зворотне прокручування на сенсорній панелі</translation>
<translation id="8050038245906040378">Підписування комерційного коду Microsoft</translation>
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 @@
<form id="urlForm"
action="[[uploadUrlAction_]]"
method="GET">
+ <input name="rpt" value="imageview"></input>
<input name="url" value="[[uploadUrl_]]"></input>
<input name="ep" value="[[uploadUrlEntrypoint_]]"></input>
<input name="hl" value="[[language_]]"></input>
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 @@
</template>
<!-- Normal state -->
<template is="dom-if" if="{{isNormalOrError_}}">
- <div class="drag-drop-title-container">
+ <!--<div class="drag-drop-title-container">
<div id="dragDropIllustration"></div>
<div class="drag-drop-title">
<span id="dragText">$i18n{lensSearchUploadDialogDragTitle}</span>
@@ -373,13 +373,13 @@
$i18n{lensSearchUploadDialogUploadFileTitle}
</span>
</div>
- </div>
+ </div>//-->
<div id="urlUploadContainer">
- <div id="sectionDivider">
+ <!--<div id="sectionDivider">
<div class="divider-line"></div>
<div id="orLabel">$i18n{lensSearchUploadDialogOrText}</div>
<div class="divider-line"></div>
- </div>
+ </div>//-->
<div id="inputContainer">
<input id="inputBox" autocomplete="false" autocorrect="false"
placeholder="$i18n{lensSearchUploadDialogTextPlaceholder}"
diff --git a/chrome/browser/resources/new_tab_page/logo.html b/chrome/browser/resources/new_tab_page/logo.html
index f1bf028553..1bc12e7588 100644
--- a/chrome/browser/resources/new_tab_page/logo.html
+++ b/chrome/browser/resources/new_tab_page/logo.html
@@ -23,10 +23,7 @@
}
:host([single-colored]) #logo {
- -webkit-mask-image: url(./icons/google_logo.svg);
- -webkit-mask-repeat: no-repeat;
- -webkit-mask-size: 100%;
- background-color: var(--ntp-logo-color);
+ background-image: url(./icons/google_logo.svg);
}
:host(:not([single-colored])) #logo {
diff --git a/chrome/browser/resources/new_tab_page/logo.ts b/chrome/browser/resources/new_tab_page/logo.ts
index 20a2a2aa1e..eab610aef8 100644
--- a/chrome/browser/resources/new_tab_page/logo.ts
+++ b/chrome/browser/resources/new_tab_page/logo.ts
@@ -256,7 +256,7 @@ export class LogoElement extends PolymerElement {
}
private computeShowLogo_(): boolean {
- return !!this.loaded_ && !this.showDoodle_;
+ return false; //!!this.loaded_ && !this.showDoodle_;
}
private computeShowDoodle_(): boolean {
diff --git a/chrome/browser/resources/new_tab_page/realbox/realbox.html b/chrome/browser/resources/new_tab_page/realbox/realbox.html
index a3114401e1..78fc32dadc 100644
--- a/chrome/browser/resources/new_tab_page/realbox/realbox.html
+++ b/chrome/browser/resources/new_tab_page/realbox/realbox.html
@@ -1,4 +1,11 @@
<style include="cr-icons">
+ #voiceSearchButton {
+ visibility: hidden;
+ }
+ #lensSearchButton {
+ visibility: visible;
+ }
+
:host {
--cr-realbox-height: 44px;
--cr-realbox-min-width: var(--ntp-search-box-width);
diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc
index 3e0db181ac..0843b2ef36 100644
--- a/chrome/browser/search/search.cc
+++ b/chrome/browser/search/search.cc
@@ -179,6 +179,8 @@ struct NewTabURLDetails {
#if BUILDFLAG(IS_ANDROID)
const GURL local_url;
+ #elif 1 // Always use built-in NTp page
+ const GURL local_url(chrome::kChromeUINewTabPageURL);
#else
const bool default_is_google = DefaultSearchProviderIsGoogle(profile);
const GURL local_url(default_is_google
@@ -245,6 +247,11 @@ bool DefaultSearchProviderIsGoogle(Profile* profile) {
TemplateURLServiceFactory::GetForProfile(profile));
}
+bool DefaultSearchProviderIsYandex(Profile* profile) {
+ return DefaultSearchProviderIsYandex(
+ TemplateURLServiceFactory::GetForProfile(profile));
+}
+
bool IsNTPOrRelatedURL(const GURL& url, Profile* profile) {
if (!url.is_valid()) {
return false;
diff --git a/chrome/browser/search/search.h b/chrome/browser/search/search.h
index c7ae65114f..5859d72731 100644
--- a/chrome/browser/search/search.h
+++ b/chrome/browser/search/search.h
@@ -21,6 +21,8 @@ namespace search {
// Returns whether Google is selected as the default search engine.
bool DefaultSearchProviderIsGoogle(Profile* profile);
+bool DefaultSearchProviderIsYandex(Profile* profile);
+
// Returns true if |url| corresponds to a New Tab page or its service worker.
bool IsNTPOrRelatedURL(const GURL& url, Profile* profile);
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
index d9b6c3500f..a2b1bfb9df 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/search/background/ntp_custom_background_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_provider_logos/logo_service_factory.h"
+#include "chrome/browser/search/search.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/themes/theme_service_factory.h"
@@ -621,6 +622,10 @@ content::WebUIDataSource* CreateAndAddNewTabPageUiHtmlSource(Profile* profile) {
source->AddBoolean("historyClustersModuleDiscountsEnabled",
base::FeatureList::IsEnabled(
ntp_features::kNtpHistoryClustersModuleDiscounts));
+
+ source->AddBoolean(
+ "googleLensForYandex",
+ search::DefaultSearchProviderIsYandex(profile));
webui::SetupChromeRefresh2023(source);
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 5e616ec8b2..f0ffa97e6b 100644
--- a/components/search_engines/keyword_table.cc
+++ b/components/search_engines/keyword_table.cc
@@ -170,7 +170,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<int>(data.is_active));
@@ -521,7 +523,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 9f4e01c1bf..4574d793d2 100644
--- a/components/search_engines/prepopulated_engines.json
+++ b/components/search_engines/prepopulated_engines.json
@@ -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",
"keyword": "yandex.com",
"favicon_url": "https://yastatic.net/lego/_/rBTjd6UOPk5913OSn5ZQVYMTQWQ.ico",
- "search_url": "https://yandex.com/search/?text={searchTerms}&from=os&clid=1836588",
+ "search_url": "https://yandex.com/search/?text={searchTerms}from=os&{yandex:referralID}",
"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_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
},
@@ -661,11 +662,11 @@
"keyword": "yandex.kz",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
- "search_url": "https://yandex.kz/{yandex:searchPath}?text={searchTerms}",
+ "search_url": "https://yandex.kz/{yandex:searchPath}?text={searchTerms}&from=os&{yandex:referralID}",
"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
},
@@ -675,11 +676,11 @@
"keyword": "yandex.ru",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
- "search_url": "https://yandex.ru/{yandex:searchPath}?text={searchTerms}&{yandex:referralID}",
+ "search_url": "https://yandex.ru/{yandex:searchPath}?text={searchTerms}&from=os&{yandex:referralID}",
"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
},
@@ -688,11 +689,11 @@
"name": "Yandex",
"keyword": "yandex.com.tr",
"favicon_url": "https://yastatic.net/lego/_/rBTjd6UOPk5913OSn5ZQVYMTQWQ.ico",
- "search_url": "https://www.yandex.com.tr/{yandex:searchPath}?text={searchTerms}",
+ "search_url": "https://www.yandex.com.tr/{yandex:searchPath}?text={searchTerms}&from=os&{yandex:referralID}",
"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
},
@@ -702,11 +703,11 @@
"keyword": "yandex.ua",
"favicon_url": "https://yastatic.net/lego/_/pDu9OWAQKB0s2J9IojKpiS_Eho.ico",
"logo_url": "https://storage.ape.yandex.net/get/browser/Doodles/yandex/drawable-xxhdpi/yandex.png",
- "search_url": "https://yandex.ua/{yandex:searchPath}?text={searchTerms}",
+ "search_url": "https://yandex.ua/{yandex:searchPath}?text={searchTerms}&from=os&{yandex:referralID}",
"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/template_url_data_util.cc b/components/search_engines/template_url_data_util.cc
index f81d966533..6188b52c47 100644
--- a/components/search_engines/template_url_data_util.cc
+++ b/components/search_engines/template_url_data_util.cc
@@ -71,10 +71,12 @@ std::unique_ptr<TemplateURLData> 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;
@@ -344,7 +346,7 @@ std::unique_ptr<TemplateURLData> TemplateURLDataFromPrepopulatedEngine(
ToStringPiece(engine.search_url), ToStringPiece(engine.suggest_url),
ToStringPiece(engine.image_url),
ToStringPiece(engine.image_translate_url),
- ToStringPiece(engine.new_tab_url),
+ base::StringPiece(), //ToStringPiece(engine.new_tab_url),
ToStringPiece(engine.contextual_search_url),
ToStringPiece(engine.logo_url), ToStringPiece(engine.doodle_url),
ToStringPiece(engine.search_url_post_params),
@@ -435,10 +437,12 @@ std::unique_ptr<TemplateURLData> 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 05845f86a6..e7473c1850 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -61,6 +61,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},
@@ -214,8 +215,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},
@@ -602,9 +603,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},
};
@@ -707,8 +708,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},
@@ -1177,8 +1178,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},
@@ -1692,6 +1693,12 @@ GetPrepopulatedEnginesForEeaRegionCountries(int country_id,
current_number_of_engines++;
}
+
+ 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;
}
@@ -1818,12 +1825,23 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
}
}
}
+
if (default_search_provider_index) {
const auto itr =
- base::ranges::find(t_urls, google.id, &TemplateURLData::prepopulate_id);
+ base::ranges::find(t_urls, yandex_ru.id, &TemplateURLData::prepopulate_id);
*default_search_provider_index =
itr == t_urls.end() ? 0 : std::distance(t_urls.begin(), itr);
}
+
+ /* Making yandex_ru be the first in "const PrepopulatedEngine* const engines_RU[]"
+ * makes it be the first item in chrome://settings/search,
+ * but Google is still chosen by default.
+ * Removed code calculated the distance between 0 and Google's position
+ * and assign that position to default_search_provider_index,
+ * 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;
return t_urls;
}
--
2.43.0