mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: session.enableExtension and session.disableExtension
This commit is contained in:
@@ -1541,6 +1541,25 @@ Unloads an extension.
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
#### `ses.enableExtension(extensionId)`
|
||||
|
||||
* `extensionId` string - ID of extension to enable
|
||||
|
||||
Enables the extension and activates it for use by starting any background
|
||||
workers. If the extension is disabled, marks it as enabled.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
#### `ses.disableExtension(extensionId)`
|
||||
|
||||
* `extensionId` string - ID of extension to disable
|
||||
|
||||
Disables the extension and deactives it.
|
||||
|
||||
**Note:** This API cannot be called before the `ready` event of the `app` module
|
||||
is emitted.
|
||||
|
||||
#### `ses.getExtension(extensionId)`
|
||||
|
||||
* `extensionId` string - ID of extension to query
|
||||
|
||||
@@ -1361,6 +1361,18 @@ void Session::RemoveExtension(const std::string& extension_id) {
|
||||
extension_system->RemoveExtension(extension_id);
|
||||
}
|
||||
|
||||
void Session::EnableExtension(const std::string& extension_id) {
|
||||
auto* extension_system = static_cast<extensions::ElectronExtensionSystem*>(
|
||||
extensions::ExtensionSystem::Get(browser_context()));
|
||||
extension_system->EnableExtension(extension_id);
|
||||
}
|
||||
|
||||
void Session::DisableExtension(const std::string& extension_id) {
|
||||
auto* extension_system = static_cast<extensions::ElectronExtensionSystem*>(
|
||||
extensions::ExtensionSystem::Get(browser_context()));
|
||||
extension_system->DisableExtension(extension_id);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Session::GetExtension(const std::string& extension_id) {
|
||||
auto* registry = extensions::ExtensionRegistry::Get(browser_context());
|
||||
const extensions::Extension* extension =
|
||||
|
||||
@@ -182,6 +182,8 @@ class Session final : public gin::Wrappable<Session>,
|
||||
v8::Local<v8::Promise> LoadExtension(const base::FilePath& extension_path,
|
||||
gin::Arguments* args);
|
||||
void RemoveExtension(const std::string& extension_id);
|
||||
void EnableExtension(const std::string& extension_id);
|
||||
void DisableExtension(const std::string& extension_id);
|
||||
v8::Local<v8::Value> GetExtension(const std::string& extension_id);
|
||||
v8::Local<v8::Value> GetAllExtensions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user