Implement chrome.runtime.sendMessage
This commit is contained in:
parent
ba315248e0
commit
62fb4f9820
2 changed files with 42 additions and 2 deletions
|
@ -86,6 +86,16 @@ ipcMain.on('CHROME_RUNTIME_CONNECT', function (event, extensionId, connectInfo)
|
|||
page.webContents.sendToAll('CHROME_RUNTIME_ONCONNECT', event.sender.id, portId, extensionId, connectInfo)
|
||||
})
|
||||
|
||||
ipcMain.on('CHROME_RUNTIME_SENDMESSAGE', function (event, extensionId, message) {
|
||||
const page = backgroundPages[extensionId]
|
||||
if (!page) {
|
||||
console.error(`Connect to unkown extension ${extensionId}`)
|
||||
return
|
||||
}
|
||||
|
||||
page.webContents.sendToAll('CHROME_RUNTIME_ONMESSAGE', message)
|
||||
})
|
||||
|
||||
ipcMain.on('CHROME_TABS_EXECUTESCRIPT', function (event, requestId, webContentsId, extensionId, details) {
|
||||
const contents = webContents.fromId(webContentsId)
|
||||
if (!contents) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue