refactor: use separate ipc-renderer-internal / ipc-main-internal APIs for Electron internals (#13940)

This commit is contained in:
Milan Burda 2018-10-06 13:48:00 +02:00 committed by Samuel Attard
parent f7122610cc
commit b50f86ef43
49 changed files with 322 additions and 133 deletions

View file

@ -5,6 +5,7 @@ const v8Util = process.atomBinding('v8_util')
// Created by init.js.
const ipcRenderer = v8Util.getHiddenValue(global, 'ipc')
const internal = false
ipcRenderer.send = function (...args) {
return binding.send('ipc-message', args)
@ -19,19 +20,11 @@ ipcRenderer.sendToHost = function (...args) {
}
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
return binding.sendTo(false, webContentsId, channel, args)
return binding.sendTo(internal, false, webContentsId, channel, args)
}
ipcRenderer.sendToAll = function (webContentsId, channel, ...args) {
return binding.sendTo(true, webContentsId, channel, args)
}
const removeAllListeners = ipcRenderer.removeAllListeners.bind(ipcRenderer)
ipcRenderer.removeAllListeners = function (...args) {
if (args.length === 0) {
throw new Error('Removing all listeners from ipcRenderer will make Electron internals stop working. Please specify a event name')
}
removeAllListeners(...args)
return binding.sendTo(internal, true, webContentsId, channel, args)
}
module.exports = ipcRenderer