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

Unified Diff: chrome/browser/ui/cocoa/browser_window_touch_bar.mm

Issue 2742633002: [Mac] UMA Metrics for the Default Touch Bar (Closed)
Patch Set: Fix for isherman Created 3 years, 9 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 | « no previous file | 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/ui/cocoa/browser_window_touch_bar.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_touch_bar.mm b/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
index 274ff4cb49db3577037cbb36c933f521362718c7..06d7c2e1920af6da135bea057429c570fb11d07a 100644
--- a/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
+++ b/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
@@ -9,6 +9,7 @@
#include "base/mac/mac_util.h"
#import "base/mac/scoped_nsobject.h"
#import "base/mac/sdk_forward_declarations.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/vector_icons/vector_icons.h"
@@ -35,6 +36,20 @@
namespace {
+// The touch bar actions that are being recorded in a histogram. These values
+// should not be re-ordered or removed.
+enum TouchBarAction {
+ BACK = 0,
+ FORWARD,
+ STOP,
+ RELOAD,
+ HOME,
+ SEARCH,
+ STAR,
+ NEW_TAB,
+ TOUCH_BAR_ACTION_COUNT
+};
+
// The touch bar's identifier.
const NSTouchBarCustomizationIdentifier kBrowserWindowTouchBarId =
@"BrowserWindowTouchBarId";
@@ -83,6 +98,37 @@ NSButton* CreateTouchBarButton(const gfx::VectorIcon& icon,
return button;
}
+TouchBarAction TouchBarActionFromCommand(int command) {
+ switch (command) {
+ case IDC_BACK:
+ return TouchBarAction::BACK;
+ case IDC_FORWARD:
+ return TouchBarAction::FORWARD;
+ case IDC_STOP:
+ return TouchBarAction::STOP;
+ case IDC_RELOAD:
+ return TouchBarAction::RELOAD;
+ case IDC_HOME:
+ return TouchBarAction::HOME;
+ case IDC_FOCUS_LOCATION:
+ return TouchBarAction::SEARCH;
+ case IDC_BOOKMARK_PAGE:
+ return TouchBarAction::STAR;
+ case IDC_NEW_TAB:
+ return TouchBarAction::NEW_TAB;
+ default:
+ NOTREACHED();
+ return TouchBarAction::TOUCH_BAR_ACTION_COUNT;
+ }
+}
+
+// Logs the sample's UMA metrics into the DefaultTouchBar.Metrics histogram.
+void LogTouchBarUMA(int command) {
+ UMA_HISTOGRAM_ENUMERATION("TouchBar.Default.Metrics",
+ TouchBarActionFromCommand(command),
+ TOUCH_BAR_ACTION_COUNT);
+}
+
// A class registered for C++ notifications. This is used to detect changes in
// the home button preferences and update the Touch Bar.
class HomePrefNotificationBridge {
@@ -268,14 +314,16 @@ class HomePrefNotificationBridge {
- (void)backOrForward:(id)sender {
NSSegmentedControl* control = sender;
- if ([control selectedSegment] == kBackSegmentIndex)
- commandUpdater_->ExecuteCommand(IDC_BACK);
- else
- commandUpdater_->ExecuteCommand(IDC_FORWARD);
+ int command =
+ [control selectedSegment] == kBackSegmentIndex ? IDC_BACK : IDC_FORWARD;
+ LogTouchBarUMA(command);
+ commandUpdater_->ExecuteCommand(command);
}
- (void)executeCommand:(id)sender {
- commandUpdater_->ExecuteCommand([sender tag]);
+ int command = [sender tag];
+ LogTouchBarUMA(command);
+ commandUpdater_->ExecuteCommand(command);
}
@end
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698