mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-23 00:47:31 +09:00
WebUSB pt.4
This commit is contained in:
parent
e686f8a313
commit
f7222385ac
3 changed files with 8 additions and 6 deletions
|
|
@ -96,7 +96,7 @@ private:
|
||||||
RefPtr<Promise> mPromise;
|
RefPtr<Promise> mPromise;
|
||||||
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
||||||
nsTArray<RefPtr<USBDevice>> mCandidates;
|
nsTArray<RefPtr<USBDevice>> mCandidates;
|
||||||
RefPtr<nsContentPermissionRequester> mRequester;
|
nsCOMPtr<nsIContentPermissionRequester> mRequester;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(USBPermissionRequest)
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(USBPermissionRequest)
|
||||||
|
|
@ -127,12 +127,14 @@ USBPermissionRequest::GetTypes(nsIArray** aTypes)
|
||||||
{
|
{
|
||||||
nsTArray<nsString> options;
|
nsTArray<nsString> options;
|
||||||
for (const auto& device : mCandidates) {
|
for (const auto& device : mCandidates) {
|
||||||
Nullable<nsString> label;
|
DOMString label;
|
||||||
device->GetProductName(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"));
|
options.AppendElement(NS_LITERAL_STRING("USB device"));
|
||||||
} else {
|
} else {
|
||||||
options.AppendElement(label.Value());
|
options.AppendElement(labelString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nsContentPermissionUtils::CreatePermissionArray(
|
return nsContentPermissionUtils::CreatePermissionArray(
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
|
|
||||||
#include <setupapi.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <setupapi.h>
|
||||||
#include <winusb.h>
|
#include <winusb.h>
|
||||||
|
|
||||||
#include "mozilla/fallible.h"
|
#include "mozilla/fallible.h"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include "USBDescriptors.h"
|
#include "USBDescriptors.h"
|
||||||
|
|
||||||
#include "mozilla/HoldDropJSObjects.h"
|
#include "mozilla/HoldDropJSObjects.h"
|
||||||
#include "mozilla/dom/ArrayBuffer.h"
|
#include "mozilla/dom/TypedArray.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue