Use destroyed event instead of closed event

This commit is contained in:
Kevin Sawicki 2016-06-07 10:10:56 -07:00
parent 4f46f75d8f
commit 4c1ede32cf

View file

@ -81,13 +81,13 @@ const removeBackgroundPages = function (manifest) {
} }
// Dispatch tabs events. // Dispatch tabs events.
const hookWindowForTabEvents = function (win, webContents) { const hookWindowForTabEvents = function (webContents) {
const tabId = webContents.id const tabId = webContents.id
for (const page of objectValues(backgroundPages)) { for (const page of objectValues(backgroundPages)) {
page.webContents.sendToAll('CHROME_TABS_ONCREATED', tabId) page.webContents.sendToAll('CHROME_TABS_ONCREATED', tabId)
} }
win.once('closed', () => { webContents.once('destroyed', () => {
for (const page of objectValues(backgroundPages)) { for (const page of objectValues(backgroundPages)) {
page.webContents.sendToAll('CHROME_TABS_ONREMOVED', tabId) page.webContents.sendToAll('CHROME_TABS_ONREMOVED', tabId)
} }
@ -320,7 +320,7 @@ app.once('ready', function () {
} }
BrowserWindow.prototype._loadDevToolsExtensions = function (webContents) { BrowserWindow.prototype._loadDevToolsExtensions = function (webContents) {
hookWindowForTabEvents(this, webContents) hookWindowForTabEvents(webContents)
webContents.on('devtools-opened', function () { webContents.on('devtools-opened', function () {
loadDevToolsExtensions(webContents, objectValues(manifestMap)) loadDevToolsExtensions(webContents, objectValues(manifestMap))
}) })