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

Unified Diff: chrome/browser/usb/usb_chooser_context.cc

Issue 1584283003: Add UMA histograms for WebUSB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments. 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
« no previous file with comments | « chrome/browser/usb/usb_chooser_bubble_delegate.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/usb/usb_chooser_context.cc
diff --git a/chrome/browser/usb/usb_chooser_context.cc b/chrome/browser/usb/usb_chooser_context.cc
index 702c98adc162caa1287464026dd3efd3a40b3f37..4aeb569dcf118aed415dbc4a4111ee22fa0631cc 100644
--- a/chrome/browser/usb/usb_chooser_context.cc
+++ b/chrome/browser/usb/usb_chooser_context.cc
@@ -7,6 +7,7 @@
#include <utility>
#include <vector>
+#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -24,6 +25,24 @@ const char kProductIdKey[] = "product-id";
const char kSerialNumberKey[] = "serial-number";
const char kVendorIdKey[] = "vendor-id";
+// Reasons a permission may be closed. These are used in histograms so do not
+// remove/reorder entries. Only add at the end just before
+// WEBUSB_PERMISSION_REVOKED_MAX. Also remember to update the enum listing in
+// tools/metrics/histograms/histograms.xml.
+enum WebUsbPermissionRevoked {
+ // Permission to access a USB device was revoked by the user.
+ WEBUSB_PERMISSION_REVOKED = 0,
+ // Permission to access an ephemeral USB device was revoked by the user.
+ WEBUSB_PERMISSION_REVOKED_EPHEMERAL,
+ // Maximum value for the enum.
+ WEBUSB_PERMISSION_REVOKED_MAX
+};
+
+void RecordPermissionRevocation(WebUsbPermissionRevoked kind) {
+ UMA_HISTOGRAM_ENUMERATION("WebUsb.PermissionRevoked", kind,
+ WEBUSB_PERMISSION_REVOKED_MAX);
+}
+
bool CanStorePersistentEntry(const scoped_refptr<const UsbDevice>& device) {
return !device->serial_number().empty();
}
@@ -116,9 +135,11 @@ void UsbChooserContext::RevokeObjectPermission(
std::string guid;
if (object.GetString(kGuidKey, &guid)) {
RevokeDevicePermission(requesting_origin, embedding_origin, guid);
+ RecordPermissionRevocation(WEBUSB_PERMISSION_REVOKED_EPHEMERAL);
} else {
ChooserContextBase::RevokeObjectPermission(requesting_origin,
embedding_origin, object);
+ RecordPermissionRevocation(WEBUSB_PERMISSION_REVOKED);
}
}
« no previous file with comments | « chrome/browser/usb/usb_chooser_bubble_delegate.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698