Upload upstream chromium 114.0.5735.31
[platform/framework/web/chromium-efl.git] / components / search_engines / template_url_prepopulate_data.h
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.
4
5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11 #include <string>
12 #include <vector>
13
14 #include "build/build_config.h"
15
16 class PrefService;
17 struct TemplateURLData;
18
19 namespace user_prefs {
20 class PrefRegistrySyncable;
21 }
22
23 namespace TemplateURLPrepopulateData {
24
25 struct PrepopulatedEngine;
26
27 extern const int kMaxPrepopulatedEngineID;
28
29 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
30
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);
35
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(
40     PrefService* prefs,
41     size_t* default_search_provider_index);
42
43 // Returns the prepopulated search engine with the given |prepopulated_id|.
44 std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs,
45                                                        int prepopulated_id);
46
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);
52 #endif
53
54 // Returns all prepopulated engines for all locales. Used only by tests.
55 std::vector<const PrepopulatedEngine*> GetAllPrepopulatedEngines();
56
57 // Removes prepopulated engines and their version stored in user prefs.
58 void ClearPrepopulatedEnginesInPrefs(PrefService* prefs);
59
60 // Returns the default search provider specified by the prepopulate data, which
61 // may be NULL.
62 // If |prefs| is NULL, any search provider overrides from the preferences are
63 // not used.
64 std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
65     PrefService* prefs);
66
67 }  // namespace TemplateURLPrepopulateData
68
69 #endif  // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_