Make WebContents inherit NavigationController
This commit is contained in:
parent
025034127a
commit
edb573d69e
1 changed files with 5 additions and 12 deletions
|
@ -82,7 +82,8 @@ const defaultPrintingSetting = {
|
||||||
const binding = process.atomBinding('web_contents')
|
const binding = process.atomBinding('web_contents')
|
||||||
const {WebContents} = binding
|
const {WebContents} = binding
|
||||||
|
|
||||||
Object.setPrototypeOf(WebContents.prototype, EventEmitter.prototype)
|
Object.setPrototypeOf(NavigationController.prototype, EventEmitter.prototype)
|
||||||
|
Object.setPrototypeOf(WebContents.prototype, NavigationController.prototype)
|
||||||
|
|
||||||
// WebContents::send(channel, args..)
|
// WebContents::send(channel, args..)
|
||||||
// WebContents::sendToAll(channel, args..)
|
// WebContents::sendToAll(channel, args..)
|
||||||
|
@ -196,21 +197,13 @@ WebContents.prototype.printToPDF = function (options, callback) {
|
||||||
|
|
||||||
// Add JavaScript wrappers for WebContents class.
|
// Add JavaScript wrappers for WebContents class.
|
||||||
WebContents.prototype._init = function () {
|
WebContents.prototype._init = function () {
|
||||||
|
// The navigation controller.
|
||||||
|
NavigationController.call(this, this)
|
||||||
|
|
||||||
// Every remote callback from renderer process would add a listenter to the
|
// Every remote callback from renderer process would add a listenter to the
|
||||||
// render-view-deleted event, so ignore the listenters warning.
|
// render-view-deleted event, so ignore the listenters warning.
|
||||||
this.setMaxListeners(0)
|
this.setMaxListeners(0)
|
||||||
|
|
||||||
// The navigation controller.
|
|
||||||
const controller = new NavigationController(this)
|
|
||||||
for (const name in NavigationController.prototype) {
|
|
||||||
const method = NavigationController.prototype[name]
|
|
||||||
if (method instanceof Function) {
|
|
||||||
this[name] = function () {
|
|
||||||
return method.apply(controller, arguments)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dispatch IPC messages to the ipc module.
|
// Dispatch IPC messages to the ipc module.
|
||||||
this.on('ipc-message', function (event, [channel, ...args]) {
|
this.on('ipc-message', function (event, [channel, ...args]) {
|
||||||
ipcMain.emit(channel, event, ...args)
|
ipcMain.emit(channel, event, ...args)
|
||||||
|
|
Loading…
Reference in a new issue