Implement chrome.tab.onCreated/onRemoved APIs

This commit is contained in:
Cheng Zhao 2016-05-29 11:50:14 +09:00
parent 2431d886bf
commit ec1944c146
2 changed files with 29 additions and 4 deletions

View file

@ -90,6 +90,14 @@ exports.injectTo = function (extensionId, isBackgroundPage, context) {
chrome.runtime.onMessage.emit(message, new MessageSender(tabId, extensionId))
})
ipcRenderer.on('CHROME_TABS_ONCREATED', (event, tabId) => {
chrome.tabs.onCreated.emit(new Tab(tabId))
})
ipcRenderer.on('CHROME_TABS_ONREMOVED', (event, tabId) => {
chrome.tabs.onRemoved.emit(tabId)
})
chrome.runtime = {
getURL: function (path) {
return url.format({
@ -100,8 +108,6 @@ exports.injectTo = function (extensionId, isBackgroundPage, context) {
})
},
onConnect: new Event(),
connect (...args) {
if (isBackgroundPage) {
console.error('chrome.runtime.connect is not supported in background page')
@ -141,7 +147,9 @@ exports.injectTo = function (extensionId, isBackgroundPage, context) {
ipcRenderer.send('CHROME_RUNTIME_SENDMESSAGE', targetExtensionId, message)
},
onMessage: new Event()
onConnect: new Event(),
onMessage: new Event(),
onInstalled: new Event()
}
chrome.tabs = {
@ -160,7 +168,9 @@ exports.injectTo = function (extensionId, isBackgroundPage, context) {
ipcRenderer.send(`CHROME_TABS_SEND_MESSAGE`, tabId, extensionId, isBackgroundPage, message)
},
onUpdated: new Event()
onUpdated: new Event(),
onCreated: new Event(),
onRemoved: new Event()
}
chrome.extension = {