Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/search_engines/template_url_service_factory.cc

Issue 15517005: Remove references to Profile from browser_context_keyed_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & style Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/search_engines/template_url_service_factory.h" 5 #include "chrome/browser/search_engines/template_url_service_factory.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/google/google_url_tracker_factory.h" 8 #include "chrome/browser/google/google_url_tracker_factory.h"
9 #include "chrome/browser/history/history_service_factory.h" 9 #include "chrome/browser/history/history_service_factory.h"
10 #include "chrome/browser/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/search_engines/template_url_service.h" 11 #include "chrome/browser/search_engines/template_url_service.h"
12 #include "chrome/browser/webdata/web_data_service_factory.h" 12 #include "chrome/browser/webdata/web_data_service_factory.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 14 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
15 #include "components/user_prefs/pref_registry_syncable.h" 15 #include "components/user_prefs/pref_registry_syncable.h"
16 16
17 // static 17 // static
18 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { 18 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) {
19 return static_cast<TemplateURLService*>( 19 return static_cast<TemplateURLService*>(
20 GetInstance()->GetServiceForProfile(profile, true)); 20 GetInstance()->GetServiceForBrowserContext(profile, true));
21 } 21 }
22 22
23 // static 23 // static
24 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { 24 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() {
25 return Singleton<TemplateURLServiceFactory>::get(); 25 return Singleton<TemplateURLServiceFactory>::get();
26 } 26 }
27 27
28 // static 28 // static
29 ProfileKeyedService* TemplateURLServiceFactory::BuildInstanceFor( 29 BrowserContextKeyedService* TemplateURLServiceFactory::BuildInstanceFor(
30 content::BrowserContext* profile) { 30 content::BrowserContext* profile) {
31 return new TemplateURLService(static_cast<Profile*>(profile)); 31 return new TemplateURLService(static_cast<Profile*>(profile));
32 } 32 }
33 33
34 TemplateURLServiceFactory::TemplateURLServiceFactory() 34 TemplateURLServiceFactory::TemplateURLServiceFactory()
35 : ProfileKeyedServiceFactory("TemplateURLServiceFactory", 35 : BrowserContextKeyedServiceFactory(
36 ProfileDependencyManager::GetInstance()) { 36 "TemplateURLServiceFactory",
37 BrowserContextDependencyManager::GetInstance()) {
37 DependsOn(GoogleURLTrackerFactory::GetInstance()); 38 DependsOn(GoogleURLTrackerFactory::GetInstance());
38 DependsOn(HistoryServiceFactory::GetInstance()); 39 DependsOn(HistoryServiceFactory::GetInstance());
39 DependsOn(WebDataServiceFactory::GetInstance()); 40 DependsOn(WebDataServiceFactory::GetInstance());
40 } 41 }
41 42
42 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} 43 TemplateURLServiceFactory::~TemplateURLServiceFactory() {}
43 44
44 ProfileKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( 45 BrowserContextKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor(
45 content::BrowserContext* profile) const { 46 content::BrowserContext* profile) const {
46 return BuildInstanceFor(static_cast<Profile*>(profile)); 47 return BuildInstanceFor(static_cast<Profile*>(profile));
47 } 48 }
48 49
49 void TemplateURLServiceFactory::RegisterUserPrefs( 50 void TemplateURLServiceFactory::RegisterUserPrefs(
50 user_prefs::PrefRegistrySyncable* registry) { 51 user_prefs::PrefRegistrySyncable* registry) {
51 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, 52 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID,
52 std::string(), 53 std::string(),
53 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 54 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
54 registry->RegisterBooleanPref( 55 registry->RegisterBooleanPref(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // incognito profiles so that search-term-replacement can be disabled in 106 // incognito profiles so that search-term-replacement can be disabled in
106 // incognito (see crbug.com/232065). Switch back to a shared instance once 107 // incognito (see crbug.com/232065). Switch back to a shared instance once
107 // this is no longer necessary. 108 // this is no longer necessary.
108 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 109 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
109 } 110 }
110 111
111 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { 112 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const {
112 return true; 113 return true;
113 } 114 }
114 115
115 void TemplateURLServiceFactory::ProfileShutdown( 116 void TemplateURLServiceFactory::BrowserContextShutdown(
116 content::BrowserContext* profile) { 117 content::BrowserContext* profile) {
117 // We shutdown AND destroy the TemplateURLService during this pass. 118 // We shutdown AND destroy the TemplateURLService during this pass.
118 // TemplateURLService schedules a task on the WebDataService from its 119 // TemplateURLService schedules a task on the WebDataService from its
119 // destructor. Delete it first to ensure the task gets scheduled before we 120 // destructor. Delete it first to ensure the task gets scheduled before we
120 // shut down the database. 121 // shut down the database.
121 ProfileKeyedServiceFactory::ProfileShutdown(profile); 122 BrowserContextKeyedServiceFactory::BrowserContextShutdown(profile);
122 ProfileKeyedServiceFactory::ProfileDestroyed(profile); 123 BrowserContextKeyedServiceFactory::BrowserContextDestroyed(profile);
123 } 124 }
124 125
125 void TemplateURLServiceFactory::ProfileDestroyed( 126 void TemplateURLServiceFactory::BrowserContextDestroyed(
126 content::BrowserContext* profile) { 127 content::BrowserContext* profile) {
127 // Don't double delete. 128 // Don't double delete.
128 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698