#include "chrome/browser/usb/usb_chooser_controller.h"
#include <stddef.h>
#include <utility>
#include "base/functional/bind.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/chooser_controller/title_util.h"
#include "chrome/browser/net/referrer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/usb/usb_blocklist.h"
#include "chrome/browser/usb/usb_chooser_context_factory.h"
#include "chrome/browser/usb/web_usb_histograms.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/isolated_context_util.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "services/device/public/cpp/usb/usb_utils.h"
#include "services/device/public/mojom/usb_enumeration_options.mojom.h"
#include "third_party/blink/public/common/features_generated.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#if !BUILDFLAG(IS_ANDROID)
#include "services/device/public/cpp/usb/usb_ids.h"
#endif
RenderFrameHost;
WebContents;
namespace {
std::u16string FormatUsbDeviceName(
const device::mojom::UsbDeviceInfo& device_info) { … }
void OnDeviceInfoRefreshed(
base::WeakPtr<UsbChooserContext> chooser_context,
const url::Origin& origin,
blink::mojom::WebUsbService::GetPermissionCallback callback,
device::mojom::UsbDeviceInfoPtr device_info) { … }
}
UsbChooserController::UsbChooserController(
RenderFrameHost* render_frame_host,
blink::mojom::WebUsbRequestDeviceOptionsPtr options,
blink::mojom::WebUsbService::GetPermissionCallback callback)
: … { … }
UsbChooserController::~UsbChooserController() { … }
std::u16string UsbChooserController::GetNoOptionsText() const { … }
std::u16string UsbChooserController::GetOkButtonLabel() const { … }
std::pair<std::u16string, std::u16string>
UsbChooserController::GetThrobberLabelAndTooltip() const { … }
size_t UsbChooserController::NumOptions() const { … }
std::u16string UsbChooserController::GetOption(size_t index) const { … }
bool UsbChooserController::IsPaired(size_t index) const { … }
void UsbChooserController::Select(const std::vector<size_t>& indices) { … }
void UsbChooserController::Cancel() { … }
void UsbChooserController::Close() { … }
void UsbChooserController::OpenHelpCenterUrl() const { … }
void UsbChooserController::OnDeviceAdded(
const device::mojom::UsbDeviceInfo& device_info) { … }
void UsbChooserController::OnDeviceRemoved(
const device::mojom::UsbDeviceInfo& device_info) { … }
void UsbChooserController::OnBrowserContextShutdown() { … }
void UsbChooserController::GotUsbDeviceList(
std::vector<::device::mojom::UsbDeviceInfoPtr> devices) { … }
bool UsbChooserController::DisplayDevice(
const device::mojom::UsbDeviceInfo& device_info) const { … }