ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / extensions / extension_sync_service_factory.cc
blob07c4f18881ace990b3ee334f38f8da0e684ff7a6
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_sync_service.h"
9 #include "chrome/browser/extensions/extension_system_factory.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "extensions/browser/extension_prefs_factory.h"
13 #include "extensions/browser/extension_registry_factory.h"
14 #include "extensions/browser/extension_system.h"
15 #include "extensions/browser/extensions_browser_client.h"
17 // static
18 ExtensionSyncService* ExtensionSyncServiceFactory::GetForBrowserContext(
19 content::BrowserContext* context) {
20 return static_cast<ExtensionSyncService*>(
21 GetInstance()->GetServiceForBrowserContext(context, true));
24 // static
25 ExtensionSyncServiceFactory* ExtensionSyncServiceFactory::GetInstance() {
26 return Singleton<ExtensionSyncServiceFactory>::get();
29 ExtensionSyncServiceFactory::ExtensionSyncServiceFactory()
30 : BrowserContextKeyedServiceFactory(
31 "ExtensionSyncService",
32 BrowserContextDependencyManager::GetInstance()) {
33 DependsOn(extensions::ExtensionPrefsFactory::GetInstance());
34 DependsOn(extensions::ExtensionRegistryFactory::GetInstance());
35 DependsOn(extensions::ExtensionSystemFactory::GetInstance());
38 ExtensionSyncServiceFactory::~ExtensionSyncServiceFactory() {}
40 KeyedService* ExtensionSyncServiceFactory::BuildServiceInstanceFor(
41 content::BrowserContext* context) const {
42 return new ExtensionSyncService(Profile::FromBrowserContext(context));
45 content::BrowserContext* ExtensionSyncServiceFactory::GetBrowserContextToUse(
46 content::BrowserContext* context) const {
47 return extensions::ExtensionsBrowserClient::Get()->
48 GetOriginalContext(context);