WebUSB pt.4

This commit is contained in:
wuggy 2026-09-19 12:15:05 -07:00
commit f7222385ac
3 changed files with 8 additions and 6 deletions

View file

@ -96,7 +96,7 @@ private:
RefPtr<Promise> mPromise;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
nsTArray<RefPtr<USBDevice>> mCandidates;
RefPtr<nsContentPermissionRequester> mRequester;
nsCOMPtr<nsIContentPermissionRequester> mRequester;
};
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(USBPermissionRequest)
@ -127,12 +127,14 @@ USBPermissionRequest::GetTypes(nsIArray** aTypes)
{
nsTArray<nsString> options;
for (const auto& device : mCandidates) {
Nullable<nsString> label;
DOMString label;
device->GetProductName(label);
if (label.IsNull() || label.Value().IsEmpty()) {
nsAutoString labelString;
label.ToString(labelString);
if (label.IsNull() || labelString.IsEmpty()) {
options.AppendElement(NS_LITERAL_STRING("USB device"));
} else {
options.AppendElement(label.Value());
options.AppendElement(labelString);
}
}
return nsContentPermissionUtils::CreatePermissionArray(

View file

@ -4,9 +4,9 @@
#ifdef XP_WIN
#include <setupapi.h>
#include <string.h>
#include <windows.h>
#include <setupapi.h>
#include <winusb.h>
#include "mozilla/fallible.h"

View file

@ -3,7 +3,7 @@
#include "USBDescriptors.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/ArrayBuffer.h"
#include "mozilla/dom/TypedArray.h"
namespace mozilla {
namespace dom {