cd05834d96
This change gives sandboxed renderer scripts a similar structure to what already exists in the lib/{browser,renderer,common} directories. It also allows sandboxed renderer initialization to share more code with non-sandboxed renderers (ipcRenderer is now imported directly from lib/renderer/api/ipc-renderer).
20 lines
675 B
JavaScript
20 lines
675 B
JavaScript
const ipcRenderer = require('../../renderer/api/ipc-renderer')
|
|
|
|
const v8Util = process.atomBinding('v8_util')
|
|
const ipcNative = process.atomBinding('ipc')
|
|
|
|
// AtomSandboxedRendererClient will look for the "ipcNative" hidden object when
|
|
// invoking the `onMessage`/`onExit` callbacks. We could reuse "ipc" and assign
|
|
// `onMessage`/`onExit` directly to `ipcRenderer`, but it is better to separate
|
|
// private/public APIs.
|
|
v8Util.setHiddenValue(global, 'ipcNative', ipcNative)
|
|
|
|
ipcNative.onMessage = function (channel, args) {
|
|
ipcRenderer.emit(channel, {sender: ipcRenderer}, ...args)
|
|
}
|
|
|
|
ipcNative.onExit = function () {
|
|
process.emit('exit')
|
|
}
|
|
|
|
module.exports = ipcRenderer
|