1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444 |
- // Copyright 2014 The Chromium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- #include "components/search_engines/template_url_prepopulate_data.h"
- #include "base/logging.h"
- #include "build/build_config.h"
- #include "components/country_codes/country_codes.h"
- #include "components/pref_registry/pref_registry_syncable.h"
- #include "components/prefs/pref_service.h"
- #include "components/search_engines/prepopulated_engines.h"
- #include "components/search_engines/search_engines_pref_names.h"
- #include "components/search_engines/template_url_data.h"
- #include "components/search_engines/template_url_data_util.h"
- namespace TemplateURLPrepopulateData {
- // Helpers --------------------------------------------------------------------
- namespace {
- // NOTE: You should probably not change the data in this file without changing
- // |kCurrentDataVersion| in prepopulated_engines.json. See comments in
- // GetDataVersion() below!
- // Put the engines within each country in order with most interesting/important
- // first. The default will be the first engine.
- // Default (for countries with no better engine set)
- const PrepopulatedEngine* const engines_default[] = {
- &google,
- &bing,
- &yahoo,
- };
- // Note, the below entries are sorted by country code, not the name in comment.
- // Engine selection by country ------------------------------------------------
- // clang-format off
- // United Arab Emirates
- const PrepopulatedEngine* const engines_AE[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Albania
- const PrepopulatedEngine* const engines_AL[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_com,
- };
- // Argentina
- const PrepopulatedEngine* const engines_AR[] = {
- &google,
- &bing,
- &yahoo_ar,
- &duckduckgo,
- &ecosia,
- };
- // Austria
- const PrepopulatedEngine* const engines_AT[] = {
- &google,
- &bing,
- &duckduckgo,
- &yahoo_at,
- &ecosia,
- };
- // Australia
- const PrepopulatedEngine* const engines_AU[] = {
- &google,
- &bing,
- &yahoo_au,
- &duckduckgo,
- &ecosia,
- };
- // Bosnia and Herzegovina
- const PrepopulatedEngine* const engines_BA[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_com,
- };
- // Belgium
- const PrepopulatedEngine* const engines_BE[] = {
- &google,
- &bing,
- &yahoo,
- &ecosia,
- &duckduckgo,
- };
- // Bulgaria
- const PrepopulatedEngine* const engines_BG[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_ru,
- };
- // Bahrain
- const PrepopulatedEngine* const engines_BH[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_com,
- };
- // Burundi
- const PrepopulatedEngine* const engines_BI[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_ru,
- };
- // Brunei
- const PrepopulatedEngine* const engines_BN[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Bolivia
- const PrepopulatedEngine* const engines_BO[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Brazil
- const PrepopulatedEngine* const engines_BR[] = {
- &google,
- &bing,
- &yahoo_br,
- &duckduckgo,
- &ecosia,
- };
- // Belarus
- const PrepopulatedEngine* const engines_BY[] = {
- &google,
- &yandex_by,
- &mail_ru,
- &bing,
- &duckduckgo,
- };
- // Belize
- const PrepopulatedEngine* const engines_BZ[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Canada
- const PrepopulatedEngine* const engines_CA[] = {
- &google,
- &bing,
- &yahoo_ca,
- &duckduckgo,
- &ecosia,
- };
- // Switzerland
- const PrepopulatedEngine* const engines_CH[] = {
- &google,
- &bing,
- &duckduckgo,
- &ecosia,
- &yahoo_ch,
- };
- // Chile
- const PrepopulatedEngine* const engines_CL[] = {
- &google,
- &bing,
- &yahoo_cl,
- &duckduckgo,
- &ecosia,
- };
- // China
- const PrepopulatedEngine* const engines_CN[] = {
- &sogou,
- &baidu,
- &bing,
- &google,
- &so_360,
- };
- // Colombia
- const PrepopulatedEngine* const engines_CO[] = {
- &google,
- &bing,
- &yahoo_co,
- &ecosia,
- &duckduckgo,
- };
- // Costa Rica
- const PrepopulatedEngine* const engines_CR[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Czech Republic
- const PrepopulatedEngine* const engines_CZ[] = {
- &google,
- &seznam_cz,
- &bing,
- &yahoo,
- &duckduckgo,
- };
- // Germany
- const PrepopulatedEngine* const engines_DE[] = {
- &google,
- &bing,
- &ecosia,
- &duckduckgo,
- &yahoo_de,
- };
- // Denmark
- const PrepopulatedEngine* const engines_DK[] = {
- &google,
- &bing,
- &yahoo_dk,
- &duckduckgo,
- &ecosia,
- };
- // Dominican Republic
- const PrepopulatedEngine* const engines_DO[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Algeria
- const PrepopulatedEngine* const engines_DZ[] = {
- &google,
- &bing,
- &yahoo_fr,
- &yandex_com,
- &duckduckgo,
- };
- // Ecuador
- const PrepopulatedEngine* const engines_EC[] = {
- &google,
- &bing,
- &yahoo,
- &ecosia,
- &duckduckgo,
- };
- // Estonia
- const PrepopulatedEngine* const engines_EE[] = {
- &google,
- &bing,
- &yandex_ru,
- &duckduckgo,
- &yahoo,
- };
- // Egypt
- const PrepopulatedEngine* const engines_EG[] = {
- &google,
- &bing,
- &yahoo,
- &yandex_com,
- &duckduckgo,
- };
- // Spain
- const PrepopulatedEngine* const engines_ES[] = {
- &google,
- &bing,
- &yahoo_es,
- &duckduckgo,
- &ecosia,
- };
- // Finland
- const PrepopulatedEngine* const engines_FI[] = {
- &google,
- &bing,
- &yahoo_fi,
- &duckduckgo,
- &yandex_ru,
- };
- // Faroe Islands
- const PrepopulatedEngine* const engines_FO[] = {
- &google,
- &bing,
- &yahoo_dk,
- &duckduckgo,
- &ecosia,
- };
- // France
- const PrepopulatedEngine* const engines_FR[] = {
- &google,
- &bing,
- &yahoo_fr,
- &qwant,
- &ecosia,
- };
- // United Kingdom
- const PrepopulatedEngine* const engines_GB[] = {
- &google,
- &bing,
- &yahoo_uk,
- &duckduckgo,
- &ecosia,
- };
- // Greece
- const PrepopulatedEngine* const engines_GR[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_ru,
- };
- // Guatemala
- const PrepopulatedEngine* const engines_GT[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Hong Kong
- const PrepopulatedEngine* const engines_HK[] = {
- &google,
- &yahoo_hk,
- &bing,
- &baidu,
- &duckduckgo,
- };
- // Honduras
- const PrepopulatedEngine* const engines_HN[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Croatia
- const PrepopulatedEngine* const engines_HR[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Hungary
- const PrepopulatedEngine* const engines_HU[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_com,
- };
- // Indonesia
- const PrepopulatedEngine* const engines_ID[] = {
- &google,
- &yahoo_id,
- &bing,
- &yandex_com,
- &duckduckgo,
- };
- // Ireland
- const PrepopulatedEngine* const engines_IE[] = {
- &google,
- &bing,
- &yahoo_uk,
- &duckduckgo,
- &ecosia,
- };
- // Israel
- const PrepopulatedEngine* const engines_IL[] = {
- &google,
- &bing,
- &yandex_ru,
- &yahoo,
- &duckduckgo,
- };
- // India
- const PrepopulatedEngine* const engines_IN[] = {
- &google,
- &bing,
- &yahoo_in,
- &duckduckgo,
- &info_com,
- };
- // Iraq
- const PrepopulatedEngine* const engines_IQ[] = {
- &google,
- &bing,
- &yahoo,
- &yandex_tr,
- &duckduckgo,
- };
- // Iran
- const PrepopulatedEngine* const engines_IR[] = {
- &google,
- &bing,
- &yahoo,
- &ask,
- &duckduckgo,
- };
- // Iceland
- const PrepopulatedEngine* const engines_IS[] = {
- &google,
- &bing,
- &duckduckgo,
- &yahoo,
- &ecosia,
- };
- // Italy
- const PrepopulatedEngine* const engines_IT[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Jamaica
- const PrepopulatedEngine* const engines_JM[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Jordan
- const PrepopulatedEngine* const engines_JO[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_com,
- };
- // Japan
- const PrepopulatedEngine* const engines_JP[] = {
- &google,
- &yahoo_jp,
- &bing,
- &duckduckgo,
- &baidu,
- };
- // Kenya
- const PrepopulatedEngine* const engines_KE[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // South Korea
- const PrepopulatedEngine* const engines_KR[] = {
- &google,
- &naver,
- &daum,
- &bing,
- &yahoo,
- };
- // Kuwait
- const PrepopulatedEngine* const engines_KW[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_com,
- };
- // Kazakhstan
- const PrepopulatedEngine* const engines_KZ[] = {
- &google,
- &yandex_kz,
- &mail_ru,
- &bing,
- &duckduckgo,
- };
- // Lebanon
- const PrepopulatedEngine* const engines_LB[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Liechtenstein
- const PrepopulatedEngine* const engines_LI[] = {
- &google,
- &bing,
- &duckduckgo,
- &yahoo,
- &ecosia,
- };
- // Lithuania
- const PrepopulatedEngine* const engines_LT[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_ru,
- };
- // Luxembourg
- const PrepopulatedEngine* const engines_LU[] = {
- &google,
- &bing,
- &duckduckgo,
- &yahoo,
- &ecosia,
- };
- // Latvia
- const PrepopulatedEngine* const engines_LV[] = {
- &google,
- &bing,
- &yandex_ru,
- &yahoo,
- &duckduckgo,
- };
- // Libya
- const PrepopulatedEngine* const engines_LY[] = {
- &google,
- &bing,
- &yahoo,
- &yandex_com,
- &duckduckgo,
- };
- // Morocco
- const PrepopulatedEngine* const engines_MA[] = {
- &google,
- &bing,
- &yahoo_fr,
- &yandex_com,
- &duckduckgo,
- };
- // Monaco
- const PrepopulatedEngine* const engines_MC[] = {
- &google,
- &bing,
- &duckduckgo,
- &yahoo_fr,
- &ecosia,
- };
- // Moldova
- const PrepopulatedEngine* const engines_MD[] = {
- &google,
- &yandex_ru,
- &bing,
- &mail_ru,
- &yahoo,
- };
- // Montenegro
- const PrepopulatedEngine* const engines_ME[] = {
- &google,
- &bing,
- &yahoo,
- &yandex_ru,
- &duckduckgo,
- };
- // Macedonia
- const PrepopulatedEngine* const engines_MK[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_ru,
- };
- // Mexico
- const PrepopulatedEngine* const engines_MX[] = {
- &google,
- &bing,
- &yahoo_mx,
- &duckduckgo,
- &ecosia,
- };
- // Malaysia
- const PrepopulatedEngine* const engines_MY[] = {
- &google,
- &bing,
- &yahoo_my,
- &duckduckgo,
- &ecosia,
- };
- // Nicaragua
- const PrepopulatedEngine* const engines_NI[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Netherlands
- const PrepopulatedEngine* const engines_NL[] = {
- &google,
- &bing,
- &yahoo_nl,
- &duckduckgo,
- &ecosia,
- };
- // Norway
- const PrepopulatedEngine* const engines_NO[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // New Zealand
- const PrepopulatedEngine* const engines_NZ[] = {
- &google,
- &bing,
- &yahoo_nz,
- &duckduckgo,
- &ecosia,
- };
- // Oman
- const PrepopulatedEngine* const engines_OM[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &petal_search,
- };
- // Panama
- const PrepopulatedEngine* const engines_PA[] = {
- &google,
- &bing,
- &yahoo_es,
- &duckduckgo,
- &ecosia,
- };
- // Peru
- const PrepopulatedEngine* const engines_PE[] = {
- &google,
- &bing,
- &yahoo_pe,
- &ecosia,
- &duckduckgo,
- };
- // Philippines
- const PrepopulatedEngine* const engines_PH[] = {
- &google,
- &bing,
- &yahoo,
- &ecosia,
- &duckduckgo,
- };
- // Pakistan
- const PrepopulatedEngine* const engines_PK[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_com,
- };
- // Poland
- const PrepopulatedEngine* const engines_PL[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_ru,
- };
- // Puerto Rico
- const PrepopulatedEngine* const engines_PR[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Portugal
- const PrepopulatedEngine* const engines_PT[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Paraguay
- const PrepopulatedEngine* const engines_PY[] = {
- &google,
- &bing,
- &yahoo_es,
- &duckduckgo,
- &ecosia,
- };
- // Qatar
- const PrepopulatedEngine* const engines_QA[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_tr,
- };
- // Romania
- const PrepopulatedEngine* const engines_RO[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_tr,
- };
- // Serbia
- const PrepopulatedEngine* const engines_RS[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &yandex_ru,
- };
- // Russia
- const PrepopulatedEngine* const engines_RU[] = {
- &google,
- &yandex_ru,
- &mail_ru,
- &bing,
- &duckduckgo,
- };
- // Rwanda
- const PrepopulatedEngine* const engines_RW[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Saudi Arabia
- const PrepopulatedEngine* const engines_SA[] = {
- &google,
- &bing,
- &yahoo,
- &yandex_com,
- &duckduckgo,
- };
- // Sweden
- const PrepopulatedEngine* const engines_SE[] = {
- &google,
- &bing,
- &yahoo_se,
- &duckduckgo,
- &ecosia,
- };
- // Singapore
- const PrepopulatedEngine* const engines_SG[] = {
- &google,
- &bing,
- &yahoo_sg,
- &duckduckgo,
- &baidu,
- };
- // Slovenia
- const PrepopulatedEngine* const engines_SI[] = {
- &google,
- &bing,
- &duckduckgo,
- &yahoo,
- &yandex_com,
- };
- // Slovakia
- const PrepopulatedEngine* const engines_SK[] = {
- &google,
- &bing,
- &duckduckgo,
- &yahoo,
- &yandex_com,
- };
- // El Salvador
- const PrepopulatedEngine* const engines_SV[] = {
- &google,
- &bing,
- &yahoo_es,
- &duckduckgo,
- &ecosia,
- };
- // Syria
- const PrepopulatedEngine* const engines_SY[] = {
- &google,
- &bing,
- &yahoo,
- &yandex_com,
- &duckduckgo,
- };
- // Thailand
- const PrepopulatedEngine* const engines_TH[] = {
- &google,
- &bing,
- &yahoo_th,
- &yandex_ru,
- &mail_ru,
- };
- // Tunisia
- const PrepopulatedEngine* const engines_TN[] = {
- &google,
- &bing,
- &yahoo_fr,
- &duckduckgo,
- &yandex_com,
- };
- // Turkey
- const PrepopulatedEngine* const engines_TR[] = {
- &google,
- &yandex_tr,
- &yahoo_tr,
- &bing,
- &duckduckgo,
- };
- // Trinidad and Tobago
- const PrepopulatedEngine* const engines_TT[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Taiwan
- const PrepopulatedEngine* const engines_TW[] = {
- &google,
- &yahoo_tw,
- &bing,
- &baidu,
- &duckduckgo,
- };
- // Tanzania
- const PrepopulatedEngine* const engines_TZ[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &baidu,
- };
- // Ukraine
- const PrepopulatedEngine* const engines_UA[] = {
- &google,
- &yandex_ua,
- &bing,
- &duckduckgo,
- &yahoo,
- };
- // United States
- const PrepopulatedEngine* const engines_US[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Uruguay
- const PrepopulatedEngine* const engines_UY[] = {
- &google,
- &bing,
- &yahoo_es,
- &duckduckgo,
- &ecosia,
- };
- // Venezuela
- const PrepopulatedEngine* const engines_VE[] = {
- &google,
- &bing,
- &yahoo_es,
- &duckduckgo,
- &ecosia,
- };
- // Vietnam
- const PrepopulatedEngine* const engines_VN[] = {
- &google,
- &coccoc,
- &yahoo,
- &bing,
- &yandex_ru,
- };
- // Yemen
- const PrepopulatedEngine* const engines_YE[] = {
- &google,
- &bing,
- &yahoo,
- &yandex_com,
- &duckduckgo,
- };
- // South Africa
- const PrepopulatedEngine* const engines_ZA[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // Zimbabwe
- const PrepopulatedEngine* const engines_ZW[] = {
- &google,
- &bing,
- &yahoo,
- &duckduckgo,
- &ecosia,
- };
- // clang-format on
- // ----------------------------------------------------------------------------
- std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulationSetFromCountryID(
- int country_id) {
- const PrepopulatedEngine* const* engines;
- size_t num_engines;
- // If you add a new country make sure to update the unit test for coverage.
- switch (country_id) {
- #define UNHANDLED_COUNTRY(code1, code2) \
- case country_codes::CountryCharsToCountryID((#code1)[0], (#code2)[0]):
- #define END_UNHANDLED_COUNTRIES(code1, code2) \
- engines = engines_##code1##code2; \
- num_engines = std::size(engines_##code1##code2); \
- break;
- #define DECLARE_COUNTRY(code1, code2)\
- UNHANDLED_COUNTRY(code1, code2)\
- END_UNHANDLED_COUNTRIES(code1, code2)
- // Countries with their own, dedicated engine set.
- DECLARE_COUNTRY(A, E) // United Arab Emirates
- DECLARE_COUNTRY(A, L) // Albania
- DECLARE_COUNTRY(A, R) // Argentina
- DECLARE_COUNTRY(A, T) // Austria
- DECLARE_COUNTRY(A, U) // Australia
- DECLARE_COUNTRY(B, A) // Bosnia and Herzegovina
- DECLARE_COUNTRY(B, E) // Belgium
- DECLARE_COUNTRY(B, G) // Bulgaria
- DECLARE_COUNTRY(B, H) // Bahrain
- DECLARE_COUNTRY(B, I) // Burundi
- DECLARE_COUNTRY(B, N) // Brunei
- DECLARE_COUNTRY(B, O) // Bolivia
- DECLARE_COUNTRY(B, R) // Brazil
- DECLARE_COUNTRY(B, Y) // Belarus
- DECLARE_COUNTRY(B, Z) // Belize
- DECLARE_COUNTRY(C, A) // Canada
- DECLARE_COUNTRY(C, H) // Switzerland
- DECLARE_COUNTRY(C, L) // Chile
- DECLARE_COUNTRY(C, N) // China
- DECLARE_COUNTRY(C, O) // Colombia
- DECLARE_COUNTRY(C, R) // Costa Rica
- DECLARE_COUNTRY(C, Z) // Czech Republic
- DECLARE_COUNTRY(D, E) // Germany
- DECLARE_COUNTRY(D, K) // Denmark
- DECLARE_COUNTRY(D, O) // Dominican Republic
- DECLARE_COUNTRY(D, Z) // Algeria
- DECLARE_COUNTRY(E, C) // Ecuador
- DECLARE_COUNTRY(E, E) // Estonia
- DECLARE_COUNTRY(E, G) // Egypt
- DECLARE_COUNTRY(E, S) // Spain
- DECLARE_COUNTRY(F, I) // Finland
- DECLARE_COUNTRY(F, O) // Faroe Islands
- DECLARE_COUNTRY(F, R) // France
- DECLARE_COUNTRY(G, B) // United Kingdom
- DECLARE_COUNTRY(G, R) // Greece
- DECLARE_COUNTRY(G, T) // Guatemala
- DECLARE_COUNTRY(H, K) // Hong Kong
- DECLARE_COUNTRY(H, N) // Honduras
- DECLARE_COUNTRY(H, R) // Croatia
- DECLARE_COUNTRY(H, U) // Hungary
- DECLARE_COUNTRY(I, D) // Indonesia
- DECLARE_COUNTRY(I, E) // Ireland
- DECLARE_COUNTRY(I, L) // Israel
- DECLARE_COUNTRY(I, N) // India
- DECLARE_COUNTRY(I, Q) // Iraq
- DECLARE_COUNTRY(I, R) // Iran
- DECLARE_COUNTRY(I, S) // Iceland
- DECLARE_COUNTRY(I, T) // Italy
- DECLARE_COUNTRY(J, M) // Jamaica
- DECLARE_COUNTRY(J, O) // Jordan
- DECLARE_COUNTRY(J, P) // Japan
- DECLARE_COUNTRY(K, E) // Kenya
- DECLARE_COUNTRY(K, R) // South Korea
- DECLARE_COUNTRY(K, W) // Kuwait
- DECLARE_COUNTRY(K, Z) // Kazakhstan
- DECLARE_COUNTRY(L, B) // Lebanon
- DECLARE_COUNTRY(L, I) // Liechtenstein
- DECLARE_COUNTRY(L, T) // Lithuania
- DECLARE_COUNTRY(L, U) // Luxembourg
- DECLARE_COUNTRY(L, V) // Latvia
- DECLARE_COUNTRY(L, Y) // Libya
- DECLARE_COUNTRY(M, A) // Morocco
- DECLARE_COUNTRY(M, C) // Monaco
- DECLARE_COUNTRY(M, D) // Moldova
- DECLARE_COUNTRY(M, E) // Montenegro
- DECLARE_COUNTRY(M, K) // Macedonia
- DECLARE_COUNTRY(M, X) // Mexico
- DECLARE_COUNTRY(M, Y) // Malaysia
- DECLARE_COUNTRY(N, I) // Nicaragua
- DECLARE_COUNTRY(N, L) // Netherlands
- DECLARE_COUNTRY(N, O) // Norway
- DECLARE_COUNTRY(N, Z) // New Zealand
- DECLARE_COUNTRY(O, M) // Oman
- DECLARE_COUNTRY(P, A) // Panama
- DECLARE_COUNTRY(P, E) // Peru
- DECLARE_COUNTRY(P, H) // Philippines
- DECLARE_COUNTRY(P, K) // Pakistan
- DECLARE_COUNTRY(P, L) // Poland
- DECLARE_COUNTRY(P, R) // Puerto Rico
- DECLARE_COUNTRY(P, T) // Portugal
- DECLARE_COUNTRY(P, Y) // Paraguay
- DECLARE_COUNTRY(Q, A) // Qatar
- DECLARE_COUNTRY(R, O) // Romania
- DECLARE_COUNTRY(R, S) // Serbia
- DECLARE_COUNTRY(R, U) // Russia
- DECLARE_COUNTRY(R, W) // Rwanda
- DECLARE_COUNTRY(S, A) // Saudi Arabia
- DECLARE_COUNTRY(S, E) // Sweden
- DECLARE_COUNTRY(S, G) // Singapore
- DECLARE_COUNTRY(S, I) // Slovenia
- DECLARE_COUNTRY(S, K) // Slovakia
- DECLARE_COUNTRY(S, V) // El Salvador
- DECLARE_COUNTRY(S, Y) // Syria
- DECLARE_COUNTRY(T, H) // Thailand
- DECLARE_COUNTRY(T, N) // Tunisia
- DECLARE_COUNTRY(T, R) // Turkey
- DECLARE_COUNTRY(T, T) // Trinidad and Tobago
- DECLARE_COUNTRY(T, W) // Taiwan
- DECLARE_COUNTRY(T, Z) // Tanzania
- DECLARE_COUNTRY(U, A) // Ukraine
- DECLARE_COUNTRY(U, S) // United States
- DECLARE_COUNTRY(U, Y) // Uruguay
- DECLARE_COUNTRY(V, E) // Venezuela
- DECLARE_COUNTRY(V, N) // Vietnam
- DECLARE_COUNTRY(Y, E) // Yemen
- DECLARE_COUNTRY(Z, A) // South Africa
- DECLARE_COUNTRY(Z, W) // Zimbabwe
- // Countries using the "Australia" engine set.
- UNHANDLED_COUNTRY(C, C) // Cocos Islands
- UNHANDLED_COUNTRY(C, X) // Christmas Island
- UNHANDLED_COUNTRY(H, M) // Heard Island and McDonald Islands
- UNHANDLED_COUNTRY(N, F) // Norfolk Island
- END_UNHANDLED_COUNTRIES(A, U)
- // Countries using the "China" engine set.
- UNHANDLED_COUNTRY(M, O) // Macao
- END_UNHANDLED_COUNTRIES(C, N)
- // Countries using the "Denmark" engine set.
- UNHANDLED_COUNTRY(G, L) // Greenland
- END_UNHANDLED_COUNTRIES(D, K)
- // Countries using the "Spain" engine set.
- UNHANDLED_COUNTRY(A, D) // Andorra
- END_UNHANDLED_COUNTRIES(E, S)
- // Countries using the "Finland" engine set.
- UNHANDLED_COUNTRY(A, X) // Aland Islands
- END_UNHANDLED_COUNTRIES(F, I)
- // Countries using the "France" engine set.
- UNHANDLED_COUNTRY(B, F) // Burkina Faso
- UNHANDLED_COUNTRY(B, J) // Benin
- UNHANDLED_COUNTRY(C, D) // Congo - Kinshasa
- UNHANDLED_COUNTRY(C, F) // Central African Republic
- UNHANDLED_COUNTRY(C, G) // Congo - Brazzaville
- UNHANDLED_COUNTRY(C, I) // Ivory Coast
- UNHANDLED_COUNTRY(C, M) // Cameroon
- UNHANDLED_COUNTRY(D, J) // Djibouti
- UNHANDLED_COUNTRY(G, A) // Gabon
- UNHANDLED_COUNTRY(G, F) // French Guiana
- UNHANDLED_COUNTRY(G, N) // Guinea
- UNHANDLED_COUNTRY(G, P) // Guadeloupe
- UNHANDLED_COUNTRY(H, T) // Haiti
- #if BUILDFLAG(IS_WIN)
- UNHANDLED_COUNTRY(I, P) // Clipperton Island ('IP' is an WinXP-ism; ISO
- // includes it with France)
- #endif
- UNHANDLED_COUNTRY(M, L) // Mali
- UNHANDLED_COUNTRY(M, Q) // Martinique
- UNHANDLED_COUNTRY(N, C) // New Caledonia
- UNHANDLED_COUNTRY(N, E) // Niger
- UNHANDLED_COUNTRY(P, F) // French Polynesia
- UNHANDLED_COUNTRY(P, M) // Saint Pierre and Miquelon
- UNHANDLED_COUNTRY(R, E) // Reunion
- UNHANDLED_COUNTRY(S, N) // Senegal
- UNHANDLED_COUNTRY(T, D) // Chad
- UNHANDLED_COUNTRY(T, F) // French Southern Territories
- UNHANDLED_COUNTRY(T, G) // Togo
- UNHANDLED_COUNTRY(W, F) // Wallis and Futuna
- UNHANDLED_COUNTRY(Y, T) // Mayotte
- END_UNHANDLED_COUNTRIES(F, R)
- // Countries using the "Greece" engine set.
- UNHANDLED_COUNTRY(C, Y) // Cyprus
- END_UNHANDLED_COUNTRIES(G, R)
- // Countries using the "Italy" engine set.
- UNHANDLED_COUNTRY(S, M) // San Marino
- UNHANDLED_COUNTRY(V, A) // Vatican
- END_UNHANDLED_COUNTRIES(I, T)
- // Countries using the "Morocco" engine set.
- UNHANDLED_COUNTRY(E, H) // Western Sahara
- END_UNHANDLED_COUNTRIES(M, A)
- // Countries using the "Netherlands" engine set.
- UNHANDLED_COUNTRY(A, N) // Netherlands Antilles
- UNHANDLED_COUNTRY(A, W) // Aruba
- END_UNHANDLED_COUNTRIES(N, L)
- // Countries using the "Norway" engine set.
- UNHANDLED_COUNTRY(B, V) // Bouvet Island
- UNHANDLED_COUNTRY(S, J) // Svalbard and Jan Mayen
- END_UNHANDLED_COUNTRIES(N, O)
- // Countries using the "New Zealand" engine set.
- UNHANDLED_COUNTRY(C, K) // Cook Islands
- UNHANDLED_COUNTRY(N, U) // Niue
- UNHANDLED_COUNTRY(T, K) // Tokelau
- END_UNHANDLED_COUNTRIES(N, Z)
- // Countries using the "Portugal" engine set.
- UNHANDLED_COUNTRY(C, V) // Cape Verde
- UNHANDLED_COUNTRY(G, W) // Guinea-Bissau
- UNHANDLED_COUNTRY(M, Z) // Mozambique
- UNHANDLED_COUNTRY(S, T) // Sao Tome and Principe
- UNHANDLED_COUNTRY(T, L) // Timor-Leste
- END_UNHANDLED_COUNTRIES(P, T)
- // Countries using the "Russia" engine set.
- UNHANDLED_COUNTRY(A, M) // Armenia
- UNHANDLED_COUNTRY(A, Z) // Azerbaijan
- UNHANDLED_COUNTRY(K, G) // Kyrgyzstan
- UNHANDLED_COUNTRY(T, J) // Tajikistan
- UNHANDLED_COUNTRY(T, M) // Turkmenistan
- UNHANDLED_COUNTRY(U, Z) // Uzbekistan
- END_UNHANDLED_COUNTRIES(R, U)
- // Countries using the "Saudi Arabia" engine set.
- UNHANDLED_COUNTRY(M, R) // Mauritania
- UNHANDLED_COUNTRY(P, S) // Palestinian Territory
- UNHANDLED_COUNTRY(S, D) // Sudan
- END_UNHANDLED_COUNTRIES(S, A)
- // Countries using the "United Kingdom" engine set.
- UNHANDLED_COUNTRY(B, M) // Bermuda
- UNHANDLED_COUNTRY(F, K) // Falkland Islands
- UNHANDLED_COUNTRY(G, G) // Guernsey
- UNHANDLED_COUNTRY(G, I) // Gibraltar
- UNHANDLED_COUNTRY(G, S) // South Georgia and the South Sandwich
- // Islands
- UNHANDLED_COUNTRY(I, M) // Isle of Man
- UNHANDLED_COUNTRY(I, O) // British Indian Ocean Territory
- UNHANDLED_COUNTRY(J, E) // Jersey
- UNHANDLED_COUNTRY(K, Y) // Cayman Islands
- UNHANDLED_COUNTRY(M, S) // Montserrat
- UNHANDLED_COUNTRY(M, T) // Malta
- UNHANDLED_COUNTRY(P, N) // Pitcairn Islands
- UNHANDLED_COUNTRY(S, H) // Saint Helena, Ascension Island, and Tristan da
- // Cunha
- UNHANDLED_COUNTRY(T, C) // Turks and Caicos Islands
- UNHANDLED_COUNTRY(V, G) // British Virgin Islands
- END_UNHANDLED_COUNTRIES(G, B)
- // Countries using the "United States" engine set.
- UNHANDLED_COUNTRY(A, S) // American Samoa
- UNHANDLED_COUNTRY(G, U) // Guam
- UNHANDLED_COUNTRY(M, P) // Northern Mariana Islands
- UNHANDLED_COUNTRY(U, M) // U.S. Minor Outlying Islands
- UNHANDLED_COUNTRY(V, I) // U.S. Virgin Islands
- END_UNHANDLED_COUNTRIES(U, S)
- // Countries using the "default" engine set.
- UNHANDLED_COUNTRY(A, F) // Afghanistan
- UNHANDLED_COUNTRY(A, G) // Antigua and Barbuda
- UNHANDLED_COUNTRY(A, I) // Anguilla
- UNHANDLED_COUNTRY(A, O) // Angola
- UNHANDLED_COUNTRY(A, Q) // Antarctica
- UNHANDLED_COUNTRY(B, B) // Barbados
- UNHANDLED_COUNTRY(B, D) // Bangladesh
- UNHANDLED_COUNTRY(B, S) // Bahamas
- UNHANDLED_COUNTRY(B, T) // Bhutan
- UNHANDLED_COUNTRY(B, W) // Botswana
- UNHANDLED_COUNTRY(C, U) // Cuba
- UNHANDLED_COUNTRY(D, M) // Dominica
- UNHANDLED_COUNTRY(E, R) // Eritrea
- UNHANDLED_COUNTRY(E, T) // Ethiopia
- UNHANDLED_COUNTRY(F, J) // Fiji
- UNHANDLED_COUNTRY(F, M) // Micronesia
- UNHANDLED_COUNTRY(G, D) // Grenada
- UNHANDLED_COUNTRY(G, E) // Georgia
- UNHANDLED_COUNTRY(G, H) // Ghana
- UNHANDLED_COUNTRY(G, M) // Gambia
- UNHANDLED_COUNTRY(G, Q) // Equatorial Guinea
- UNHANDLED_COUNTRY(G, Y) // Guyana
- UNHANDLED_COUNTRY(K, H) // Cambodia
- UNHANDLED_COUNTRY(K, I) // Kiribati
- UNHANDLED_COUNTRY(K, M) // Comoros
- UNHANDLED_COUNTRY(K, N) // Saint Kitts and Nevis
- UNHANDLED_COUNTRY(K, P) // North Korea
- UNHANDLED_COUNTRY(L, A) // Laos
- UNHANDLED_COUNTRY(L, C) // Saint Lucia
- UNHANDLED_COUNTRY(L, K) // Sri Lanka
- UNHANDLED_COUNTRY(L, R) // Liberia
- UNHANDLED_COUNTRY(L, S) // Lesotho
- UNHANDLED_COUNTRY(M, G) // Madagascar
- UNHANDLED_COUNTRY(M, H) // Marshall Islands
- UNHANDLED_COUNTRY(M, M) // Myanmar
- UNHANDLED_COUNTRY(M, N) // Mongolia
- UNHANDLED_COUNTRY(M, U) // Mauritius
- UNHANDLED_COUNTRY(M, V) // Maldives
- UNHANDLED_COUNTRY(M, W) // Malawi
- UNHANDLED_COUNTRY(N, A) // Namibia
- UNHANDLED_COUNTRY(N, G) // Nigeria
- UNHANDLED_COUNTRY(N, P) // Nepal
- UNHANDLED_COUNTRY(N, R) // Nauru
- UNHANDLED_COUNTRY(P, G) // Papua New Guinea
- UNHANDLED_COUNTRY(P, W) // Palau
- UNHANDLED_COUNTRY(S, B) // Solomon Islands
- UNHANDLED_COUNTRY(S, C) // Seychelles
- UNHANDLED_COUNTRY(S, L) // Sierra Leone
- UNHANDLED_COUNTRY(S, O) // Somalia
- UNHANDLED_COUNTRY(S, R) // Suriname
- UNHANDLED_COUNTRY(S, Z) // Swaziland
- UNHANDLED_COUNTRY(T, O) // Tonga
- UNHANDLED_COUNTRY(T, V) // Tuvalu
- UNHANDLED_COUNTRY(U, G) // Uganda
- UNHANDLED_COUNTRY(V, C) // Saint Vincent and the Grenadines
- UNHANDLED_COUNTRY(V, U) // Vanuatu
- UNHANDLED_COUNTRY(W, S) // Samoa
- UNHANDLED_COUNTRY(Z, M) // Zambia
- case country_codes::kCountryIDUnknown:
- default: // Unhandled location
- END_UNHANDLED_COUNTRIES(def, ault)
- }
- std::vector<std::unique_ptr<TemplateURLData>> t_urls;
- for (size_t i = 0; i < num_engines; ++i)
- t_urls.push_back(TemplateURLDataFromPrepopulatedEngine(*engines[i]));
- return t_urls;
- }
- std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedTemplateURLData(
- PrefService* prefs) {
- std::vector<std::unique_ptr<TemplateURLData>> t_urls;
- if (!prefs)
- return t_urls;
- const base::Value::List& list =
- prefs->GetValueList(prefs::kSearchProviderOverrides);
- for (const base::Value& engine : list) {
- if (engine.is_dict()) {
- auto t_url = TemplateURLDataFromOverrideDictionary(engine);
- if (t_url)
- t_urls.push_back(std::move(t_url));
- }
- }
- return t_urls;
- }
- } // namespace
- // Global functions -----------------------------------------------------------
- void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
- country_codes::RegisterProfilePrefs(registry);
- registry->RegisterListPref(prefs::kSearchProviderOverrides);
- registry->RegisterIntegerPref(prefs::kSearchProviderOverridesVersion, -1);
- }
- int GetDataVersion(PrefService* prefs) {
- // Allow tests to override the local version.
- return (prefs && prefs->HasPrefPath(prefs::kSearchProviderOverridesVersion)) ?
- prefs->GetInteger(prefs::kSearchProviderOverridesVersion) :
- kCurrentDataVersion;
- }
- std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
- PrefService* prefs,
- size_t* default_search_provider_index) {
- // If there is a set of search engines in the preferences file, it overrides
- // the built-in set.
- std::vector<std::unique_ptr<TemplateURLData>> t_urls =
- GetPrepopulatedTemplateURLData(prefs);
- if (t_urls.empty()) {
- t_urls = GetPrepopulationSetFromCountryID(
- country_codes::GetCountryIDFromPrefs(prefs));
- }
- if (default_search_provider_index) {
- const auto itr = std::find_if(
- t_urls.begin(), t_urls.end(),
- [](const auto& t_url) { return t_url->prepopulate_id == google.id; });
- *default_search_provider_index =
- itr == t_urls.end() ? 0 : std::distance(t_urls.begin(), itr);
- }
- return t_urls;
- }
- std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs,
- int prepopulated_id) {
- auto engines =
- TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, nullptr);
- for (auto& engine : engines) {
- if (engine->prepopulate_id == prepopulated_id)
- return std::move(engine);
- }
- return nullptr;
- }
- #if BUILDFLAG(IS_ANDROID)
- std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines(
- const std::string& locale) {
- int country_id = country_codes::CountryStringToCountryID(locale);
- if (country_id == country_codes::kCountryIDUnknown) {
- LOG(ERROR) << "Unknown country code specified: " << locale;
- return std::vector<std::unique_ptr<TemplateURLData>>();
- }
- return GetPrepopulationSetFromCountryID(country_id);
- }
- #endif
- std::vector<const PrepopulatedEngine*> GetAllPrepopulatedEngines() {
- return std::vector<const PrepopulatedEngine*>(
- &kAllEngines[0], &kAllEngines[0] + kAllEnginesLength);
- }
- void ClearPrepopulatedEnginesInPrefs(PrefService* prefs) {
- if (!prefs)
- return;
- prefs->ClearPref(prefs::kSearchProviderOverrides);
- prefs->ClearPref(prefs::kSearchProviderOverridesVersion);
- }
- std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
- PrefService* prefs) {
- size_t default_search_index;
- // This could be more efficient. We load all URLs but keep only the default.
- std::vector<std::unique_ptr<TemplateURLData>> loaded_urls =
- GetPrepopulatedEngines(prefs, &default_search_index);
- return (default_search_index < loaded_urls.size())
- ? std::move(loaded_urls[default_search_index])
- : nullptr;
- }
- } // namespace TemplateURLPrepopulateData
|