blob: c1700780b5adb5dd1e9ddde60c496c7cd33565f7 [file] [log] [blame]
[email protected]31d8f5f22012-04-02 15:22:081// 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_message_service.h"
8#include "chrome/browser/extensions/extension_prefs.h"
9#include "chrome/browser/extensions/extension_service.h"
10#include "chrome/browser/extensions/extension_system.h"
11#include "chrome/browser/profiles/profile.h"
12#include "chrome/browser/profiles/profile_dependency_manager.h"
[email protected]89a773b2012-06-11 20:24:3013#include "chrome/browser/protector/protector_service_factory.h"
[email protected]31d8f5f22012-04-02 15:22:0814#include "chrome/browser/themes/theme_service_factory.h"
[email protected]1ba55cf2012-06-29 19:11:3915#include "chrome/browser/ui/global_error/global_error_service_factory.h"
[email protected]31d8f5f22012-04-02 15:22:0816
17// ExtensionSystemSharedFactory
18
19// static
20ExtensionSystemImpl::Shared* ExtensionSystemSharedFactory::GetForProfile(
21 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());
[email protected]31d8f5f22012-04-02 15:22:0836 DependsOn(ThemeServiceFactory::GetInstance());
[email protected]89a773b2012-06-11 20:24:3037 // ProtectorService should be destroyed after us.
38 DependsOn(protector::ProtectorServiceFactory::GetInstance());
[email protected]31d8f5f22012-04-02 15:22:0839}
40
41ExtensionSystemSharedFactory::~ExtensionSystemSharedFactory() {
42}
43
44ProfileKeyedService* ExtensionSystemSharedFactory::BuildServiceInstanceFor(
45 Profile* profile) const {
46 return new ExtensionSystemImpl::Shared(profile);
47}
48
49bool ExtensionSystemSharedFactory::ServiceRedirectedInIncognito() {
50 return true;
51}
52
53// ExtensionSystemFactory
54
55// static
[email protected]749d59a2012-04-05 00:23:2456ExtensionSystem* ExtensionSystemFactory::GetForProfile(Profile* profile) {
[email protected]31d8f5f22012-04-02 15:22:0857 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() {
82 return true;
83}
84
85bool ExtensionSystemFactory::ServiceIsCreatedWithProfile() {
86 return true;
87}