// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_USB_DELEGATE_OBSERVER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_USB_DELEGATE_OBSERVER_H_ #include "base/memory/weak_ptr.h" #include "base/scoped_observation_traits.h" #include "content/browser/service_worker/service_worker_device_delegate_observer.h" #include "content/browser/usb/web_usb_service_impl.h" #include "content/public/browser/usb_delegate.h" namespace content { class ServiceWorkerContextCore; // ServiceWorkerUsbDelegateObserver acts as a broker between the // content::WebUsbService and content::UsbDelegate when the WebUsbService is // created for a service worker. Each ServiceWorkerContextCore has one // ServiceWorkerUsbDelegateObserver, which is used to track all of the // ServiceWorkerRegistration objects whose script uses the WebUSB API. // Furthermore, when a device event happens, the // ServiceWorkerUsbDelegateObserver's UsbDelegate::Observer methods will be // invoked and deliver the device events to the service worker that has a device // event handler registered. // For more information, please see go/usb-hid-extension-access. class CONTENT_EXPORT ServiceWorkerUsbDelegateObserver : public ServiceWorkerDeviceDelegateObserver, public UsbDelegate::Observer { … }; } // namespace content namespace base { template <> struct ScopedObservationTraits<content::UsbDelegate, content::ServiceWorkerUsbDelegateObserver> { … }; } // namespace base #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_USB_DELEGATE_OBSERVER_H_