summaryrefslogtreecommitdiffstats
path: root/extensions/browser/process_manager_factory.cc
blob: f6c001caed456dc95868a37ba0e52c99e6f93e51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/extension_registry_factory.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_manager_factory.h"

using content::BrowserContext;

namespace extensions {

// static
ProcessManager* ProcessManagerFactory::GetForBrowserContext(
    BrowserContext* context) {
  return static_cast<ProcessManager*>(
      GetInstance()->GetServiceForBrowserContext(context, true));
}

// static
ProcessManager* ProcessManagerFactory::GetForBrowserContextIfExists(
    BrowserContext* context) {
  return static_cast<ProcessManager*>(
      GetInstance()->GetServiceForBrowserContext(context, false));
}

// static
ProcessManagerFactory* ProcessManagerFactory::GetInstance() {
  return base::Singleton<ProcessManagerFactory>::get();
}

ProcessManagerFactory::ProcessManagerFactory()
    : BrowserContextKeyedServiceFactory(
          "ProcessManager",
          BrowserContextDependencyManager::GetInstance()) {
  DependsOn(extensions::ExtensionRegistryFactory::GetInstance());
}

ProcessManagerFactory::~ProcessManagerFactory() {
}

KeyedService* ProcessManagerFactory::BuildServiceInstanceFor(
    BrowserContext* context) const {
  return ProcessManager::Create(context);
}

BrowserContext* ProcessManagerFactory::GetBrowserContextToUse(
    BrowserContext* context) const {
  // ProcessManager::Create handles guest and incognito profiles, returning an
  // IncognitoProcessManager in incognito mode.
  return context;
}

}  // namespace extensions