Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4930)

Unified Diff: chrome/browser/chrome_webusb_browser_client.cc

Issue 1584283003: Add UMA histograms for WebUSB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
};
« no previous file with comments | « no previous file | chrome/browser/usb/usb_chooser_bubble_delegate.cc » ('j') | chrome/browser/usb/usb_chooser_bubble_delegate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698