OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
| 13 #include "base/string16.h" |
| 14 #include "chrome/browser/search_engines/search_engine_type.h" |
| 15 |
13 class GURL; | 16 class GURL; |
14 class PrefService; | 17 class PrefService; |
15 class TemplateURL; | 18 class TemplateURL; |
16 | 19 |
17 namespace TemplateURLPrepopulateData { | 20 namespace TemplateURLPrepopulateData { |
18 | 21 |
19 extern const int kMaxPrepopulatedEngineID; | 22 extern const int kMaxPrepopulatedEngineID; |
20 | 23 |
21 void RegisterUserPrefs(PrefService* prefs); | 24 void RegisterUserPrefs(PrefService* prefs); |
22 | 25 |
23 // Returns the current version of the prepopulate data, so callers can know when | 26 // Returns the current version of the prepopulate data, so callers can know when |
24 // they need to re-merge. If the prepopulate data comes from the preferences | 27 // they need to re-merge. If the prepopulate data comes from the preferences |
25 // file then it returns the version specified there. | 28 // file then it returns the version specified there. |
26 int GetDataVersion(PrefService* prefs); | 29 int GetDataVersion(PrefService* prefs); |
27 | 30 |
28 // Loads the set of TemplateURLs from the prepopulate data. Ownership of the | 31 // Loads the set of TemplateURLs from the prepopulate data. Ownership of the |
29 // TemplateURLs is passed to the caller. On return, | 32 // TemplateURLs is passed to the caller. On return, |
30 // |default_search_provider_index| is set to the index of the default search | 33 // |default_search_provider_index| is set to the index of the default search |
31 // provider. | 34 // provider. |
32 void GetPrepopulatedEngines(PrefService* prefs, | 35 void GetPrepopulatedEngines(PrefService* prefs, |
33 std::vector<TemplateURL*>* t_urls, | 36 std::vector<TemplateURL*>* t_urls, |
34 size_t* default_search_provider_index); | 37 size_t* default_search_provider_index); |
35 | 38 |
36 // Returns the default search provider specified by the prepopulate data. | 39 // Returns the default search provider specified by the prepopulate data. |
37 // The caller owns the returned value, which may be NULL. | 40 // The caller owns the returned value, which may be NULL. |
38 // If |prefs| is NULL, search provider overrides from preferences are not used. | 41 // If |prefs| is NULL, any search provider overrides from the preferences are |
| 42 // not used. |
39 TemplateURL* GetPrepopulatedDefaultSearch(PrefService* prefs); | 43 TemplateURL* GetPrepopulatedDefaultSearch(PrefService* prefs); |
40 | 44 |
41 // Returns a TemplateURL from the prepopulated data which has the same origin | 45 // Both the next two functions use same-origin checks unless the |url| is a |
42 // as the given url. The caller is responsible for deleting the returned | 46 // Google seach URL, in which case we'll identify any valid Google hostname, or |
43 // TemplateURL. | 47 // the unsubstituted Google prepopulate URL, as "Google". |
44 TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find); | |
45 | 48 |
46 // Returns the prepopulated search provider whose search URL origin matches the | 49 // Returns the short name for the matching engine, or url.host() if no engines |
47 // origin of |search_url| or NULL if none is found. The caller is responsible | 50 // match. If no engines match and the |url| can't be converted to a valid GURL, |
48 // for deleting the returned TemplateURL. | 51 // returns the string in IDS_UNKNOWN_SEARCH_ENGINE_NAME. |
49 TemplateURL* FindPrepopulatedEngine(const std::string& search_url); | 52 string16 GetEngineName(const std::string& url); |
| 53 |
| 54 // Returns the type of the matching engine, or SEARCH_ENGINE_OTHER if no engines |
| 55 // match. |
| 56 SearchEngineType GetEngineType(const std::string& url); |
50 | 57 |
51 } // namespace TemplateURLPrepopulateData | 58 } // namespace TemplateURLPrepopulateData |
52 | 59 |
53 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ | 60 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ |
OLD | NEW |