AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

This commit is contained in:
wuggy 2026-09-19 15:11:02 -07:00
commit 99e4dc450c
2 changed files with 31 additions and 0 deletions

View file

@ -368,6 +368,8 @@ geolocation.shareWithSite2=Would you like to share your location with this site?
geolocation.shareWithFile2=Would you like to share your location with this file?
webUSB.connectToSite=Would you like to let this site access USB devices?
webUSB.selectDeviceTitle=Select USB device
webUSB.selectDevice=Choose a USB device to access:
webUSB.allow=Allow USB Devices
webUSB.allow.accesskey=A
webUSB.block=Block USB Devices

View file

@ -550,6 +550,35 @@ USBPermissionPrompt.prototype = {
return "web-usb";
},
// PopupNotifications in older UXP builds cannot reliably render a
// permission request that contains a variable list of USB devices. Use
// the native prompt service so the chooser is always visible and the
// selected device can be returned to the content request.
prompt() {
let choices = getUSBDeviceChoices(this.request);
if (!choices.length) {
this.cancel();
return;
}
let browser = this.browser;
let parent = browser && browser.ownerGlobal ? browser.ownerGlobal : null;
let selected = { value: 0 };
let accepted = Services.prompt.select(
parent,
getUSBString("webUSB.selectDeviceTitle", "Select USB device"),
getUSBString("webUSB.selectDevice", "Choose a USB device to access:"),
choices.length,
choices,
selected);
if (accepted && selected.value >= 0 && selected.value < choices.length) {
this.request.allow({usb: choices[selected.value]});
} else {
this.cancel();
}
},
get anchorID() {
return "default-notification-icon";
},