feat: support Web Serial & WebUSB blocklists (#46600)

This commit is contained in:
Shelley Vohr 2025-04-17 20:34:34 +02:00 committed by GitHub
parent 352a403efd
commit a29e1170b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 106 additions and 4 deletions

View file

@ -8,7 +8,9 @@
#include <cstddef>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "chrome/browser/usb/usb_blocklist.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@ -140,6 +142,8 @@ void UsbChooserController::GotUsbDeviceList(
bool UsbChooserController::DisplayDevice(
const device::mojom::UsbDeviceInfo& device_info) const {
bool blocklist_disabled =
base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableUSBBlocklist);
if (!device::UsbDeviceFilterMatchesAny(options_->filters, device_info)) {
return false;
}
@ -151,6 +155,10 @@ bool UsbChooserController::DisplayDevice(
return false;
}
if (!blocklist_disabled && UsbBlocklist::Get().IsExcluded(device_info)) {
return false;
}
return true;
}