extension_system_factory.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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
3// found in the LICENSE file.
4
5#include "chrome/browser/extensions/extension_system_factory.h"
6
7#include "chrome/browser/extensions/extension_prefs.h"
8#include "chrome/browser/extensions/extension_service.h"
9#include "chrome/browser/extensions/extension_system.h"
10#include "chrome/browser/profiles/profile.h"
11#include "chrome/browser/profiles/profile_dependency_manager.h"
12#include "chrome/browser/protector/protector_service_factory.h"
13#include "chrome/browser/themes/theme_service_factory.h"
14#include "chrome/browser/ui/global_error/global_error_service_factory.h"
15
16namespace extensions {
17
18// ExtensionSystemSharedFactory
19
20// static
21ExtensionSystemImpl::Shared*
22ExtensionSystemSharedFactory::GetForProfile(Profile* profile) {
23  return static_cast<ExtensionSystemImpl::Shared*>(
24      GetInstance()->GetServiceForProfile(profile, true));
25}
26
27// static
28ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() {
29  return Singleton<ExtensionSystemSharedFactory>::get();
30}
31
32ExtensionSystemSharedFactory::ExtensionSystemSharedFactory()
33    : ProfileKeyedServiceFactory(
34        "ExtensionSystemShared",
35        ProfileDependencyManager::GetInstance()) {
36  DependsOn(GlobalErrorServiceFactory::GetInstance());
37#if defined(ENABLE_THEMES)
38  DependsOn(ThemeServiceFactory::GetInstance());
39#endif
40#if defined(ENABLE_PROTECTOR_SERVICE)
41  // ProtectorService should be destroyed after us.
42  DependsOn(protector::ProtectorServiceFactory::GetInstance());
43#endif
44}
45
46ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() {
47}
48
49ProfileKeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor(
50    Profile* profile) const {
51  return new ExtensionSystemImpl::Shared(profile);
52}
53
54bool ExtensionSystemSharedFactory::ServiceRedirectedInIncognito() const {
55  return true;
56}
57
58// ExtensionSystemFactory
59
60// static
61ExtensionSystem* ExtensionSystemFactory::GetForProfile(Profile* profile) {
62  return static_cast<ExtensionSystem*>(
63      GetInstance()->GetServiceForProfile(profile, true));
64}
65
66// static
67ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() {
68  return Singleton<ExtensionSystemFactory>::get();
69}
70
71ExtensionSystemFactory::ExtensionSystemFactory()
72    : ProfileKeyedServiceFactory(
73        "ExtensionSystem",
74        ProfileDependencyManager::GetInstance()) {
75  DependsOn(ExtensionSystemSharedFactory::GetInstance());
76}
77
78ExtensionSystemFactory::~ExtensionSystemFactory() {
79}
80
81ProfileKeyedService* ExtensionSystemFactory::BuildServiceInstanceFor(
82    Profile* profile) const {
83  return new ExtensionSystemImpl(profile);
84}
85
86bool ExtensionSystemFactory::ServiceHasOwnInstanceInIncognito() const {
87  return true;
88}
89
90bool ExtensionSystemFactory::ServiceIsCreatedWithProfile() const {
91  return true;
92}
93
94}  // namespace extensions
95