#include "extensions/browser/api/hid/hid_api.h"
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/values.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/common/api/hid.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "services/device/public/cpp/hid/hid_device_filter.h"
hid;
HidDeviceFilter;
namespace {
const char kErrorPermissionDenied[] = …;
const char kErrorInvalidDeviceId[] = …;
const char kErrorFailedToOpenDevice[] = …;
const char kErrorConnectionNotFound[] = …;
const char kErrorTransfer[] = …;
base::Value::Dict PopulateHidConnection(int connection_id) { … }
void ConvertHidDeviceFilter(const hid::DeviceFilter& input,
HidDeviceFilter* output) { … }
}
namespace extensions {
HidGetDevicesFunction::HidGetDevicesFunction() = default;
HidGetDevicesFunction::~HidGetDevicesFunction() = default;
ExtensionFunction::ResponseAction HidGetDevicesFunction::Run() { … }
void HidGetDevicesFunction::OnEnumerationComplete(base::Value::List devices) { … }
HidConnectFunction::HidConnectFunction() : … { … }
HidConnectFunction::~HidConnectFunction() = default;
ExtensionFunction::ResponseAction HidConnectFunction::Run() { … }
void HidConnectFunction::OnConnectComplete(
mojo::PendingRemote<device::mojom::HidConnection> connection) { … }
HidDisconnectFunction::HidDisconnectFunction() = default;
HidDisconnectFunction::~HidDisconnectFunction() = default;
ExtensionFunction::ResponseAction HidDisconnectFunction::Run() { … }
HidConnectionIoFunction::HidConnectionIoFunction() { … }
HidConnectionIoFunction::~HidConnectionIoFunction() { … }
ExtensionFunction::ResponseAction HidConnectionIoFunction::Run() { … }
HidReceiveFunction::HidReceiveFunction() = default;
HidReceiveFunction::~HidReceiveFunction() = default;
bool HidReceiveFunction::ReadParameters() { … }
void HidReceiveFunction::StartWork(device::mojom::HidConnection* connection) { … }
void HidReceiveFunction::OnFinished(
bool success,
uint8_t report_id,
const std::optional<std::vector<uint8_t>>& buffer) { … }
HidSendFunction::HidSendFunction() = default;
HidSendFunction::~HidSendFunction() = default;
bool HidSendFunction::ReadParameters() { … }
void HidSendFunction::StartWork(device::mojom::HidConnection* connection) { … }
void HidSendFunction::OnFinished(bool success) { … }
HidReceiveFeatureReportFunction::HidReceiveFeatureReportFunction() = default;
HidReceiveFeatureReportFunction::~HidReceiveFeatureReportFunction() = default;
bool HidReceiveFeatureReportFunction::ReadParameters() { … }
void HidReceiveFeatureReportFunction::StartWork(
device::mojom::HidConnection* connection) { … }
void HidReceiveFeatureReportFunction::OnFinished(
bool success,
const std::optional<std::vector<uint8_t>>& buffer) { … }
HidSendFeatureReportFunction::HidSendFeatureReportFunction() = default;
HidSendFeatureReportFunction::~HidSendFeatureReportFunction() = default;
bool HidSendFeatureReportFunction::ReadParameters() { … }
void HidSendFeatureReportFunction::StartWork(
device::mojom::HidConnection* connection) { … }
void HidSendFeatureReportFunction::OnFinished(bool success) { … }
}