Add ipcRenderer.sendTo

This commit is contained in:
Cheng Zhao 2016-05-18 21:19:50 +09:00
parent d55b96fdf5
commit ae1f442b02
3 changed files with 39 additions and 2 deletions

View file

@ -2,7 +2,7 @@
const electron = require('electron')
const v8Util = process.atomBinding('v8_util')
const {ipcMain, isPromise} = electron
const {ipcMain, isPromise, webContents} = electron
const objectsRegistry = require('./objects-registry')
@ -351,3 +351,13 @@ ipcMain.on('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, request
event.returnValue = exceptionToMeta(error)
}
})
ipcMain.on('ELECTRON_BROWSER_SEND_TO', function (event, webContentsId, channel, ...args) {
let contents = webContents.fromId(webContentsId)
if (!contents) {
console.error(`Sending message to WebContents with unknown ID ${webContentsId}`)
return
}
contents.send(channel, ...args)
})