Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / search_engines / template_url_service_factory.cc
blobb991d3ebbc747a8de5f3b66ad6dccb7aa1108a63
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.
5 #include "chrome/browser/search_engines/template_url_service_factory.h"
7 #include <string>
9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/google/google_url_tracker_factory.h"
11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/incognito_helpers.h"
13 #include "chrome/browser/search_engines/template_url_service.h"
14 #include "chrome/browser/webdata/web_data_service_factory.h"
15 #include "chrome/common/pref_names.h"
16 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
17 #include "components/user_prefs/pref_registry_syncable.h"
19 // static
20 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) {
21 return static_cast<TemplateURLService*>(
22 GetInstance()->GetServiceForBrowserContext(profile, true));
25 // static
26 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() {
27 return Singleton<TemplateURLServiceFactory>::get();
30 // static
31 BrowserContextKeyedService* TemplateURLServiceFactory::BuildInstanceFor(
32 content::BrowserContext* profile) {
33 return new TemplateURLService(static_cast<Profile*>(profile));
36 TemplateURLServiceFactory::TemplateURLServiceFactory()
37 : BrowserContextKeyedServiceFactory(
38 "TemplateURLServiceFactory",
39 BrowserContextDependencyManager::GetInstance()) {
40 DependsOn(GoogleURLTrackerFactory::GetInstance());
41 DependsOn(HistoryServiceFactory::GetInstance());
42 DependsOn(WebDataServiceFactory::GetInstance());
45 TemplateURLServiceFactory::~TemplateURLServiceFactory() {}
47 BrowserContextKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor(
48 content::BrowserContext* profile) const {
49 return BuildInstanceFor(static_cast<Profile*>(profile));
52 void TemplateURLServiceFactory::RegisterProfilePrefs(
53 user_prefs::PrefRegistrySyncable* registry) {
54 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID,
55 std::string(),
56 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
57 registry->RegisterBooleanPref(
58 prefs::kDefaultSearchProviderEnabled,
59 true,
60 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
61 registry->RegisterStringPref(
62 prefs::kDefaultSearchProviderName,
63 std::string(),
64 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
65 registry->RegisterStringPref(
66 prefs::kDefaultSearchProviderID,
67 std::string(),
68 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
69 registry->RegisterStringPref(
70 prefs::kDefaultSearchProviderPrepopulateID,
71 std::string(),
72 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
73 registry->RegisterStringPref(
74 prefs::kDefaultSearchProviderSuggestURL,
75 std::string(),
76 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
77 registry->RegisterStringPref(
78 prefs::kDefaultSearchProviderSearchURL,
79 std::string(),
80 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
81 registry->RegisterStringPref(
82 prefs::kDefaultSearchProviderInstantURL,
83 std::string(),
84 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
85 registry->RegisterStringPref(
86 prefs::kDefaultSearchProviderImageURL,
87 std::string(),
88 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
89 registry->RegisterStringPref(
90 prefs::kDefaultSearchProviderNewTabURL,
91 std::string(),
92 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
93 registry->RegisterStringPref(
94 prefs::kDefaultSearchProviderSearchURLPostParams,
95 std::string(),
96 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
97 registry->RegisterStringPref(
98 prefs::kDefaultSearchProviderSuggestURLPostParams,
99 std::string(),
100 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
101 registry->RegisterStringPref(
102 prefs::kDefaultSearchProviderInstantURLPostParams,
103 std::string(),
104 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
105 registry->RegisterStringPref(
106 prefs::kDefaultSearchProviderImageURLPostParams,
107 std::string(),
108 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
109 registry->RegisterStringPref(
110 prefs::kDefaultSearchProviderKeyword,
111 std::string(),
112 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
113 registry->RegisterStringPref(
114 prefs::kDefaultSearchProviderIconURL,
115 std::string(),
116 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
117 registry->RegisterStringPref(
118 prefs::kDefaultSearchProviderEncodings,
119 std::string(),
120 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
121 registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs,
122 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
123 registry->RegisterStringPref(
124 prefs::kDefaultSearchProviderSearchTermsReplacementKey,
125 std::string(),
126 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
129 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse(
130 content::BrowserContext* context) const {
131 return chrome::GetBrowserContextRedirectedInIncognito(context);
134 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const {
135 return true;