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/refcounted_browser_context_keyed_serv
ice_factory.h" | 5 #include "components/keyed_service/content/refcounted_browser_context_keyed_serv
ice_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/refcounted_keyed_service.h" | 9 #include "components/keyed_service/core/refcounted_keyed_service.h" |
11 #include "components/pref_registry/pref_registry_syncable.h" | |
12 #include "components/user_prefs/user_prefs.h" | |
13 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
14 | 11 |
15 void RefcountedBrowserContextKeyedServiceFactory::SetTestingFactory( | 12 void RefcountedBrowserContextKeyedServiceFactory::SetTestingFactory( |
16 content::BrowserContext* context, | 13 content::BrowserContext* context, |
17 TestingFactoryFunction testing_factory) { | 14 TestingFactoryFunction testing_factory) { |
18 RefcountedKeyedServiceFactory::SetTestingFactory( | 15 RefcountedKeyedServiceFactory::SetTestingFactory( |
19 context, | 16 context, |
20 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>( | 17 reinterpret_cast<RefcountedKeyedServiceFactory::TestingFactoryFunction>( |
21 testing_factory)); | 18 testing_factory)); |
22 } | 19 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 base::SupportsUserData* context) const { | 92 base::SupportsUserData* context) const { |
96 return BuildServiceInstanceFor( | 93 return BuildServiceInstanceFor( |
97 static_cast<content::BrowserContext*>(context)); | 94 static_cast<content::BrowserContext*>(context)); |
98 } | 95 } |
99 | 96 |
100 bool RefcountedBrowserContextKeyedServiceFactory::IsOffTheRecord( | 97 bool RefcountedBrowserContextKeyedServiceFactory::IsOffTheRecord( |
101 base::SupportsUserData* context) const { | 98 base::SupportsUserData* context) const { |
102 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); | 99 return static_cast<content::BrowserContext*>(context)->IsOffTheRecord(); |
103 } | 100 } |
104 | 101 |
105 user_prefs::PrefRegistrySyncable* | |
106 RefcountedBrowserContextKeyedServiceFactory::GetAssociatedPrefRegistry( | |
107 base::SupportsUserData* context) const { | |
108 PrefService* prefs = user_prefs::UserPrefs::Get(context); | |
109 user_prefs::PrefRegistrySyncable* registry = | |
110 static_cast<user_prefs::PrefRegistrySyncable*>( | |
111 prefs->DeprecatedGetPrefRegistry()); | |
112 return registry; | |
113 } | |
114 | |
115 base::SupportsUserData* | 102 base::SupportsUserData* |
116 RefcountedBrowserContextKeyedServiceFactory::GetContextToUse( | 103 RefcountedBrowserContextKeyedServiceFactory::GetContextToUse( |
117 base::SupportsUserData* context) const { | 104 base::SupportsUserData* context) const { |
118 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); | 105 return GetBrowserContextToUse(static_cast<content::BrowserContext*>(context)); |
119 } | 106 } |
120 | 107 |
121 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() | 108 bool RefcountedBrowserContextKeyedServiceFactory::ServiceIsCreatedWithContext() |
122 const { | 109 const { |
123 return ServiceIsCreatedWithBrowserContext(); | 110 return ServiceIsCreatedWithBrowserContext(); |
124 } | 111 } |
125 | 112 |
126 void RefcountedBrowserContextKeyedServiceFactory::ContextShutdown( | 113 void RefcountedBrowserContextKeyedServiceFactory::ContextShutdown( |
127 base::SupportsUserData* context) { | 114 base::SupportsUserData* context) { |
128 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); | 115 BrowserContextShutdown(static_cast<content::BrowserContext*>(context)); |
129 } | 116 } |
130 | 117 |
131 void RefcountedBrowserContextKeyedServiceFactory::ContextDestroyed( | 118 void RefcountedBrowserContextKeyedServiceFactory::ContextDestroyed( |
132 base::SupportsUserData* context) { | 119 base::SupportsUserData* context) { |
133 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); | 120 BrowserContextDestroyed(static_cast<content::BrowserContext*>(context)); |
134 } | 121 } |
135 | 122 |
136 void RefcountedBrowserContextKeyedServiceFactory::RegisterPrefs( | 123 void RefcountedBrowserContextKeyedServiceFactory::RegisterPrefs( |
137 user_prefs::PrefRegistrySyncable* registry) { | 124 user_prefs::PrefRegistrySyncable* registry) { |
138 RegisterProfilePrefs(registry); | 125 RegisterProfilePrefs(registry); |
139 } | 126 } |
OLD | NEW |