// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/search_engines/template_url_service_factory.h" #include #include "base/prefs/pref_service.h" #include "chrome/browser/google/google_url_tracker_factory.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/webdata/web_data_service_factory.h" #include "chrome/common/pref_names.h" #include "components/browser_context_keyed_service/browser_context_dependency_manager.h" #include "components/user_prefs/pref_registry_syncable.h" // static TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { return static_cast( GetInstance()->GetServiceForBrowserContext(profile, true)); } // static TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { return Singleton::get(); } // static BrowserContextKeyedService* TemplateURLServiceFactory::BuildInstanceFor( content::BrowserContext* profile) { return new TemplateURLService(static_cast(profile)); } TemplateURLServiceFactory::TemplateURLServiceFactory() : BrowserContextKeyedServiceFactory( "TemplateURLServiceFactory", BrowserContextDependencyManager::GetInstance()) { DependsOn(GoogleURLTrackerFactory::GetInstance()); DependsOn(HistoryServiceFactory::GetInstance()); DependsOn(WebDataServiceFactory::GetInstance()); } TemplateURLServiceFactory::~TemplateURLServiceFactory() {} BrowserContextKeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor( content::BrowserContext* profile) const { return BuildInstanceFor(static_cast(profile)); } void TemplateURLServiceFactory::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { registry->RegisterStringPref(prefs::kSyncedDefaultSearchProviderGUID, std::string(), user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterBooleanPref( prefs::kDefaultSearchProviderEnabled, true, user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderName, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderID, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderPrepopulateID, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderSuggestURL, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderSearchURL, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderInstantURL, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderImageURL, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderNewTabURL, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderSearchURLPostParams, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderSuggestURLPostParams, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderInstantURLPostParams, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderImageURLPostParams, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderKeyword, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderIconURL, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderEncodings, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterListPref(prefs::kDefaultSearchProviderAlternateURLs, user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); registry->RegisterStringPref( prefs::kDefaultSearchProviderSearchTermsReplacementKey, std::string(), user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); } content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( content::BrowserContext* context) const { return chrome::GetBrowserContextRedirectedInIncognito(context); } bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { return true; }