template_url_prepopulate_data.h 2.4 KB

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