refactor: use helpers when using the remote module in sandboxed renderers (#15960)
This commit is contained in:
parent
d243a45173
commit
ab2a061b59
11 changed files with 46 additions and 28 deletions
|
@ -2,9 +2,24 @@
|
|||
|
||||
const { remote } = require('electron')
|
||||
|
||||
exports.getRemoteForUsage = function (usage) {
|
||||
exports.getRemote = function (name) {
|
||||
if (!remote) {
|
||||
throw new Error(`${name} requires remote, which is not enabled`)
|
||||
}
|
||||
return remote[name]
|
||||
}
|
||||
|
||||
exports.getRemoteFor = function (usage) {
|
||||
if (!remote) {
|
||||
throw new Error(`${usage} requires remote, which is not enabled`)
|
||||
}
|
||||
return remote
|
||||
}
|
||||
|
||||
exports.nativeRequire = function (name) {
|
||||
if (process.sandboxed) {
|
||||
return exports.getRemoteFor(name).require(name)
|
||||
} else {
|
||||
return require(name)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue