New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add event.senderId property to IPCs sent via ipcRenderer.sendTo #14395
Conversation
fca3fc7
to
618de55
Compare
@@ -41,7 +41,7 @@ void RemoteCallbackFreer::RunDestructor() { | |||
auto* frame_host = web_contents()->GetMainFrame(); | |||
if (frame_host) { | |||
frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(), false, | |||
channel, args)); | |||
channel, args, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<...>, args, /* sender_id */ 0));
const {ipcRenderer} = require('electron') | ||
ipcRenderer.on('ping', function (event, id) { | ||
ipcRenderer.sendTo(id, 'pong', id) | ||
ipcRenderer.on('ping', function (event, payload) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipcRenderer
is probably undefined
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's exposed by the preload script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preload: path.join(fixtures, 'module', 'preload-inject-ipc.js'),
618de55
to
7315354
Compare
7315354
to
79ad682
Compare
bool SendIPCMessageWithSender(bool all_frames, | ||
const std::string& channel, | ||
const base::ListValue& args, | ||
int32_t sender_id = 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add this default fourth arg to SendIPCMessage()
instead of adding a new function -- do we need both functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not work for methods exposed to JS via mate. The default arguments are ignored. It has to be a separate method unfortunatelly
Release Notes Persisted
|
Description of Change
Currently, it's not possible to tell whether an IPC was sent directly from the main process or from another renderer via
renderer.sendTo
. This PR addsevent.senderId
property, which identifies the originating webContents. If the IPC was sent directly from the main process, the value is 0.The modified
spec/api-ipc-renderer-spec.js
demonstrates this.Checklist
npm test
passesRelease Notes
Notes: Added
event.senderId
property to IPCs sent viaipcRenderer.sendTo
.