#include "content/browser/service_worker/service_worker_usb_delegate_observer.h"
#include <cstdint>
#include "base/functional/bind.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/browser/usb/web_usb_service_impl.h"
#include "content/public/common/content_client.h"
#include "services/device/public/mojom/usb_device.mojom.h"
#include "third_party/blink/public/common/service_worker/embedded_worker_status.h"
namespace content {
namespace {
bool HasDevicePermission(UsbDelegate* delegate,
BrowserContext* browser_context,
const blink::StorageKey& key,
const device::mojom::UsbDeviceInfo& device_info) { … }
}
ServiceWorkerUsbDelegateObserver::ServiceWorkerUsbDelegateObserver(
ServiceWorkerContextCore* context)
: … { … }
ServiceWorkerUsbDelegateObserver::~ServiceWorkerUsbDelegateObserver() = default;
void ServiceWorkerUsbDelegateObserver::OnDeviceAdded(
const device::mojom::UsbDeviceInfo& device_info) { … }
void ServiceWorkerUsbDelegateObserver::OnDeviceRemoved(
const device::mojom::UsbDeviceInfo& device_info) { … }
void ServiceWorkerUsbDelegateObserver::OnDeviceManagerConnectionError() { … }
void ServiceWorkerUsbDelegateObserver::OnPermissionRevoked(
const url::Origin& origin) { … }
void ServiceWorkerUsbDelegateObserver::RegisterUsbService(
int64_t registration_id,
base::WeakPtr<WebUsbServiceImpl> usb_service) { … }
void ServiceWorkerUsbDelegateObserver::RegistrationAdded(
int64_t registration_id) { … }
void ServiceWorkerUsbDelegateObserver::RegistrationRemoved(
int64_t registration_id) { … }
void ServiceWorkerUsbDelegateObserver::DispatchUsbDeviceEventToWorkers(
const device::mojom::UsbDeviceInfo& device_info,
UsbServiceDeviceEventCallback callback) { … }
void ServiceWorkerUsbDelegateObserver::WorkerStarted(
device::mojom::UsbDeviceInfoPtr device_info,
UsbServiceDeviceEventCallback callback,
scoped_refptr<ServiceWorkerVersion> version,
blink::ServiceWorkerStatusCode service_worker_status) { … }
WebUsbServiceImpl* ServiceWorkerUsbDelegateObserver::GetUsbService(
int64_t registration_id) { … }
}