From 56001b481e610c29f0edd6bafcd1bba419082870 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 13 Jun 2016 08:59:03 -0700 Subject: [PATCH] Emit web-contents-created on app --- lib/browser/api/web-contents.js | 22 +++++++++++----------- lib/browser/chrome-extension.js | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index a3b4009aae7..afe9bd67096 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -1,7 +1,7 @@ 'use strict' const {EventEmitter} = require('events') -const {ipcMain, session, Menu, NavigationController} = require('electron') +const {app, ipcMain, session, Menu, NavigationController} = require('electron') // session is not used here, the purpose is to make sure session is initalized // before the webContents module. @@ -10,14 +10,6 @@ session const binding = process.atomBinding('web_contents') const debuggerBinding = process.atomBinding('debugger') -const WebContents = new EventEmitter() -WebContents.create = (options = {}) => { - return binding.create(options) -} -WebContents.fromId = (id) => { - return binding.fromId(id) -} - let nextId = 0 const getNextId = function () { return ++nextId @@ -232,7 +224,7 @@ const wrapWebContents = function (webContents) { this._printToPDF(printingSetting, callback) } - WebContents.emit('web-contents-created', webContents) + app.emit('web-contents-created', {}, webContents) } binding._setWrapWebContents(wrapWebContents) @@ -245,4 +237,12 @@ const wrapDebugger = function (webContentsDebugger) { debuggerBinding._setWrapDebugger(wrapDebugger) -module.exports = WebContents +module.exports = { + create () { + return binding.create(options) + }, + + fromId (id) { + return binding.fromId(id) + } +} diff --git a/lib/browser/chrome-extension.js b/lib/browser/chrome-extension.js index 8739c7a0aba..8ba5f29f0dc 100644 --- a/lib/browser/chrome-extension.js +++ b/lib/browser/chrome-extension.js @@ -236,7 +236,7 @@ const loadDevToolsExtensions = function (win, manifests) { win.devToolsWebContents.executeJavaScript(`DevToolsAPI.addExtensions(${JSON.stringify(extensionInfoArray)})`) } -webContents.on('web-contents-created', function (webContents) { +app.on('web-contents-created', function (event, webContents) { if (webContents.getType() === 'remote') return hookWebContentsForTabEvents(webContents)