chromium/extensions/browser/api/hid/hid_device_manager.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/api/hid/hid_device_manager.h"

#include <stdint.h>

#include <functional>
#include <iterator>
#include <limits>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/device_service.h"
#include "extensions/browser/api/device_permissions_manager.h"
#include "extensions/common/mojom/context_type.mojom.h"
#include "extensions/common/mojom/event_dispatcher.mojom-forward.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/permissions/usb_device_permission.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/device/public/cpp/hid/hid_device_filter.h"
#include "services/device/public/cpp/hid/hid_report_type.h"
#include "services/device/public/cpp/hid/hid_report_utils.h"
#include "services/device/public/mojom/hid.mojom.h"

hid;

namespace extensions {

namespace {

HidDeviceFilter;
HidReportType;
IsAlwaysProtected;

// Return true if all reports in `device` with `report_id` are protected.
// Protected report IDs are not exposed in the API.
bool IsReportIdProtected(const device::mojom::HidDeviceInfo& device,
                         uint8_t report_id) {}

void PopulateHidDeviceInfo(hid::HidDeviceInfo* output,
                           const device::mojom::HidDeviceInfo& input) {}

bool WillDispatchDeviceEvent(
    base::WeakPtr<HidDeviceManager> device_manager,
    const device::mojom::HidDeviceInfo& device_info,
    content::BrowserContext* browser_context,
    mojom::ContextType target_context,
    const Extension* extension,
    const base::Value::Dict* listener_filter,
    std::optional<base::Value::List>& event_args_out,
    mojom::EventFilteringInfoPtr& event_filtering_info_out) {}

HidDeviceManager::HidManagerBinder& GetHidManagerBinderOverride() {}

}  // namespace

struct HidDeviceManager::GetApiDevicesParams {};

HidDeviceManager::HidDeviceManager(content::BrowserContext* context)
    :{}

HidDeviceManager::~HidDeviceManager() {}

// static
BrowserContextKeyedAPIFactory<HidDeviceManager>*
HidDeviceManager::GetFactoryInstance() {}

void HidDeviceManager::GetApiDevices(
    const Extension* extension,
    const std::vector<HidDeviceFilter>& filters,
    GetApiDevicesCallback callback) {}

const device::mojom::HidDeviceInfo* HidDeviceManager::GetDeviceInfo(
    int resource_id) {}

void HidDeviceManager::Connect(const std::string& device_guid,
                               ConnectCallback callback) {}

bool HidDeviceManager::HasPermission(
    const Extension* extension,
    const device::mojom::HidDeviceInfo& device_info,
    bool update_last_used) {}

void HidDeviceManager::Shutdown() {}

void HidDeviceManager::OnListenerAdded(const EventListenerInfo& details) {}
void HidDeviceManager::DeviceAdded(device::mojom::HidDeviceInfoPtr device) {}

void HidDeviceManager::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {}

void HidDeviceManager::DeviceChanged(device::mojom::HidDeviceInfoPtr device) {}

void HidDeviceManager::LazyInitialize() {}

// static
void HidDeviceManager::OverrideHidManagerBinderForTesting(
    HidManagerBinder binder) {}

base::Value::List HidDeviceManager::CreateApiDeviceList(
    const Extension* extension,
    const std::vector<HidDeviceFilter>& filters) {}

void HidDeviceManager::OnEnumerationComplete(
    std::vector<device::mojom::HidDeviceInfoPtr> devices) {}

void HidDeviceManager::DispatchEvent(
    events::HistogramValue histogram_value,
    const std::string& event_name,
    base::Value::List event_args,
    const device::mojom::HidDeviceInfo& device_info) {}

}  // namespace extensions