electron/shell/browser/extensions/electron_extension_system_factory.cc
trop[bot] 748f293400
refactor: remove use of deprecated API BuildServiceInstanceFor() (#43707)
* refactor: update BadgeManagerFactory

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: update NetworkContextServiceFactory

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: update ElectronExtensionSystemFactory

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: update UsbChooserContextFactory

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: update UsbHidChooserContextFactory

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: update SerialChooserContextFactory

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: update FileSystemAccessPermissionContextFactory

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* empty commit

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-09-13 15:26:10 -05:00

55 lines
1.8 KiB
C++

// 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 "shell/browser/extensions/electron_extension_system_factory.h"
#include "base/no_destructor.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/browser/extension_registry_factory.h"
#include "shell/browser/extensions/electron_extension_system.h"
using content::BrowserContext;
namespace extensions {
ExtensionSystem* ElectronExtensionSystemFactory::GetForBrowserContext(
BrowserContext* context) {
return static_cast<ElectronExtensionSystem*>(
GetInstance()->GetServiceForBrowserContext(context, true));
}
// static
ElectronExtensionSystemFactory* ElectronExtensionSystemFactory::GetInstance() {
static base::NoDestructor<ElectronExtensionSystemFactory> instance;
return instance.get();
}
ElectronExtensionSystemFactory::ElectronExtensionSystemFactory()
: ExtensionSystemProvider("ElectronExtensionSystem",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(ExtensionPrefsFactory::GetInstance());
DependsOn(ExtensionRegistryFactory::GetInstance());
}
ElectronExtensionSystemFactory::~ElectronExtensionSystemFactory() = default;
std::unique_ptr<KeyedService>
ElectronExtensionSystemFactory::BuildServiceInstanceForBrowserContext(
BrowserContext* context) const {
return std::make_unique<ElectronExtensionSystem>(context);
}
BrowserContext* ElectronExtensionSystemFactory::GetBrowserContextToUse(
BrowserContext* context) const {
// Use a separate instance for incognito.
return context;
}
bool ElectronExtensionSystemFactory::ServiceIsCreatedWithBrowserContext()
const {
return true;
}
} // namespace extensions