1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
14 #include "build/build_config.h"
17 struct TemplateURLData;
19 namespace user_prefs {
20 class PrefRegistrySyncable;
23 namespace TemplateURLPrepopulateData {
25 struct PrepopulatedEngine;
27 extern const int kMaxPrepopulatedEngineID;
29 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
31 // Returns the current version of the prepopulate data, so callers can know when
32 // they need to re-merge. If the prepopulate data comes from the preferences
33 // file then it returns the version specified there.
34 int GetDataVersion(PrefService* prefs);
36 // Returns the prepopulated URLs for the current country.
37 // If |default_search_provider_index| is non-null, it is set to the index of the
38 // default search provider within the returned vector.
39 std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
41 size_t* default_search_provider_index);
43 // Returns the prepopulated search engine with the given |prepopulated_id|.
44 std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs,
47 #if BUILDFLAG(IS_ANDROID)
48 // Returns the prepopulated URLs associated with |locale|. |locale| should be a
49 // two-character uppercase ISO 3166-1 country code.
50 std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines(
51 const std::string& locale);
54 // Returns all prepopulated engines for all locales. Used only by tests.
55 std::vector<const PrepopulatedEngine*> GetAllPrepopulatedEngines();
57 // Removes prepopulated engines and their version stored in user prefs.
58 void ClearPrepopulatedEnginesInPrefs(PrefService* prefs);
60 // Returns the default search provider specified by the prepopulate data, which
62 // If |prefs| is NULL, any search provider overrides from the preferences are
64 std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
67 } // namespace TemplateURLPrepopulateData
69 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_