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

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

Issue 367863005: No chrome dependencies in TemplateURLService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename to TemplateURLServiceClient Created 6 years, 5 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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/google/google_url_tracker_factory.h" 12 #include "chrome/browser/google/google_url_tracker_factory.h"
13 #include "chrome/browser/history/history_service_factory.h" 13 #include "chrome/browser/history/history_service_factory.h"
14 #include "chrome/browser/profiles/incognito_helpers.h" 14 #include "chrome/browser/profiles/incognito_helpers.h"
15 #include "chrome/browser/rlz/rlz.h" 15 #include "chrome/browser/rlz/rlz.h"
16 #include "chrome/browser/search_engines/chrome_template_url_service_client.h"
16 #include "chrome/browser/search_engines/template_url_service.h" 17 #include "chrome/browser/search_engines/template_url_service.h"
18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
17 #include "chrome/browser/webdata/web_data_service_factory.h" 19 #include "chrome/browser/webdata/web_data_service_factory.h"
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" 20 #include "components/keyed_service/content/browser_context_dependency_manager.h"
19 #include "components/pref_registry/pref_registry_syncable.h" 21 #include "components/pref_registry/pref_registry_syncable.h"
20 #include "components/search_engines/default_search_manager.h" 22 #include "components/search_engines/default_search_manager.h"
21 #include "components/search_engines/search_engines_pref_names.h" 23 #include "components/search_engines/search_engines_pref_names.h"
22 24
23 // static 25 // static
24 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { 26 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) {
25 return static_cast<TemplateURLService*>( 27 return static_cast<TemplateURLService*>(
26 GetInstance()->GetServiceForBrowserContext(profile, true)); 28 GetInstance()->GetServiceForBrowserContext(profile, true));
27 } 29 }
28 30
29 // static 31 // static
30 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { 32 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() {
31 return Singleton<TemplateURLServiceFactory>::get(); 33 return Singleton<TemplateURLServiceFactory>::get();
32 } 34 }
33 35
34 // static 36 // static
35 KeyedService* TemplateURLServiceFactory::BuildInstanceFor( 37 KeyedService* TemplateURLServiceFactory::BuildInstanceFor(
36 content::BrowserContext* profile) { 38 content::BrowserContext* context) {
37 base::Closure dsp_change_callback; 39 base::Closure dsp_change_callback;
38 #if defined(ENABLE_RLZ) 40 #if defined(ENABLE_RLZ)
39 dsp_change_callback = 41 dsp_change_callback =
40 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), 42 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent),
41 rlz_lib::CHROME, 43 rlz_lib::CHROME,
42 RLZTracker::ChromeOmnibox(), 44 RLZTracker::ChromeOmnibox(),
43 rlz_lib::SET_TO_GOOGLE); 45 rlz_lib::SET_TO_GOOGLE);
44 #endif 46 #endif
45 return new TemplateURLService(static_cast<Profile*>(profile), 47 Profile* profile = static_cast<Profile*>(context);
46 g_browser_process->rappor_service(), 48 return new TemplateURLService(
47 dsp_change_callback); 49 profile->GetPrefs(),
50 scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)),
51 WebDataServiceFactory::GetKeywordWebDataForProfile(
52 profile, Profile::EXPLICIT_ACCESS),
53 scoped_ptr<TemplateURLServiceClient>(
54 new ChromeTemplateURLServiceClient(profile)),
55 GoogleURLTrackerFactory::GetForProfile(profile),
56 g_browser_process->rappor_service(),
57 dsp_change_callback);
48 } 58 }
49 59
50 TemplateURLServiceFactory::TemplateURLServiceFactory() 60 TemplateURLServiceFactory::TemplateURLServiceFactory()
51 : BrowserContextKeyedServiceFactory( 61 : BrowserContextKeyedServiceFactory(
52 "TemplateURLServiceFactory", 62 "TemplateURLServiceFactory",
53 BrowserContextDependencyManager::GetInstance()) { 63 BrowserContextDependencyManager::GetInstance()) {
54 DependsOn(GoogleURLTrackerFactory::GetInstance()); 64 DependsOn(GoogleURLTrackerFactory::GetInstance());
55 DependsOn(HistoryServiceFactory::GetInstance()); 65 DependsOn(HistoryServiceFactory::GetInstance());
56 DependsOn(WebDataServiceFactory::GetInstance()); 66 DependsOn(WebDataServiceFactory::GetInstance());
57 } 67 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 152 }
143 153
144 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( 154 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse(
145 content::BrowserContext* context) const { 155 content::BrowserContext* context) const {
146 return chrome::GetBrowserContextRedirectedInIncognito(context); 156 return chrome::GetBrowserContextRedirectedInIncognito(context);
147 } 157 }
148 158
149 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { 159 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const {
150 return true; 160 return true;
151 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698