Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / search_engines / template_url_prepopulate_data.h
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.
4
5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
7
8 #include <stddef.h>
9 #include <string>
10 #include <vector>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/strings/string16.h"
15 #include "chrome/browser/search_engines/search_engine_type.h"
16
17 class GURL;
18 class PrefService;
19 class Profile;
20 class TemplateURL;
21 struct TemplateURLData;
22
23 namespace user_prefs {
24 class PrefRegistrySyncable;
25 }
26
27 namespace TemplateURLPrepopulateData {
28
29 extern const int kMaxPrepopulatedEngineID;
30
31 // Sizes at which search provider logos are available.
32 enum LogoSize {
33   LOGO_100_PERCENT,
34   LOGO_200_PERCENT,
35 };
36
37 #if defined(OS_ANDROID)
38 // This must be called early only once. |country_code| is the country code at
39 // install following the ISO-3166 specification.
40 void InitCountryCode(const std::string& country_code);
41 #endif
42
43 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
44
45 // Returns the current version of the prepopulate data, so callers can know when
46 // they need to re-merge. If the prepopulate data comes from the preferences
47 // file then it returns the version specified there.
48 int GetDataVersion(PrefService* prefs);
49
50 // Loads the set of TemplateURLs from the prepopulate data. On return,
51 // |default_search_provider_index| is set to the index of the default search
52 // provider.
53 ScopedVector<TemplateURLData> GetPrepopulatedEngines(
54     PrefService* prefs,
55     size_t* default_search_provider_index);
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 scoped_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(PrefService* prefs);
65
66 // Returns the type of the provided engine, or SEARCH_ENGINE_OTHER if no engines
67 // match.  This checks the TLD+1 for the most part, but will report the type as
68 // SEARCH_ENGINE_GOOGLE for any hostname that causes
69 // google_util::IsGoogleHostname() to return true.
70 //
71 // NOTE: Must be called on the UI thread.
72 SearchEngineType GetEngineType(const TemplateURL& template_url);
73
74 // Like the above, but takes a GURL which is expected to represent a search URL.
75 // This may be called on any thread.
76 SearchEngineType GetEngineType(const GURL& url);
77
78 // Returns the logo at the specified |size| for |template_url|.  If no logo is
79 // known, this will return an empty GURL.
80 //
81 // NOTE: Must be called on the UI thread.
82 GURL GetLogoURL(const TemplateURL& template_url, LogoSize size);
83
84 }  // namespace TemplateURLPrepopulateData
85
86 #endif  // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_