run webframe methods for webview in its context

This commit is contained in:
Robo 2016-02-25 23:35:01 +05:30
parent 8386baf267
commit 1235907835
5 changed files with 32 additions and 27 deletions

View file

@ -354,11 +354,17 @@ ipcMain.on('ATOM_BROWSER_GUEST_WEB_CONTENTS', function(event, guestInstanceId) {
}
});
ipcMain.on('ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function(event, guestInstanceId, method, ...args) {
ipcMain.on('ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function(event, requestId, guestInstanceId, method, ...args) {
try {
let guestViewManager = require('./guest-view-manager');
let guest = guestViewManager.getGuest(guestInstanceId);
return guest[method].apply(guest, args);
if (requestId) {
const responseCallback = function(result) {
event.sender.send(`ATOM_RENDERER_ASYNC_CALL_TO_GUEST_VIEW_RESPONSE_${requestId}`, result);
};
args.push(responseCallback);
}
guest[method].apply(guest, args);
} catch (error) {
return event.returnValue = exceptionToMeta(error);
}