chore: bump chromium to 102.0.4989.0 (main) (#33557)
* chore: bump chromium in DEPS to 102.0.4975.0 * chore: bump chromium in DEPS to 102.0.4977.0 * chore: update patches * Remove parameter of OnGpuProcessCrashed()3543396
* hid: Add exclusionFilters option to requestDevice3478175
* chore: bump chromium in DEPS to 102.0.4979.0 * chore: bump chromium in DEPS to 102.0.4981.0 * chore: update patches * Deny notification/push permission for documents in non-standard StoragePartitions3257305
* Improve FrameTreeNode tracking in URLLoaderNetworkContext3341866
* fixup! Remove parameter of OnGpuProcessCrashed() * chore: fix lint * Reland "Use gfx::Insets[F]::TLBR() and gfx::Insets[F]::VH() in the rest of Chrome"3554236
* chore: bump chromium in DEPS to 102.0.4983.0 * Ensure EyeDropperView does not access a destroyed window3561542
* ci: don't delete dawn .git directory 83901: Adds a generated file with the dawn git hash encoded at build time. | https://dawn-review.googlesource.com/c/dawn/+/83901 * ci: update Windows toolchain 3550827: New toolchain for Windows 10 20348 SDK |3550827
* chore: bump chromium in DEPS to 102.0.4985.0 * chore: update patches * chore: bump chromium in DEPS to 102.0.4987.0 * chore: update patches * 3563432: codehealth: remove uses of DictionaryValue in cbui/webui3563432
* chore: update patches after rebase * Use gfx::Insets[F]::TLBR() and gfx::Insets[F]::VH() in the rest of Chrome3554236
* 3565724: Preserve "proper method names" as-is in error.stack.3565724
* chore: bump chromium in DEPS to 102.0.4989.0 * chore: update patches * fixup ci: don't delete dawn .git directory for Windows * 3560843: Remove multi-parameter version of gfx::Rect[F]::Inset()3560843
* 3572711: Remove unused IDS_PDF_TOOLTIP_ROTATE_CW resource.3572711
* 3572926: Reland "[Sysroot] Switch to Debian Bullseye stable"3572926
* build: fixup sysroots with electron specific dependencies * fixup Remove multi-parameter version of gfx::Rect[F]::Inset() * fixup 3565724: Preserve "proper method names" as-is in error.stack. * fixup Remove multi-parameter version of gfx::Rect[F]::Inset() * test: add spec for navigator.hid.requestDevice({ exclusionFilters: [...] } * fixup 3565724: Preserve "proper method names" as-is in error.stack. * ci: use python3 to get the windows toolchain profile 3525960: Explicitly run everything with python3 |3525960
* chore: add diagnostic logging * fix: try calling process.crash() * chore: remove logging Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
e8ed9cb4b5
commit
59dd17f2cf
90 changed files with 973 additions and 443 deletions
|
@ -40,6 +40,47 @@ std::string PhysicalDeviceIdFromDeviceInfo(
|
|||
: device.physical_device_id;
|
||||
}
|
||||
|
||||
bool FilterMatch(const blink::mojom::HidDeviceFilterPtr& filter,
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
if (filter->device_ids) {
|
||||
if (filter->device_ids->is_vendor()) {
|
||||
if (filter->device_ids->get_vendor() != device.vendor_id)
|
||||
return false;
|
||||
} else if (filter->device_ids->is_vendor_and_product()) {
|
||||
const auto& vendor_and_product =
|
||||
filter->device_ids->get_vendor_and_product();
|
||||
if (vendor_and_product->vendor != device.vendor_id)
|
||||
return false;
|
||||
if (vendor_and_product->product != device.product_id)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (filter->usage) {
|
||||
if (filter->usage->is_page()) {
|
||||
const uint16_t usage_page = filter->usage->get_page();
|
||||
auto find_it =
|
||||
std::find_if(device.collections.begin(), device.collections.end(),
|
||||
[=](const device::mojom::HidCollectionInfoPtr& c) {
|
||||
return usage_page == c->usage->usage_page;
|
||||
});
|
||||
if (find_it == device.collections.end())
|
||||
return false;
|
||||
} else if (filter->usage->is_usage_and_page()) {
|
||||
const auto& usage_and_page = filter->usage->get_usage_and_page();
|
||||
auto find_it = std::find_if(
|
||||
device.collections.begin(), device.collections.end(),
|
||||
[&usage_and_page](const device::mojom::HidCollectionInfoPtr& c) {
|
||||
return usage_and_page->usage_page == c->usage->usage_page &&
|
||||
usage_and_page->usage == c->usage->usage;
|
||||
});
|
||||
if (find_it == device.collections.end())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace gin {
|
||||
|
@ -62,11 +103,13 @@ namespace electron {
|
|||
HidChooserController::HidChooserController(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
std::vector<blink::mojom::HidDeviceFilterPtr> filters,
|
||||
std::vector<blink::mojom::HidDeviceFilterPtr> exclusion_filters,
|
||||
content::HidChooser::Callback callback,
|
||||
content::WebContents* web_contents,
|
||||
base::WeakPtr<ElectronHidDelegate> hid_delegate)
|
||||
: WebContentsObserver(web_contents),
|
||||
filters_(std::move(filters)),
|
||||
exclusion_filters_(std::move(exclusion_filters)),
|
||||
callback_(std::move(callback)),
|
||||
origin_(content::WebContents::FromRenderFrameHost(render_frame_host)
|
||||
->GetMainFrame()
|
||||
|
@ -251,7 +294,7 @@ bool HidChooserController::DisplayDevice(
|
|||
return false;
|
||||
}
|
||||
|
||||
return FilterMatchesAny(device);
|
||||
return FilterMatchesAny(device) && !IsExcluded(device);
|
||||
}
|
||||
|
||||
bool HidChooserController::FilterMatchesAny(
|
||||
|
@ -260,44 +303,18 @@ bool HidChooserController::FilterMatchesAny(
|
|||
return true;
|
||||
|
||||
for (const auto& filter : filters_) {
|
||||
if (filter->device_ids) {
|
||||
if (filter->device_ids->is_vendor()) {
|
||||
if (filter->device_ids->get_vendor() != device.vendor_id)
|
||||
continue;
|
||||
} else if (filter->device_ids->is_vendor_and_product()) {
|
||||
const auto& vendor_and_product =
|
||||
filter->device_ids->get_vendor_and_product();
|
||||
if (vendor_and_product->vendor != device.vendor_id)
|
||||
continue;
|
||||
if (vendor_and_product->product != device.product_id)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (FilterMatch(filter, device))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (filter->usage) {
|
||||
if (filter->usage->is_page()) {
|
||||
const uint16_t usage_page = filter->usage->get_page();
|
||||
auto find_it =
|
||||
std::find_if(device.collections.begin(), device.collections.end(),
|
||||
[=](const device::mojom::HidCollectionInfoPtr& c) {
|
||||
return usage_page == c->usage->usage_page;
|
||||
});
|
||||
if (find_it == device.collections.end())
|
||||
continue;
|
||||
} else if (filter->usage->is_usage_and_page()) {
|
||||
const auto& usage_and_page = filter->usage->get_usage_and_page();
|
||||
auto find_it = std::find_if(
|
||||
device.collections.begin(), device.collections.end(),
|
||||
[&usage_and_page](const device::mojom::HidCollectionInfoPtr& c) {
|
||||
return usage_and_page->usage_page == c->usage->usage_page &&
|
||||
usage_and_page->usage == c->usage->usage;
|
||||
});
|
||||
if (find_it == device.collections.end())
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
bool HidChooserController::IsExcluded(
|
||||
const device::mojom::HidDeviceInfo& device) const {
|
||||
for (const auto& exclusion_filter : exclusion_filters_) {
|
||||
if (FilterMatch(exclusion_filter, device))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue