electron/shell/common/gin_converters/hid_device_info_converter.h
Milan Burda 6dc46e5bcf
refactor: replace deprecated base::Value::Set<Type>Key usage (#37570)
Co-authored-by: Milan Burda <miburda@microsoft.com>
2023-03-15 09:07:51 -04:00

31 lines
1 KiB
C++

// 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.GetDict().Set(
"deviceId",
electron::HidChooserController::PhysicalDeviceIdFromDeviceInfo(
*device));
return gin::ConvertToV8(isolate, value);
}
};
} // namespace gin
#endif // ELECTRON_SHELL_COMMON_GIN_CONVERTERS_HID_DEVICE_INFO_CONVERTER_H_