[email protected] | 0915b35 | 2014-06-25 19:58:14 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 0915b35 | 2014-06-25 19:58:14 | [diff] [blame] | 5 | #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ |
6 | #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ | ||||
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 7 | |
[email protected] | d43f86e | 2011-05-16 01:22:46 | [diff] [blame] | 8 | #include <stddef.h> |
dcheng | d967d950 | 2016-04-21 22:36:51 | [diff] [blame] | 9 | |
10 | #include <memory> | ||||
[email protected] | 333808db | 2011-11-21 19:19:56 | [diff] [blame] | 11 | #include <string> |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 12 | #include <vector> |
13 | |||||
[email protected] | 24a555b6 | 2013-06-10 22:01:17 | [diff] [blame] | 14 | #include "base/strings/string16.h" |
[email protected] | f92b15b | 2014-06-12 04:16:18 | [diff] [blame] | 15 | #include "components/search_engines/search_engine_type.h" |
[email protected] | 623de74f | 2012-03-14 21:36:02 | [diff] [blame] | 16 | |
[email protected] | 258ecdb | 2010-10-19 05:02:54 | [diff] [blame] | 17 | class GURL; |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 18 | class PrefService; |
[email protected] | c6dea6b | 2014-04-30 18:06:04 | [diff] [blame] | 19 | struct TemplateURLData; |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 20 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 21 | namespace user_prefs { |
22 | class PrefRegistrySyncable; | ||||
23 | } | ||||
24 | |||||
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 25 | namespace TemplateURLPrepopulateData { |
26 | |||||
fdoray | 95b217e | 2015-11-15 03:03:33 | [diff] [blame] | 27 | struct PrepopulatedEngine; |
28 | |||||
[email protected] | 542bce32 | 2011-10-10 01:18:11 | [diff] [blame] | 29 | extern const int kMaxPrepopulatedEngineID; |
30 | |||||
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 31 | void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 32 | |
33 | // Returns the current version of the prepopulate data, so callers can know when | ||||
[email protected] | af4d764 | 2010-07-13 21:57:18 | [diff] [blame] | 34 | // they need to re-merge. If the prepopulate data comes from the preferences |
35 | // file then it returns the version specified there. | ||||
36 | int GetDataVersion(PrefService* prefs); | ||||
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 37 | |
ianwen | a27b1df | 2016-09-23 23:08:23 | [diff] [blame] | 38 | // Returns the prepopulated URLs for the current country. |
a-v-y | 0e169cd2 | 2017-01-09 17:27:00 | [diff] [blame] | 39 | // If |default_search_provider_index| is non-null, it is set to the index of the |
40 | // default search provider within the returned vector. | ||||
avi | e8828f2 | 2016-09-02 18:07:58 | [diff] [blame] | 41 | std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines( |
[email protected] | c6dea6b | 2014-04-30 18:06:04 | [diff] [blame] | 42 | PrefService* prefs, |
[email protected] | 64cf60c1 | 2014-03-10 21:53:42 | [diff] [blame] | 43 | size_t* default_search_provider_index); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 44 | |
a-v-y | 858416e | 2017-03-01 16:42:45 | [diff] [blame] | 45 | // Returns the prepopulated search engine with the given |prepopulated_id|. |
46 | std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs, | ||||
47 | int prepopulated_id); | ||||
48 | |||||
ianwen | a27b1df | 2016-09-23 23:08:23 | [diff] [blame] | 49 | #if defined(OS_ANDROID) |
Ted Choc | a2e926a | 2017-08-16 20:35:21 | [diff] [blame] | 50 | // Returns the prepopulated URLs associated with |locale|. |locale| should be a |
51 | // two-character uppercase ISO 3166-1 country code. | ||||
ianwen | a27b1df | 2016-09-23 23:08:23 | [diff] [blame] | 52 | std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines( |
Ted Choc | 46ddf858 | 2017-09-15 02:31:25 | [diff] [blame^] | 53 | const std::string& locale); |
ianwen | a27b1df | 2016-09-23 23:08:23 | [diff] [blame] | 54 | #endif |
55 | |||||
vitbar | da6a5018 | 2016-06-14 18:20:32 | [diff] [blame] | 56 | // Returns all prepopulated engines for all locales. Used only by tests. |
57 | std::vector<const PrepopulatedEngine*> GetAllPrepopulatedEngines(); | ||||
58 | |||||
[email protected] | 4a40facd | 2013-05-29 14:44:56 | [diff] [blame] | 59 | // Removes prepopulated engines and their version stored in user prefs. |
[email protected] | c6dea6b | 2014-04-30 18:06:04 | [diff] [blame] | 60 | void ClearPrepopulatedEnginesInPrefs(PrefService* prefs); |
[email protected] | 4a40facd | 2013-05-29 14:44:56 | [diff] [blame] | 61 | |
[email protected] | c6dea6b | 2014-04-30 18:06:04 | [diff] [blame] | 62 | // Returns the default search provider specified by the prepopulate data, which |
63 | // may be NULL. | ||||
64 | // If |prefs| is NULL, any search provider overrides from the preferences are | ||||
[email protected] | 623de74f | 2012-03-14 21:36:02 | [diff] [blame] | 65 | // not used. |
dcheng | d967d950 | 2016-04-21 22:36:51 | [diff] [blame] | 66 | std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch( |
67 | PrefService* prefs); | ||||
[email protected] | b6fd1fa7 | 2010-10-05 23:49:31 | [diff] [blame] | 68 | |
[email protected] | 6fc30f0 | 2013-08-20 19:55:16 | [diff] [blame] | 69 | // Like the above, but takes a GURL which is expected to represent a search URL. |
70 | // This may be called on any thread. | ||||
71 | SearchEngineType GetEngineType(const GURL& url); | ||||
72 | |||||
sdefresne | 71c91039 | 2015-05-20 09:14:39 | [diff] [blame] | 73 | // Returns the identifier for the user current country. Used to update the list |
74 | // of search engines when user switches device region settings. For use on iOS | ||||
75 | // only. | ||||
76 | // TODO(ios): Once user can customize search engines ( http://crbug.com/153047 ) | ||||
77 | // this declaration should be removed and the definition in the .cc file be | ||||
78 | // moved back to the anonymous namespace. | ||||
79 | int GetCurrentCountryID(); | ||||
80 | |||||
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 81 | } // namespace TemplateURLPrepopulateData |
82 | |||||
[email protected] | 0915b35 | 2014-06-25 19:58:14 | [diff] [blame] | 83 | #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ |