fix: ensure bluetooth devices are not returned by default (#32178)

This commit is contained in:
Samuel Attard 2021-12-16 08:46:48 +13:00 committed by GitHub
parent 1facbb4a09
commit a11f5cbb27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -736,6 +736,8 @@ first available device will be selected. `callback` should be called with
`deviceId` to be selected, passing empty string to `callback` will `deviceId` to be selected, passing empty string to `callback` will
cancel the request. cancel the request.
If no event listener is added for this event, all bluetooth requests will be cancelled.
```javascript ```javascript
const { app, BrowserWindow } = require('electron') const { app, BrowserWindow } = require('electron')

View file

@ -749,6 +749,14 @@ WebContents.prototype._init = function () {
} }
}); });
this.on('select-bluetooth-device', (event, devices, callback) => {
if (this.listenerCount('select-bluetooth-device') === 0) {
// Cancel it if there are no handlers
event.preventDefault();
callback('');
}
});
const event = process._linkedBinding('electron_browser_event').createEmpty(); const event = process._linkedBinding('electron_browser_event').createEmpty();
app.emit('web-contents-created', event, this); app.emit('web-contents-created', event, this);