• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 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.
4 
5 #include "chrome/browser/extensions/install_tracker_factory.h"
6 
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/extensions/install_tracker.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "extensions/browser/extension_prefs.h"
11 #include "extensions/browser/extension_prefs_factory.h"
12 #include "extensions/browser/extension_system_provider.h"
13 #include "extensions/browser/extensions_browser_client.h"
14 
15 namespace extensions {
16 
17 // static
GetForBrowserContext(content::BrowserContext * context)18 InstallTracker* InstallTrackerFactory::GetForBrowserContext(
19     content::BrowserContext* context) {
20   return static_cast<InstallTracker*>(
21       GetInstance()->GetServiceForBrowserContext(context, true));
22 }
23 
GetInstance()24 InstallTrackerFactory* InstallTrackerFactory::GetInstance() {
25   return Singleton<InstallTrackerFactory>::get();
26 }
27 
InstallTrackerFactory()28 InstallTrackerFactory::InstallTrackerFactory()
29     : BrowserContextKeyedServiceFactory(
30         "InstallTracker",
31         BrowserContextDependencyManager::GetInstance()) {
32   DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
33   DependsOn(ExtensionPrefsFactory::GetInstance());
34 }
35 
~InstallTrackerFactory()36 InstallTrackerFactory::~InstallTrackerFactory() {
37 }
38 
BuildServiceInstanceFor(content::BrowserContext * context) const39 KeyedService* InstallTrackerFactory::BuildServiceInstanceFor(
40     content::BrowserContext* context) const {
41   return new InstallTracker(context, ExtensionPrefs::Get(context));
42 }
43 
GetBrowserContextToUse(content::BrowserContext * context) const44 content::BrowserContext* InstallTrackerFactory::GetBrowserContextToUse(
45     content::BrowserContext* context) const {
46   // The installs themselves are routed to the non-incognito profile and so
47   // should the install progress.
48   return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
49 }
50 
51 }  // namespace extensions
52