Emit web-contents-created on app
This commit is contained in:
parent
2dc453b4be
commit
56001b481e
2 changed files with 12 additions and 12 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue