feat: add support for HIDDevice.forget() (#34210)
* feat: add support for HIDDevice.forget() * chore: remove whitespace * chore: use `SetGetter` to serialize the render_frame_host Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> * fixup chore: use `SetGetter` to serialize the render_frame_host * fixup after rebase * fixup for crash on navigator.serial.getPorts() * fixup for lint Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
This commit is contained in:
parent
df9383cb3c
commit
ba573f5583
15 changed files with 359 additions and 114 deletions
31
shell/common/gin_converters/hid_device_info_converter.h
Normal file
31
shell/common/gin_converters/hid_device_info_converter.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) 2022 Microsoft, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_HID_DEVICE_INFO_CONVERTER_H_
|
||||
#define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_HID_DEVICE_INFO_CONVERTER_H_
|
||||
|
||||
#include "gin/converter.h"
|
||||
#include "services/device/public/mojom/hid.mojom.h"
|
||||
#include "shell/browser/hid/hid_chooser_context.h"
|
||||
#include "shell/browser/hid/hid_chooser_controller.h"
|
||||
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<device::mojom::HidDeviceInfoPtr> {
|
||||
static v8::Local<v8::Value> ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const device::mojom::HidDeviceInfoPtr& device) {
|
||||
base::Value value = electron::HidChooserContext::DeviceInfoToValue(*device);
|
||||
value.SetStringKey(
|
||||
"deviceId",
|
||||
electron::HidChooserController::PhysicalDeviceIdFromDeviceInfo(
|
||||
*device));
|
||||
return gin::ConvertToV8(isolate, value);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gin
|
||||
|
||||
#endif // ELECTRON_SHELL_COMMON_GIN_CONVERTERS_HID_DEVICE_INFO_CONVERTER_H_
|
Loading…
Add table
Add a link
Reference in a new issue