blob: 9d6787305b98f5014824974bbadff162755d5574 [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]e937a9702013-10-03 22:59:4314#include "base/memory/scoped_vector.h"
[email protected]24a555b62013-06-10 22:01:1715#include "base/strings/string16.h"
[email protected]f92b15b2014-06-12 04:16:1816#include "components/search_engines/search_engine_type.h"
[email protected]623de74f2012-03-14 21:36:0217
[email protected]258ecdb2010-10-19 05:02:5418class GURL;
[email protected]d82443b2009-01-15 19:54:5619class PrefService;
[email protected]ce7ee5f2014-06-16 23:41:1920class SearchTermsData;
[email protected]d82443b2009-01-15 19:54:5621class TemplateURL;
[email protected]c6dea6b2014-04-30 18:06:0422struct TemplateURLData;
[email protected]d82443b2009-01-15 19:54:5623
[email protected]443e9312013-05-06 06:17:3424namespace user_prefs {
25class PrefRegistrySyncable;
26}
27
[email protected]d82443b2009-01-15 19:54:5628namespace TemplateURLPrepopulateData {
29
fdoray95b217e2015-11-15 03:03:3330struct PrepopulatedEngine;
31
[email protected]542bce322011-10-10 01:18:1132extern const int kMaxPrepopulatedEngineID;
33
[email protected]37ca3fe02013-07-05 15:32:4434void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
[email protected]d82443b2009-01-15 19:54:5635
36// Returns the current version of the prepopulate data, so callers can know when
[email protected]af4d7642010-07-13 21:57:1837// they need to re-merge. If the prepopulate data comes from the preferences
38// file then it returns the version specified there.
39int GetDataVersion(PrefService* prefs);
[email protected]d82443b2009-01-15 19:54:5640
[email protected]e937a9702013-10-03 22:59:4341// Loads the set of TemplateURLs from the prepopulate data. On return,
[email protected]d82443b2009-01-15 19:54:5642// |default_search_provider_index| is set to the index of the default search
43// provider.
[email protected]c6dea6b2014-04-30 18:06:0444ScopedVector<TemplateURLData> GetPrepopulatedEngines(
45 PrefService* prefs,
[email protected]64cf60c12014-03-10 21:53:4246 size_t* default_search_provider_index);
[email protected]d82443b2009-01-15 19:54:5647
fdoray95b217e2015-11-15 03:03:3348// Returns a TemplateURLData for the specified prepopulated engine.
dchengd967d9502016-04-21 22:36:5149std::unique_ptr<TemplateURLData> MakeTemplateURLDataFromPrepopulatedEngine(
fdoray95b217e2015-11-15 03:03:3350 const PrepopulatedEngine& engine);
51
[email protected]4a40facd2013-05-29 14:44:5652// Removes prepopulated engines and their version stored in user prefs.
[email protected]c6dea6b2014-04-30 18:06:0453void ClearPrepopulatedEnginesInPrefs(PrefService* prefs);
[email protected]4a40facd2013-05-29 14:44:5654
[email protected]c6dea6b2014-04-30 18:06:0455// Returns the default search provider specified by the prepopulate data, which
56// may be NULL.
57// If |prefs| is NULL, any search provider overrides from the preferences are
[email protected]623de74f2012-03-14 21:36:0258// not used.
dchengd967d9502016-04-21 22:36:5159std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
60 PrefService* prefs);
[email protected]b6fd1fa72010-10-05 23:49:3161
[email protected]628392f2013-08-16 00:34:4562// Returns the type of the provided engine, or SEARCH_ENGINE_OTHER if no engines
63// match. This checks the TLD+1 for the most part, but will report the type as
64// SEARCH_ENGINE_GOOGLE for any hostname that causes
65// google_util::IsGoogleHostname() to return true.
[email protected]fe6552312012-06-12 04:59:5966//
67// NOTE: Must be called on the UI thread.
[email protected]ce7ee5f2014-06-16 23:41:1968SearchEngineType GetEngineType(const TemplateURL& template_url,
69 const SearchTermsData& search_terms_data);
[email protected]333808db2011-11-21 19:19:5670
[email protected]6fc30f02013-08-20 19:55:1671// Like the above, but takes a GURL which is expected to represent a search URL.
72// This may be called on any thread.
73SearchEngineType GetEngineType(const GURL& url);
74
sdefresne71c910392015-05-20 09:14:3975// Returns the identifier for the user current country. Used to update the list
76// of search engines when user switches device region settings. For use on iOS
77// only.
78// TODO(ios): Once user can customize search engines ( http://crbug.com/153047 )
79// this declaration should be removed and the definition in the .cc file be
80// moved back to the anonymous namespace.
81int GetCurrentCountryID();
82
[email protected]d82443b2009-01-15 19:54:5683} // namespace TemplateURLPrepopulateData
84
[email protected]0915b352014-06-25 19:58:1485#endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_