1 // Copyright 2013 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 "chrome/browser/extensions/extension_sync_service_factory.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/extensions/extension_prefs_factory.h"
9 #include "chrome/browser/extensions/extension_sync_service.h"
10 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/extensions/extension_system_factory.h"
12 #include "chrome/browser/profiles/incognito_helpers.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
17 ExtensionSyncService
* ExtensionSyncServiceFactory::GetForProfile(
19 return static_cast<ExtensionSyncService
*>(
20 GetInstance()->GetServiceForBrowserContext(profile
, true));
24 ExtensionSyncServiceFactory
* ExtensionSyncServiceFactory::GetInstance() {
25 return Singleton
<ExtensionSyncServiceFactory
>::get();
28 ExtensionSyncServiceFactory::ExtensionSyncServiceFactory()
29 : BrowserContextKeyedServiceFactory(
30 "ExtensionSyncService",
31 BrowserContextDependencyManager::GetInstance()) {
32 DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
33 DependsOn(extensions::ExtensionSystemFactory::GetInstance());
36 ExtensionSyncServiceFactory::~ExtensionSyncServiceFactory() {}
38 BrowserContextKeyedService
*
39 ExtensionSyncServiceFactory::BuildServiceInstanceFor(
40 content::BrowserContext
* context
) const {
41 Profile
* profile
= Profile::FromBrowserContext(context
);
42 return new ExtensionSyncService(
44 extensions::ExtensionPrefsFactory::GetForBrowserContext(profile
),
45 extensions::ExtensionSystemFactory::GetForProfile(profile
)->
49 content::BrowserContext
* ExtensionSyncServiceFactory::GetBrowserContextToUse(
50 content::BrowserContext
* context
) const {
51 return chrome::GetBrowserContextRedirectedInIncognito(context
);