// 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/protector/protector_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_dependency_manager.h" #include "chrome/browser/protector/protected_prefs_watcher.h" #include "chrome/browser/protector/protector_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" namespace protector { // static ProtectorService* ProtectorServiceFactory::GetForProfile(Profile* profile) { return static_cast( GetInstance()->GetServiceForProfile(profile, true)); } // static ProtectorServiceFactory* ProtectorServiceFactory::GetInstance() { return Singleton::get(); } ProtectorServiceFactory::ProtectorServiceFactory() : ProfileKeyedServiceFactory("ProtectorService", ProfileDependencyManager::GetInstance()) { // Dependencies for the correct service shutdown order. DependsOn(GlobalErrorServiceFactory::GetInstance()); DependsOn(TemplateURLServiceFactory::GetInstance()); // BUG(ivankr): to be bullet-proof, ProtectorService must outlive the // ExtensionService as well and be the second to last thing destroyed in // ProfileImpl (the last being the PrefService itself). This cannot be // accomplished with ProfileKeyedService implementation. } ProtectorServiceFactory::~ProtectorServiceFactory() { } ProfileKeyedService* ProtectorServiceFactory::BuildServiceInstanceFor( Profile* profile) const { return new ProtectorService(profile); } void ProtectorServiceFactory::RegisterUserPrefs(PrefService* user_prefs) { ProtectedPrefsWatcher::RegisterUserPrefs(user_prefs); } bool ProtectorServiceFactory::ServiceIsCreatedWithProfile() { // ProtectorService watches changes for protected prefs so it must be started // right with the profile creation. return true; } bool ProtectorServiceFactory::ServiceRedirectedInIncognito() { return true; } } // namespace protector