From edb573d69e5839e5fa0bf595b0137548dc975e69 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 2 Aug 2016 20:55:56 +0900 Subject: [PATCH] Make WebContents inherit NavigationController --- lib/browser/api/web-contents.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index c255cd0ff951..eba951b6d7d5 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -82,7 +82,8 @@ const defaultPrintingSetting = { const binding = process.atomBinding('web_contents') 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::sendToAll(channel, args..) @@ -196,21 +197,13 @@ WebContents.prototype.printToPDF = function (options, callback) { // Add JavaScript wrappers for WebContents class. WebContents.prototype._init = function () { + // The navigation controller. + NavigationController.call(this, this) + // Every remote callback from renderer process would add a listenter to the // render-view-deleted event, so ignore the listenters warning. 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. this.on('ipc-message', function (event, [channel, ...args]) { ipcMain.emit(channel, event, ...args)