Simplify the implementation of sendToAll

This commit is contained in:
Cheng Zhao 2016-05-29 12:10:32 +09:00
parent de001a9bbf
commit 5f3fdbe635
3 changed files with 9 additions and 20 deletions

View file

@ -71,20 +71,15 @@ let wrapWebContents = function (webContents) {
webContents.setMaxListeners(0)
// WebContents::send(channel, args..)
webContents.send = function (channel, ...args) {
if (channel == null) {
throw new Error('Missing required channel argument')
}
return this._send(channel, args)
}
// WebContents::sendToAll(channel, args..)
webContents.sendToAll = function (channel, ...args) {
const sendWrapper = (allFrames, channel, ...args) => {
if (channel == null) {
throw new Error('Missing required channel argument')
}
return this._sendToAll(channel, args)
return webContents._send(allFrames, channel, args)
}
webContents.send = sendWrapper.bind(null, false)
webContents.sendToAll = sendWrapper.bind(null, true)
// The navigation controller.
controller = new NavigationController(webContents)