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

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

Issue 2742633002: [Mac] UMA Metrics for the Default Touch Bar (Closed)
Patch Set: nit 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 d812ab1ad0045f6dadfe83c946904de5f2abd9b3..a723eb8a6cfca830af816d48bab9f1951299b1f9 100644
--- a/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
+++ b/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
@@ -7,6 +7,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"
@@ -30,6 +31,19 @@
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,
+ SEARCH,
+ STAR,
+ NEW_TAB,
+ TOUCH_BAR_ACTION_COUNT
+};
+
// The touch bar's identifier.
const NSTouchBarCustomizationIdentifier kBrowserWindowTouchBarId =
@"BrowserWindowTouchBarId";
@@ -76,6 +90,31 @@ NSButton* CreateTouchBarButton(const gfx::VectorIcon& icon,
return button;
}
+// Logs the sample's UMA metrics into the DefaultTouchBar.Metrics histogram.
+void LogTouchBarUMA(int command) {
+ TouchBarAction action;
+ if (command == IDC_BACK)
+ action = TouchBarAction::BACK;
+ else if (command == IDC_FORWARD)
+ action = TouchBarAction::FORWARD;
+ else if (command == IDC_STOP)
+ action = TouchBarAction::STOP;
+ else if (command == IDC_RELOAD)
+ action = TouchBarAction::RELOAD;
+ else if (command == IDC_FOCUS_LOCATION)
+ action = TouchBarAction::SEARCH;
+ else if (command == IDC_BOOKMARK_PAGE)
+ action = TouchBarAction::STAR;
+ else if (command == IDC_NEW_TAB)
+ action = TouchBarAction::NEW_TAB;
+ else
+ action = TouchBarAction::TOUCH_BAR_ACTION_COUNT;
+
+ DCHECK_NE(action, TouchBarAction::TOUCH_BAR_ACTION_COUNT);
+ UMA_HISTOGRAM_ENUMERATION("DefaultTouchBar.Metrics", action,
Robert Sesek 2017/03/09 18:11:55 Since we may have multiple touch bars, how about s
Ilya Sherman 2017/03/09 20:13:44 +1 -- let's choose a fairly general top-level cate
spqchan 2017/03/13 20:58:05 Sure thing
+ TOUCH_BAR_ACTION_COUNT);
+}
+
} // namespace
@interface BrowserWindowTouchBar () {
@@ -215,14 +254,19 @@ NSButton* CreateTouchBarButton(const gfx::VectorIcon& icon,
- (void)backOrForward:(id)sender {
NSSegmentedControl* control = sender;
- if ([control selectedSegment] == kBackSegmentIndex)
+ if ([control selectedSegment] == kBackSegmentIndex) {
commandUpdater_->ExecuteCommand(IDC_BACK);
- else
+ LogTouchBarUMA(IDC_BACK);
+ } else {
commandUpdater_->ExecuteCommand(IDC_FORWARD);
+ LogTouchBarUMA(IDC_FORWARD);
+ }
}
- (void)executeCommand:(id)sender {
- commandUpdater_->ExecuteCommand([sender tag]);
+ int command = [sender tag];
+ LogTouchBarUMA(command);
Robert Sesek 2017/03/09 18:11:55 In -backOrForward, the UMA is logged before the Ex
spqchan 2017/03/13 20:58:05 Done.
+ 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