feat: implement allowFileAccess loadExtension option (#25198)
Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org>
This commit is contained in:
parent
a75cd89d2a
commit
a5e9af330f
8 changed files with 38 additions and 11 deletions
|
@ -795,7 +795,8 @@ std::vector<base::FilePath> Session::GetPreloads() const {
|
|||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
v8::Local<v8::Promise> Session::LoadExtension(
|
||||
const base::FilePath& extension_path) {
|
||||
const base::FilePath& extension_path,
|
||||
gin::Arguments* args) {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
gin_helper::Promise<const extensions::Extension*> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
@ -812,10 +813,19 @@ v8::Local<v8::Promise> Session::LoadExtension(
|
|||
return handle;
|
||||
}
|
||||
|
||||
int load_flags = extensions::Extension::FOLLOW_SYMLINKS_ANYWHERE;
|
||||
gin_helper::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
bool allowFileAccess = false;
|
||||
options.Get("allowFileAccess", &allowFileAccess);
|
||||
if (allowFileAccess)
|
||||
load_flags |= extensions::Extension::ALLOW_FILE_ACCESS;
|
||||
}
|
||||
|
||||
auto* extension_system = static_cast<extensions::ElectronExtensionSystem*>(
|
||||
extensions::ExtensionSystem::Get(browser_context()));
|
||||
extension_system->LoadExtension(
|
||||
extension_path,
|
||||
extension_path, load_flags,
|
||||
base::BindOnce(
|
||||
[](gin_helper::Promise<const extensions::Extension*> promise,
|
||||
const extensions::Extension* extension,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue