• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 "libcef/browser/extensions/extension_system_factory.h"
6 
7 #include "libcef/browser/extensions/extension_system.h"
8 
9 #include "chrome/browser/profiles/incognito_helpers.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #include "extensions/browser/extension_prefs_factory.h"
12 #include "extensions/browser/extension_registry_factory.h"
13 
14 using content::BrowserContext;
15 
16 namespace extensions {
17 
GetForBrowserContext(BrowserContext * context)18 ExtensionSystem* CefExtensionSystemFactory::GetForBrowserContext(
19     BrowserContext* context) {
20   return static_cast<CefExtensionSystem*>(
21       GetInstance()->GetServiceForBrowserContext(context, true));
22 }
23 
24 // static
GetInstance()25 CefExtensionSystemFactory* CefExtensionSystemFactory::GetInstance() {
26   return base::Singleton<CefExtensionSystemFactory>::get();
27 }
28 
CefExtensionSystemFactory()29 CefExtensionSystemFactory::CefExtensionSystemFactory()
30     : ExtensionSystemProvider("CefExtensionSystem",
31                               BrowserContextDependencyManager::GetInstance()) {
32   // Other factories that this factory depends on. See
33   // libcef/common/extensions/api/README.txt for additional details.
34   DependsOn(ExtensionPrefsFactory::GetInstance());
35   DependsOn(ExtensionRegistryFactory::GetInstance());
36 }
37 
~CefExtensionSystemFactory()38 CefExtensionSystemFactory::~CefExtensionSystemFactory() {}
39 
BuildServiceInstanceFor(BrowserContext * context) const40 KeyedService* CefExtensionSystemFactory::BuildServiceInstanceFor(
41     BrowserContext* context) const {
42   return new CefExtensionSystem(context);
43 }
44 
GetBrowserContextToUse(BrowserContext * context) const45 BrowserContext* CefExtensionSystemFactory::GetBrowserContextToUse(
46     BrowserContext* context) const {
47   // Use a separate instance for incognito.
48   return chrome::GetBrowserContextOwnInstanceInIncognito(context);
49 }
50 
ServiceIsCreatedWithBrowserContext() const51 bool CefExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {
52   return true;
53 }
54 
55 }  // namespace extensions
56