standardize by hand
This commit is contained in:
parent
cfdfdc8ccc
commit
e6698102c9
13 changed files with 34 additions and 33 deletions
|
@ -5,12 +5,12 @@ const ipcMain = require('electron').ipcMain
|
|||
// The history operation in renderer is redirected to browser.
|
||||
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function (event, method, ...args) {
|
||||
var ref
|
||||
return (ref = event.sender)[method].apply(ref, args)
|
||||
(ref = event.sender)[method].apply(ref, args)
|
||||
})
|
||||
|
||||
ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function (event, method, ...args) {
|
||||
var ref
|
||||
return event.returnValue = (ref = event.sender)[method].apply(ref, args)
|
||||
event.returnValue = (ref = event.sender)[method].apply(ref, args)
|
||||
})
|
||||
|
||||
// JavaScript implementation of Chromium's NavigationController.
|
||||
|
@ -41,10 +41,10 @@ var NavigationController = (function () {
|
|||
// Go to index.
|
||||
this.currentIndex = this.pendingIndex
|
||||
this.pendingIndex = -1
|
||||
return this.history[this.currentIndex] = url
|
||||
this.history[this.currentIndex] = url
|
||||
} else if (replaceEntry) {
|
||||
// Non-user initialized navigation.
|
||||
return this.history[this.currentIndex] = url
|
||||
this.history[this.currentIndex] = url
|
||||
} else {
|
||||
// Normal navigation. Clear history.
|
||||
this.history = this.history.slice(0, this.currentIndex + 1)
|
||||
|
@ -111,7 +111,7 @@ var NavigationController = (function () {
|
|||
this.history = []
|
||||
this.currentIndex = -1
|
||||
this.pendingIndex = -1
|
||||
return this.inPageIndex = -1
|
||||
this.inPageIndex = -1
|
||||
}
|
||||
|
||||
NavigationController.prototype.goBack = function () {
|
||||
|
|
|
@ -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))
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue