2018-09-22 12:28:50 +00:00
|
|
|
'use strict'
|
|
|
|
|
2018-09-13 16:10:51 +00:00
|
|
|
const { ipcRenderer, webFrame } = require('electron')
|
2018-09-20 03:43:26 +00:00
|
|
|
const errorUtils = require('@electron/internal/common/error-utils')
|
2018-04-12 01:57:40 +00:00
|
|
|
|
|
|
|
module.exports = () => {
|
|
|
|
// Call webFrame method
|
2018-09-11 09:56:00 +00:00
|
|
|
ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', (event, method, args) => {
|
|
|
|
webFrame[method](...args)
|
2018-04-12 01:57:40 +00:00
|
|
|
})
|
|
|
|
|
2018-09-11 09:56:00 +00:00
|
|
|
ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
|
|
|
new Promise(resolve =>
|
|
|
|
webFrame[method](...args, resolve)
|
|
|
|
).then(result => {
|
|
|
|
return [null, result]
|
|
|
|
}, error => {
|
|
|
|
return [errorUtils.serialize(error)]
|
|
|
|
}).then(responseArgs => {
|
|
|
|
event.sender.send(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, ...responseArgs)
|
|
|
|
})
|
2018-04-12 01:57:40 +00:00
|
|
|
})
|
|
|
|
}
|