electron/shell/browser/serial
Shelley Vohr 2c6dd1156c
fix: use requesting frame origin in permission helper and device choosers (#50052)
* fix: use requesting frame origin instead of top-level URL for permissions

`WebContentsPermissionHelper::RequestPermission` passes
`web_contents_->GetLastCommittedURL()` as the origin to the permission
manager instead of the actual requesting frame's origin. This enables
origin confusion when granting permissions to embedded third-party iframes,
since app permission handlers see the top-level origin instead of the
iframe's. The same pattern exists in the HID, USB, and Serial device
choosers, where grants are keyed to the primary main frame's origin rather
than the requesting frame's.

Fix this by using `requesting_frame->GetLastCommittedOrigin()` in all
affected code paths, renaming `details.requestingUrl` to
`details.requestingOrigin`, and populating it with the serialized
origin only.

* chore: keep requestingUrl name in permission handler details

The previous commit changed the details.requestingUrl field to
details.requestingOrigin in permission request/check handlers. That
field was already populated from the requesting frame's RFH, so the
rename was unnecessary and would break apps that read the existing
property. Revert to requestingUrl to preserve the existing API shape.

The functional changes to use the requesting frame in
WebContentsPermissionHelper and the HID/USB/Serial choosers remain.

---------

Co-authored-by: Samuel Attard <sattard@anthropic.com>
2026-03-09 09:20:22 -07:00
..
electron_serial_delegate.cc fix: use requesting frame origin in permission helper and device choosers (#50052) 2026-03-09 09:20:22 -07:00
electron_serial_delegate.h perf: use absl::flat_hash_map instead of std::unordered_map (#46202) 2025-03-24 10:09:14 +01:00
serial_chooser_context.cc chore: bump chromium to 146.0.7666.0 (main) (#49528) 2026-02-12 12:37:56 -05:00
serial_chooser_context.h feat: support Web Serial & WebUSB blocklists (#46600) 2025-04-17 20:34:34 +02:00
serial_chooser_context_factory.cc refactor: remove use of deprecated API BuildServiceInstanceFor() (#43690) 2024-09-12 15:44:14 -05:00
serial_chooser_context_factory.h refactor: remove use of deprecated API BuildServiceInstanceFor() (#43690) 2024-09-12 15:44:14 -05:00
serial_chooser_controller.cc fix: use requesting frame origin in permission helper and device choosers (#50052) 2026-03-09 09:20:22 -07:00
serial_chooser_controller.h refactor: allocate api::Session on cpp heap (#48141) 2025-08-25 18:52:06 +09:00