зеркало из https://github.com/electron/electron.git
Emit web-contents-created on app
This commit is contained in:
Родитель
2dc453b4be
Коммит
56001b481e
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче