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
3 // found in the LICENSE file.
5 #include "components/keyed_service/content/browser_context_keyed_base_factory.h"
7 #include "components/keyed_service/content/browser_context_dependency_manager.h"
8 #include "content/public/browser/browser_context.h"
10 BrowserContextKeyedBaseFactory::BrowserContextKeyedBaseFactory(
12 BrowserContextDependencyManager
* manager
)
13 : KeyedServiceBaseFactory(name
, manager
) {
16 BrowserContextKeyedBaseFactory::~BrowserContextKeyedBaseFactory() {
19 content::BrowserContext
* BrowserContextKeyedBaseFactory::GetBrowserContextToUse(
20 content::BrowserContext
* context
) const {
21 DCHECK(CalledOnValidThread());
24 AssertContextWasntDestroyed(context
);
27 // Safe default for the Incognito mode: no service.
28 if (context
->IsOffTheRecord())
34 void BrowserContextKeyedBaseFactory::RegisterUserPrefsOnBrowserContextForTest(
35 content::BrowserContext
* context
) {
36 KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(context
);
39 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext()
41 return KeyedServiceBaseFactory::ServiceIsCreatedWithContext();
44 bool BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting() const {
45 return KeyedServiceBaseFactory::ServiceIsNULLWhileTesting();
48 void BrowserContextKeyedBaseFactory::BrowserContextDestroyed(
49 content::BrowserContext
* context
) {
50 KeyedServiceBaseFactory::ContextDestroyed(context
);
53 base::SupportsUserData
* BrowserContextKeyedBaseFactory::GetContextToUse(
54 base::SupportsUserData
* context
) const {
55 return GetBrowserContextToUse(static_cast<content::BrowserContext
*>(context
));
58 bool BrowserContextKeyedBaseFactory::ServiceIsCreatedWithContext() const {
59 return ServiceIsCreatedWithBrowserContext();
62 void BrowserContextKeyedBaseFactory::ContextShutdown(
63 base::SupportsUserData
* context
) {
64 BrowserContextShutdown(static_cast<content::BrowserContext
*>(context
));
67 void BrowserContextKeyedBaseFactory::ContextDestroyed(
68 base::SupportsUserData
* context
) {
69 BrowserContextDestroyed(static_cast<content::BrowserContext
*>(context
));
72 void BrowserContextKeyedBaseFactory::RegisterPrefs(
73 user_prefs::PrefRegistrySyncable
* registry
) {
74 RegisterProfilePrefs(registry
);
77 void BrowserContextKeyedBaseFactory::SetEmptyTestingFactory(
78 base::SupportsUserData
* context
) {
79 SetEmptyTestingFactory(static_cast<content::BrowserContext
*>(context
));
82 bool BrowserContextKeyedBaseFactory::HasTestingFactory(
83 base::SupportsUserData
* context
) {
84 return HasTestingFactory(static_cast<content::BrowserContext
*>(context
));
87 void BrowserContextKeyedBaseFactory::CreateServiceNow(
88 base::SupportsUserData
* context
) {
89 CreateServiceNow(static_cast<content::BrowserContext
*>(context
));