#include "chrome/browser/usb/web_usb_detector.h"
#include <optional>
#include <string>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/net/referrer.h"
#include "chrome/browser/notifications/system_notification_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_tab_strip_tracker.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/grit/generated_resources.h"
#include "components/url_formatter/elide_url.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/web_contents.h"
#include "services/device/public/mojom/usb_device.mojom.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/message_center/public/cpp/notification.h"
#include "ui/message_center/public/cpp/notification_delegate.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/notifier_catalogs.h"
#include "chrome/browser/ash/crosapi/browser_util.h"
#endif
namespace {
const char kNotifierWebUsb[] = …;
enum WebUsbNotificationClosed { … };
void RecordNotificationClosure(WebUsbNotificationClosed disposition) { … }
GURL GetActiveTabURL() { … }
void OpenURL(const GURL& url) { … }
class WebUsbNotificationDelegate : public TabStripModelObserver,
public message_center::NotificationDelegate { … };
}
WebUsbDetector::WebUsbDetector() = default;
WebUsbDetector::~WebUsbDetector() = default;
void WebUsbDetector::Initialize() { … }
void WebUsbDetector::OnDeviceAdded(
device::mojom::UsbDeviceInfoPtr device_info) { … }
bool WebUsbDetector::IsDisplayingNotification(const GURL& url) { … }
void WebUsbDetector::RemoveNotification(const std::string& id) { … }
void WebUsbDetector::OnDeviceRemoved(
device::mojom::UsbDeviceInfoPtr device_info) { … }
void WebUsbDetector::SetDeviceManagerForTesting(
mojo::PendingRemote<device::mojom::UsbDeviceManager> fake_device_manager) { … }