Repository navigation
Track the origin of webRequest events - #10429
Conversation
MarshallOfSound
left a comment
There was a problem hiding this comment.
Please remove package-lock.json 👍
|
@MarshallOfSound Done 😃 |
| if (info) { | ||
| int64_t process_id = info->GetChildID(); | ||
| int64_t routing_id = info->GetRouteID(); | ||
| details->SetDouble("webContentsGetId", (process_id << 32) + routing_id); |
There was a problem hiding this comment.
This should probably be just webContentsId
And assuming my understanding of this bit shifting is correct that ID should just work with https://electron.atom.io/docs/api/web-contents/#webcontentsfromidid 👍
There was a problem hiding this comment.
webContentsIdis actually theIDin a weak map, as shown here.webContentsGetIdis, in the other hand, a 64-bit integer composed of both the process id(high 32) and the RenderViewHost routing id(low 32), as shown here.
Thus, the argument passed to webContents.fromId(id) should be webContentsId, not webContentsGetId, as shown here. Besides, there's no api to get back the corresponding webContents from webContentsGetId afaik 😭 .
There was a problem hiding this comment.
I think you can use the process ID and routing ID to get the WebContents with:
content::WebContents* webContents = content::WebContents::FromRenderFrameHost(RenderFrameHost::FromID(process_id, routing_id));And then get the webContentsId by calling api::WebContents::GetIDFromWrappedClass(webContents).
(We would need to make that method public though).
| if (info) { | ||
| int64_t process_id = info->GetChildID(); | ||
| int64_t routing_id = info->GetRouteID(); | ||
| details->SetDouble("webContentsGetId", (process_id << 32) + routing_id); |
There was a problem hiding this comment.
I think you can use the process ID and routing ID to get the WebContents with:
content::WebContents* webContents = content::WebContents::FromRenderFrameHost(RenderFrameHost::FromID(process_id, routing_id));And then get the webContentsId by calling api::WebContents::GetIDFromWrappedClass(webContents).
(We would need to make that method public though).
|
@zcbenz By the way, I just changed |
2. remove mappings member in vuex 3. we now track each webRequest events by electron/electron#10429 4. store the corresponding tabId as an attribute into its webContents object
2. remove mappings member in vuex 3. we now track each webRequest events by electron/electron#10429 4. store the corresponding webContentsId as an attribute into extension API's TabObject
This PR is a mitigation to #10061, and therefore ppl can use the webContentsGetId to track the origin requester. The variable name
webContentsGetIdis taken from a64978b.In addition, it would be convenient if we can have a
webContents.fromGetIdapi to get the correspondingWebContents, just like whatwebContents.fromIddoes. How do you think?