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

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

Issue 2742633002: [Mac] UMA Metrics for the Default Touch Bar (Closed)
Patch Set: update for home button 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..9fed0249fc2274511629f9ca476595b52d0d8b71 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,33 @@ 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)
Robert Sesek 2017/03/13 21:05:25 Would this be better as a switch?
spqchan 2017/03/14 00:04:33 Done.
+ 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_HOME)
+ action = TouchBarAction::HOME;
+ 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("TouchBar.Default.Metrics", action,
+ 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 +310,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