|
@@ -7,6 +7,7 @@ const fs = require('fs')
|
|
|
const os = require('os')
|
|
|
const path = require('path')
|
|
|
const v8Util = process.atomBinding('v8_util')
|
|
|
+const eventBinding = process.atomBinding('event')
|
|
|
|
|
|
const { isPromise } = electron
|
|
|
|
|
@@ -290,16 +291,38 @@ handleRemoteCommand('ELECTRON_BROWSER_WRONG_CONTEXT_ERROR', function (event, con
|
|
|
removeRemoteListenersAndLogWarning(event.sender, rendererFunctions.get(objectId))
|
|
|
})
|
|
|
|
|
|
-handleRemoteCommand('ELECTRON_BROWSER_REQUIRE', function (event, contextId, module) {
|
|
|
- return valueToMeta(event.sender, contextId, process.mainModule.require(module))
|
|
|
+handleRemoteCommand('ELECTRON_BROWSER_REQUIRE', function (event, contextId, moduleName) {
|
|
|
+ const customEvent = eventBinding.createWithSender(event.sender)
|
|
|
+ event.sender.emit('remote-require', customEvent, moduleName)
|
|
|
+
|
|
|
+ if (customEvent.defaultPrevented) {
|
|
|
+ if (typeof customEvent.returnValue === 'undefined') {
|
|
|
+ throw new Error(`Invalid module: ${moduleName}`)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ customEvent.returnValue = process.mainModule.require(moduleName)
|
|
|
+ }
|
|
|
+
|
|
|
+ return valueToMeta(event.sender, contextId, customEvent.returnValue)
|
|
|
})
|
|
|
|
|
|
handleRemoteCommand('ELECTRON_BROWSER_GET_BUILTIN', function (event, contextId, module) {
|
|
|
return valueToMeta(event.sender, contextId, electron[module])
|
|
|
})
|
|
|
|
|
|
-handleRemoteCommand('ELECTRON_BROWSER_GLOBAL', function (event, contextId, name) {
|
|
|
- return valueToMeta(event.sender, contextId, global[name])
|
|
|
+handleRemoteCommand('ELECTRON_BROWSER_GLOBAL', function (event, contextId, globalName) {
|
|
|
+ const customEvent = eventBinding.createWithSender(event.sender)
|
|
|
+ event.sender.emit('remote-get-global', customEvent, globalName)
|
|
|
+
|
|
|
+ if (customEvent.defaultPrevented) {
|
|
|
+ if (typeof customEvent.returnValue === 'undefined') {
|
|
|
+ throw new Error(`Invalid global: ${globalName}`)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ customEvent.returnValue = global[globalName]
|
|
|
+ }
|
|
|
+
|
|
|
+ return valueToMeta(event.sender, contextId, customEvent.returnValue)
|
|
|
})
|
|
|
|
|
|
handleRemoteCommand('ELECTRON_BROWSER_CURRENT_WINDOW', function (event, contextId) {
|