| 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/bind.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 return static_cast<TemplateURLService*>( | 28 return static_cast<TemplateURLService*>( |
| 29 GetInstance()->GetServiceForBrowserContext(profile, true)); | 29 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { | 33 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { |
| 34 return Singleton<TemplateURLServiceFactory>::get(); | 34 return Singleton<TemplateURLServiceFactory>::get(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 KeyedService* TemplateURLServiceFactory::BuildInstanceFor( | 38 scoped_ptr<KeyedService> TemplateURLServiceFactory::BuildInstanceFor( |
| 39 content::BrowserContext* context) { | 39 content::BrowserContext* context) { |
| 40 base::Closure dsp_change_callback; | 40 base::Closure dsp_change_callback; |
| 41 #if defined(ENABLE_RLZ) | 41 #if defined(ENABLE_RLZ) |
| 42 dsp_change_callback = | 42 dsp_change_callback = |
| 43 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), | 43 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), |
| 44 rlz_lib::CHROME, | 44 rlz_lib::CHROME, |
| 45 RLZTracker::ChromeOmnibox(), | 45 RLZTracker::ChromeOmnibox(), |
| 46 rlz_lib::SET_TO_GOOGLE); | 46 rlz_lib::SET_TO_GOOGLE); |
| 47 #endif | 47 #endif |
| 48 Profile* profile = static_cast<Profile*>(context); | 48 Profile* profile = static_cast<Profile*>(context); |
| 49 return new TemplateURLService( | 49 return make_scoped_ptr(new TemplateURLService( |
| 50 profile->GetPrefs(), | 50 profile->GetPrefs(), |
| 51 scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)), | 51 scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)), |
| 52 WebDataServiceFactory::GetKeywordWebDataForProfile( | 52 WebDataServiceFactory::GetKeywordWebDataForProfile( |
| 53 profile, ServiceAccessType::EXPLICIT_ACCESS), | 53 profile, ServiceAccessType::EXPLICIT_ACCESS), |
| 54 scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient( | 54 scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient( |
| 55 HistoryServiceFactory::GetForProfile( | 55 HistoryServiceFactory::GetForProfile( |
| 56 profile, ServiceAccessType::EXPLICIT_ACCESS))), | 56 profile, ServiceAccessType::EXPLICIT_ACCESS))), |
| 57 GoogleURLTrackerFactory::GetForProfile(profile), | 57 GoogleURLTrackerFactory::GetForProfile(profile), |
| 58 g_browser_process->rappor_service(), | 58 g_browser_process->rappor_service(), dsp_change_callback)); |
| 59 dsp_change_callback); | |
| 60 } | 59 } |
| 61 | 60 |
| 62 TemplateURLServiceFactory::TemplateURLServiceFactory() | 61 TemplateURLServiceFactory::TemplateURLServiceFactory() |
| 63 : BrowserContextKeyedServiceFactory( | 62 : BrowserContextKeyedServiceFactory( |
| 64 "TemplateURLServiceFactory", | 63 "TemplateURLServiceFactory", |
| 65 BrowserContextDependencyManager::GetInstance()) { | 64 BrowserContextDependencyManager::GetInstance()) { |
| 66 DependsOn(GoogleURLTrackerFactory::GetInstance()); | 65 DependsOn(GoogleURLTrackerFactory::GetInstance()); |
| 67 DependsOn(HistoryServiceFactory::GetInstance()); | 66 DependsOn(HistoryServiceFactory::GetInstance()); |
| 68 DependsOn(WebDataServiceFactory::GetInstance()); | 67 DependsOn(WebDataServiceFactory::GetInstance()); |
| 69 } | 68 } |
| 70 | 69 |
| 71 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} | 70 TemplateURLServiceFactory::~TemplateURLServiceFactory() {} |
| 72 | 71 |
| 73 KeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( | 72 KeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( |
| 74 content::BrowserContext* profile) const { | 73 content::BrowserContext* profile) const { |
| 75 return BuildInstanceFor(static_cast<Profile*>(profile)); | 74 return BuildInstanceFor(static_cast<Profile*>(profile)).release(); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void TemplateURLServiceFactory::RegisterProfilePrefs( | 77 void TemplateURLServiceFactory::RegisterProfilePrefs( |
| 79 user_prefs::PrefRegistrySyncable* registry) { | 78 user_prefs::PrefRegistrySyncable* registry) { |
| 80 DefaultSearchManager::RegisterProfilePrefs(registry); | 79 DefaultSearchManager::RegisterProfilePrefs(registry); |
| 81 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, | 80 registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, |
| 82 std::string(), | 81 std::string(), |
| 83 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 82 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 84 registry->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, true); | 83 registry->RegisterBooleanPref(prefs::kDefaultSearchProviderEnabled, true); |
| 85 registry->RegisterStringPref(prefs::kDefaultSearchProviderName, | 84 registry->RegisterStringPref(prefs::kDefaultSearchProviderName, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 116 } |
| 118 | 117 |
| 119 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( | 118 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( |
| 120 content::BrowserContext* context) const { | 119 content::BrowserContext* context) const { |
| 121 return chrome::GetBrowserContextRedirectedInIncognito(context); | 120 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 122 } | 121 } |
| 123 | 122 |
| 124 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 123 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
| 125 return true; | 124 return true; |
| 126 } | 125 } |
| OLD | NEW |