mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
refactor: remove use of deprecated API BuildServiceInstanceFor() (#43690)
* refactor: update BadgeManagerFactory * refactor: update NetworkContextServiceFactory * refactor: update ElectronExtensionSystemFactory * refactor: update UsbChooserContextFactory * refactor: update UsbHidChooserContextFactory * refactor: update SerialChooserContextFactory * refactor: update FileSystemAccessPermissionContextFactory
This commit is contained in:
@@ -30,9 +30,10 @@ BadgeManagerFactory::BadgeManagerFactory()
|
|||||||
|
|
||||||
BadgeManagerFactory::~BadgeManagerFactory() = default;
|
BadgeManagerFactory::~BadgeManagerFactory() = default;
|
||||||
|
|
||||||
KeyedService* BadgeManagerFactory::BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService>
|
||||||
|
BadgeManagerFactory::BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const {
|
content::BrowserContext* context) const {
|
||||||
return new BadgeManager();
|
return std::make_unique<BadgeManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace badging
|
} // namespace badging
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class BadgeManagerFactory : public BrowserContextKeyedServiceFactory {
|
|||||||
~BadgeManagerFactory() override;
|
~BadgeManagerFactory() override;
|
||||||
|
|
||||||
// BrowserContextKeyedServiceFactory
|
// BrowserContextKeyedServiceFactory
|
||||||
KeyedService* BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ ElectronExtensionSystemFactory::ElectronExtensionSystemFactory()
|
|||||||
|
|
||||||
ElectronExtensionSystemFactory::~ElectronExtensionSystemFactory() = default;
|
ElectronExtensionSystemFactory::~ElectronExtensionSystemFactory() = default;
|
||||||
|
|
||||||
KeyedService* ElectronExtensionSystemFactory::BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService>
|
||||||
|
ElectronExtensionSystemFactory::BuildServiceInstanceForBrowserContext(
|
||||||
BrowserContext* context) const {
|
BrowserContext* context) const {
|
||||||
return new ElectronExtensionSystem(context);
|
return std::make_unique<ElectronExtensionSystem>(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserContext* ElectronExtensionSystemFactory::GetBrowserContextToUse(
|
BrowserContext* ElectronExtensionSystemFactory::GetBrowserContextToUse(
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef ELECTRON_SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_
|
#ifndef ELECTRON_SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_
|
||||||
#define ELECTRON_SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_
|
#define ELECTRON_SHELL_BROWSER_EXTENSIONS_ELECTRON_EXTENSION_SYSTEM_FACTORY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "extensions/browser/extension_system_provider.h"
|
#include "extensions/browser/extension_system_provider.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
@@ -36,7 +38,7 @@ class ElectronExtensionSystemFactory : public ExtensionSystemProvider {
|
|||||||
~ElectronExtensionSystemFactory() override;
|
~ElectronExtensionSystemFactory() override;
|
||||||
|
|
||||||
// BrowserContextKeyedServiceFactory implementation:
|
// BrowserContextKeyedServiceFactory implementation:
|
||||||
KeyedService* BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
content::BrowserContext* GetBrowserContextToUse(
|
content::BrowserContext* GetBrowserContextToUse(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
|
|||||||
@@ -35,15 +35,9 @@ FileSystemAccessPermissionContextFactory::
|
|||||||
FileSystemAccessPermissionContextFactory::
|
FileSystemAccessPermissionContextFactory::
|
||||||
~FileSystemAccessPermissionContextFactory() = default;
|
~FileSystemAccessPermissionContextFactory() = default;
|
||||||
|
|
||||||
// static
|
|
||||||
KeyedService* FileSystemAccessPermissionContextFactory::BuildServiceInstanceFor(
|
|
||||||
content::BrowserContext* context) const {
|
|
||||||
return BuildInstanceFor(context).release();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<KeyedService>
|
std::unique_ptr<KeyedService>
|
||||||
FileSystemAccessPermissionContextFactory::BuildInstanceFor(
|
FileSystemAccessPermissionContextFactory::BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) {
|
content::BrowserContext* context) const {
|
||||||
return std::make_unique<FileSystemAccessPermissionContext>(context);
|
return std::make_unique<FileSystemAccessPermissionContext>(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef ELECTRON_SHELL_BROWSER_FILE_SYSTEM_ACCESS_FILE_SYSTEM_ACCESS_PERMISSION_CONTEXT_FACTORY_H_
|
#ifndef ELECTRON_SHELL_BROWSER_FILE_SYSTEM_ACCESS_FILE_SYSTEM_ACCESS_PERMISSION_CONTEXT_FACTORY_H_
|
||||||
#define ELECTRON_SHELL_BROWSER_FILE_SYSTEM_ACCESS_FILE_SYSTEM_ACCESS_PERMISSION_CONTEXT_FACTORY_H_
|
#define ELECTRON_SHELL_BROWSER_FILE_SYSTEM_ACCESS_FILE_SYSTEM_ACCESS_PERMISSION_CONTEXT_FACTORY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "base/no_destructor.h"
|
#include "base/no_destructor.h"
|
||||||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
||||||
#include "shell/browser/file_system_access/file_system_access_permission_context.h"
|
#include "shell/browser/file_system_access/file_system_access_permission_context.h"
|
||||||
@@ -18,9 +20,6 @@ class FileSystemAccessPermissionContextFactory
|
|||||||
content::BrowserContext* context);
|
content::BrowserContext* context);
|
||||||
static FileSystemAccessPermissionContextFactory* GetInstance();
|
static FileSystemAccessPermissionContextFactory* GetInstance();
|
||||||
|
|
||||||
static std::unique_ptr<KeyedService> BuildInstanceFor(
|
|
||||||
content::BrowserContext* context);
|
|
||||||
|
|
||||||
FileSystemAccessPermissionContextFactory(
|
FileSystemAccessPermissionContextFactory(
|
||||||
const FileSystemAccessPermissionContextFactory&) = delete;
|
const FileSystemAccessPermissionContextFactory&) = delete;
|
||||||
FileSystemAccessPermissionContextFactory& operator=(
|
FileSystemAccessPermissionContextFactory& operator=(
|
||||||
@@ -33,7 +32,7 @@ class FileSystemAccessPermissionContextFactory
|
|||||||
~FileSystemAccessPermissionContextFactory() override;
|
~FileSystemAccessPermissionContextFactory() override;
|
||||||
|
|
||||||
// BrowserContextKeyedServiceFactory:
|
// BrowserContextKeyedServiceFactory:
|
||||||
KeyedService* BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ HidChooserContextFactory::HidChooserContextFactory()
|
|||||||
|
|
||||||
HidChooserContextFactory::~HidChooserContextFactory() = default;
|
HidChooserContextFactory::~HidChooserContextFactory() = default;
|
||||||
|
|
||||||
KeyedService* HidChooserContextFactory::BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService>
|
||||||
|
HidChooserContextFactory::BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const {
|
content::BrowserContext* context) const {
|
||||||
auto* browser_context =
|
return std::make_unique<HidChooserContext>(
|
||||||
static_cast<electron::ElectronBrowserContext*>(context);
|
static_cast<electron::ElectronBrowserContext*>(context));
|
||||||
return new HidChooserContext(browser_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content::BrowserContext* HidChooserContextFactory::GetBrowserContextToUse(
|
content::BrowserContext* HidChooserContextFactory::GetBrowserContextToUse(
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef ELECTRON_SHELL_BROWSER_HID_HID_CHOOSER_CONTEXT_FACTORY_H_
|
#ifndef ELECTRON_SHELL_BROWSER_HID_HID_CHOOSER_CONTEXT_FACTORY_H_
|
||||||
#define ELECTRON_SHELL_BROWSER_HID_HID_CHOOSER_CONTEXT_FACTORY_H_
|
#define ELECTRON_SHELL_BROWSER_HID_HID_CHOOSER_CONTEXT_FACTORY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "base/no_destructor.h"
|
#include "base/no_destructor.h"
|
||||||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ class HidChooserContextFactory : public BrowserContextKeyedServiceFactory {
|
|||||||
~HidChooserContextFactory() override;
|
~HidChooserContextFactory() override;
|
||||||
|
|
||||||
// BrowserContextKeyedServiceFactory:
|
// BrowserContextKeyedServiceFactory:
|
||||||
KeyedService* BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* profile) const override;
|
content::BrowserContext* profile) const override;
|
||||||
content::BrowserContext* GetBrowserContextToUse(
|
content::BrowserContext* GetBrowserContextToUse(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ NetworkContextServiceFactory::NetworkContextServiceFactory()
|
|||||||
|
|
||||||
NetworkContextServiceFactory::~NetworkContextServiceFactory() = default;
|
NetworkContextServiceFactory::~NetworkContextServiceFactory() = default;
|
||||||
|
|
||||||
KeyedService* NetworkContextServiceFactory::BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService>
|
||||||
|
NetworkContextServiceFactory::BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const {
|
content::BrowserContext* context) const {
|
||||||
return new NetworkContextService(
|
return std::make_unique<NetworkContextService>(
|
||||||
static_cast<ElectronBrowserContext*>(context));
|
static_cast<ElectronBrowserContext*>(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef ELECTRON_SHELL_BROWSER_NET_NETWORK_CONTEXT_SERVICE_FACTORY_H_
|
#ifndef ELECTRON_SHELL_BROWSER_NET_NETWORK_CONTEXT_SERVICE_FACTORY_H_
|
||||||
#define ELECTRON_SHELL_BROWSER_NET_NETWORK_CONTEXT_SERVICE_FACTORY_H_
|
#define ELECTRON_SHELL_BROWSER_NET_NETWORK_CONTEXT_SERVICE_FACTORY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
||||||
|
|
||||||
class KeyedService;
|
class KeyedService;
|
||||||
@@ -43,7 +45,7 @@ class NetworkContextServiceFactory : public BrowserContextKeyedServiceFactory {
|
|||||||
~NetworkContextServiceFactory() override;
|
~NetworkContextServiceFactory() override;
|
||||||
|
|
||||||
// BrowserContextKeyedServiceFactory implementation:
|
// BrowserContextKeyedServiceFactory implementation:
|
||||||
KeyedService* BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
content::BrowserContext* GetBrowserContextToUse(
|
content::BrowserContext* GetBrowserContextToUse(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ SerialChooserContextFactory::SerialChooserContextFactory()
|
|||||||
|
|
||||||
SerialChooserContextFactory::~SerialChooserContextFactory() = default;
|
SerialChooserContextFactory::~SerialChooserContextFactory() = default;
|
||||||
|
|
||||||
KeyedService* SerialChooserContextFactory::BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService>
|
||||||
|
SerialChooserContextFactory::BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const {
|
content::BrowserContext* context) const {
|
||||||
auto* browser_context =
|
return std::make_unique<SerialChooserContext>(
|
||||||
static_cast<electron::ElectronBrowserContext*>(context);
|
static_cast<electron::ElectronBrowserContext*>(context));
|
||||||
return new SerialChooserContext(browser_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef ELECTRON_SHELL_BROWSER_SERIAL_SERIAL_CHOOSER_CONTEXT_FACTORY_H_
|
#ifndef ELECTRON_SHELL_BROWSER_SERIAL_SERIAL_CHOOSER_CONTEXT_FACTORY_H_
|
||||||
#define ELECTRON_SHELL_BROWSER_SERIAL_SERIAL_CHOOSER_CONTEXT_FACTORY_H_
|
#define ELECTRON_SHELL_BROWSER_SERIAL_SERIAL_CHOOSER_CONTEXT_FACTORY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
||||||
#include "shell/browser/serial/serial_chooser_context.h"
|
#include "shell/browser/serial/serial_chooser_context.h"
|
||||||
|
|
||||||
@@ -35,7 +37,7 @@ class SerialChooserContextFactory : public BrowserContextKeyedServiceFactory {
|
|||||||
delete;
|
delete;
|
||||||
|
|
||||||
// BrowserContextKeyedServiceFactory methods:
|
// BrowserContextKeyedServiceFactory methods:
|
||||||
KeyedService* BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
content::BrowserContext* GetBrowserContextToUse(
|
content::BrowserContext* GetBrowserContextToUse(
|
||||||
content::BrowserContext* context) const override;
|
content::BrowserContext* context) const override;
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ UsbChooserContextFactory::UsbChooserContextFactory()
|
|||||||
|
|
||||||
UsbChooserContextFactory::~UsbChooserContextFactory() = default;
|
UsbChooserContextFactory::~UsbChooserContextFactory() = default;
|
||||||
|
|
||||||
KeyedService* UsbChooserContextFactory::BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService>
|
||||||
|
UsbChooserContextFactory::BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* context) const {
|
content::BrowserContext* context) const {
|
||||||
auto* browser_context =
|
return std::make_unique<UsbChooserContext>(
|
||||||
static_cast<electron::ElectronBrowserContext*>(context);
|
static_cast<electron::ElectronBrowserContext*>(context));
|
||||||
return new UsbChooserContext(browser_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef ELECTRON_SHELL_BROWSER_USB_USB_CHOOSER_CONTEXT_FACTORY_H_
|
#ifndef ELECTRON_SHELL_BROWSER_USB_USB_CHOOSER_CONTEXT_FACTORY_H_
|
||||||
#define ELECTRON_SHELL_BROWSER_USB_USB_CHOOSER_CONTEXT_FACTORY_H_
|
#define ELECTRON_SHELL_BROWSER_USB_USB_CHOOSER_CONTEXT_FACTORY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
@@ -34,7 +36,7 @@ class UsbChooserContextFactory : public BrowserContextKeyedServiceFactory {
|
|||||||
~UsbChooserContextFactory() override;
|
~UsbChooserContextFactory() override;
|
||||||
|
|
||||||
// BrowserContextKeyedServiceFactory methods:
|
// BrowserContextKeyedServiceFactory methods:
|
||||||
KeyedService* BuildServiceInstanceFor(
|
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
|
||||||
content::BrowserContext* profile) const override;
|
content::BrowserContext* profile) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user