File: README.md

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (25 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
chrome/browser/ash/usb
======================

This directory contains the CrosUsbDetector, whose job it is to deal with devices that are plugged
into a chromeOS device - notifications of which come from the UsbDeviceManager Mojo service.

Once a new device has been detected, CrosUsbDetector will first query permission_broker to see if
the device is allowed - either via device policy or via the rules which can allow or deny devices
based on various characteristics. CrosUsbDetector furthermore makes a decision if a user-facing
notification (of the form 'Share with Android/Linux') should be shown, or if the device will be made
silently available via the settings pages.

If a user elects to share a device (in this case via the notification, as the settings flow is
handled elsewhere), the flow is roughly: AttachUsbDeviceToGuest() -> UnmountFilesystems() ->
OnUnmountFilesystems() -> AttachAfterDetach() -> OnAttachUsbDeviceOpened() -> DoVmAttach() ->
OnUsbDeviceAttachFinished(). A more thorough depiction of the flow can be seen below:

![Usb device share flow](cros_usb_detector_callgraph.png)

Things to note:
- permission_broker is actually asked twice if it is ok with a device being shared, once upon new
  device detection and then once more upon the request to share it / pass it through.
- CrosUsbDetector also keeps a list of USB classes which it does not wish to be passed through, and
  these are used to create an interface mask that permission_broker uses to drop those interfaces when
  passing the device through.