Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / search_engines / template_url_prepopulate_data.h
blob2d6449822bfa787a767fd3996a59c9540536d65e
1 // Copyright (c) 2012 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 CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
8 #include <stddef.h>
9 #include <string>
10 #include <vector>
12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/search_engines/search_engine_type.h"
16 class GURL;
17 class PrefService;
18 class Profile;
19 class TemplateURL;
21 namespace user_prefs {
22 class PrefRegistrySyncable;
25 namespace TemplateURLPrepopulateData {
27 extern const int kMaxPrepopulatedEngineID;
29 // Sizes at which search provider logos are available.
30 enum LogoSize {
31 LOGO_100_PERCENT,
32 LOGO_200_PERCENT,
35 #if defined(OS_ANDROID)
36 // This must be called early only once. |country_code| is the country code at
37 // install following the ISO-3166 specification.
38 void InitCountryCode(const std::string& country_code);
39 #endif
41 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
43 // Returns the current version of the prepopulate data, so callers can know when
44 // they need to re-merge. If the prepopulate data comes from the preferences
45 // file then it returns the version specified there.
46 int GetDataVersion(PrefService* prefs);
48 // Loads the set of TemplateURLs from the prepopulate data. On return,
49 // |default_search_provider_index| is set to the index of the default search
50 // provider.
51 ScopedVector<TemplateURL> GetPrepopulatedEngines(
52 Profile* profile, size_t* default_search_provider_index);
54 // Removes prepopulated engines and their version stored in user prefs.
55 void ClearPrepopulatedEnginesInPrefs(Profile* profile);
57 // Returns the default search provider specified by the prepopulate data.
58 // The caller owns the returned value, which may be NULL.
59 // If |profile| is NULL, any search provider overrides from the preferences are
60 // not used.
61 TemplateURL* GetPrepopulatedDefaultSearch(Profile* profile);
63 // Returns the type of the provided engine, or SEARCH_ENGINE_OTHER if no engines
64 // match. This checks the TLD+1 for the most part, but will report the type as
65 // SEARCH_ENGINE_GOOGLE for any hostname that causes
66 // google_util::IsGoogleHostname() to return true.
68 // NOTE: Must be called on the UI thread.
69 SearchEngineType GetEngineType(const TemplateURL& template_url);
71 // Like the above, but takes a GURL which is expected to represent a search URL.
72 // This may be called on any thread.
73 SearchEngineType GetEngineType(const GURL& url);
75 // Returns the logo at the specified |size| for |template_url|. If no logo is
76 // known, this will return an empty GURL.
78 // NOTE: Must be called on the UI thread.
79 GURL GetLogoURL(const TemplateURL& template_url, LogoSize size);
81 } // namespace TemplateURLPrepopulateData
83 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_