Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
serialPort.forget()
(#36062)
feat: enable serialPort.revoke() Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
- Loading branch information
1 parent
0525247
commit abf7a48
Showing
8 changed files
with
246 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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_SERIAL_PORT_INFO_CONVERTER_H_ | ||
#define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_SERIAL_PORT_INFO_CONVERTER_H_ | ||
|
||
#include "gin/converter.h" | ||
#include "shell/common/gin_helper/dictionary.h" | ||
#include "third_party/blink/public/mojom/serial/serial.mojom.h" | ||
|
||
namespace gin { | ||
|
||
template <> | ||
struct Converter<device::mojom::SerialPortInfoPtr> { | ||
static v8::Local<v8::Value> ToV8( | ||
v8::Isolate* isolate, | ||
const device::mojom::SerialPortInfoPtr& port) { | ||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); | ||
dict.Set("portId", port->token.ToString()); | ||
dict.Set("portName", port->path.BaseName().LossyDisplayName()); | ||
if (port->display_name && !port->display_name->empty()) | ||
dict.Set("displayName", *port->display_name); | ||
if (port->has_vendor_id) | ||
dict.Set("vendorId", base::StringPrintf("%u", port->vendor_id)); | ||
if (port->has_product_id) | ||
dict.Set("productId", base::StringPrintf("%u", port->product_id)); | ||
if (port->serial_number && !port->serial_number->empty()) | ||
dict.Set("serialNumber", *port->serial_number); | ||
#if BUILDFLAG(IS_MAC) | ||
if (port->usb_driver_name && !port->usb_driver_name->empty()) | ||
dict.Set("usbDriverName", *port->usb_driver_name); | ||
#elif BUILDFLAG(IS_WIN) | ||
if (!port->device_instance_id.empty()) | ||
dict.Set("deviceInstanceId", port->device_instance_id); | ||
#endif | ||
return gin::ConvertToV8(isolate, dict); | ||
} | ||
}; | ||
|
||
} // namespace gin | ||
|
||
#endif // ELECTRON_SHELL_COMMON_GIN_CONVERTERS_SERIAL_PORT_INFO_CONVERTER_H_ |
Oops, something went wrong.