blob: 4e76dab2cfbe92b2e809bd215cea7c0a8860573b [file] [log] [blame]
[email protected]0915b352014-06-25 19:58:141// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]d82443b2009-01-15 19:54:562// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]0915b352014-06-25 19:58:145#ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
6#define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_
[email protected]d82443b2009-01-15 19:54:567
[email protected]d43f86e2011-05-16 01:22:468#include <stddef.h>
dchengd967d9502016-04-21 22:36:519
10#include <memory>
[email protected]333808db2011-11-21 19:19:5611#include <string>
[email protected]d82443b2009-01-15 19:54:5612#include <vector>
13
[email protected]24a555b62013-06-10 22:01:1714#include "base/strings/string16.h"
[email protected]f92b15b2014-06-12 04:16:1815#include "components/search_engines/search_engine_type.h"
[email protected]623de74f2012-03-14 21:36:0216
[email protected]258ecdb2010-10-19 05:02:5417class GURL;
[email protected]d82443b2009-01-15 19:54:5618class PrefService;
[email protected]c6dea6b2014-04-30 18:06:0419struct TemplateURLData;
[email protected]d82443b2009-01-15 19:54:5620
[email protected]443e9312013-05-06 06:17:3421namespace user_prefs {
22class PrefRegistrySyncable;
23}
24
[email protected]d82443b2009-01-15 19:54:5625namespace TemplateURLPrepopulateData {
26
fdoray95b217e2015-11-15 03:03:3327struct PrepopulatedEngine;
28
[email protected]542bce322011-10-10 01:18:1129extern const int kMaxPrepopulatedEngineID;
30
[email protected]37ca3fe02013-07-05 15:32:4431void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
[email protected]d82443b2009-01-15 19:54:5632
33// Returns the current version of the prepopulate data, so callers can know when
[email protected]af4d7642010-07-13 21:57:1834// they need to re-merge. If the prepopulate data comes from the preferences
35// file then it returns the version specified there.
36int GetDataVersion(PrefService* prefs);
[email protected]d82443b2009-01-15 19:54:5637
ianwena27b1df2016-09-23 23:08:2338// Returns the prepopulated URLs for the current country.
a-v-y0e169cd22017-01-09 17:27:0039// If |default_search_provider_index| is non-null, it is set to the index of the
40// default search provider within the returned vector.
avie8828f22016-09-02 18:07:5841std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
[email protected]c6dea6b2014-04-30 18:06:0442 PrefService* prefs,
[email protected]64cf60c12014-03-10 21:53:4243 size_t* default_search_provider_index);
[email protected]d82443b2009-01-15 19:54:5644
a-v-y858416e2017-03-01 16:42:4545// Returns the prepopulated search engine with the given |prepopulated_id|.
46std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs,
47 int prepopulated_id);
48
ianwena27b1df2016-09-23 23:08:2349#if defined(OS_ANDROID)
Ted Choca2e926a2017-08-16 20:35:2150// Returns the prepopulated URLs associated with |locale|. |locale| should be a
51// two-character uppercase ISO 3166-1 country code.
ianwena27b1df2016-09-23 23:08:2352std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines(
Ted Choc46ddf8582017-09-15 02:31:2553 const std::string& locale);
ianwena27b1df2016-09-23 23:08:2354#endif
55
vitbarda6a50182016-06-14 18:20:3256// Returns all prepopulated engines for all locales. Used only by tests.
57std::vector<const PrepopulatedEngine*> GetAllPrepopulatedEngines();
58
[email protected]4a40facd2013-05-29 14:44:5659// Removes prepopulated engines and their version stored in user prefs.
[email protected]c6dea6b2014-04-30 18:06:0460void ClearPrepopulatedEnginesInPrefs(PrefService* prefs);
[email protected]4a40facd2013-05-29 14:44:5661
[email protected]c6dea6b2014-04-30 18:06:0462// Returns the default search provider specified by the prepopulate data, which
63// may be NULL.
64// If |prefs| is NULL, any search provider overrides from the preferences are
[email protected]623de74f2012-03-14 21:36:0265// not used.
dchengd967d9502016-04-21 22:36:5166std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
67 PrefService* prefs);
[email protected]b6fd1fa72010-10-05 23:49:3168
[email protected]6fc30f02013-08-20 19:55:1669// Like the above, but takes a GURL which is expected to represent a search URL.
70// This may be called on any thread.
71SearchEngineType GetEngineType(const GURL& url);
72
sdefresne71c910392015-05-20 09:14:3973// Returns the identifier for the user current country. Used to update the list
74// of search engines when user switches device region settings. For use on iOS
75// only.
76// TODO(ios): Once user can customize search engines ( http://crbug.com/153047 )
77// this declaration should be removed and the definition in the .cc file be
78// moved back to the anonymous namespace.
79int GetCurrentCountryID();
80
[email protected]d82443b2009-01-15 19:54:5681} // namespace TemplateURLPrepopulateData
82
[email protected]0915b352014-06-25 19:58:1483#endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_