feat: attribute Web Bluetooth requests to the requesting frame - #53661
Open
MarshallOfSound wants to merge 4 commits into
Open
feat: attribute Web Bluetooth requests to the requesting frame#53661MarshallOfSound wants to merge 4 commits into
MarshallOfSound wants to merge 4 commits into
Conversation
MarshallOfSound
force-pushed
the
feat/bluetooth-permissions-requesting-frame
branch
from
September 7, 2026 09:03
921fdeb to
cb8bf18
Compare
MarshallOfSound
force-pushed
the
feat/bluetooth-permissions-requesting-frame
branch
from
September 7, 2026 15:53
2b63662 to
3555757
Compare
* add a `bluetooth` permission type; ElectronBluetoothDelegate::MayUseBluetooth
asks session.setPermissionCheckHandler for the requesting frame, so apps
can turn Web Bluetooth off per origin or frame like hid/usb/serial
* new session events `select-bluetooth-device` (details { deviceList, frame },
callback) and `bluetooth-device-added` (details { device, frame }); the
webContents `select-bluetooth-device` event keeps working, gains a trailing
`frame` argument and is deprecated
* if listeners exist but none calls event.preventDefault(), cancel the
request once discovery finishes instead of selecting the first discovered
device; with no listener at all the request is still cancelled immediately
* run the content event handler from a posted task so a listener that answers
synchronously cannot re-enter content mid-discovery; look the webContents
wrapper up per emission instead of caching it; only re-emit when a device's
name actually changes
* DCHECK that kWebBluetoothNewPermissionsBackend stays disabled until the
delegate's device-permission methods are implemented
* testing: drive a bluetooth::FakeCentral from the testing binding and cover
attribution per topology, session events, synchronous answers,
unanswered/unhandled choosers and the check handler in
spec/api-device-permissions-spec.ts
* docs: session and web-contents events, check-handler list, devices and
permissions tutorials, fiddle, breaking-changes entries
MarshallOfSound
force-pushed
the
feat/bluetooth-permissions-requesting-frame
branch
from
September 7, 2026 19:44
3555757 to
c9a2d90
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #53657. Brings Web Bluetooth in line with the hid/usb/serial model from that PR. Refs #31869, #52383, #53659.
session.setPermissionCheckHandleris consulted with a newbluetoothpermission for the requesting frame on every Web Bluetooth call; returningfalsemakes Web Bluetooth unavailable to that frame.sessioneventsselect-bluetooth-device(details: { deviceList, frame },callback) andbluetooth-device-added(details: { device, frame }), shaped like the hid/usb chooser events. ThewebContentsselect-bluetooth-deviceevent keeps working, gains a trailingframeargument, and is deprecated.event.preventDefault(), the request is cancelled when discovery finishes instead of Electron selecting the first discovered device. With no listener at all the request is still cancelled immediately.webContentswrapper is looked up per emission rather than cached.DCHECKthatkWebBluetoothNewPermissionsBackendstays disabled untilElectronBluetoothDelegate's device-permission methods are implemented.bluetooth::FakeCentraldriven from the testing binding;spec/api-device-permissions-spec.tscovers attribution per topology, the session events, synchronous answers, unhandled choosers and the check handler.Notes: Added
bluetoothtosession.setPermissionCheckHandlerandselect-bluetooth-device/bluetooth-device-addedevents onsessionthat identify the requesting frame; thewebContentsselect-bluetooth-deviceevent is deprecated and no longer auto-selects a device when unhandled.