| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 5 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_service.h" | |
| 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 10 #include "components/keyed_service/core/keyed_service.h" | 9 #include "components/keyed_service/core/keyed_service.h" |
| 11 #include "components/pref_registry/pref_registry_syncable.h" | 10 #include "components/pref_registry/pref_registry_syncable.h" |
| 12 #include "components/user_prefs/user_prefs.h" | 11 #include "components/user_prefs/user_prefs.h" |
| 13 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 14 | 13 |
| 15 void BrowserContextKeyedServiceFactory::SetTestingFactory( | 14 void BrowserContextKeyedServiceFactory::SetTestingFactory( |
| 16 content::BrowserContext* context, | 15 content::BrowserContext* context, |
| 17 TestingFactoryFunction testing_factory) { | 16 TestingFactoryFunction testing_factory) { |
| 18 KeyedServiceFactory::SetTestingFactory( | 17 KeyedServiceFactory::SetTestingFactory( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 base::SupportsUserData* context) const { | 89 base::SupportsUserData* context) const { |
| 91 return BuildServiceInstanceFor( | 90 return BuildServiceInstanceFor( |
| 92 static_cast<content::BrowserContext*>(context)); | 91 static_cast<content::BrowserContext*>(context)); |
| 93 } | 92 } |
| 94 | 93 |
| 95 bool BrowserContextKeyedServiceFactory::IsOffTheRecord( | 94 bool BrowserContextKeyedServiceFactory::IsOffTheRecord( |
| 96 base::SupportsUserData* context) const { | 95 base::SupportsUserData* context) const { |
| 97 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); | 96 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); |
| 98 } | 97 } |
| 99 | 98 |
| 100 user_prefs::PrefRegistrySyncable* | 99 base::SupportsUserData* |
| 101 BrowserContextKeyedServiceFactory::GetAssociatedPrefRegistry( | 100 BrowserContextKeyedServiceFactory::GetUnderlyingContextInternal( |
| 102 base::SupportsUserData* context) const { | 101 base::SupportsUserData* context) const { |
| 103 PrefService* prefs = user_prefs::UserPrefs::Get(context); | 102 return context; |
| 104 user_prefs::PrefRegistrySyncable* registry = | 103 } |
| 105 static_cast<user_prefs::PrefRegistrySyncable*>( | 104 |
| 106 prefs->DeprecatedGetPrefRegistry()); | 105 base::SupportsUserData* |
| 107 return registry; | 106 BrowserContextKeyedServiceFactory::GetOriginalContextInternal( |
| 107 base::SupportsUserData* context) const { |
| 108 return context; |
| 108 } | 109 } |
| 109 | 110 |
| 110 base::SupportsUserData* BrowserContextKeyedServiceFactory::GetContextToUse( | 111 base::SupportsUserData* BrowserContextKeyedServiceFactory::GetContextToUse( |
| 111 base::SupportsUserData* context) const { | 112 base::SupportsUserData* context) const { |
| 112 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); | 113 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); |
| 113 } | 114 } |
| 114 | 115 |
| 115 bool BrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() const { | 116 bool BrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() const { |
| 116 return ServiceIsCreatedWithBrowserContext(); | 117 return ServiceIsCreatedWithBrowserContext(); |
| 117 } | 118 } |
| 118 | 119 |
| 119 void BrowserContextKeyedServiceFactory::ContextShutdown( | 120 void BrowserContextKeyedServiceFactory::ContextShutdown( |
| 120 base::SupportsUserData* context) { | 121 base::SupportsUserData* context) { |
| 121 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); | 122 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void BrowserContextKeyedServiceFactory::ContextDestroyed( | 125 void BrowserContextKeyedServiceFactory::ContextDestroyed( |
| 125 base::SupportsUserData* context) { | 126 base::SupportsUserData* context) { |
| 126 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); | 127 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void BrowserContextKeyedServiceFactory::RegisterPrefs( | 130 void BrowserContextKeyedServiceFactory::RegisterPrefs( |
| 130 user_prefs::PrefRegistrySyncable* registry) { | 131 user_prefs::PrefRegistrySyncable* registry) { |
| 131 RegisterProfilePrefs(registry); | 132 RegisterProfilePrefs(registry); |
| 132 } | 133 } |
| OLD | NEW |