Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/google/google_url_tracker_factory.h" | 12 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/profiles/incognito_helpers.h" | 14 #include "chrome/browser/profiles/incognito_helpers.h" |
| 15 #include "chrome/browser/rlz/rlz.h" | |
| 14 #include "chrome/browser/search_engines/template_url_service.h" | 16 #include "chrome/browser/search_engines/template_url_service.h" |
| 15 #include "chrome/browser/webdata/web_data_service_factory.h" | 17 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 17 #include "components/pref_registry/pref_registry_syncable.h" | 19 #include "components/pref_registry/pref_registry_syncable.h" |
| 18 #include "components/search_engines/default_search_manager.h" | 20 #include "components/search_engines/default_search_manager.h" |
| 19 #include "components/search_engines/search_engines_pref_names.h" | 21 #include "components/search_engines/search_engines_pref_names.h" |
| 20 | 22 |
| 21 // static | 23 // static |
| 22 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { | 24 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { |
| 23 return static_cast<TemplateURLService*>( | 25 return static_cast<TemplateURLService*>( |
| 24 GetInstance()->GetServiceForBrowserContext(profile, true)); | 26 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 25 } | 27 } |
| 26 | 28 |
| 27 // static | 29 // static |
| 28 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { | 30 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { |
| 29 return Singleton<TemplateURLServiceFactory>::get(); | 31 return Singleton<TemplateURLServiceFactory>::get(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 // static | 34 // static |
| 33 KeyedService* TemplateURLServiceFactory::BuildInstanceFor( | 35 KeyedService* TemplateURLServiceFactory::BuildInstanceFor( |
| 34 content::BrowserContext* profile) { | 36 content::BrowserContext* profile) { |
| 35 return new TemplateURLService(static_cast<Profile*>(profile), | 37 TemplateURLService* service = new TemplateURLService( |
| 36 g_browser_process->rappor_service()); | 38 static_cast<Profile*>(profile), |
| 39 g_browser_process->rappor_service()); | |
| 40 | |
| 41 #if defined(ENABLE_RLZ) | |
| 42 service->set_dsp_changed_to_google_event_recorder( | |
|
Peter Kasting
2014/07/01 18:19:08
If we're going to call this at the same time we co
hashimoto
2014/07/01 23:24:49
Done.
| |
| 43 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), | |
| 44 rlz_lib::CHROME, | |
| 45 RLZTracker::ChromeOmnibox(), | |
| 46 rlz_lib::SET_TO_GOOGLE)); | |
| 47 #endif | |
| 48 | |
| 49 return service; | |
| 37 } | 50 } |
| 38 | 51 |
| 39 TemplateURLServiceFactory::TemplateURLServiceFactory() | 52 TemplateURLServiceFactory::TemplateURLServiceFactory() |
| 40 : BrowserContextKeyedServiceFactory( | 53 : BrowserContextKeyedServiceFactory( |
| 41 "TemplateURLServiceFactory", | 54 "TemplateURLServiceFactory", |
| 42 BrowserContextDependencyManager::GetInstance()) { | 55 BrowserContextDependencyManager::GetInstance()) { |
| 43 DependsOn(GoogleURLTrackerFactory::GetInstance()); | 56 DependsOn(GoogleURLTrackerFactory::GetInstance()); |
| 44 DependsOn(HistoryServiceFactory::GetInstance()); | 57 DependsOn(HistoryServiceFactory::GetInstance()); |
| 45 DependsOn(WebDataServiceFactory::GetInstance()); | 58 DependsOn(WebDataServiceFactory::GetInstance()); |
| 46 } | 59 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 } | 144 } |
| 132 | 145 |
| 133 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( | 146 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( |
| 134 content::BrowserContext* context) const { | 147 content::BrowserContext* context) const { |
| 135 return chrome::GetBrowserContextRedirectedInIncognito(context); | 148 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 136 } | 149 } |
| 137 | 150 |
| 138 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 151 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 139 return true; | 152 return true; |
| 140 } | 153 } |
| OLD | NEW |