feat: add USB protected classes handler (#38263)
* feat: add USB protected classes handler * chore: apply review suggestions Co-authored-by: Charles Kerr <charles@charleskerr.com> * chore: update docs * chore: apply review suggestions * update doc per suggestion --------- Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
71fb19ea14
commit
b4ec363b3d
9 changed files with 176 additions and 31 deletions
|
@ -35,6 +35,8 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
|||
ElectronPermissionManager& operator=(const ElectronPermissionManager&) =
|
||||
delete;
|
||||
|
||||
using USBProtectedClasses = std::vector<uint8_t>;
|
||||
|
||||
using StatusCallback =
|
||||
base::OnceCallback<void(blink::mojom::PermissionStatus)>;
|
||||
using StatusesCallback = base::OnceCallback<void(
|
||||
|
@ -52,6 +54,10 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
|||
|
||||
using DeviceCheckHandler =
|
||||
base::RepeatingCallback<bool(const v8::Local<v8::Object>&)>;
|
||||
|
||||
using ProtectedUSBHandler = base::RepeatingCallback<USBProtectedClasses(
|
||||
const v8::Local<v8::Object>&)>;
|
||||
|
||||
using BluetoothPairingHandler =
|
||||
base::RepeatingCallback<void(gin_helper::Dictionary, PairCallback)>;
|
||||
|
||||
|
@ -59,6 +65,7 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
|||
void SetPermissionRequestHandler(const RequestHandler& handler);
|
||||
void SetPermissionCheckHandler(const CheckHandler& handler);
|
||||
void SetDevicePermissionHandler(const DeviceCheckHandler& handler);
|
||||
void SetProtectedUSBHandler(const ProtectedUSBHandler& handler);
|
||||
void SetBluetoothPairingHandler(const BluetoothPairingHandler& handler);
|
||||
|
||||
// content::PermissionControllerDelegate:
|
||||
|
@ -109,6 +116,9 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
|||
const base::Value& object,
|
||||
ElectronBrowserContext* browser_context) const;
|
||||
|
||||
USBProtectedClasses CheckProtectedUSBClasses(
|
||||
const USBProtectedClasses& classes) const;
|
||||
|
||||
protected:
|
||||
void OnPermissionResponse(int request_id,
|
||||
int permission_id,
|
||||
|
@ -159,6 +169,7 @@ class ElectronPermissionManager : public content::PermissionControllerDelegate {
|
|||
RequestHandler request_handler_;
|
||||
CheckHandler check_handler_;
|
||||
DeviceCheckHandler device_permission_handler_;
|
||||
ProtectedUSBHandler protected_usb_handler_;
|
||||
BluetoothPairingHandler bluetooth_pairing_handler_;
|
||||
|
||||
PendingRequestsMap pending_requests_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue