From e4d5dc138fd909de288fde82ee5d03106fe092f2 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 31 Jan 2024 15:53:30 +0100 Subject: [PATCH] fix: `select-usb-device` should respect `filters` option (#41166) fix: select-usb-device should respect filters option --- shell/browser/usb/usb_chooser_controller.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shell/browser/usb/usb_chooser_controller.cc b/shell/browser/usb/usb_chooser_controller.cc index 992b9f7b3202..b3676268367c 100644 --- a/shell/browser/usb/usb_chooser_controller.cc +++ b/shell/browser/usb/usb_chooser_controller.cc @@ -120,6 +120,14 @@ void UsbChooserController::GotUsbDeviceList( auto* rfh = content::RenderFrameHost::FromID(render_frame_host_id_); v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); + + // "select-usb-device" should respect |filters|. + devices.erase(std::remove_if(devices.begin(), devices.end(), + [this](const auto& device_info) { + return !DisplayDevice(*device_info); + }), + devices.end()); + v8::Local details = gin::DataObjectBuilder(isolate) .Set("deviceList", devices) .Set("frame", rfh)