2019-07-24 23:01:08 +00:00
|
|
|
// 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.
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
#include "shell/browser/extensions/electron_extension_system_factory.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
2024-02-23 09:35:20 +00:00
|
|
|
#include "base/no_destructor.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
|
|
|
#include "extensions/browser/extension_prefs_factory.h"
|
|
|
|
#include "extensions/browser/extension_registry_factory.h"
|
2020-02-03 22:01:10 +00:00
|
|
|
#include "shell/browser/extensions/electron_extension_system.h"
|
2019-07-24 23:01:08 +00:00
|
|
|
|
|
|
|
using content::BrowserContext;
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
ExtensionSystem* ElectronExtensionSystemFactory::GetForBrowserContext(
|
2019-07-24 23:01:08 +00:00
|
|
|
BrowserContext* context) {
|
2020-02-03 22:01:10 +00:00
|
|
|
return static_cast<ElectronExtensionSystem*>(
|
2019-07-24 23:01:08 +00:00
|
|
|
GetInstance()->GetServiceForBrowserContext(context, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionSystemFactory* ElectronExtensionSystemFactory::GetInstance() {
|
2024-02-23 09:35:20 +00:00
|
|
|
static base::NoDestructor<ElectronExtensionSystemFactory> instance;
|
|
|
|
return instance.get();
|
2019-07-24 23:01:08 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
ElectronExtensionSystemFactory::ElectronExtensionSystemFactory()
|
|
|
|
: ExtensionSystemProvider("ElectronExtensionSystem",
|
2019-07-24 23:01:08 +00:00
|
|
|
BrowserContextDependencyManager::GetInstance()) {
|
|
|
|
DependsOn(ExtensionPrefsFactory::GetInstance());
|
|
|
|
DependsOn(ExtensionRegistryFactory::GetInstance());
|
|
|
|
}
|
|
|
|
|
2021-06-04 04:16:13 +00:00
|
|
|
ElectronExtensionSystemFactory::~ElectronExtensionSystemFactory() = default;
|
2019-07-24 23:01:08 +00:00
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
KeyedService* ElectronExtensionSystemFactory::BuildServiceInstanceFor(
|
2019-07-24 23:01:08 +00:00
|
|
|
BrowserContext* context) const {
|
2020-02-03 22:01:10 +00:00
|
|
|
return new ElectronExtensionSystem(context);
|
2019-07-24 23:01:08 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
BrowserContext* ElectronExtensionSystemFactory::GetBrowserContextToUse(
|
2019-07-24 23:01:08 +00:00
|
|
|
BrowserContext* context) const {
|
|
|
|
// Use a separate instance for incognito.
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:01:10 +00:00
|
|
|
bool ElectronExtensionSystemFactory::ServiceIsCreatedWithBrowserContext()
|
|
|
|
const {
|
2019-07-24 23:01:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace extensions
|