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