standardize by hand

This commit is contained in:
Zeke Sikelianos 2016-03-28 17:35:49 -07:00 committed by Kevin Sawicki
parent cfdfdc8ccc
commit e6698102c9
13 changed files with 34 additions and 33 deletions

View file

@ -87,7 +87,7 @@ let wrapWebContents = function (webContents) {
method = ref1[name]
if (method instanceof Function) {
(function (name, method) {
return webContents[name] = function () {
webContents[name] = function () {
return method.apply(controller, arguments)
}
})(name, method)
@ -104,8 +104,7 @@ let wrapWebContents = function (webContents) {
const asyncWebFrameMethods = function (requestId, method, callback, ...args) {
this.send('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', requestId, method, args)
ipcMain.once(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, function (event, result) {
if (callback)
callback(result)
if (callback) callback(result)
})
}
@ -117,10 +116,11 @@ let wrapWebContents = function (webContents) {
callback = hasUserGesture
hasUserGesture = false
}
if (this.getURL() && !this.isLoading())
if (this.getURL() && !this.isLoading()) {
return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
else
} else {
return this.once('did-finish-load', asyncWebFrameMethods.bind(this, requestId, 'executeJavaScript', callback, code, hasUserGesture))
}
}
// Dispatch IPC messages to the ipc module.
@ -128,11 +128,14 @@ let wrapWebContents = function (webContents) {
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args))
})
webContents.on('ipc-message-sync', function (event, [channel, ...args]) {
/* eslint-disable */
// standard complains: Getter is not present
Object.defineProperty(event, 'returnValue', {
set: function (value) {
return event.sendReply(JSON.stringify(value))
}
})
/* eslint-enable */
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args))
})