webContents: provide responses for executeJavscript method

This commit is contained in:
Robo 2016-02-17 22:33:27 +05:30
parent d00490271b
commit 2b547bd44a
9 changed files with 113 additions and 13 deletions

View file

@ -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);
});