mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
add enabled property
This commit is contained in:
@@ -155,10 +155,7 @@ class ElectronBrowserContext : public content::BrowserContext {
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
extensions::ElectronExtensionSystem* extension_system() {
|
||||
// Guard usages of extension_system() with !IsOffTheRecord()
|
||||
// There is no extension system for in-memory sessions
|
||||
DCHECK(!IsOffTheRecord());
|
||||
extensions::ElectronExtensionSystem* extension_system() const {
|
||||
return extension_system_;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -98,6 +98,11 @@ void ElectronExtensionSystem::DisableExtension(
|
||||
extension_id, disable_reason::DisableReason::DISABLE_NONE);
|
||||
}
|
||||
|
||||
bool ElectronExtensionSystem::IsExtensionEnabled(
|
||||
const ExtensionId& extension_id) const {
|
||||
return extension_registrar_.IsExtensionEnabled(extension_id);
|
||||
}
|
||||
|
||||
void ElectronExtensionSystem::Shutdown() {
|
||||
extension_loader_.reset();
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ class ElectronExtensionSystem : public ExtensionSystem {
|
||||
// policy), does nothing.
|
||||
void DisableExtension(const ExtensionId& extension_id);
|
||||
|
||||
bool IsExtensionEnabled(const ExtensionId& extension_id) const;
|
||||
|
||||
// KeyedService implementation:
|
||||
void Shutdown() override;
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
#include "extensions/common/extension.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "shell/browser/electron_browser_context.h"
|
||||
#include "shell/browser/extensions/electron_extension_info.h"
|
||||
#include "shell/browser/extensions/electron_extension_system.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
@@ -17,14 +19,18 @@ namespace gin {
|
||||
v8::Local<v8::Value> Converter<extensions::ElectronExtensionInfo>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const extensions::ElectronExtensionInfo& info) {
|
||||
auto extension_id = info.extension->id();
|
||||
auto dict = gin::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("id", info.extension->id());
|
||||
dict.Set("id", extension_id);
|
||||
dict.Set("name", info.extension->name());
|
||||
dict.Set("path", info.extension->path());
|
||||
dict.Set("url", info.extension->url());
|
||||
dict.Set("version", info.extension->VersionString());
|
||||
dict.Set("manifest", *info.extension->manifest()->value());
|
||||
|
||||
auto* ext_system = info.browser_context->extension_system();
|
||||
dict.Set("enabled", ext_system->IsExtensionEnabled(extension_id));
|
||||
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user