extension_system_factory.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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/themes/theme_service_factory.h"
13#include "chrome/browser/ui/global_error/global_error_service_factory.h"
14
15namespace extensions {
16
17// ExtensionSystemSharedFactory
18
19// static
20ExtensionSystemImpl::Shared*
21ExtensionSystemSharedFactory::GetForProfile(Profile* profile) {
22  return static_cast<ExtensionSystemImpl::Shared*>(
23      GetInstance()->GetServiceForProfile(profile, true));
24}
25
26// static
27ExtensionSystemSharedFactory* ExtensionSystemSharedFactory::GetInstance() {
28  return Singleton<ExtensionSystemSharedFactory>::get();
29}
30
31ExtensionSystemSharedFactory::ExtensionSystemSharedFactory()
32    : ProfileKeyedServiceFactory(
33        "ExtensionSystemShared",
34        ProfileDependencyManager::GetInstance()) {
35  DependsOn(GlobalErrorServiceFactory::GetInstance());
36#if defined(ENABLE_THEMES)
37  DependsOn(ThemeServiceFactory::GetInstance());
38#endif
39}
40
41ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() {
42}
43
44ProfileKeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor(
45    Profile* profile) const {
46  return new ExtensionSystemImpl::Shared(profile);
47}
48
49bool ExtensionSystemSharedFactory::ServiceRedirectedInIncognito() const {
50  return true;
51}
52
53// ExtensionSystemFactory
54
55// static
56ExtensionSystem* ExtensionSystemFactory::GetForProfile(Profile* profile) {
57  return static_cast<ExtensionSystem*>(
58      GetInstance()->GetServiceForProfile(profile, true));
59}
60
61// static
62ExtensionSystemFactory* ExtensionSystemFactory::GetInstance() {
63  return Singleton<ExtensionSystemFactory>::get();
64}
65
66ExtensionSystemFactory::ExtensionSystemFactory()
67    : ProfileKeyedServiceFactory(
68        "ExtensionSystem",
69        ProfileDependencyManager::GetInstance()) {
70  DependsOn(ExtensionSystemSharedFactory::GetInstance());
71}
72
73ExtensionSystemFactory::~ExtensionSystemFactory() {
74}
75
76ProfileKeyedService* ExtensionSystemFactory::BuildServiceInstanceFor(
77    Profile* profile) const {
78  return new ExtensionSystemImpl(profile);
79}
80
81bool ExtensionSystemFactory::ServiceHasOwnInstanceInIncognito() const {
82  return true;
83}
84
85bool ExtensionSystemFactory::ServiceIsCreatedWithProfile() const {
86  return true;
87}
88
89}  // namespace extensions
90