diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-16 11:45:35 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-17 08:59:23 +0000 |
commit | 552906b0f222c5d5dd11b9fd73829d510980461a (patch) | |
tree | 3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/components/search_engines | |
parent | 1b05827804eaf047779b597718c03e7d38344261 (diff) | |
download | qtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz |
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/search_engines')
15 files changed, 300 insertions, 127 deletions
diff --git a/chromium/components/search_engines/BUILD.gn b/chromium/components/search_engines/BUILD.gn index af19d6fecb3..e67da174f0f 100644 --- a/chromium/components/search_engines/BUILD.gn +++ b/chromium/components/search_engines/BUILD.gn @@ -103,9 +103,7 @@ static_library("search_engines") { } source_set("search_engine_type") { - sources = [ - "search_engine_type.h", - ] + sources = [ "search_engine_type.h" ] } static_library("test_support") { @@ -174,15 +172,11 @@ json_to_struct("prepopulated_engines") { source = "prepopulated_engines.json" schema_file = "prepopulated_engines_schema.json" namespace = "TemplateURLPrepopulateData" - deps = [ - ":search_engine_type", - ] + deps = [ ":search_engine_type" ] } if (is_android) { java_cpp_enum("search_engine_type_java") { - sources = [ - "search_engine_type.h", - ] + sources = [ "search_engine_type.h" ] } } diff --git a/chromium/components/search_engines/android/BUILD.gn b/chromium/components/search_engines/android/BUILD.gn index 0247b737534..2131e7b799e 100644 --- a/chromium/components/search_engines/android/BUILD.gn +++ b/chromium/components/search_engines/android/BUILD.gn @@ -12,7 +12,7 @@ android_library("java") { ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] - java_files = [ + sources = [ "java/src/org/chromium/components/search_engines/TemplateUrl.java", "java/src/org/chromium/components/search_engines/TemplateUrlService.java", ] diff --git a/chromium/components/search_engines/keyword_web_data_service.cc b/chromium/components/search_engines/keyword_web_data_service.cc index fd0df7464a4..265bbdd8426 100644 --- a/chromium/components/search_engines/keyword_web_data_service.cc +++ b/chromium/components/search_engines/keyword_web_data_service.cc @@ -73,9 +73,8 @@ KeywordWebDataService::BatchModeScoper::~BatchModeScoper() { KeywordWebDataService::KeywordWebDataService( scoped_refptr<WebDatabaseService> wdbs, - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, - const ProfileErrorCallback& callback) - : WebDataServiceBase(wdbs, callback, ui_task_runner), + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) + : WebDataServiceBase(std::move(wdbs), std::move(ui_task_runner)), timer_(FROM_HERE, base::TimeDelta::FromSeconds(5), base::BindRepeating(&KeywordWebDataService::CommitQueuedOperations, diff --git a/chromium/components/search_engines/keyword_web_data_service.h b/chromium/components/search_engines/keyword_web_data_service.h index f3e23ca9e52..4cd1408117c 100644 --- a/chromium/components/search_engines/keyword_web_data_service.h +++ b/chromium/components/search_engines/keyword_web_data_service.h @@ -64,8 +64,7 @@ class KeywordWebDataService : public WebDataServiceBase { KeywordWebDataService( scoped_refptr<WebDatabaseService> wdbs, - scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, - const ProfileErrorCallback& callback); + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); // As the database processes requests at a later date, all deletion is done on // the background sequence. diff --git a/chromium/components/search_engines/prepopulated_engines.json b/chromium/components/search_engines/prepopulated_engines.json index d4679b35bdc..933cd564dac 100644 --- a/chromium/components/search_engines/prepopulated_engines.json +++ b/chromium/components/search_engines/prepopulated_engines.json @@ -23,12 +23,12 @@ // When adding new engines, increment this number and use it as the new // max ID. This is used by UMA stats and must be updated to include the full // range or else not all engines will be counted in stats. - "kMaxPrepopulatedEngineID": 100, + "kMaxPrepopulatedEngineID": 101, // Increment this if you change the data in ways that mean users with // existing data should get a new version. Otherwise, existing data may // continue to be used and updates made here will not always appear. - "kCurrentDataVersion": 117 + "kCurrentDataVersion": 121 }, // The following engines are included in country lists and are added to the @@ -102,6 +102,16 @@ "id": 92 }, + "ecosia": { + "name": "Ecosia", + "keyword": "ecosia.org", + "favicon_url": "https://cdn.ecosia.org/assets/images/ico/favicon.ico", + "search_url": "https://www.ecosia.org/search?q={searchTerms}&addon=opensearch", + "suggest_url": "https://ac.ecosia.org/autocomplete?q={searchTerms}&type=list", + "type": "SEARCH_ENGINE_ECOSIA", + "id": 101 + }, + "google": { "name": "Google", "keyword": "google.com", @@ -341,9 +351,7 @@ "search_url": "https://fr.search.yahoo.com/search{google:pathWildcard}?ei={inputEncoding}&fr=crmas&p={searchTerms}", "suggest_url": "https://fr.search.yahoo.com/sugg/chrome?output=fxjson&appid=crmas&command={searchTerms}", "type": "SEARCH_ENGINE_YAHOO", - - // Can't be 2 as this has to appear in the Belgium list alongside yahoo. - "id": 5 + "id": 2 }, "yahoo_hk": { @@ -446,18 +454,6 @@ "id": 2 }, - "yahoo_qc": { - "name": "Yahoo! Qu\u00e9bec", - "keyword": "qc.yahoo.com", - "favicon_url": "https://qc.search.yahoo.com/favicon.ico", - "search_url": "https://qc.search.yahoo.com/search{google:pathWildcard}?ei={inputEncoding}&fr=crmas&p={searchTerms}", - "suggest_url": "https://qc.search.yahoo.com/sugg/chrome?output=fxjson&appid=crmas&command={searchTerms}", - "type": "SEARCH_ENGINE_YAHOO", - - // Can't be 2 as this has to appear in the Canada list alongside yahoo_ca. - "id": 5 - }, - "yahoo_se": { "name": "Yahoo! Sverige", "keyword": "se.yahoo.com", @@ -1125,6 +1121,16 @@ "id": 76 }, + "yahoo_qc": { + "name": "Yahoo! Qu\u00e9bec", + "keyword": "qc.yahoo.com", + "favicon_url": "https://qc.search.yahoo.com/favicon.ico", + "search_url": "https://qc.search.yahoo.com/search{google:pathWildcard}?ei={inputEncoding}&fr=crmas&p={searchTerms}", + "suggest_url": "https://qc.search.yahoo.com/sugg/chrome?output=fxjson&appid=crmas&command={searchTerms}", + "type": "SEARCH_ENGINE_YAHOO", + "id": 2 + }, + "zoznam": { "name": "Zoznam", "keyword": "zoznam.sk", diff --git a/chromium/components/search_engines/search_engine_type.h b/chromium/components/search_engines/search_engine_type.h index ff303b8f304..707c5c8785b 100644 --- a/chromium/components/search_engines/search_engine_type.h +++ b/chromium/components/search_engines/search_engine_type.h @@ -73,6 +73,7 @@ enum SearchEngineType { SEARCH_ENGINE_METAGER, SEARCH_ENGINE_OCEANHERO, SEARCH_ENGINE_PRIVACYWALL, + SEARCH_ENGINE_ECOSIA, SEARCH_ENGINE_MAX // Bounding value needed for UMA histogram macro. }; diff --git a/chromium/components/search_engines/template_url.cc b/chromium/components/search_engines/template_url.cc index 96c96e154c4..39968b30cf4 100644 --- a/chromium/components/search_engines/template_url.cc +++ b/chromium/components/search_engines/template_url.cc @@ -128,7 +128,7 @@ class SearchTermLocation { TryMatchSearchParam(value_string, kGoogleUnescapedSearchTermsParameterFull)) { found_ = true; - url_component.substr(key.begin, key.len).CopyToString(&key_); + key_ = std::string(url_component.substr(key.begin, key.len)); break; } } @@ -149,8 +149,8 @@ class SearchTermLocation { size_t pos = value.find(pattern); if (pos == base::StringPiece::npos) return false; - value.substr(0, pos).CopyToString(&value_prefix_); - value.substr(pos + pattern.length()).CopyToString(&value_suffix_); + value_prefix_ = std::string(value.substr(0, pos)); + value_suffix_ = std::string(value.substr(pos + pattern.size())); return true; } @@ -216,23 +216,25 @@ size_t TemplateURLRef::SearchTermsArgs::EstimateMemoryUsage() const { } TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: - ContextualSearchParams() - : version(-1), - contextual_cards_version(0), - previous_event_id(0), - previous_event_results(0) {} + ContextualSearchParams() = default; TemplateURLRef::SearchTermsArgs::ContextualSearchParams::ContextualSearchParams( int version, int contextual_cards_version, - const std::string& home_country, + std::string home_country, int64_t previous_event_id, - int previous_event_results) + int previous_event_results, + bool is_exact_search, + std::string source_lang, + std::string target_lang) : version(version), contextual_cards_version(contextual_cards_version), home_country(home_country), previous_event_id(previous_event_id), - previous_event_results(previous_event_results) {} + previous_event_results(previous_event_results), + is_exact_search(is_exact_search), + source_lang(source_lang), + target_lang(target_lang) {} TemplateURLRef::SearchTermsArgs::ContextualSearchParams::ContextualSearchParams( const ContextualSearchParams& other) = default; @@ -995,6 +997,12 @@ std::string TemplateURLRef::HandleReplacements( args.push_back("ctxsl_per=" + base::NumberToString(params.previous_event_results)); } + if (params.is_exact_search) + args.push_back("ctxsl_exact=1"); + if (!params.source_lang.empty()) + args.push_back("tlitesl=" + params.source_lang); + if (!params.target_lang.empty()) + args.push_back("tlitetl=" + params.target_lang); HandleReplacement(std::string(), base::JoinString(args, "&"), *i, &url); break; diff --git a/chromium/components/search_engines/template_url.h b/chromium/components/search_engines/template_url.h index 1cfa0196ed7..8bffdf35dbf 100644 --- a/chromium/components/search_engines/template_url.h +++ b/chromium/components/search_engines/template_url.h @@ -107,11 +107,25 @@ class TemplateURLRef { // The |previous_event_results| are the results of the user-interaction of // that previous request. // The "previous_xyz" parameters are documented in go/cs-sanitized. + // The |is_exact_search| allows the search request to be narrowed down to + // an "exact" search only, meaning just search for X rather than X + + // whatever else is in the context. The returned search term should not + // be expanded, and the server will honor this along with creating a + // narrow Search Term. + // The |source_lang| specifies a source language hint to apply for + // translation or to indicate that translation might be appropriate. + // This comes from CLD evaluating the selection and/or page content. + // The |target_lang| specifies the best language to translate into for + // the user, which also indicates when translation is appropriate or + // helpful. This comes from the Chrome Language Model. ContextualSearchParams(int version, int contextual_cards_version, - const std::string& home_country, + std::string home_country, int64_t previous_event_id, - int previous_event_results); + int previous_event_results, + bool is_exact_search, + std::string source_lang, + std::string target_lang); ContextualSearchParams(const ContextualSearchParams& other); ~ContextualSearchParams(); @@ -120,11 +134,11 @@ class TemplateURLRef { size_t EstimateMemoryUsage() const; // The version of contextual search. - int version; + int version = -1; // The version of Contextual Cards data to request. // A value of 0 indicates no data needed. - int contextual_cards_version; + int contextual_cards_version = 0; // The locale of the user's home country in an ISO country code format, // or an empty string if not available. This indicates where the user @@ -133,11 +147,21 @@ class TemplateURLRef { // An EventID from a previous interaction (sent by server, recorded by // client). - int64_t previous_event_id; + int64_t previous_event_id = 0l; // An encoded set of booleans that represent the interaction results from // the previous event. - int previous_event_results; + int previous_event_results = 0; + + // A flag that restricts the search to exactly match the selection rather + // than expanding the Search Term to include other words in the context. + bool is_exact_search = false; + + // Source language string to translate from. + std::string source_lang; + + // Target language string to be translated into. + std::string target_lang; }; // Estimates dynamic memory usage. diff --git a/chromium/components/search_engines/template_url_fetcher.cc b/chromium/components/search_engines/template_url_fetcher.cc index 60176e2f73a..d34bb702108 100644 --- a/chromium/components/search_engines/template_url_fetcher.cc +++ b/chromium/components/search_engines/template_url_fetcher.cc @@ -67,7 +67,8 @@ class TemplateURLFetcher::RequestDelegate { const url::Origin& initiator, network::mojom::URLLoaderFactory* url_loader_factory, int render_frame_id, - int resource_type); + int resource_type, + int32_t request_id); // If data contains a valid OSDD, a TemplateURL is created and added to // the TemplateURLService. @@ -104,7 +105,8 @@ TemplateURLFetcher::RequestDelegate::RequestDelegate( const url::Origin& initiator, network::mojom::URLLoaderFactory* url_loader_factory, int render_frame_id, - int resource_type) + int resource_type, + int32_t request_id) : fetcher_(fetcher), keyword_(keyword), osdd_url_(osdd_url), @@ -133,6 +135,7 @@ TemplateURLFetcher::RequestDelegate::RequestDelegate( base::TimeDelta::FromSeconds(kOpenSearchTimeoutSeconds)); simple_url_loader_->SetRetryOptions( kOpenSearchRetryCount, network::SimpleURLLoader::RETRY_ON_NETWORK_CHANGE); + simple_url_loader_->SetRequestID(request_id); simple_url_loader_->DownloadToString( url_loader_factory, base::BindOnce( @@ -235,7 +238,8 @@ void TemplateURLFetcher::ScheduleDownload( const url::Origin& initiator, network::mojom::URLLoaderFactory* url_loader_factory, int render_frame_id, - int resource_type) { + int resource_type, + int32_t request_id) { DCHECK(osdd_url.is_valid()); DCHECK(!keyword.empty()); @@ -260,7 +264,7 @@ void TemplateURLFetcher::ScheduleDownload( requests_.push_back(std::make_unique<RequestDelegate>( this, keyword, osdd_url, favicon_url, initiator, url_loader_factory, - render_frame_id, resource_type)); + render_frame_id, resource_type, request_id)); } void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { diff --git a/chromium/components/search_engines/template_url_fetcher.h b/chromium/components/search_engines/template_url_fetcher.h index 9944c70d872..448bd68b5f7 100644 --- a/chromium/components/search_engines/template_url_fetcher.h +++ b/chromium/components/search_engines/template_url_fetcher.h @@ -52,7 +52,8 @@ class TemplateURLFetcher : public KeyedService { const url::Origin& initiator, network::mojom::URLLoaderFactory* url_loader_factory, int render_frame_id, - int resource_type); + int resource_type, + int32_t request_id); // The current number of outstanding requests. int requests_count() const { return requests_.size(); } diff --git a/chromium/components/search_engines/template_url_prepopulate_data.cc b/chromium/components/search_engines/template_url_prepopulate_data.cc index afd8d81a177..60c60a4d09e 100644 --- a/chromium/components/search_engines/template_url_prepopulate_data.cc +++ b/chromium/components/search_engines/template_url_prepopulate_data.cc @@ -45,6 +45,7 @@ const PrepopulatedEngine* const engines_AE[] = { &bing, &yahoo, &duckduckgo, + &yandex_ru, }; // Albania @@ -52,7 +53,8 @@ const PrepopulatedEngine* const engines_AL[] = { &google, &yahoo, &bing, - &ask, + &duckduckgo, + &yandex_ru, }; // Argentina @@ -61,29 +63,33 @@ const PrepopulatedEngine* const engines_AR[] = { &bing, &yahoo_ar, &duckduckgo, + &ecosia, }; // Austria const PrepopulatedEngine* const engines_AT[] = { &google, &bing, - &yahoo_at, &duckduckgo, + &yahoo_at, + &ecosia, }; // Australia const PrepopulatedEngine* const engines_AU[] = { &google, &bing, - &yahoo_au, &duckduckgo, + &yahoo_au, + &ecosia, }; // Bosnia and Herzegovina const PrepopulatedEngine* const engines_BA[] = { &google, - &yahoo, &bing, + &yahoo, + &duckduckgo, &ask, }; @@ -92,6 +98,7 @@ const PrepopulatedEngine* const engines_BE[] = { &google, &bing, &yahoo, + &ecosia, &duckduckgo, }; @@ -100,6 +107,7 @@ const PrepopulatedEngine* const engines_BG[] = { &google, &bing, &yahoo, + &duckduckgo, &yandex_ru, }; @@ -108,7 +116,8 @@ const PrepopulatedEngine* const engines_BH[] = { &google, &bing, &yahoo, - &ask, + &duckduckgo, + &ecosia, }; // Burundi @@ -116,7 +125,8 @@ const PrepopulatedEngine* const engines_BI[] = { &google, &bing, &yahoo, - &yandex_ru, + &duckduckgo, + &ask, }; // Brunei @@ -125,6 +135,7 @@ const PrepopulatedEngine* const engines_BN[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Bolivia @@ -133,6 +144,7 @@ const PrepopulatedEngine* const engines_BO[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Brazil @@ -141,6 +153,7 @@ const PrepopulatedEngine* const engines_BR[] = { &bing, &yahoo_br, &duckduckgo, + &ecosia, }; // Belarus @@ -149,6 +162,7 @@ const PrepopulatedEngine* const engines_BY[] = { &yandex_by, &mail_ru, &bing, + &yahoo, }; // Belize @@ -157,11 +171,16 @@ const PrepopulatedEngine* const engines_BZ[] = { &bing, &yahoo, &duckduckgo, + &ask, }; // Canada const PrepopulatedEngine* const engines_CA[] = { - &google, &bing, &yahoo_ca, &yahoo_qc, &duckduckgo, + &google, + &bing, + &yahoo_ca, + &duckduckgo, + &ecosia, }; // Switzerland @@ -170,6 +189,7 @@ const PrepopulatedEngine* const engines_CH[] = { &bing, &duckduckgo, &yahoo_ch, + &ecosia, }; // Chile @@ -178,18 +198,24 @@ const PrepopulatedEngine* const engines_CL[] = { &bing, &yahoo_cl, &duckduckgo, + &ecosia, }; // China const PrepopulatedEngine* const engines_CN[] = { - &baidu, &so_360, &google, &sogou, &bing, + &baidu, + &sogou, + &google, + &so_360, + &bing, }; // Colombia const PrepopulatedEngine* const engines_CO[] = { &google, - &yahoo_co, &bing, + &yahoo_co, + &ecosia, &duckduckgo, }; @@ -199,6 +225,7 @@ const PrepopulatedEngine* const engines_CR[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Czech Republic @@ -207,6 +234,7 @@ const PrepopulatedEngine* const engines_CZ[] = { &seznam_cz, &bing, &yahoo, + &duckduckgo, }; // Germany @@ -215,6 +243,7 @@ const PrepopulatedEngine* const engines_DE[] = { &bing, &yahoo_de, &duckduckgo, + &ecosia, }; // Denmark @@ -223,6 +252,7 @@ const PrepopulatedEngine* const engines_DK[] = { &bing, &yahoo_dk, &duckduckgo, + &ecosia, }; // Dominican Republic @@ -231,6 +261,7 @@ const PrepopulatedEngine* const engines_DO[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Algeria @@ -239,6 +270,7 @@ const PrepopulatedEngine* const engines_DZ[] = { &yahoo, &bing, &yandex_ru, + &duckduckgo, }; // Ecuador @@ -246,6 +278,7 @@ const PrepopulatedEngine* const engines_EC[] = { &google, &bing, &yahoo, + &ecosia, &duckduckgo, }; @@ -254,7 +287,8 @@ const PrepopulatedEngine* const engines_EE[] = { &google, &bing, &yandex_ru, - &neti, + &yahoo, + &mail_ru, }; // Egypt @@ -263,6 +297,7 @@ const PrepopulatedEngine* const engines_EG[] = { &yahoo, &bing, &yandex_ru, + &duckduckgo, }; // Spain @@ -271,6 +306,7 @@ const PrepopulatedEngine* const engines_ES[] = { &bing, &yahoo_es, &duckduckgo, + &ecosia, }; // Finland @@ -279,14 +315,16 @@ const PrepopulatedEngine* const engines_FI[] = { &bing, &yahoo_fi, &duckduckgo, + &yandex_ru, }; // Faroe Islands const PrepopulatedEngine* const engines_FO[] = { &google, &bing, - &yahoo, + &yahoo_dk, &duckduckgo, + &ecosia, }; // France @@ -295,6 +333,7 @@ const PrepopulatedEngine* const engines_FR[] = { &bing, &yahoo_fr, &qwant, + &ecosia, }; // United Kingdom @@ -303,6 +342,7 @@ const PrepopulatedEngine* const engines_GB[] = { &bing, &yahoo_uk, &duckduckgo, + &ecosia, }; // Greece @@ -311,6 +351,7 @@ const PrepopulatedEngine* const engines_GR[] = { &bing, &yahoo, &duckduckgo, + &yandex_ru, }; // Guatemala @@ -318,6 +359,7 @@ const PrepopulatedEngine* const engines_GT[] = { &google, &bing, &yahoo, + &ecosia, &duckduckgo, }; @@ -326,6 +368,7 @@ const PrepopulatedEngine* const engines_HK[] = { &google, &yahoo_hk, &bing, + &yandex_com, &baidu, }; @@ -334,6 +377,7 @@ const PrepopulatedEngine* const engines_HN[] = { &google, &bing, &yahoo, + &yandex_ru, &duckduckgo, }; @@ -343,14 +387,16 @@ const PrepopulatedEngine* const engines_HR[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Hungary const PrepopulatedEngine* const engines_HU[] = { &google, - &yahoo, &bing, + &yahoo, &duckduckgo, + &ecosia, }; // Indonesia @@ -359,6 +405,7 @@ const PrepopulatedEngine* const engines_ID[] = { &yahoo_id, &bing, &duckduckgo, + &yandex_com, }; // Ireland @@ -367,6 +414,7 @@ const PrepopulatedEngine* const engines_IE[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Israel @@ -375,6 +423,7 @@ const PrepopulatedEngine* const engines_IL[] = { &bing, &yahoo, &yandex_ru, + &duckduckgo, }; // India @@ -383,6 +432,7 @@ const PrepopulatedEngine* const engines_IN[] = { &yahoo_in, &bing, &duckduckgo, + &yandex_ru, }; // Iraq @@ -391,6 +441,7 @@ const PrepopulatedEngine* const engines_IQ[] = { &yahoo, &bing, &yandex_ru, + &duckduckgo, }; // Iran @@ -398,14 +449,17 @@ const PrepopulatedEngine* const engines_IR[] = { &google, &bing, &yahoo, + &yandex_ru, + &ask, }; // Iceland const PrepopulatedEngine* const engines_IS[] = { &google, &bing, - &yahoo, &duckduckgo, + &yahoo, + &ecosia, }; // Italy @@ -414,6 +468,7 @@ const PrepopulatedEngine* const engines_IT[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Jamaica @@ -422,14 +477,16 @@ const PrepopulatedEngine* const engines_JM[] = { &bing, &yahoo, &duckduckgo, + &ask, }; // Jordan const PrepopulatedEngine* const engines_JO[] = { &google, - &yahoo, &bing, - &yandex_ru, + &yahoo, + &duckduckgo, + &yandex_com, }; // Japan @@ -438,22 +495,25 @@ const PrepopulatedEngine* const engines_JP[] = { &yahoo_jp, &bing, &baidu, + &duckduckgo, }; // Kenya const PrepopulatedEngine* const engines_KE[] = { &google, - &yahoo, &bing, + &yahoo, &duckduckgo, + &yandex_ru, }; // South Korea const PrepopulatedEngine* const engines_KR[] = { &google, &naver, - &daum, &bing, + &daum, + &yahoo_jp, }; // Kuwait @@ -461,7 +521,8 @@ const PrepopulatedEngine* const engines_KW[] = { &google, &bing, &yahoo, - &ask, + &duckduckgo, + &yandex_com, }; // Kazakhstan @@ -470,6 +531,7 @@ const PrepopulatedEngine* const engines_KZ[] = { &yandex_kz, &mail_ru, &bing, + &yahoo, }; // Lebanon @@ -478,6 +540,7 @@ const PrepopulatedEngine* const engines_LB[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Liechtenstein @@ -486,6 +549,7 @@ const PrepopulatedEngine* const engines_LI[] = { &bing, &duckduckgo, &yahoo, + &ecosia, }; // Lithuania @@ -494,6 +558,7 @@ const PrepopulatedEngine* const engines_LT[] = { &bing, &yahoo, &yandex_ru, + &duckduckgo, }; // Luxembourg @@ -502,14 +567,16 @@ const PrepopulatedEngine* const engines_LU[] = { &bing, &duckduckgo, &yahoo, + &ecosia, }; // Latvia const PrepopulatedEngine* const engines_LV[] = { &google, - &bing, &yandex_ru, + &bing, &yahoo, + &duckduckgo, }; // Libya @@ -518,6 +585,7 @@ const PrepopulatedEngine* const engines_LY[] = { &yahoo, &bing, &yandex_com, + &duckduckgo, }; // Morocco @@ -525,15 +593,17 @@ const PrepopulatedEngine* const engines_MA[] = { &google, &yahoo, &bing, - &yandex_ru, + &duckduckgo, + &yandex_com, }; // Monaco const PrepopulatedEngine* const engines_MC[] = { &google, &bing, - &yahoo, &duckduckgo, + &yahoo, + &qwant, }; // Moldova @@ -542,22 +612,25 @@ const PrepopulatedEngine* const engines_MD[] = { &yandex_ru, &mail_ru, &duckduckgo, + &bing, }; // Montenegro const PrepopulatedEngine* const engines_ME[] = { &google, - &yahoo, &bing, + &yahoo, &yandex_ru, + &duckduckgo, }; // Macedonia const PrepopulatedEngine* const engines_MK[] = { &google, - &yahoo, &bing, + &yahoo, &duckduckgo, + &yandex_ru, }; // Mexico @@ -565,14 +638,16 @@ const PrepopulatedEngine* const engines_MX[] = { &google, &bing, &yahoo_mx, + &ecosia, &duckduckgo, }; // Malaysia const PrepopulatedEngine* const engines_MY[] = { &google, - &yahoo_my, &bing, + &yahoo_my, + &duckduckgo, &baidu, }; @@ -582,6 +657,7 @@ const PrepopulatedEngine* const engines_NI[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Netherlands @@ -590,6 +666,7 @@ const PrepopulatedEngine* const engines_NL[] = { &bing, &yahoo_nl, &duckduckgo, + &yandex_ru, }; // Norway @@ -598,6 +675,7 @@ const PrepopulatedEngine* const engines_NO[] = { &bing, &yahoo, &duckduckgo, + &yandex_ru, }; // New Zealand @@ -606,6 +684,7 @@ const PrepopulatedEngine* const engines_NZ[] = { &bing, &duckduckgo, &yahoo_nz, + &ecosia, }; // Oman @@ -613,7 +692,8 @@ const PrepopulatedEngine* const engines_OM[] = { &google, &bing, &yahoo, - &ask, + &duckduckgo, + &ecosia, }; // Panama @@ -622,13 +702,15 @@ const PrepopulatedEngine* const engines_PA[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Peru const PrepopulatedEngine* const engines_PE[] = { &google, - &yahoo_pe, &bing, + &yahoo_pe, + &ecosia, &duckduckgo, }; @@ -637,6 +719,7 @@ const PrepopulatedEngine* const engines_PH[] = { &google, &yahoo_ph, &bing, + &ecosia, &duckduckgo, }; @@ -645,7 +728,8 @@ const PrepopulatedEngine* const engines_PK[] = { &google, &yahoo, &bing, - &baidu, + &duckduckgo, + &yandex_com, }; // Poland @@ -654,6 +738,7 @@ const PrepopulatedEngine* const engines_PL[] = { &bing, &yahoo, &duckduckgo, + &yandex_ru, }; // Puerto Rico @@ -662,6 +747,7 @@ const PrepopulatedEngine* const engines_PR[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Portugal @@ -670,6 +756,7 @@ const PrepopulatedEngine* const engines_PT[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Paraguay @@ -678,6 +765,7 @@ const PrepopulatedEngine* const engines_PY[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Qatar @@ -685,7 +773,8 @@ const PrepopulatedEngine* const engines_QA[] = { &google, &bing, &yahoo, - &ask, + &duckduckgo, + &yandex_com, }; // Romania @@ -694,6 +783,7 @@ const PrepopulatedEngine* const engines_RO[] = { &bing, &yahoo, &duckduckgo, + &yandex_ru, }; // Serbia @@ -702,14 +792,16 @@ const PrepopulatedEngine* const engines_RS[] = { &yahoo, &bing, &duckduckgo, + &yandex_ru, }; // Russia const PrepopulatedEngine* const engines_RU[] = { - &yandex_ru, &google, + &yandex_ru, &mail_ru, &bing, + &yahoo, }; // Rwanda @@ -717,7 +809,8 @@ const PrepopulatedEngine* const engines_RW[] = { &google, &bing, &yahoo, - &yandex_ru, + &duckduckgo, + &mail_ru, }; // Saudi Arabia @@ -726,6 +819,7 @@ const PrepopulatedEngine* const engines_SA[] = { &bing, &yahoo, &yandex_com, + &duckduckgo, }; // Sweden @@ -734,22 +828,25 @@ const PrepopulatedEngine* const engines_SE[] = { &bing, &yahoo_se, &duckduckgo, + &ecosia, }; // Singapore const PrepopulatedEngine* const engines_SG[] = { &google, &bing, - &yahoo_sg, &yandex_com, + &yahoo_sg, + &baidu, }; // Slovenia const PrepopulatedEngine* const engines_SI[] = { &google, &bing, - &yahoo, &duckduckgo, + &yahoo, + &yandex_ru, }; // Slovakia @@ -758,6 +855,7 @@ const PrepopulatedEngine* const engines_SK[] = { &bing, &yahoo, &duckduckgo, + &seznam_cz, }; // El Salvador @@ -766,6 +864,7 @@ const PrepopulatedEngine* const engines_SV[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Syria @@ -774,6 +873,7 @@ const PrepopulatedEngine* const engines_SY[] = { &bing, &yahoo, &yandex_ru, + &duckduckgo, }; // Thailand @@ -781,7 +881,8 @@ const PrepopulatedEngine* const engines_TH[] = { &google, &yahoo_th, &bing, - &ask, + &duckduckgo, + &baidu, }; // Tunisia @@ -790,6 +891,7 @@ const PrepopulatedEngine* const engines_TN[] = { &yahoo, &bing, &yandex_ru, + &duckduckgo, }; // Turkey @@ -798,6 +900,7 @@ const PrepopulatedEngine* const engines_TR[] = { &yandex_tr, &yahoo_tr, &bing, + &duckduckgo, }; // Trinidad and Tobago @@ -806,6 +909,7 @@ const PrepopulatedEngine* const engines_TT[] = { &bing, &yahoo, &duckduckgo, + &ask, }; // Taiwan @@ -814,6 +918,7 @@ const PrepopulatedEngine* const engines_TW[] = { &yahoo_tw, &bing, &baidu, + &ecosia, }; // Tanzania @@ -821,6 +926,7 @@ const PrepopulatedEngine* const engines_TZ[] = { &google, &bing, &yahoo, + &duckduckgo, &yandex_ru, }; @@ -828,8 +934,9 @@ const PrepopulatedEngine* const engines_TZ[] = { const PrepopulatedEngine* const engines_UA[] = { &google, &yandex_ua, - &mail_ru, &bing, + &mail_ru, + &yahoo, }; // United States @@ -838,6 +945,7 @@ const PrepopulatedEngine* const engines_US[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Uruguay @@ -846,6 +954,7 @@ const PrepopulatedEngine* const engines_UY[] = { &bing, &yahoo, &duckduckgo, + &ecosia, }; // Venezuela @@ -854,14 +963,16 @@ const PrepopulatedEngine* const engines_VE[] = { &yahoo_ve, &bing, &duckduckgo, + &ecosia, }; // Vietnam const PrepopulatedEngine* const engines_VN[] = { &google, &coccoc, + &yahoo, &bing, - &yahoo_vn, + &ecosia, }; // Yemen @@ -869,7 +980,8 @@ const PrepopulatedEngine* const engines_YE[] = { &google, &bing, &yahoo, - &baidu, + &yandex_ru, + &duckduckgo, }; // South Africa @@ -878,6 +990,7 @@ const PrepopulatedEngine* const engines_ZA[] = { &bing, &yahoo, &duckduckgo, + &baidu, }; // Zimbabwe @@ -885,7 +998,8 @@ const PrepopulatedEngine* const engines_ZW[] = { &google, &bing, &yahoo, - &baidu, + &ask, + &duckduckgo, }; // ---------------------------------------------------------------------------- diff --git a/chromium/components/search_engines/template_url_service.cc b/chromium/components/search_engines/template_url_service.cc index 1c4944a2e43..fd6828e3095 100644 --- a/chromium/components/search_engines/template_url_service.cc +++ b/chromium/components/search_engines/template_url_service.cc @@ -1444,19 +1444,13 @@ void TemplateURLService::Init(const Initializer* initializers, TemplateURL* TemplateURLService::BestEngineForKeyword(TemplateURL* engine1, TemplateURL* engine2) { - DCHECK(engine1); - DCHECK(engine2); - DCHECK_EQ(engine1->keyword(), engine2->keyword()); + CHECK(engine1); + CHECK(engine2); + CHECK_EQ(engine1->keyword(), engine2->keyword()); // We should only have overlapping keywords when at least one comes from // an extension. - DCHECK(IsCreatedByExtension(engine1) || IsCreatedByExtension(engine2)); - - // TODO(a-v-y) Remove following code for non extension engines when reasons - // for crash https://bugs.chromium.org/p/chromium/issues/detail?id=697745 - // become clear. - if (!IsCreatedByExtension(engine1) && !IsCreatedByExtension(engine2)) - return CanReplace(engine1) ? engine2 : engine1; + CHECK(IsCreatedByExtension(engine1) || IsCreatedByExtension(engine2)); if (engine2->type() == engine1->type()) { return engine1->extension_info_->install_time > @@ -1474,8 +1468,11 @@ TemplateURL* TemplateURLService::BestEngineForKeyword(TemplateURL* engine1, void TemplateURLService::RemoveFromMaps(const TemplateURL* template_url) { const base::string16& keyword = template_url->keyword(); - DCHECK_NE(0U, keyword_to_turl_and_length_.count(keyword)); - if (keyword_to_turl_and_length_[keyword].first == template_url) { + auto iter = keyword_to_turl_and_length_.find(keyword); + CHECK(iter != keyword_to_turl_and_length_.end()); + // The entry at |iter| may not be |template_url| if it's an extension-created + // entry with the same keyword. + if (iter->second.first == template_url) { // We need to check whether the keyword can now be provided by another // TemplateURL. See the comments for BestEngineForKeyword() for more // information on extension keywords and how they can coexist with @@ -1494,7 +1491,7 @@ void TemplateURLService::RemoveFromMaps(const TemplateURL* template_url) { AddToMap(best_fallback); AddToDomainMap(best_fallback); } else { - keyword_to_turl_and_length_.erase(keyword); + keyword_to_turl_and_length_.erase(iter); } } @@ -1520,7 +1517,7 @@ void TemplateURLService::AddToMaps(TemplateURL* template_url) { AddToDomainMap(template_url); } else { TemplateURL* existing_url = i->second.first; - DCHECK_NE(existing_url, template_url); + CHECK_NE(existing_url, template_url); if (BestEngineForKeyword(existing_url, template_url) != existing_url) { RemoveFromDomainMap(existing_url); AddToMap(template_url); @@ -1690,8 +1687,10 @@ bool TemplateURLService::Update(TemplateURL* existing_turl, // calling AddToMaps() below). existing_turl->CopyFrom(new_values); existing_turl->data_.id = previous_id; - if (keep_old_keyword) + if (keep_old_keyword) { + CHECK_NE(old_keyword, new_values.keyword()); existing_turl->data_.SetKeyword(old_keyword); + } AddToMaps(existing_turl); @@ -1709,7 +1708,7 @@ bool TemplateURLService::Update(TemplateURL* existing_turl, if (default_search_provider_source_ != DefaultSearchManager::FROM_FALLBACK) MaybeUpdateDSEViaPrefs(existing_turl); - DCHECK(!HasDuplicateKeywords()); + CHECK(!HasDuplicateKeywords()); return true; } @@ -1824,6 +1823,14 @@ void TemplateURLService::ApplyDefaultSearchChange( bool TemplateURLService::ApplyDefaultSearchChangeNoMetrics( const TemplateURLData* data, DefaultSearchManager::Source source) { + // We do not want any sort of reentrancy while changing the default search + // engine. This can occur when resolving conflicting entries. In those cases, + // it's best to early exit and let the original process finish. + if (applying_default_search_engine_change_) + return false; + base::AutoReset<bool> applying_change(&applying_default_search_engine_change_, + true); + if (!loaded_) { // Set |initial_default_search_provider_| from the preferences. This is // mainly so we can hold ownership until we get to the point where the list @@ -1842,15 +1849,6 @@ bool TemplateURLService::ApplyDefaultSearchChangeNoMetrics( return changed; } - // Prevent recursion if we update the value stored in default_search_manager_. - // Note that we exclude the case of data == NULL because that could cause a - // false positive for recursion when the initial_default_search_provider_ is - // NULL due to policy. We'll never actually get recursion with data == NULL. - if (source == default_search_provider_source_ && data != nullptr && - TemplateURL::MatchesData(default_search_provider_, data, - search_terms_data())) - return false; - // This may be deleted later. Use exclusively for pointer comparison to detect // a change. TemplateURL* previous_default_search_engine = default_search_provider_; @@ -1988,7 +1986,7 @@ TemplateURL* TemplateURLService::Add(std::unique_ptr<TemplateURL> template_url, if (template_url_ptr) model_mutated_notification_pending_ = true; - DCHECK(!HasDuplicateKeywords()); + CHECK(!HasDuplicateKeywords()); return template_url_ptr; } diff --git a/chromium/components/search_engines/template_url_service.h b/chromium/components/search_engines/template_url_service.h index cfda0d16f88..362b1f64b0e 100644 --- a/chromium/components/search_engines/template_url_service.h +++ b/chromium/components/search_engines/template_url_service.h @@ -365,7 +365,7 @@ class TemplateURLService : public WebDataServiceConsumer, // Returns all syncable TemplateURLs from this model as SyncData. This should // include every search engine and no Extension keywords. - syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; + syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const; // Process new search engine changes from Sync, merging them into our local // data. This may send notifications if local search engines are added, // updated or removed. @@ -813,6 +813,10 @@ class TemplateURLService : public WebDataServiceConsumer, // true, we ignore any local search engine changes, since we triggered them. bool processing_syncer_changes_ = false; + // We never want reentrancy while applying a default search engine change. + // This can happen when deleting keyword conflicts. crbug.com/1031506 + bool applying_default_search_engine_change_ = false; + // Sync's syncer::SyncChange handler. We push all our changes through this. std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_; diff --git a/chromium/components/search_engines/template_url_service_util_unittest.cc b/chromium/components/search_engines/template_url_service_util_unittest.cc index 172662684d5..335b41016f1 100644 --- a/chromium/components/search_engines/template_url_service_util_unittest.cc +++ b/chromium/components/search_engines/template_url_service_util_unittest.cc @@ -22,12 +22,11 @@ std::unique_ptr<TemplateURLData> CreatePrepopulateTemplateURLData( const std::string& keyword) { return std::make_unique<TemplateURLData>( base::ASCIIToUTF16("Search engine name"), base::ASCIIToUTF16(keyword), - "https://search.url", nullptr /* suggest_url */, nullptr /* image_url */, - nullptr /* new_tab_url */, nullptr /* contextual_search_url */, - nullptr /* logo_url */, nullptr /* doodle_url */, - nullptr /* search_url_post_params */, - nullptr /* suggest_url_post_params */, - nullptr /* image_url_post_params */, nullptr /* favicon_url */, "UTF-8", + "https://search.url", "" /* suggest_url */, "" /* image_url */, + "" /* new_tab_url */, "" /* contextual_search_url */, "" /* logo_url */, + "" /* doodle_url */, "" /* search_url_post_params */, + "" /* suggest_url_post_params */, "" /* image_url_post_params */, + "" /* favicon_url */, "UTF-8", base::ListValue() /* alternate_urls_list */, prepopulate_id); } diff --git a/chromium/components/search_engines/template_url_unittest.cc b/chromium/components/search_engines/template_url_unittest.cc index a96c8a0f415..d2514a07e91 100644 --- a/chromium/components/search_engines/template_url_unittest.cc +++ b/chromium/components/search_engines/template_url_unittest.cc @@ -1741,7 +1741,7 @@ TEST_F(TemplateURLTest, ContextualSearchParameters) { // Test the current common case, which uses no home country or previous // event. TemplateURLRef::SearchTermsArgs::ContextualSearchParams params( - 2, 1, std::string(), 0, 0); + 2, 1, std::string(), 0, 0, false, std::string(), std::string()); search_terms_args.contextual_search_params = params; result = url.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); @@ -1753,8 +1753,8 @@ TEST_F(TemplateURLTest, ContextualSearchParameters) { // Test the home country and non-zero event data case. search_terms_args.contextual_search_params = - TemplateURLRef::SearchTermsArgs::ContextualSearchParams(2, 2, "CH", - 1657713458, 5); + TemplateURLRef::SearchTermsArgs::ContextualSearchParams( + 2, 2, "CH", 1657713458, 5, false, std::string(), std::string()); result = url.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); @@ -1766,6 +1766,28 @@ TEST_F(TemplateURLTest, ContextualSearchParameters) { "ctxsl_pid=1657713458&" "ctxsl_per=5", result); + + // Test exact-search. + search_terms_args.contextual_search_params = + TemplateURLRef::SearchTermsArgs::ContextualSearchParams( + 2, 1, std::string(), 0, 0, true, std::string(), std::string()); + result = + url.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); + // Find our param. + size_t found_pos = result.find("ctxsl_exact=1"); + EXPECT_NE(found_pos, std::string::npos); + + // Test source and target languages. + search_terms_args.contextual_search_params = + TemplateURLRef::SearchTermsArgs::ContextualSearchParams( + 2, 1, std::string(), 0, 0, true, "es", "de"); + result = + url.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); + // Find our params. + size_t source_pos = result.find("tlitesl=es"); + EXPECT_NE(source_pos, std::string::npos); + size_t target_pos = result.find("tlitetl=de"); + EXPECT_NE(target_pos, std::string::npos); } TEST_F(TemplateURLTest, GenerateKeyword) { |