Implement chrome.tab.onCreated/onRemoved APIs
This commit is contained in:
parent
2431d886bf
commit
ec1944c146
2 changed files with 29 additions and 4 deletions
|
@ -68,6 +68,20 @@ const removeBackgroundPages = function (manifest) {
|
|||
delete backgroundPages[manifest.extensionId]
|
||||
}
|
||||
|
||||
// Dispatch tabs events.
|
||||
const hookWindowForTabEvents = function (win) {
|
||||
const tabId = win.webContents.id
|
||||
for (const page of objectValues(backgroundPages)) {
|
||||
page.webContents.sendToAll('CHROME_TABS_ONCREATED', tabId)
|
||||
}
|
||||
|
||||
win.once('closed', () => {
|
||||
for (const page of objectValues(backgroundPages)) {
|
||||
page.webContents.sendToAll('CHROME_TABS_ONREMOVED', tabId)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Handle the chrome.* API messages.
|
||||
let nextId = 0
|
||||
|
||||
|
@ -290,6 +304,7 @@ app.once('ready', function () {
|
|||
const init = BrowserWindow.prototype._init
|
||||
BrowserWindow.prototype._init = function () {
|
||||
init.call(this)
|
||||
hookWindowForTabEvents(this)
|
||||
this.webContents.on('devtools-opened', () => {
|
||||
loadDevToolsExtensions(this, objectValues(manifestMap))
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue