webContents: provide responses for executeJavscript method
This commit is contained in:
parent
d00490271b
commit
2b547bd44a
9 changed files with 113 additions and 13 deletions
|
@ -32,7 +32,17 @@ v8Util.setHiddenValue(global, 'ipc', new events.EventEmitter);
|
|||
const electron = require('electron');
|
||||
|
||||
// Call webFrame method.
|
||||
const asyncWebFrameMethods = [
|
||||
'executeJavaScript'
|
||||
];
|
||||
|
||||
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', (event, method, args) => {
|
||||
if (asyncWebFrameMethods.includes(method)) {
|
||||
const responseCallback = function(result) {
|
||||
event.sender.send('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_RESPONSE', method, result);
|
||||
};
|
||||
args.push(responseCallback);
|
||||
}
|
||||
electron.webFrame[method].apply(electron.webFrame, args);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue