Merge pull request #5711 from electron/extension-code-cleanup

Implement partial chrome.* API for devtools extension
This commit is contained in:
Cheng Zhao 2016-05-29 23:29:08 +00:00
commit 9f0fc96025
32 changed files with 1151 additions and 216 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')
@ -353,3 +353,17 @@ ipcMain.on('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, request
event.returnValue = exceptionToMeta(error)
}
})
ipcMain.on('ELECTRON_BROWSER_SEND_TO', function (event, sendToAll, webContentsId, channel, ...args) {
let contents = webContents.fromId(webContentsId)
if (!contents) {
console.error(`Sending message to WebContents with unknown ID ${webContentsId}`)
return
}
if (sendToAll) {
contents.sendToAll(channel, ...args)
} else {
contents.send(channel, ...args)
}
})