| 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/protector/protector_service_factory.h" | 5 #include "chrome/browser/protector/protector_service_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/profiles/profile_dependency_manager.h" | 8 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 9 #include "chrome/browser/protector/protected_prefs_watcher.h" |
| 9 #include "chrome/browser/protector/protector_service.h" | 10 #include "chrome/browser/protector/protector_service.h" |
| 10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 11 | 12 |
| 12 namespace protector { | 13 namespace protector { |
| 13 | 14 |
| 14 // static | 15 // static |
| 15 ProtectorService* ProtectorServiceFactory::GetForProfile(Profile* profile) { | 16 ProtectorService* ProtectorServiceFactory::GetForProfile(Profile* profile) { |
| 16 return static_cast<ProtectorService*>( | 17 return static_cast<ProtectorService*>( |
| 17 GetInstance()->GetServiceForProfile(profile, true)); | 18 GetInstance()->GetServiceForProfile(profile, true)); |
| 18 } | 19 } |
| 19 | 20 |
| 20 // static | 21 // static |
| 21 ProtectorServiceFactory* ProtectorServiceFactory::GetInstance() { | 22 ProtectorServiceFactory* ProtectorServiceFactory::GetInstance() { |
| 22 return Singleton<ProtectorServiceFactory>::get(); | 23 return Singleton<ProtectorServiceFactory>::get(); |
| 23 } | 24 } |
| 24 | 25 |
| 25 ProtectorServiceFactory::ProtectorServiceFactory() | 26 ProtectorServiceFactory::ProtectorServiceFactory() |
| 26 : ProfileKeyedServiceFactory("ProtectorService", | 27 : ProfileKeyedServiceFactory("ProtectorService", |
| 27 ProfileDependencyManager::GetInstance()) { | 28 ProfileDependencyManager::GetInstance()) { |
| 29 // Dependencies for the correct service shutdown order. |
| 28 DependsOn(GlobalErrorServiceFactory::GetInstance()); | 30 DependsOn(GlobalErrorServiceFactory::GetInstance()); |
| 29 DependsOn(TemplateURLServiceFactory::GetInstance()); | 31 DependsOn(TemplateURLServiceFactory::GetInstance()); |
| 32 // BUG(ivankr): to be bullet-proof, ProtectorService must outlive the |
| 33 // ExtensionService as well and be the second to last thing destroyed in |
| 34 // ProfileImpl (the last being the PrefService itself). This cannot be |
| 35 // accomplished with ProfileKeyedService implementation. |
| 30 } | 36 } |
| 31 | 37 |
| 32 ProtectorServiceFactory::~ProtectorServiceFactory() { | 38 ProtectorServiceFactory::~ProtectorServiceFactory() { |
| 33 } | 39 } |
| 34 | 40 |
| 35 ProfileKeyedService* ProtectorServiceFactory::BuildServiceInstanceFor( | 41 ProfileKeyedService* ProtectorServiceFactory::BuildServiceInstanceFor( |
| 36 Profile* profile) const { | 42 Profile* profile) const { |
| 37 return new ProtectorService(profile); | 43 return new ProtectorService(profile); |
| 38 } | 44 } |
| 39 | 45 |
| 46 void ProtectorServiceFactory::RegisterUserPrefs(PrefService* user_prefs) { |
| 47 ProtectedPrefsWatcher::RegisterUserPrefs(user_prefs); |
| 48 } |
| 49 |
| 50 bool ProtectorServiceFactory::ServiceIsCreatedWithProfile() { |
| 51 // ProtectorService watches changes for protected prefs so it must be started |
| 52 // right with the profile creation. |
| 53 return true; |
| 54 } |
| 55 |
| 40 bool ProtectorServiceFactory::ServiceRedirectedInIncognito() { | 56 bool ProtectorServiceFactory::ServiceRedirectedInIncognito() { |
| 41 return true; | 57 return true; |
| 42 } | 58 } |
| 43 | 59 |
| 44 } // namespace protector | 60 } // namespace protector |
| OLD | NEW |