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

Unified Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 700673003: Add metrics to all items in the 'wrench' menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved comments, added histogram suffixes Created 6 years, 1 month 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/ui/toolbar/wrench_menu_model.cc
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index cedb29767146d6c5ce194e2507186d567665edef..917a4e6298b7db4e3b511612937d9f762d9c7b54 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -8,6 +8,7 @@
#include <cmath>
#include "base/command_line.h"
+#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -276,6 +277,7 @@ void ToolsMenuModel::Build(Browser* browser) {
WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider,
Browser* browser)
: ui::SimpleMenuModel(this),
+ uma_action_recorded_(false),
provider_(provider),
browser_(browser),
tab_strip_model_(browser_->tab_strip_model()) {
@@ -404,17 +406,280 @@ void WrenchMenuModel::ExecuteCommand(int command_id, int event_flags) {
}
}
- if (command_id == IDC_HELP_PAGE_VIA_MENU)
- content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu"));
+ LogMenuMetrics(command_id);
+ chrome::ExecuteCommand(browser_, command_id);
+}
+
+void WrenchMenuModel::LogMenuMetrics(int command_id) {
+ base::TimeDelta now = timer_.Elapsed();
Alexei Svitkine (slow) 2014/11/17 18:51:18 Nit: Use a different name - |now| implies it's a t
edwardjung 2014/11/17 19:18:56 Done.
+
+ switch (command_id) {
+ case IDC_NEW_TAB:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_NewTab", now);
+ LogMenuAction(MENU_ACTION_NEW_TAB);
+ break;
+ case IDC_NEW_WINDOW:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_NewWindow", now);
+ LogMenuAction(MENU_ACTION_NEW_WINDOW);
+ break;
+ case IDC_NEW_INCOGNITO_WINDOW:
+ if (!uma_action_recorded_)
Alexei Svitkine (slow) 2014/11/17 18:51:18 Nit: {}'s because body is multiline. Same for othe
edwardjung 2014/11/17 19:18:56 This is actually single line. We still want to rec
Alexei Svitkine (slow) 2014/11/17 19:57:04 The style guide is not about number of statements,
edwardjung 2014/11/17 23:45:26 My bad, still getting used to the C++ style guide.
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_NewIncognitoWindow",
+ now);
+ LogMenuAction(MENU_ACTION_NEW_INCOGNITO_WINDOW);
+ break;
+
+ // Bookmarks sub menu.
+ case IDC_SHOW_BOOKMARK_BAR:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ShowBookmarkBar",
+ now);
+ LogMenuAction(MENU_ACTION_SHOW_BOOKMARK_BAR);
+ break;
+ case IDC_SHOW_BOOKMARK_MANAGER:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ShowBookmarkMgr",
+ now);
+ LogMenuAction(MENU_ACTION_SHOW_BOOKMARK_MANAGER);
+ break;
+ case IDC_IMPORT_SETTINGS:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ImportSettings",
+ now);
+ LogMenuAction(MENU_ACTION_IMPORT_SETTINGS);
+ break;
+ case IDC_BOOKMARK_PAGE:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_BookmarkPage", now);
+ LogMenuAction(MENU_ACTION_BOOKMARK_PAGE);
+ break;
+ case IDC_BOOKMARK_ALL_TABS:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_BookmarkAllTabs",
+ now);
+ LogMenuAction(MENU_ACTION_BOOKMARK_ALL_TABS);
+ break;
+ case IDC_PIN_TO_START_SCREEN:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_PinToStartScreen",
+ now);
+ LogMenuAction(MENU_ACTION_PIN_TO_START_SCREEN);
+ break;
+
+ // Recent tabs menu.
+ case IDC_RESTORE_TAB:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_RestoreTab", now);
+ LogMenuAction(MENU_ACTION_RESTORE_TAB);
+ break;
- if (command_id == IDC_FULLSCREEN) {
- // We issue the UMA command here and not in BrowserCommandController or even
- // FullscreenController since we want to be able to distinguish this event
- // and a menu which is under development.
- content::RecordAction(UserMetricsAction("EnterFullScreenWithWrenchMenu"));
+ // Windows.
+ case IDC_WIN_DESKTOP_RESTART:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_WinDesktopRestart",
+ now);
+ LogMenuAction(MENU_ACTION_WIN_DESKTOP_RESTART);
+ break;
+ case IDC_WIN8_METRO_RESTART:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Win8MetroRestart",
+ now);
+ LogMenuAction(MENU_ACTION_WIN8_METRO_RESTART);
+ break;
+
+ case IDC_WIN_CHROMEOS_RESTART:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ChromeOSRestart",
+ now);
+ LogMenuAction(MENU_ACTION_WIN_CHROMEOS_RESTART);
+ break;
+ case IDC_DISTILL_PAGE:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_DistillPage", now);
+ LogMenuAction(MENU_ACTION_DISTILL_PAGE);
+ break;
+ case IDC_SAVE_PAGE:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_SavePage", now);
+ LogMenuAction(MENU_ACTION_SAVE_PAGE);
+ break;
+ case IDC_FIND:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Find", now);
+ LogMenuAction(MENU_ACTION_FIND);
+ break;
+ case IDC_PRINT:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Print", now);
+ LogMenuAction(MENU_ACTION_PRINT);
+ break;
+
+ // Edit menu.
+ case IDC_CUT:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Cut", now);
+ LogMenuAction(MENU_ACTION_CUT);
+ break;
+ case IDC_COPY:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Copy", now);
+ LogMenuAction(MENU_ACTION_COPY);
+ break;
+ case IDC_PASTE:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Paste", now);
+ LogMenuAction(MENU_ACTION_PASTE);
+ break;
+
+ // Tools menu.
+ case IDC_CREATE_HOSTED_APP:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_CreateHostedApp",
+ now);
+ LogMenuAction(MENU_ACTION_CREATE_HOSTED_APP);
+ break;
+ case IDC_CREATE_SHORTCUTS:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_CreateShortcuts",
+ now);
+ LogMenuAction(MENU_ACTION_CREATE_SHORTCUTS);
+ break;
+ case IDC_MANAGE_EXTENSIONS:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ManageExtensions",
+ now);
+ LogMenuAction(MENU_ACTION_MANAGE_EXTENSIONS);
+ break;
+ case IDC_TASK_MANAGER:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_TaskManager", now);
+ LogMenuAction(MENU_ACTION_TASK_MANAGER);
+ break;
+ case IDC_CLEAR_BROWSING_DATA:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ClearBrowsingData",
+ now);
+ LogMenuAction(MENU_ACTION_CLEAR_BROWSING_DATA);
+ break;
+ case IDC_VIEW_SOURCE:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ViewSource", now);
+ LogMenuAction(MENU_ACTION_VIEW_SOURCE);
+ break;
+ case IDC_DEV_TOOLS:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_DevTools", now);
+ LogMenuAction(MENU_ACTION_DEV_TOOLS);
+ break;
+ case IDC_DEV_TOOLS_CONSOLE:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_DevToolsConsole",
+ now);
+ LogMenuAction(MENU_ACTION_DEV_TOOLS_CONSOLE);
+ break;
+ case IDC_DEV_TOOLS_DEVICES:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_DevToolsDevices",
+ now);
+ LogMenuAction(MENU_ACTION_DEV_TOOLS_DEVICES);
+ break;
+ case IDC_PROFILING_ENABLED:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ProfilingEnabled",
+ now);
+ LogMenuAction(MENU_ACTION_PROFILING_ENABLED);
+ break;
+
+ // Zoom menu
+ case IDC_ZOOM_MINUS:
+ if (!uma_action_recorded_) {
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ZoomMinus", now);
+ LogMenuAction(MENU_ACTION_ZOOM_MINUS);
+ }
+ break;
+ case IDC_ZOOM_PLUS:
+ if (!uma_action_recorded_) {
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ZoomPlus", now);
+ LogMenuAction(MENU_ACTION_ZOOM_PLUS);
+ }
+ break;
+ case IDC_FULLSCREEN:
+ content::RecordAction(UserMetricsAction("EnterFullScreenWithWrenchMenu"));
+
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_EnterFullScreen",
+ now);
+ LogMenuAction(MENU_ACTION_FULLSCREEN);
+ break;
+
+ case IDC_SHOW_HISTORY:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ShowHistory", now);
+ LogMenuAction(MENU_ACTION_SHOW_HISTORY);
+ break;
+ case IDC_SHOW_DOWNLOADS:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ShowDownloads",
+ now);
+ LogMenuAction(MENU_ACTION_SHOW_DOWNLOADS);
+ break;
+ case IDC_SHOW_SYNC_SETUP:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_ShowSyncSetup",
+ now);
+ LogMenuAction(MENU_ACTION_SHOW_SYNC_SETUP);
+ break;
+ case IDC_OPTIONS:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Settings", now);
+ LogMenuAction(MENU_ACTION_OPTIONS);
+ break;
+ case IDC_ABOUT:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_About", now);
+ LogMenuAction(MENU_ACTION_ABOUT);
+ break;
+
+ // Help menu.
+ case IDC_HELP_PAGE_VIA_MENU:
+ content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu"));
+
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_HelpPage", now);
+ LogMenuAction(MENU_ACTION_HELP_PAGE_VIA_MENU);
+ break;
+ #if defined(GOOGLE_CHROME_BUILD)
+ case IDC_FEEDBACK:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Feedback", now);
+ LogMenuAction(MENU_ACTION_FEEDBACK);
+ break;
+ #endif
+
+ case IDC_TOGGLE_REQUEST_TABLET_SITE:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_RequestTabletSite",
+ now);
+ LogMenuAction(MENU_ACTION_TOGGLE_REQUEST_TABLET_SITE);
+ break;
+ case IDC_EXIT:
+ if (!uma_action_recorded_)
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction_Exit", now);
+ LogMenuAction(MENU_ACTION_EXIT);
+ break;
}
- chrome::ExecuteCommand(browser_, command_id);
+ if (!uma_action_recorded_) {
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction", now);
+ uma_action_recorded_ = true;
+ }
+}
+
+void WrenchMenuModel::LogMenuAction(int action_id) {
+ UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", action_id,
+ LIMIT_MENU_ACTION);
Alexei Svitkine (slow) 2014/11/17 18:51:18 Nit: Align.
edwardjung 2014/11/17 19:18:56 Done.
}
bool WrenchMenuModel::IsCommandIdChecked(int command_id) const {
@@ -665,6 +930,7 @@ void WrenchMenuModel::Build() {
}
RemoveTrailingSeparators();
+ uma_action_recorded_ = false;
}
void WrenchMenuModel::AddGlobalErrorMenuItems() {

Powered by Google App Engine
This is Rietveld 408576698