| Index: chrome/browser/chrome_webusb_browser_client.cc
|
| diff --git a/chrome/browser/chrome_webusb_browser_client.cc b/chrome/browser/chrome_webusb_browser_client.cc
|
| index 24a63f29f81320b87f1cac3260878c09647449f0..79c4bf2770bb3f80b2ff5ebadcb8763470075106 100644
|
| --- a/chrome/browser/chrome_webusb_browser_client.cc
|
| +++ b/chrome/browser/chrome_webusb_browser_client.cc
|
| @@ -7,6 +7,7 @@
|
| #include <utility>
|
|
|
| #include "base/macros.h"
|
| +#include "base/metrics/histogram_macros.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/net/referrer.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| @@ -30,6 +31,18 @@ namespace {
|
|
|
| const char kWebUsbDetectorNotificationID[] = "webusb.detector";
|
|
|
| +enum WebUsbNotificationClosed {
|
| + // The notification was dismissed but not by the user (either automatically
|
| + // or because the device was unplugged).
|
| + WEBUSB_NOTIFICATION_CLOSED,
|
| + // The user closed the notification.
|
| + WEBUSB_NOTIFICATION_CLOSED_BY_USER,
|
| + // The user clicked on the notification.
|
| + WEBUSB_NOTIFICATION_CLOSED_CLICKED,
|
| + // Maximum value for the enum.
|
| + WEBUSB_NOTIFICATION_CLOSED_MAX
|
| +};
|
| +
|
| Browser* GetBrowser() {
|
| chrome::ScopedTabbedBrowserDisplayer browser_displayer(
|
| ProfileManager::GetActiveUserProfile(), chrome::GetActiveDesktop());
|
| @@ -51,16 +64,31 @@ class WebUsbNotificationDelegate : public message_center::NotificationDelegate {
|
| : landing_page_(landing_page), notification_id_(notification_id) {}
|
|
|
| void Click() override {
|
| + clicked_ = true;
|
| OpenURL(landing_page_);
|
| message_center::MessageCenter::Get()->RemoveNotification(
|
| notification_id_, false /* by_user */);
|
| }
|
|
|
| + void Close(bool by_user) override {
|
| + WebUsbNotificationClosed result;
|
| + if (clicked_) {
|
| + result = WEBUSB_NOTIFICATION_CLOSED_CLICKED;
|
| + } else if (by_user) {
|
| + result = WEBUSB_NOTIFICATION_CLOSED_BY_USER;
|
| + } else {
|
| + result = WEBUSB_NOTIFICATION_CLOSED;
|
| + }
|
| + UMA_HISTOGRAM_ENUMERATION("WebUsb.NotificationClosed", result,
|
| + WEBUSB_NOTIFICATION_CLOSED_MAX);
|
| + }
|
| +
|
| private:
|
| ~WebUsbNotificationDelegate() override = default;
|
|
|
| GURL landing_page_;
|
| std::string notification_id_;
|
| + bool clicked_ = false;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(WebUsbNotificationDelegate);
|
| };
|
|
|