feat: add additional remote APIs filtering (#16293)

This commit is contained in:
Milan Burda 2019-01-08 23:27:56 +01:00 committed by Jeremy Apthorp
parent 6436a12d7f
commit 349a3c20ae
8 changed files with 323 additions and 69 deletions

View file

@ -235,29 +235,38 @@ app.on('ready', function () {
})
})
ipcMain.on('handle-next-desktop-capturer-get-sources', function (event) {
event.sender.once('desktop-capturer-get-sources', (event) => {
event.preventDefault()
for (const eventName of [
'remote-require',
'remote-get-global',
'remote-get-builtin'
]) {
ipcMain.on(`handle-next-${eventName}`, function (event, valuesMap = {}) {
event.sender.once(eventName, (event, name) => {
if (valuesMap.hasOwnProperty(name)) {
event.returnValue = valuesMap[name]
} else {
event.preventDefault()
}
})
})
})
}
ipcMain.on('handle-next-remote-require', function (event, modulesMap = {}) {
event.sender.once('remote-require', (event, moduleName) => {
event.preventDefault()
if (modulesMap.hasOwnProperty(moduleName)) {
event.returnValue = modulesMap[moduleName]
}
for (const eventName of [
'desktop-capturer-get-sources',
'remote-get-current-window',
'remote-get-current-web-contents',
'remote-get-guest-web-contents'
]) {
ipcMain.on(`handle-next-${eventName}`, function (event, returnValue) {
event.sender.once(eventName, (event) => {
if (returnValue) {
event.returnValue = returnValue
} else {
event.preventDefault()
}
})
})
})
ipcMain.on('handle-next-remote-get-global', function (event, globalsMap = {}) {
event.sender.once('remote-get-global', (event, globalName) => {
event.preventDefault()
if (globalsMap.hasOwnProperty(globalName)) {
event.returnValue = globalsMap[globalName]
}
})
})
}
ipcMain.on('set-client-certificate-option', function (event, skip) {
app.once('select-client-certificate', function (event, webContents, url, list, callback) {