| 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) { |
| 37 base::Closure dsp_change_callback; |
| 38 #if defined(ENABLE_RLZ) |
| 39 dsp_change_callback = |
| 40 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), |
| 41 rlz_lib::CHROME, |
| 42 RLZTracker::ChromeOmnibox(), |
| 43 rlz_lib::SET_TO_GOOGLE); |
| 44 #endif |
| 35 return new TemplateURLService(static_cast<Profile*>(profile), | 45 return new TemplateURLService(static_cast<Profile*>(profile), |
| 36 g_browser_process->rappor_service()); | 46 g_browser_process->rappor_service(), |
| 47 dsp_change_callback); |
| 37 } | 48 } |
| 38 | 49 |
| 39 TemplateURLServiceFactory::TemplateURLServiceFactory() | 50 TemplateURLServiceFactory::TemplateURLServiceFactory() |
| 40 : BrowserContextKeyedServiceFactory( | 51 : BrowserContextKeyedServiceFactory( |
| 41 "TemplateURLServiceFactory", | 52 "TemplateURLServiceFactory", |
| 42 BrowserContextDependencyManager::GetInstance()) { | 53 BrowserContextDependencyManager::GetInstance()) { |
| 43 DependsOn(GoogleURLTrackerFactory::GetInstance()); | 54 DependsOn(GoogleURLTrackerFactory::GetInstance()); |
| 44 DependsOn(HistoryServiceFactory::GetInstance()); | 55 DependsOn(HistoryServiceFactory::GetInstance()); |
| 45 DependsOn(WebDataServiceFactory::GetInstance()); | 56 DependsOn(WebDataServiceFactory::GetInstance()); |
| 46 } | 57 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 142 } |
| 132 | 143 |
| 133 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( | 144 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( |
| 134 content::BrowserContext* context) const { | 145 content::BrowserContext* context) const { |
| 135 return chrome::GetBrowserContextRedirectedInIncognito(context); | 146 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 136 } | 147 } |
| 137 | 148 |
| 138 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 149 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 139 return true; | 150 return true; |
| 140 } | 151 } |
| OLD | NEW |