Files
cromite/build/patches/Add-search-engine.patch
T
2025-01-05 15:51:21 +01:00

190 lines
9.3 KiB
Diff

From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Mon, 11 Dec 2017 22:42:11 +0100
Subject: Add search engine
Add a Google search engine that forces languages to English,
disable from all its searches RLZ and field experiments querystring parameters.
Add DuckDuckGo Lite
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
---
.../search_engine_choice/default_favicon.png | Bin 0 -> 903 bytes
...search_engine_choice_scaled_resources.grdp | 1 +
.../search_engines/prepopulated_engines.json | 31 ++++++++++++++++++
.../search_engine_choice_utils.cc | 5 +--
.../search_engine_countries-inc.cc | 3 ++
.../search_engines/search_engine_type.h | 5 +++
.../template_url_prepopulate_data.cc | 1 -
.../template_url_prepopulate_data.h | 7 ----
8 files changed, 41 insertions(+), 12 deletions(-)
create mode 100644 components/resources/default_100_percent/search_engine_choice/default_favicon.png
diff --git a/components/resources/default_100_percent/search_engine_choice/default_favicon.png b/components/resources/default_100_percent/search_engine_choice/default_favicon.png
new file mode 100644
index 0000000000000000000000000000000000000000..6533419f2d6b40f7735054dec62c51ddf1ee1201
GIT binary patch
literal 903
zcmV;219<$2P)<h;3K|Lk000e1NJLTq001xm001xu1^@s6R|5Hm0009{Nkl<Zc-rk*
zHI&>u5dJaD%uTpU6K1Ny)MmAo?2~ki?Li;rI(@haGcz+YGo$8ZtH|rstmUBf-W*z<
z`LqMyjQ;vbR=naxn4FxTa$SOo%Y^Yq3CiCp`IM5k@HhA$JOj`EJVrBqK*>90<Y$Z!
zD&E1~9|C4N=Y0}PoKKzZ=aBLV-UaWB-0*4BX4X}1up41G3JAO#bVTDWd3iku6Hh={
zlma?HmsR5(hfh(b^FD*}4@!0sS4zV2hPiHTHz{QUr=p@EW3ne<xuXf?=gfeJ_n_0B
z@lJY|QARx>G)Ly==Qj#^Pm*zg`6NIm=nm~RX-}Ss_k_usva+)JncnmH^XI=4jNih$
zlz0y|WF4^Se4bG8m@v`L_#mWg6DB6I3T(&-X<X(aWBDC2?f1MT|2uB(BxS%X1$a%k
z;1;{ldEPHo!pWN$|21g&X`3k)RVSdZ`1-to+dxbxpx11tSFj1eY4p>FfHecpOCzcg
zpNwb+@DsmO2`6iI0DN;)MGkB;0q{--kR#0r9={VIfOiJ&qgPlcQV0O=qNN%EZUkK2
zXVWfZ`h5{40I)Gg`DG2UD<uwqtRPHQ`3e=w!vhePgFgO88URJiY>`5mlRG3V0I)IO
z^!VFvHvp@&1;F!4TUc<Tw?P23{124aYG2{<#pZ1%U*J~{i~%4NJtI_HQU19p>56LN
z%3gt$n(-Z(idK@zIi#qli66~IxloAGzuNPP+NSLfTs{_pT7f^J06kI9KUZ>A$&#d(
z+ZUd3gy@cNAuWhQ3vePzWtVK-4H5_<h_y6oOLkRNRsEA)yhw>iqgo-eCg3jF08o2(
zV+xr@B`n6nQmpYnUx3CSsDwu5Yyvoe1poxnZ<>do)Aj_?EW-9wQ^cQO=(N_*SpEcF
zA!n{N_=ZMrDQ)uj`{u@re$c++TFQW?-c&%T<H_NEl62(&6TL7nfTD(I>Jej=5G2dk
zc*-y0$13Q-mVE%=HZZcm54P~5#qa<$Vkc|B{qUnj<Z#y}04P$B=OI-_I^4yL*CEaE
zjS0pJfK7T{VJFY4st5f9G(|wnQru>jUSTzPpE5qa;Lv>bM_w_-mwYy_S=Aoxnl--Y
d#;<tA>kFnu^?NN9uE_uZ002ovPDHLkV1m60sc!%P
literal 0
HcmV?d00001
diff --git a/components/resources/search_engine_choice_scaled_resources.grdp b/components/resources/search_engine_choice_scaled_resources.grdp
--- a/components/resources/search_engine_choice_scaled_resources.grdp
+++ b/components/resources/search_engine_choice_scaled_resources.grdp
@@ -5,6 +5,7 @@
<if expr="_google_chrome">
<structure type="chrome_scaled_image" name="IDR_GOOGLE_COM_PNG" file="google_chrome/google_search_logo.png" />
</if>
+ <structure type="chrome_scaled_image" name="IDR_GOOGLEEN_PNG" file="search_engine_choice/default_favicon.png" />
<structure type="chrome_scaled_image" name="IDR_AR_YAHOO_COM_PNG" file="search_engine_choice/yahoo_com.png" />
<structure type="chrome_scaled_image" name="IDR_AT_YAHOO_COM_PNG" file="search_engine_choice/yahoo_com.png" />
<structure type="chrome_scaled_image" name="IDR_AU_YAHOO_COM_PNG" file="search_engine_choice/yahoo_com.png" />
diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json
--- a/components/search_engines/prepopulated_engines.json
+++ b/components/search_engines/prepopulated_engines.json
@@ -133,6 +133,16 @@
]
},
+ "duckduckgo_light": {
+ "name": "DuckDuckGo Light",
+ "keyword": "duckduckgo.com/lite",
+ "favicon_url": "https://duckduckgo.com/favicon.ico",
+ "search_url": "https://duckduckgo.com/lite/?q={searchTerms}",
+ "suggest_url": "https://duckduckgo.com/ac/?q={searchTerms}&type=list",
+ "type": "SEARCH_ENGINE_DUCKDUCKGOLIGHT",
+ "id": 12
+ },
+
"ecosia": {
"name": "Ecosia",
"keyword": "ecosia.org",
@@ -208,6 +218,27 @@
"id": 111
},
+ "googleen": {
+ "name": "Google in English",
+ "keyword": "googleen",
+ "favicon_url": "https://www.google.com/favicon.ico",
+ "search_url": "{google:baseURL}search?q={searchTerms}&ie={inputEncoding}&hl=en",
+ "suggest_url": "{google:baseSuggestURL}search?client={google:suggestClient}&q={searchTerms}&hl=en",
+ "image_url": "{google:baseURL}searchbyimage/upload?hl=en",
+ "new_tab_url": "{google:baseURL}_/chrome/newtab?hl=en&ie={inputEncoding}",
+ "contextual_search_url": "{google:baseURL}_/contextualsearch?{google:contextualSearchVersion}{google:contextualSearchContextData}&hl=en",
+ "image_url_post_params": "encoded_image={google:imageThumbnail},image_url={google:imageURL},sbisrc={google:imageSearchSource},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight}",
+ "alternate_urls": [
+ "{google:baseURL}?hl=en#q={searchTerms}",
+ "{google:baseURL}search?hl=en#q={searchTerms}",
+ "{google:baseURL}webhp?hl=en#q={searchTerms}",
+ "{google:baseURL}s?hl=en#q={searchTerms}",
+ "{google:baseURL}s?hl=en&q={searchTerms}"
+ ],
+ "type": "SEARCH_ENGINE_GOOGLE_EN",
+ "id": 13
+ },
+
"mail_ru": {
"name": "@MAIL.RU",
"keyword": "mail.ru",
diff --git a/components/search_engines/search_engine_choice/search_engine_choice_utils.cc b/components/search_engines/search_engine_choice/search_engine_choice_utils.cc
--- a/components/search_engines/search_engine_choice/search_engine_choice_utils.cc
+++ b/components/search_engines/search_engine_choice/search_engine_choice_utils.cc
@@ -186,10 +186,7 @@ void RecordChoiceScreenDefaultSearchProviderType(
}
void RecordChoiceScreenSelectedIndex(int selected_engine_index) {
- base::UmaHistogramExactLinear(
- kSearchEngineChoiceScreenSelectedEngineIndexHistogram,
- selected_engine_index,
- TemplateURLPrepopulateData::kMaxEeaPrepopulatedEngines);
+ // do nothing in Cromite
}
void RecordChoiceScreenPositionsCountryMismatch(bool has_mismatch) {
diff --git a/components/search_engines/search_engine_countries-inc.cc b/components/search_engines/search_engine_countries-inc.cc
--- 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, &googleen},
{SearchEngineTier::kTopEngines, &google},
{SearchEngineTier::kTopEngines, &bing},
{SearchEngineTier::kTopEngines, &yahoo},
@@ -1452,5 +1453,7 @@ const std::vector<EngineAndTier> GetPrepopulationSetFromCountryID(
for (size_t i = 0; i < num_engines; i++) {
t_url.push_back(engines[i]);
}
+ t_url.push_back({SearchEngineTier::kTopEngines, &googleen});
+ t_url.push_back({SearchEngineTier::kTopEngines, &duckduckgo_light});
return t_url;
}
diff --git a/components/search_engines/search_engine_type.h b/components/search_engines/search_engine_type.h
--- a/components/search_engines/search_engine_type.h
+++ b/components/search_engines/search_engine_type.h
@@ -91,10 +91,15 @@ enum SearchEngineType {
SEARCH_ENGINE_YOU = 72,
SEARCH_ENGINE_STARTER_PACK_GEMINI = 73,
SEARCH_ENGINE_LILO = 74,
+ SEARCH_ENGINE_GOOGLE_EN = 75,
+ SEARCH_ENGINE_DUCKDUCKGOLIGHT = 76,
SEARCH_ENGINE_MAX // Bounding value needed for UMA histogram macro.
};
+static_assert(SEARCH_ENGINE_DUCKDUCKGOLIGHT == (SEARCH_ENGINE_MAX - 1),
+ "Please check this patch");
+
// Enum to record the type of search engine a user used in keyword mode. This
// should be kept aligned with the `OmniboxBuiltinEngineType` enum in enums.xml.
// Entries should not be renumbered and numeric values should never be reused.
diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -78,7 +78,6 @@ GetPrepopulatedEnginesForEeaRegionCountries(int country_id,
generator.seed(profile_seed);
std::shuffle(t_urls.begin(), t_urls.end(), generator);
- CHECK_LE(t_urls.size(), kMaxEeaPrepopulatedEngines);
return t_urls;
}
diff --git a/components/search_engines/template_url_prepopulate_data.h b/components/search_engines/template_url_prepopulate_data.h
--- a/components/search_engines/template_url_prepopulate_data.h
+++ b/components/search_engines/template_url_prepopulate_data.h
@@ -32,13 +32,6 @@ struct PrepopulatedEngine;
extern const int kMaxPrepopulatedEngineID;
-// The maximum number of prepopulated search engines that can be returned in
-// any of the EEA countries by `GetPrepopulatedEngines()`.
-//
-// Note: If this is increased, please also increase the declared variant count
-// for the `Search.ChoiceScreenShowedEngineAt.Index{Index}` histogram.
-inline constexpr size_t kMaxEeaPrepopulatedEngines = 8;
-
// The maximum number of prepopulated search engines that can be returned in
// in the rest of the world by `GetPrepopulatedEngines()`.
inline constexpr size_t kMaxRowPrepopulatedEngines = 5;
--