Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for WebUSB #36289

Merged
merged 7 commits into from
Nov 22, 2022
Merged

feat: add support for WebUSB #36289

merged 7 commits into from
Nov 22, 2022

Conversation

jkleinsc
Copy link
Contributor

@jkleinsc jkleinsc commented Nov 9, 2022

Description of Change

This PR enables use of the WebUSB API in Electron by exposing several new events on Session:

  • select-usb-device - fired when navigator.usb.requestDevice is called so that an Electron developer can programmatically select a USB device.
  • usb-device-added - emitted after navigator.usb.requestDevice has been called and select-usb-device has fired if a new device becomes available before the callback from select-usb-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated with the newly added device.
  • usb-device-removed - emitted after navigator.usb.requestDevice has been called and select-usb-device has fired if a device has been removed before the callback from select-usb-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated to remove the specified device.
  • usb-device-revoked- emitted after USBDevice.forget() has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler is used.

Additionally, setDevicePermissionHandler(handler) on Session has been updated to allow developers to provide default permissioning to devices without calling navigator.usb.requestDevice first.

Checklist

Release Notes

Notes: Added support for WebUSB

@jkleinsc jkleinsc added semver/minor backwards-compatible functionality no-backport labels Nov 9, 2022
@electron-cation electron-cation bot added new-pr 🌱 PR opened in the last 24 hours api-review/requested 🗳 labels Nov 9, 2022
Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM :)

Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the API review. Code review is next.

docs/api/session.md Outdated Show resolved Hide resolved
docs/api/structures/usb-device.md Outdated Show resolved Hide resolved
docs/fiddles/features/web-usb/renderer.js Outdated Show resolved Hide resolved
docs/tutorial/devices.md Show resolved Hide resolved
docs/api/structures/usb-device.md Outdated Show resolved Hide resolved
docs/api/session.md Outdated Show resolved Hide resolved
docs/api/session.md Outdated Show resolved Hide resolved
docs/api/structures/usb-device.md Show resolved Hide resolved
docs/tutorial/devices.md Show resolved Hide resolved
docs/tutorial/devices.md Outdated Show resolved Hide resolved
@jkleinsc jkleinsc requested a review from ckerr November 14, 2022 17:34
@jkleinsc jkleinsc added semver/minor backwards-compatible functionality and removed semver/minor backwards-compatible functionality labels Nov 14, 2022
Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@jkleinsc jkleinsc removed the new-pr 🌱 PR opened in the last 24 hours label Nov 15, 2022
@electron-cation electron-cation bot added new-pr 🌱 PR opened in the last 24 hours api-review/approved ✅ and removed new-pr 🌱 PR opened in the last 24 hours api-review/requested 🗳 labels Nov 15, 2022
Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

shell/browser/usb/usb_chooser_context.cc Outdated Show resolved Hide resolved
shell/browser/usb/usb_chooser_context.cc Outdated Show resolved Hide resolved
@jkleinsc jkleinsc merged commit 629c54b into main Nov 22, 2022
@jkleinsc jkleinsc deleted the implement-web-usb branch November 22, 2022 21:50
@release-clerk
Copy link

release-clerk bot commented Nov 22, 2022

Release Notes Persisted

Added support for WebUSB

@ghost
Copy link

ghost commented Dec 8, 2022

API LGTM

@7ombie
Copy link

7ombie commented Dec 15, 2022

The device list is always empty. See #36615.

khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
* feat: add support for WebUSB

* fixup for gn check

* fixup gn check on Windows

* Apply review feedback

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: address review feedback

* chore: removed unneeded code

* Migrate non-default ScopedObservation<> instantiations to ScopedObservationTraits<> in chrome/browser/

https://chromium-review.googlesource.com/c/chromium/src/+/4016595

Co-authored-by: Charles Kerr <charles@charleskerr.com>
@jkleinsc jkleinsc mentioned this pull request Feb 28, 2023
4 tasks
@penx penx mentioned this pull request May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Device chooser for WebUSB
5 participants