Pass sender for chrome.runtime.onMessage
This commit is contained in:
parent
5eb9ed1729
commit
9ed4730cba
2 changed files with 7 additions and 5 deletions
|
@ -93,7 +93,7 @@ ipcMain.on('CHROME_RUNTIME_SENDMESSAGE', function (event, extensionId, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
page.webContents.sendToAll(`CHROME_RUNTIME_ONMESSAGE_${extensionId}`, message)
|
page.webContents.sendToAll(`CHROME_RUNTIME_ONMESSAGE_${extensionId}`, event.sender.id, message)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('CHROME_TABS_EXECUTESCRIPT', function (event, requestId, webContentsId, extensionId, details) {
|
ipcMain.on('CHROME_TABS_EXECUTESCRIPT', function (event, requestId, webContentsId, extensionId, details) {
|
||||||
|
|
|
@ -86,8 +86,8 @@ exports.injectTo = function (extensionId, context) {
|
||||||
chrome.runtime.onConnect.emit(new Port(webContentsId, portId, extensionId, connectInfo.name))
|
chrome.runtime.onConnect.emit(new Port(webContentsId, portId, extensionId, connectInfo.name))
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on(`CHROME_RUNTIME_ONMESSAGE_${extensionId}`, (event, message) => {
|
ipcRenderer.on(`CHROME_RUNTIME_ONMESSAGE_${extensionId}`, (event, tabId, message) => {
|
||||||
chrome.runtime.onMessage.emit(message)
|
chrome.runtime.onMessage.emit(message, new MessageSender(tabId, extensionId))
|
||||||
})
|
})
|
||||||
|
|
||||||
chrome.runtime = {
|
chrome.runtime = {
|
||||||
|
@ -148,8 +148,10 @@ exports.injectTo = function (extensionId, context) {
|
||||||
if (responseCallback) {
|
if (responseCallback) {
|
||||||
console.error('responseCallback is not supported')
|
console.error('responseCallback is not supported')
|
||||||
}
|
}
|
||||||
ipcRenderer.sendToAll(tabId, `CHROME_RUNTIME_ONMESSAGE_${extensionId}`, message)
|
ipcRenderer.send('CHROME_RUNTIME_SENDMESSAGE', extensionId, message)
|
||||||
}
|
},
|
||||||
|
|
||||||
|
onUpdated: new Event()
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.extension = {
|
chrome.extension = {
|
||||||
|
|
Loading…
Reference in a new issue