[Sync] Add auto-generated ModelType in Java.
[chromium-blink-merge.git] / components / search_engines / template_url_prepopulate_data.h
blob65230f56bd9f9c2e91452166bcbe97399f50dd52
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.
5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
8 #include <stddef.h>
9 #include <string>
10 #include <vector>
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/strings/string16.h"
15 #include "components/search_engines/search_engine_type.h"
17 class GURL;
18 class PrefService;
19 class SearchTermsData;
20 class TemplateURL;
21 struct TemplateURLData;
23 namespace user_prefs {
24 class PrefRegistrySyncable;
27 namespace TemplateURLPrepopulateData {
29 extern const int kMaxPrepopulatedEngineID;
31 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
33 // Returns the current version of the prepopulate data, so callers can know when
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);
38 // Loads the set of TemplateURLs from the prepopulate data. On return,
39 // |default_search_provider_index| is set to the index of the default search
40 // provider.
41 ScopedVector<TemplateURLData> GetPrepopulatedEngines(
42 PrefService* prefs,
43 size_t* default_search_provider_index);
45 // Removes prepopulated engines and their version stored in user prefs.
46 void ClearPrepopulatedEnginesInPrefs(PrefService* prefs);
48 // Returns the default search provider specified by the prepopulate data, which
49 // may be NULL.
50 // If |prefs| is NULL, any search provider overrides from the preferences are
51 // not used.
52 scoped_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(PrefService* prefs);
54 // Returns the type of the provided engine, or SEARCH_ENGINE_OTHER if no engines
55 // match. This checks the TLD+1 for the most part, but will report the type as
56 // SEARCH_ENGINE_GOOGLE for any hostname that causes
57 // google_util::IsGoogleHostname() to return true.
59 // NOTE: Must be called on the UI thread.
60 SearchEngineType GetEngineType(const TemplateURL& template_url,
61 const SearchTermsData& search_terms_data);
63 // Like the above, but takes a GURL which is expected to represent a search URL.
64 // This may be called on any thread.
65 SearchEngineType GetEngineType(const GURL& url);
67 // Returns the identifier for the user current country. Used to update the list
68 // of search engines when user switches device region settings. For use on iOS
69 // only.
70 // TODO(ios): Once user can customize search engines ( http://crbug.com/153047 )
71 // this declaration should be removed and the definition in the .cc file be
72 // moved back to the anonymous namespace.
73 int GetCurrentCountryID();
75 } // namespace TemplateURLPrepopulateData
77 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_