diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 18:14:28 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 18:14:28 +0000 |
commit | 89622004872be7f7ddaa24fa1694f76c7b9539b6 (patch) | |
tree | 81b8a42c7649c8cbca99d04305470ccbc1fe61fa | |
parent | b7544eef7b81458a88597419eed6617c41e6d3dc (diff) | |
download | chromium_src-89622004872be7f7ddaa24fa1694f76c7b9539b6.zip chromium_src-89622004872be7f7ddaa24fa1694f76c7b9539b6.tar.gz chromium_src-89622004872be7f7ddaa24fa1694f76c7b9539b6.tar.bz2 |
UMA cleanup. Replacing calls to RecordAction(char*) to use a new structure.
That way it is easier to keep track of those constants in reporting tools.
TEST=Covered with standard ui tests
Patch by Frank Mantek <fmantek@google.com>.
Review URL: http://codereview.chromium.org/811005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42362 0039d316-1c4b-4281-b951-d872f2087c98
53 files changed, 612 insertions, 393 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index d7fa3f7..8985761 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -663,13 +663,15 @@ void RecordLastRunAppBundlePath() { break; } case IDC_IMPORT_SETTINGS: { - UserMetrics::RecordAction("Import_ShowDlg", defaultProfile); + UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), + defaultProfile); [ImportSettingsDialogController showImportSettingsDialogForProfile:defaultProfile]; break; } case IDC_SHOW_BOOKMARK_MANAGER: - UserMetrics::RecordAction("ShowBookmarkManager", defaultProfile); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), + defaultProfile); if (Browser* browser = ActivateBrowser(defaultProfile)) { // Call through browser which takes care of opening a tab or the old // bookmark manager window. @@ -727,7 +729,8 @@ void RecordLastRunAppBundlePath() { defaultProfile, ProfileSyncService::START_FROM_WRENCH); break; case IDC_TASK_MANAGER: - UserMetrics::RecordAction("TaskManager", defaultProfile); + UserMetrics::RecordAction(UserMetricsAction("TaskManager"), + defaultProfile); TaskManagerMac::Show(); break; } diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 95b4b42..f4c2583 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -266,7 +266,7 @@ void AutocompleteEditModel::SendOpenNotification(size_t selected_line, const TemplateURL* const template_url = template_url_model->GetTemplateURLForKeyword(keyword); if (template_url) { - UserMetrics::RecordAction("AcceptedKeyword", profile_); + UserMetrics::RecordAction(UserMetricsAction("AcceptedKeyword"), profile_); template_url_model->IncrementUsageCount(template_url); } @@ -284,7 +284,7 @@ void AutocompleteEditModel::AcceptKeyword() { // since the edit contents have disappeared. It // doesn't really matter, but we clear it to be // consistent. - UserMetrics::RecordAction("AcceptedKeywordHint", profile_); + UserMetrics::RecordAction(UserMetricsAction("AcceptedKeywordHint"), profile_); } void AutocompleteEditModel::ClearKeyword(const std::wstring& visible_text) { diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index aa9fd4c..6ead1fe 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -2325,10 +2325,12 @@ void AutocompleteEditViewWin::StartDragIfNecessary(const CPoint& point) { drag_utils::SetURLAndDragImage(url, title, favicon, &data); data.SetURL(url, title); supported_modes |= DROPEFFECT_LINK; - UserMetrics::RecordAction("Omnibox_DragURL", model_->profile()); + UserMetrics::RecordAction(UserMetricsAction("Omnibox_DragURL"), + model_->profile()); } else { supported_modes |= DROPEFFECT_MOVE; - UserMetrics::RecordAction("Omnibox_DragString", model_->profile()); + UserMetrics::RecordAction(UserMetricsAction("Omnibox_DragString"), + model_->profile()); } data.SetString(GetSelectedText()); diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc index 7e9162a..8b7b46e 100644 --- a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc +++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc @@ -303,16 +303,19 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { WindowOpenDisposition initial_disposition; if (id == IDS_BOOMARK_BAR_OPEN_ALL) { initial_disposition = NEW_FOREGROUND_TAB; - UserMetrics::RecordAction("BookmarkBar_ContextMenu_OpenAll", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_OpenAll"), + profile_); } else if (id == IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW) { initial_disposition = NEW_WINDOW; - UserMetrics::RecordAction("BookmarkBar_ContextMenu_OpenAllInNewWindow", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_OpenAllInNewWindow"), + profile_); } else { initial_disposition = OFF_THE_RECORD; - UserMetrics::RecordAction("BookmarkBar_ContextMenu_OpenAllIncognito", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_OpenAllIncognito"), + profile_); } bookmark_utils::OpenAll(parent_window_, profile_, navigator_, selection_, initial_disposition); @@ -321,7 +324,9 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { case IDS_BOOKMARK_BAR_RENAME_FOLDER: case IDS_BOOKMARK_BAR_EDIT: - UserMetrics::RecordAction("BookmarkBar_ContextMenu_Edit", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_Edit"), + profile_); if (selection_.size() != 1) { NOTREACHED(); @@ -344,7 +349,9 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { break; case IDS_BOOKMARK_BAR_REMOVE: { - UserMetrics::RecordAction("BookmarkBar_ContextMenu_Remove", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_Remove"), + profile_); for (size_t i = 0; i < selection_.size(); ++i) { model_->Remove(selection_[i]->GetParent(), @@ -355,7 +362,9 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { } case IDS_BOOMARK_BAR_ADD_NEW_BOOKMARK: { - UserMetrics::RecordAction("BookmarkBar_ContextMenu_Add", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_Add"), + profile_); BookmarkEditor::Configuration editor_config; BookmarkEditor::Handler* handler = NULL; @@ -373,8 +382,9 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { } case IDS_BOOMARK_BAR_NEW_FOLDER: { - UserMetrics::RecordAction("BookmarkBar_ContextMenu_NewFolder", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_NewFolder"), + profile_); EditFolderController::Show(profile_, parent_window_, GetParentForNewNodes(), true, configuration_ != BOOKMARK_BAR); @@ -386,8 +396,9 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { break; case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: - UserMetrics::RecordAction("BookmarkBar_ContextMenu_ShowInFolder", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_ShowInFolder"), + profile_); if (selection_.size() != 1) { NOTREACHED(); @@ -398,7 +409,8 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { break; case IDS_BOOKMARK_MANAGER: - UserMetrics::RecordAction("ShowBookmarkManager", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), + profile_); { Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); if (browser) @@ -409,7 +421,8 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { break; case IDS_BOOKMARK_MANAGER_SORT: - UserMetrics::RecordAction("BookmarkManager_Sort", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Sort"), + profile_); model_->SortChildren(parent_); break; diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index d384107..3b77d38 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -911,7 +911,7 @@ NavigationController& Browser::GetOrCloneNavigationControllerForDisposition( } void Browser::GoBack(WindowOpenDisposition disposition) { - UserMetrics::RecordAction("Back", profile_); + UserMetrics::RecordAction(UserMetricsAction("Back"), profile_); TabContents* current_tab = GetSelectedTabContents(); if (current_tab->controller().CanGoBack()) { @@ -926,7 +926,7 @@ void Browser::GoBack(WindowOpenDisposition disposition) { } void Browser::GoForward(WindowOpenDisposition disposition) { - UserMetrics::RecordAction("Forward", profile_); + UserMetrics::RecordAction(UserMetricsAction("Forward"), profile_); if (GetSelectedTabContents()->controller().CanGoForward()) { NavigationController& controller = GetOrCloneNavigationControllerForDisposition(disposition); @@ -935,12 +935,12 @@ void Browser::GoForward(WindowOpenDisposition disposition) { } void Browser::Reload() { - UserMetrics::RecordAction("Reload", profile_); + UserMetrics::RecordAction(UserMetricsAction("Reload"), profile_); ReloadInternal(false); } void Browser::ReloadIgnoringCache() { - UserMetrics::RecordAction("ReloadIgnoringCache", profile_); + UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache"), profile_); ReloadInternal(true); } @@ -966,12 +966,12 @@ void Browser::ReloadInternal(bool ignore_cache) { } void Browser::Home(WindowOpenDisposition disposition) { - UserMetrics::RecordAction("Home", profile_); + UserMetrics::RecordAction(UserMetricsAction("Home"), profile_); OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); } void Browser::OpenCurrentURL() { - UserMetrics::RecordAction("LoadURL", profile_); + UserMetrics::RecordAction(UserMetricsAction("LoadURL"), profile_); LocationBar* location_bar = window_->GetLocationBar(); WindowOpenDisposition open_disposition = location_bar->GetWindowOpenDisposition(); @@ -993,22 +993,22 @@ void Browser::OpenCurrentURL() { } void Browser::Go(WindowOpenDisposition disposition) { - UserMetrics::RecordAction("Go", profile_); + UserMetrics::RecordAction(UserMetricsAction("Go"), profile_); window_->GetLocationBar()->AcceptInputWithDisposition(disposition); } void Browser::Stop() { - UserMetrics::RecordAction("Stop", profile_); + UserMetrics::RecordAction(UserMetricsAction("Stop"), profile_); GetSelectedTabContents()->Stop(); } void Browser::NewWindow() { - UserMetrics::RecordAction("NewWindow", profile_); + UserMetrics::RecordAction(UserMetricsAction("NewWindow"), profile_); Browser::OpenEmptyWindow(profile_->GetOriginalProfile()); } void Browser::NewIncognitoWindow() { - UserMetrics::RecordAction("NewIncognitoWindow", profile_); + UserMetrics::RecordAction(UserMetricsAction("NewIncognitoWindow"), profile_); Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile()); } @@ -1017,18 +1017,19 @@ void Browser::NewProfileWindowByIndex(int index) { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (!command_line.HasSwitch(switches::kEnableUserDataDirProfiles)) return; - UserMetrics::RecordAction("NewProfileWindowByIndex", profile_); + UserMetrics::RecordAction(UserMetricsAction("NewProfileWindowByIndex"), + profile_); UserDataManager::Get()->LaunchChromeForProfile(index); #endif } void Browser::CloseWindow() { - UserMetrics::RecordAction("CloseWindow", profile_); + UserMetrics::RecordAction(UserMetricsAction("CloseWindow"), profile_); window_->Close(); } void Browser::NewTab() { - UserMetrics::RecordAction("NewTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("NewTab"), profile_); #if defined(OS_WIN) if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kAppLauncherForNewTab)) { @@ -1050,49 +1051,51 @@ void Browser::NewTab() { } void Browser::CloseTab() { - UserMetrics::RecordAction("CloseTab_Accelerator", profile_); + UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator"), + profile_); tabstrip_model_.CloseTabContentsAt(tabstrip_model_.selected_index()); } void Browser::SelectNextTab() { - UserMetrics::RecordAction("SelectNextTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("SelectNextTab"), profile_); tabstrip_model_.SelectNextTab(); } void Browser::SelectPreviousTab() { - UserMetrics::RecordAction("SelectPrevTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("SelectPrevTab"), profile_); tabstrip_model_.SelectPreviousTab(); } void Browser::MoveTabNext() { - UserMetrics::RecordAction("MoveTabNext", profile_); + UserMetrics::RecordAction(UserMetricsAction("MoveTabNext"), profile_); tabstrip_model_.MoveTabNext(); } void Browser::MoveTabPrevious() { - UserMetrics::RecordAction("MoveTabPrevious", profile_); + UserMetrics::RecordAction(UserMetricsAction("MoveTabPrevious"), profile_); tabstrip_model_.MoveTabPrevious(); } void Browser::SelectNumberedTab(int index) { if (index < tab_count()) { - UserMetrics::RecordAction("SelectNumberedTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("SelectNumberedTab"), + profile_); tabstrip_model_.SelectTabContentsAt(index, true); } } void Browser::SelectLastTab() { - UserMetrics::RecordAction("SelectLastTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("SelectLastTab"), profile_); tabstrip_model_.SelectLastTab(); } void Browser::DuplicateTab() { - UserMetrics::RecordAction("Duplicate", profile_); + UserMetrics::RecordAction(UserMetricsAction("Duplicate"), profile_); DuplicateContentsAt(selected_index()); } void Browser::RestoreTab() { - UserMetrics::RecordAction("RestoreTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("RestoreTab"), profile_); TabRestoreService* service = profile_->GetTabRestoreService(); if (!service) return; @@ -1104,7 +1107,6 @@ void Browser::WriteCurrentURLToClipboard() { // TODO(ericu): There isn't currently a metric for this. Should there be? // We don't appear to track the action when it comes from the // RenderContextViewMenu. - // UserMetrics::RecordAction("$Metric_Name_Goes_Here$", profile_); TabContents* contents = GetSelectedTabContents(); if (!contents->ShouldDisplayURL()) @@ -1117,7 +1119,7 @@ void Browser::WriteCurrentURLToClipboard() { } void Browser::ConvertPopupToTabbedBrowser() { - UserMetrics::RecordAction("ShowAsTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowAsTab"), profile_); int tab_strip_index = tabstrip_model_.selected_index(); TabContents* contents = tabstrip_model_.DetachTabContentsAt(tab_strip_index); Browser* browser = Browser::Create(profile_); @@ -1134,7 +1136,7 @@ void Browser::ToggleFullscreenMode() { return; #endif - UserMetrics::RecordAction("ToggleFullscreen", profile_); + UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen"), profile_); window_->SetFullscreen(!window_->IsFullscreen()); // On Linux, setting fullscreen mode is an async call to the X server, which // may or may not support fullscreen mode. @@ -1145,18 +1147,19 @@ void Browser::ToggleFullscreenMode() { #if defined(OS_CHROMEOS) void Browser::ToggleCompactNavigationBar() { - UserMetrics::RecordAction("ToggleCompactNavigationBar", profile_); + UserMetrics::RecordAction(UserMetricsAction("ToggleCompactNavigationBar"), + profile_); window_->ToggleCompactNavigationBar(); } #endif void Browser::Exit() { - UserMetrics::RecordAction("Exit", profile_); + UserMetrics::RecordAction(UserMetricsAction("Exit"), profile_); BrowserList::CloseAllBrowsersAndExit(); } void Browser::BookmarkCurrentPage() { - UserMetrics::RecordAction("Star", profile_); + UserMetrics::RecordAction(UserMetricsAction("Star"), profile_); BookmarkModel* model = profile()->GetBookmarkModel(); if (!model || !model->IsLoaded()) @@ -1178,12 +1181,12 @@ void Browser::BookmarkCurrentPage() { } void Browser::SavePage() { - UserMetrics::RecordAction("SavePage", profile_); + UserMetrics::RecordAction(UserMetricsAction("SavePage"), profile_); GetSelectedTabContents()->OnSavePage(); } void Browser::ViewSource() { - UserMetrics::RecordAction("ViewSource", profile_); + UserMetrics::RecordAction(UserMetricsAction("ViewSource"), profile_); TabContents* current_tab = GetSelectedTabContents(); NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); @@ -1211,7 +1214,7 @@ bool Browser::SupportsWindowFeature(WindowFeature feature) const { features |= FEATURE_EXTENSIONSHELF; } - // On Mac, fullscreen mode has most normal things (in a slide-down panel). On + // On Mac, fullscreen mode has most normal things (in a slide-down panel). On // other platforms, we hide some controls when in fullscreen mode. bool hide_ui_for_fullscreen = false; #if !defined(OS_MACOSX) @@ -1229,17 +1232,17 @@ bool Browser::SupportsWindowFeature(WindowFeature feature) const { } void Browser::EmailPageLocation() { - UserMetrics::RecordAction("EmailPageLocation", profile_); + UserMetrics::RecordAction(UserMetricsAction("EmailPageLocation"), profile_); GetSelectedTabContents()->EmailPageLocation(); } void Browser::Print() { - UserMetrics::RecordAction("PrintPreview", profile_); + UserMetrics::RecordAction(UserMetricsAction("PrintPreview"), profile_); GetSelectedTabContents()->PrintPreview(); } void Browser::ToggleEncodingAutoDetect() { - UserMetrics::RecordAction("AutoDetectChange", profile_); + UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange"), profile_); encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); // If "auto detect" is turned on, then any current override encoding // is cleared. This also implicitly performs a reload. @@ -1253,7 +1256,7 @@ void Browser::ToggleEncodingAutoDetect() { } void Browser::OverrideEncoding(int encoding_id) { - UserMetrics::RecordAction("OverrideEncoding", profile_); + UserMetrics::RecordAction(UserMetricsAction("OverrideEncoding"), profile_); const std::string selected_encoding = CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); TabContents* contents = GetSelectedTabContents(); @@ -1272,61 +1275,66 @@ void Browser::OverrideEncoding(int encoding_id) { } void Browser::Cut() { - UserMetrics::RecordAction("Cut", profile_); + UserMetrics::RecordAction(UserMetricsAction("Cut"), profile_); window()->Cut(); } void Browser::Copy() { - UserMetrics::RecordAction("Copy", profile_); + UserMetrics::RecordAction(UserMetricsAction("Copy"), profile_); window()->Copy(); } void Browser::Paste() { - UserMetrics::RecordAction("Paste", profile_); + UserMetrics::RecordAction(UserMetricsAction("Paste"), profile_); window()->Paste(); } void Browser::Find() { - UserMetrics::RecordAction("Find", profile_); + UserMetrics::RecordAction(UserMetricsAction("Find"), profile_); FindInPage(false, false); } void Browser::FindNext() { - UserMetrics::RecordAction("FindNext", profile_); + UserMetrics::RecordAction(UserMetricsAction("FindNext"), profile_); FindInPage(true, true); } void Browser::FindPrevious() { - UserMetrics::RecordAction("FindPrevious", profile_); + UserMetrics::RecordAction(UserMetricsAction("FindPrevious"), profile_); FindInPage(true, false); } void Browser::Zoom(PageZoom::Function zoom_function) { - static const char* kActions[] = { "ZoomMinus", "ZoomNormal", "ZoomPlus" }; - UserMetrics::RecordComputedAction( - kActions[zoom_function - PageZoom::ZOOM_OUT], profile_); + static const UserMetricsAction kActions[] = { + UserMetricsAction("ZoomMinus"), + UserMetricsAction("ZoomNormal"), + UserMetricsAction("ZoomPlus") + }; + + UserMetrics::RecordAction(kActions[zoom_function - PageZoom::ZOOM_OUT], + profile_); TabContents* tab_contents = GetSelectedTabContents(); tab_contents->render_view_host()->Zoom(zoom_function); } void Browser::FocusToolbar() { - UserMetrics::RecordAction("FocusToolbar", profile_); + UserMetrics::RecordAction(UserMetricsAction("FocusToolbar"), profile_); window_->FocusToolbar(); } void Browser::FocusLocationBar() { - UserMetrics::RecordAction("FocusLocation", profile_); + UserMetrics::RecordAction(UserMetricsAction("FocusLocation"), profile_); window_->SetFocusToLocationBar(); } void Browser::FocusSearch() { // TODO(beng): replace this with FocusLocationBar - UserMetrics::RecordAction("FocusSearch", profile_); + UserMetrics::RecordAction(UserMetricsAction("FocusSearch"), profile_); window_->GetLocationBar()->FocusSearch(); } void Browser::OpenFile() { - UserMetrics::RecordAction("OpenFile", profile_); + UserMetrics::RecordAction(UserMetricsAction("OpenFile"), profile_); if (!select_file_dialog_.get()) select_file_dialog_ = SelectFileDialog::Create(this); @@ -1339,7 +1347,7 @@ void Browser::OpenFile() { } void Browser::OpenCreateShortcutsDialog() { - UserMetrics::RecordAction("CreateShortcut", profile_); + UserMetrics::RecordAction(UserMetricsAction("CreateShortcut"), profile_); #if defined(OS_WIN) || defined(OS_LINUX) TabContents* current_tab = GetSelectedTabContents(); DCHECK(current_tab && web_app::IsValidUrl(current_tab->GetURL())) << @@ -1363,15 +1371,17 @@ void Browser::OpenCreateShortcutsDialog() { void Browser::ToggleDevToolsWindow(bool open_console) { if (open_console) - UserMetrics::RecordAction("DevTools_ToggleConsole", profile_); + UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleConsole"), + profile_); else - UserMetrics::RecordAction("DevTools_ToggleWindow", profile_); + UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleWindow"), + profile_); DevToolsManager::GetInstance()->ToggleDevToolsWindow( GetSelectedTabContents()->render_view_host(), open_console); } void Browser::OpenTaskManager() { - UserMetrics::RecordAction("TaskManager", profile_); + UserMetrics::RecordAction(UserMetricsAction("TaskManager"), profile_); window_->ShowTaskManager(); } @@ -1379,7 +1389,7 @@ void Browser::OpenSelectProfileDialog() { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (!command_line.HasSwitch(switches::kEnableUserDataDirProfiles)) return; - UserMetrics::RecordAction("SelectProfile", profile_); + UserMetrics::RecordAction(UserMetricsAction("SelectProfile"), profile_); window_->ShowSelectProfileDialog(); } @@ -1387,27 +1397,28 @@ void Browser::OpenNewProfileDialog() { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (!command_line.HasSwitch(switches::kEnableUserDataDirProfiles)) return; - UserMetrics::RecordAction("CreateProfile", profile_); + UserMetrics::RecordAction(UserMetricsAction("CreateProfile"), profile_); window_->ShowNewProfileDialog(); } void Browser::OpenBugReportDialog() { - UserMetrics::RecordAction("ReportBug", profile_); + UserMetrics::RecordAction(UserMetricsAction("ReportBug"), profile_); window_->ShowReportBugDialog(); } void Browser::ToggleBookmarkBar() { - UserMetrics::RecordAction("ShowBookmarksBar", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarksBar"), profile_); window_->ToggleBookmarkBar(); } void Browser::ToggleExtensionShelf() { - UserMetrics::RecordAction("ToggleExtensionShelf", profile_); + UserMetrics::RecordAction(UserMetricsAction("ToggleExtensionShelf"), + profile_); window_->ToggleExtensionShelf(); } void Browser::OpenBookmarkManager() { - UserMetrics::RecordAction("ShowBookmarkManager", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), profile_); if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableTabbedBookmarkManager)) { window_->ShowBookmarkManager(); @@ -1417,12 +1428,12 @@ void Browser::OpenBookmarkManager() { } void Browser::ShowAppMenu() { - UserMetrics::RecordAction("ShowAppMenu", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowAppMenu"), profile_); window_->ShowAppMenu(); } void Browser::ShowPageMenu() { - UserMetrics::RecordAction("ShowPageMenu", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowPageMenu"), profile_); window_->ShowPageMenu(); } @@ -1431,7 +1442,8 @@ void Browser::ShowBookmarkManagerTab() { // we try to reuse the last active window and if that fails we open a new // window. Profile* default_profile = profile_->GetOriginalProfile(); - UserMetrics::RecordAction("ShowBookmarks", default_profile); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarks"), + default_profile); if (!profile_->IsOffTheRecord()) { ShowSingletonTab(GURL(chrome::kChromeUIBookmarksURL)); @@ -1447,32 +1459,33 @@ void Browser::ShowBookmarkManagerTab() { } void Browser::ShowHistoryTab() { - UserMetrics::RecordAction("ShowHistory", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowHistory"), profile_); ShowSingletonTab(GURL(chrome::kChromeUIHistoryURL)); } void Browser::ShowDownloadsTab() { - UserMetrics::RecordAction("ShowDownloads", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowDownloads"), profile_); ShowSingletonTab(GURL(chrome::kChromeUIDownloadsURL)); } void Browser::ShowExtensionsTab() { - UserMetrics::RecordAction("ShowExtensions", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowExtensions"), profile_); ShowSingletonTab(GURL(chrome::kChromeUIExtensionsURL)); } void Browser::OpenClearBrowsingDataDialog() { - UserMetrics::RecordAction("ClearBrowsingData_ShowDlg", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), + profile_); window_->ShowClearBrowsingDataDialog(); } void Browser::OpenOptionsDialog() { - UserMetrics::RecordAction("ShowOptions", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_); } void Browser::OpenKeywordEditor() { - UserMetrics::RecordAction("EditSearchEngines", profile_); + UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines"), profile_); window_->ShowSearchEnginesDialog(); } @@ -1481,7 +1494,7 @@ void Browser::OpenPasswordManager() { } void Browser::OpenImportSettingsDialog() { - UserMetrics::RecordAction("Import_ShowDlg", profile_); + UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), profile_); window_->ShowImportDialog(); } @@ -1491,7 +1504,7 @@ void Browser::OpenSyncMyBookmarksDialog() { } void Browser::OpenAboutChromeDialog() { - UserMetrics::RecordAction("AboutChrome", profile_); + UserMetrics::RecordAction(UserMetricsAction("AboutChrome"), profile_); window_->ShowAboutChromeDialog(); } @@ -1509,12 +1522,14 @@ void Browser::OpenThemeGalleryTabAndActivate() { #if defined(OS_CHROMEOS) void Browser::OpenSystemOptionsDialog() { - UserMetrics::RecordAction("OpenSystemOptionsDialog", profile_); + UserMetrics::RecordAction(UserMetricsAction("OpenSystemOptionsDialog"), + profile_); ShowOptionsWindow(OPTIONS_PAGE_SYSTEM, OPTIONS_GROUP_NONE, profile_); } void Browser::OpenInternetOptionsDialog() { - UserMetrics::RecordAction("OpenInternetOptionsDialog", profile_); + UserMetrics::RecordAction(UserMetricsAction("OpenInternetOptionsDialog"), + profile_); ShowOptionsWindow(OPTIONS_PAGE_INTERNET, OPTIONS_GROUP_NONE, profile_); } #endif diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc index f4f536bf..cd76142 100644 --- a/chrome/browser/browser_theme_provider.cc +++ b/chrome/browser/browser_theme_provider.cc @@ -295,7 +295,7 @@ void BrowserThemeProvider::SetTheme(Extension* extension) { SaveThemeID(extension->id()); NotifyThemeChanged(extension); - UserMetrics::RecordAction("Themes_Installed", profile_); + UserMetrics::RecordAction(UserMetricsAction("Themes_Installed"), profile_); } void BrowserThemeProvider::RemoveUnusedThemes() { @@ -320,7 +320,7 @@ void BrowserThemeProvider::RemoveUnusedThemes() { void BrowserThemeProvider::UseDefaultTheme() { ClearAllThemeData(); NotifyThemeChanged(NULL); - UserMetrics::RecordAction("Themes_Reset", profile_); + UserMetrics::RecordAction(UserMetricsAction("Themes_Reset"), profile_); } std::string BrowserThemeProvider::GetThemeID() const { @@ -542,7 +542,7 @@ void BrowserThemeProvider::LoadThemePrefs() { } if (loaded_pack) { - UserMetrics::RecordAction("Themes.Loaded", profile_); + UserMetrics::RecordAction(UserMetricsAction("Themes.Loaded"), profile_); } else { // TODO(erg): We need to pop up a dialog informing the user that their // theme is being migrated. @@ -552,11 +552,12 @@ void BrowserThemeProvider::LoadThemePrefs() { if (extension) { DLOG(ERROR) << "Migrating theme"; BuildFromExtension(extension); - UserMetrics::RecordAction("Themes.Migrated", profile_); + UserMetrics::RecordAction(UserMetricsAction("Themes.Migrated"), + profile_); } else { DLOG(ERROR) << "Theme is mysteriously gone."; ClearAllThemeData(); - UserMetrics::RecordAction("Themes.Gone", profile_); + UserMetrics::RecordAction(UserMetricsAction("Themes.Gone"), profile_); } } } diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index 614c781..7323444 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -94,7 +94,8 @@ void BrowsingDataRemover::Remove(int remove_mask) { profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); if (history_service) { std::set<GURL> restrict_urls; - UserMetrics::RecordAction("ClearBrowsingData_History", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_History"), + profile_); waiting_for_clear_history_ = true; history_service->ExpireHistoryBetween(restrict_urls, delete_begin_, delete_end_, @@ -127,14 +128,16 @@ void BrowsingDataRemover::Remove(int remove_mask) { } if (remove_mask & REMOVE_DOWNLOADS) { - UserMetrics::RecordAction("ClearBrowsingData_Downloads", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads"), + profile_); DownloadManager* download_manager = profile_->GetDownloadManager(); download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); download_manager->ClearLastDownloadPath(); } if (remove_mask & REMOVE_COOKIES) { - UserMetrics::RecordAction("ClearBrowsingData_Cookies", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"), + profile_); // Since we are running on the UI thread don't call GetURLRequestContext(). net::CookieMonster* cookie_monster = profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster(); @@ -174,7 +177,8 @@ void BrowsingDataRemover::Remove(int remove_mask) { } if (remove_mask & REMOVE_PASSWORDS) { - UserMetrics::RecordAction("ClearBrowsingData_Passwords", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords"), + profile_); PasswordStore* password_store = profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS); @@ -182,7 +186,8 @@ void BrowsingDataRemover::Remove(int remove_mask) { } if (remove_mask & REMOVE_FORM_DATA) { - UserMetrics::RecordAction("ClearBrowsingData_Autofill", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"), + profile_); WebDataService* web_data_service = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); @@ -193,7 +198,8 @@ void BrowsingDataRemover::Remove(int remove_mask) { if (remove_mask & REMOVE_CACHE) { // Invoke ClearBrowsingDataView::ClearCache on the IO thread. waiting_for_clear_cache_ = true; - UserMetrics::RecordAction("ClearBrowsingData_Cache", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Cache"), + profile_); URLRequestContextGetter* main_context_getter = profile_->GetRequestContext(); diff --git a/chrome/browser/chromeos/compact_location_bar_view.cc b/chrome/browser/chromeos/compact_location_bar_view.cc index 576f114..2ef1b21 100644 --- a/chrome/browser/chromeos/compact_location_bar_view.cc +++ b/chrome/browser/chromeos/compact_location_bar_view.cc @@ -281,7 +281,7 @@ void CompactLocationBarView::WriteDragData(views::View* sender, OSExchangeData* data) { DCHECK(GetDragOperations(sender, press_pt) != DragDropTypes::DRAG_NONE); - UserMetrics::RecordAction("CompactLocationBar_DragStar", + UserMetrics::RecordAction(UserMetricsAction("CompactLocationBar_DragStar"), browser()->profile()); // If there is a bookmark for the URL, add the bookmark drag data for it. We diff --git a/chrome/browser/chromeos/external_metrics.cc b/chrome/browser/chromeos/external_metrics.cc index 3eb8936..b0ce3f3 100644 --- a/chrome/browser/chromeos/external_metrics.cc +++ b/chrome/browser/chromeos/external_metrics.cc @@ -1,5 +1,5 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use -// of this source code is governed by a BSD-style license that can be +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/chromeos/external_metrics.h" @@ -47,11 +47,13 @@ static Profile* external_metrics_profile = NULL; // call RecordAction in a way that gets picked up by the processing scripts. static void RecordTabOverviewKeystroke(const char* ignore) { - UserMetrics::RecordAction("TabOverview_Keystroke", external_metrics_profile); + UserMetrics::RecordAction(UserMetricsAction("TabOverview_Keystroke"), + external_metrics_profile); } static void RecordTabOverviewExitMouse(const char* ignore) { - UserMetrics::RecordAction("TabOverview_ExitMouse", external_metrics_profile); + UserMetrics::RecordAction(UserMetricsAction("TabOverview_ExitMouse"), + external_metrics_profile); } static void RecordBootTime(const char* info) { diff --git a/chrome/browser/chromeos/options/system_page_view.cc b/chrome/browser/chromeos/options/system_page_view.cc index 3032dd7..cd9b491 100644 --- a/chrome/browser/chromeos/options/system_page_view.cc +++ b/chrome/browser/chromeos/options/system_page_view.cc @@ -250,16 +250,16 @@ void TouchpadSection::ButtonPressed( if (sender == enable_tap_to_click_checkbox_) { bool enabled = enable_tap_to_click_checkbox_->checked(); UserMetricsRecordAction(enabled ? - "Options_TapToClickCheckbox_Enable" : - "Options_TapToClickCheckbox_Disable", - profile()->GetPrefs()); + UserMetricsAction("Options_TapToClickCheckbox_Enable") : + UserMetricsAction("Options_TapToClickCheckbox_Disable"), + profile()->GetPrefs()); tap_to_click_enabled_.SetValue(enabled); } else if (sender == enable_vert_edge_scroll_checkbox_) { bool enabled = enable_vert_edge_scroll_checkbox_->checked(); UserMetricsRecordAction(enabled ? - "Options_VertEdgeScrollCheckbox_Enable" : - "Options_VertEdgeScrollCheckbox_Disable", - profile()->GetPrefs()); + UserMetricsAction("Options_VertEdgeScrollCheckbox_Enable") : + UserMetricsAction("Options_VertEdgeScrollCheckbox_Disable"), + profile()->GetPrefs()); vert_edge_scroll_enabled_.SetValue(enabled); } } @@ -267,13 +267,15 @@ void TouchpadSection::ButtonPressed( void TouchpadSection::SliderValueChanged(views::Slider* sender) { if (sender == speed_factor_slider_) { double value = speed_factor_slider_->value(); - UserMetricsRecordAction("Options_SpeedFactorSlider_Changed", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_SpeedFactorSlider_Changed"), + profile()->GetPrefs()); speed_factor_.SetValue(value); } else if (sender == sensitivity_slider_) { double value = sensitivity_slider_->value(); - UserMetricsRecordAction("Options_SensitivitySlider_Changed", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_SensitivitySlider_Changed"), + profile()->GetPrefs()); sensitivity_.SetValue(value); } } diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index a460f7f..ad844f5 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -1322,7 +1322,8 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { const BookmarkNode* node = [self nodeFromMenuItem:sender]; if (node) { [self openBookmarkNodesRecursive:node disposition:NEW_FOREGROUND_TAB]; - UserMetrics::RecordAction("OpenAllBookmarks", browser_->profile()); + UserMetrics::RecordAction(UserMetricsAction("OpenAllBookmarks"), + browser_->profile()); } } @@ -1330,7 +1331,8 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { const BookmarkNode* node = [self nodeFromMenuItem:sender]; if (node) { [self openBookmarkNodesRecursive:node disposition:NEW_WINDOW]; - UserMetrics::RecordAction("OpenAllBookmarksNewWindow", browser_->profile()); + UserMetrics::RecordAction(UserMetricsAction("OpenAllBookmarksNewWindow"), + browser_->profile()); } } @@ -1338,8 +1340,9 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { const BookmarkNode* node = [self nodeFromMenuItem:sender]; if (node) { [self openBookmarkNodesRecursive:node disposition:OFF_THE_RECORD]; - // Must be on 1 line due to UMA scripts - UserMetrics::RecordAction("OpenAllBookmarksIncognitoWindow", browser_->profile()); + UserMetrics::RecordAction( + UserMetricsAction("OpenAllBookmarksIncognitoWindow"), + browser_->profile()); } } diff --git a/chrome/browser/cocoa/bookmark_bubble_controller.mm b/chrome/browser/cocoa/bookmark_bubble_controller.mm index 7b29749..075034c 100644 --- a/chrome/browser/cocoa/bookmark_bubble_controller.mm +++ b/chrome/browser/cocoa/bookmark_bubble_controller.mm @@ -146,7 +146,8 @@ } - (IBAction)edit:(id)sender { - UserMetrics::RecordAction("BookmarkBubble_Edit", model_->profile()); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Edit"), + model_->profile()); [self showEditor]; } @@ -169,7 +170,8 @@ - (IBAction)remove:(id)sender { model_->SetURLStarred(node_->GetURL(), node_->GetTitle(), false); - UserMetrics::RecordAction("BookmarkBubble_Unstar", model_->profile()); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"), + model_->profile()); node_ = NULL; // no longer valid [self ok:sender]; } @@ -181,8 +183,9 @@ NSMenuItem* selected = [folderPopUpButton_ selectedItem]; ChooseAnotherFolder* chooseItem = [[self class] chooseAnotherFolderObject]; if ([[selected representedObject] isEqual:chooseItem]) { - UserMetrics::RecordAction("BookmarkBubble_EditFromCombobox", - model_->profile()); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_EditFromCombobox"), + model_->profile()); [self showEditor]; } } @@ -210,8 +213,9 @@ NSString* newTitle = [nameTextField_ stringValue]; if (![oldTitle isEqual:newTitle]) { model_->SetTitle(node_, base::SysNSStringToWide(newTitle)); - UserMetrics::RecordAction("BookmarkBubble_ChangeTitleInBubble", - model_->profile()); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"), + model_->profile()); } // Then the parent folder. const BookmarkNode* oldParent = node_->GetParent(); @@ -227,7 +231,7 @@ if (oldParent != newParent) { int index = newParent->GetChildCount(); model_->Move(node_, newParent, index); - UserMetrics::RecordAction("BookmarkBubble_ChangeParent", + UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_ChangeParent"), model_->profile()); } } diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 624757f..5280811 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -369,7 +369,7 @@ CGFloat AutoSizeUnderTheHoodContent(NSView* view, // queried to find out what happened. - (void)syncStateChanged; // Record the user performed a certain action and save the preferences. -- (void)recordUserAction:(const char*)action; +- (void)recordUserAction:(const UserMetricsAction&) action; - (void)registerPrefObservers; - (void)unregisterPrefObservers; @@ -878,8 +878,8 @@ void PersonalDataManagerObserver::ShowAutoFillDialog( } // Record the user performed a certain action and save the preferences. -- (void)recordUserAction:(const char*)action { - UserMetrics::RecordComputedAction(action, profile_); +- (void)recordUserAction:(const UserMetricsAction &)action { + UserMetrics::RecordAction(action, profile_); if (prefs_) prefs_->ScheduleSavePersistentPrefs(); } @@ -1011,13 +1011,13 @@ void PersonalDataManagerObserver::ShowAutoFillDialog( static_cast<SessionStartupPref::Type>(type); switch (startupType) { case SessionStartupPref::DEFAULT: - [self recordUserAction:"Options_Startup_Homepage"]; + [self recordUserAction:UserMetricsAction("Options_Startup_Homepage")]; break; case SessionStartupPref::LAST: - [self recordUserAction:"Options_Startup_LastSession"]; + [self recordUserAction:UserMetricsAction("Options_Startup_LastSession")]; break; case SessionStartupPref::URLS: - [self recordUserAction:"Options_Startup_Custom"]; + [self recordUserAction:UserMetricsAction("Options_Startup_Custom")]; break; default: NOTREACHED(); @@ -1105,9 +1105,9 @@ enum { kHomepageNewTabPage, kHomepageURL }; - (void)setNewTabPageIsHomePageIndex:(NSInteger)index { bool useNewTabPage = index == kHomepageNewTabPage ? true : false; if (useNewTabPage) - [self recordUserAction:"Options_Homepage_UseNewTab"]; + [self recordUserAction:UserMetricsAction("Options_Homepage_UseNewTab")]; else - [self recordUserAction:"Options_Homepage_UseURL"]; + [self recordUserAction:UserMetricsAction("Options_Homepage_UseURL")]; newTabPageIsHomePage_.SetValue(useNewTabPage); } @@ -1145,9 +1145,11 @@ enum { kHomepageNewTabPage, kHomepageURL }; // based on |value|. - (void)setShowHomeButton:(BOOL)value { if (value) - [self recordUserAction:"Options_Homepage_ShowHomeButton"]; + [self recordUserAction:UserMetricsAction( + "Options_Homepage_ShowHomeButton")]; else - [self recordUserAction:"Options_Homepage_HideHomeButton"]; + [self recordUserAction:UserMetricsAction( + "Options_Homepage_HideHomeButton")]; showHomeButton_.SetValue(value ? true : false); } @@ -1161,9 +1163,11 @@ enum { kHomepageNewTabPage, kHomepageURL }; // be displayed based on |value|. - (void)setShowPageOptionsButtons:(BOOL)value { if (value) - [self recordUserAction:"Options_Homepage_ShowPageOptionsButtons"]; + [self recordUserAction:UserMetricsAction( + "Options_Homepage_ShowPageOptionsButtons")]; else - [self recordUserAction:"Options_Homepage_HidePageOptionsButtons"]; + [self recordUserAction:UserMetricsAction( + "Options_Homepage_HidePageOptionsButtons")]; showPageOptionButtons_.SetValue(value ? true : false); } @@ -1180,7 +1184,7 @@ enum { kHomepageNewTabPage, kHomepageURL }; } - (void)setSearchEngineSelectedIndex:(NSUInteger)index { - [self recordUserAction:"Options_SearchEngineChanged"]; + [self recordUserAction:UserMetricsAction("Options_SearchEngineChanged")]; [searchEngineModel_ setDefaultIndex:index]; } @@ -1200,7 +1204,7 @@ enum { kHomepageNewTabPage, kHomepageURL }; [self willChangeValueForKey:@"defaultBrowser"]; ShellIntegration::SetAsDefaultBrowser(); - [self recordUserAction:"Options_SetAsDefaultBrowser"]; + [self recordUserAction:UserMetricsAction("Options_SetAsDefaultBrowser")]; // If the user made Chrome the default browser, then he/she arguably wants // to be notified when that changes. prefs_->SetBoolean(prefs::kCheckDefaultBrowser, true); @@ -1268,13 +1272,13 @@ const int kDisabledIndex = 1; // Called to launch the Keychain Access app to show the user's stored // passwords. - (IBAction)showSavedPasswords:(id)sender { - [self recordUserAction:"Options_ShowPasswordsExceptions"]; + [self recordUserAction:UserMetricsAction("Options_ShowPasswordsExceptions")]; [self launchKeychainAccess]; } // Called to show the Auto Fill Settings dialog. - (IBAction)showAutoFillSettings:(id)sender { - [self recordUserAction:"Options_ShowAutoFillSettings"]; + [self recordUserAction:UserMetricsAction("Options_ShowAutoFillSettings")]; PersonalDataManager* personalDataManager = profile_->GetPersonalDataManager(); if (!personalDataManager) { @@ -1301,17 +1305,17 @@ const int kDisabledIndex = 1; // Called to import data from other browsers (Safari, Firefox, etc). - (IBAction)importData:(id)sender { - UserMetrics::RecordAction("Import_ShowDlg", profile_); + UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), profile_); [ImportSettingsDialogController showImportSettingsDialogForProfile:profile_]; } - (IBAction)resetThemeToDefault:(id)sender { - [self recordUserAction:"Options_ThemesReset"]; + [self recordUserAction:UserMetricsAction("Options_ThemesReset")]; profile_->ClearTheme(); } - (IBAction)themesGallery:(id)sender { - [self recordUserAction:"Options_ThemesGallery"]; + [self recordUserAction:UserMetricsAction("Options_ThemesGallery")]; Browser* browser = BrowserList::FindBrowserWithType(profile_, Browser::TYPE_NORMAL); @@ -1379,9 +1383,11 @@ const int kDisabledIndex = 1; - (void)setPasswordManagerEnabledIndex:(NSInteger)value { if (value == kEnabledIndex) - [self recordUserAction:"Options_PasswordManager_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_PasswordManager_Enable")]; else - [self recordUserAction:"Options_PasswordManager_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_PasswordManager_Disable")]; askSavePasswords_.SetValue(value == kEnabledIndex ? true : false); } @@ -1391,9 +1397,9 @@ const int kDisabledIndex = 1; - (void)setFormAutofillEnabledIndex:(NSInteger)value { if (value == kEnabledIndex) - [self recordUserAction:"Options_FormAutofill_Enable"]; + [self recordUserAction:UserMetricsAction("Options_FormAutofill_Enable")]; else - [self recordUserAction:"Options_FormAutofill_Disable"]; + [self recordUserAction:UserMetricsAction("Options_FormAutofill_Disable")]; formAutofill_.SetValue(value == kEnabledIndex ? true : false); } @@ -1403,9 +1409,11 @@ const int kDisabledIndex = 1; - (void)setIsUsingDefaultTheme:(BOOL)value { if (value) - [self recordUserAction:"Options_IsUsingDefaultTheme_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_IsUsingDefaultTheme_Enable")]; else - [self recordUserAction:"Options_IsUsingDefaultTheme_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_IsUsingDefaultTheme_Disable")]; } - (BOOL)isUsingDefaultTheme { @@ -1449,7 +1457,7 @@ const int kDisabledIndex = 1; code:(NSInteger)returnCode context:(void*)context { if (returnCode == NSOKButton) { - [self recordUserAction:"Options_SetDownloadDirectory"]; + [self recordUserAction:UserMetricsAction("Options_SetDownloadDirectory")]; NSURL* path = [[panel URLs] lastObject]; // We only allow 1 item. [self willChangeValueForKey:@"defaultDownloadLocation"]; defaultDownloadLocation_.SetValue(base::SysNSStringToWide([path path])); @@ -1505,9 +1513,11 @@ const int kDisabledIndex = 1; // should be displayed based on |value|. - (void)setShowAlternateErrorPages:(BOOL)value { if (value) - [self recordUserAction:"Options_LinkDoctorCheckbox_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_LinkDoctorCheckbox_Enable")]; else - [self recordUserAction:"Options_LinkDoctorCheckbox_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_LinkDoctorCheckbox_Disable")]; alternateErrorPages_.SetValue(value ? true : false); } @@ -1521,9 +1531,11 @@ const int kDisabledIndex = 1; // displayed based on |value|. - (void)setUseSuggest:(BOOL)value { if (value) - [self recordUserAction:"Options_UseSuggestCheckbox_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_UseSuggestCheckbox_Enable")]; else - [self recordUserAction:"Options_UseSuggestCheckbox_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_UseSuggestCheckbox_Disable")]; useSuggest_.SetValue(value ? true : false); } @@ -1537,9 +1549,11 @@ const int kDisabledIndex = 1; // displayed based on |value|. - (void)setDnsPrefetch:(BOOL)value { if (value) - [self recordUserAction:"Options_DnsPrefetchCheckbox_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_DnsPrefetchCheckbox_Enable")]; else - [self recordUserAction:"Options_DnsPrefetchCheckbox_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_DnsPrefetchCheckbox_Disable")]; dnsPrefetch_.SetValue(value ? true : false); chrome_browser_net::EnableDnsPrefetch(value ? true : false); } @@ -1554,9 +1568,11 @@ const int kDisabledIndex = 1; // displayed based on |value|. - (void)setSafeBrowsing:(BOOL)value { if (value) - [self recordUserAction:"Options_SafeBrowsingCheckbox_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_SafeBrowsingCheckbox_Enable")]; else - [self recordUserAction:"Options_SafeBrowsingCheckbox_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_SafeBrowsingCheckbox_Disable")]; bool enabled = value ? true : false; safeBrowsing_.SetValue(enabled); SafeBrowsingService* safeBrowsingService = @@ -1575,9 +1591,11 @@ const int kDisabledIndex = 1; // displayed based on |value|. - (void)setMetricsRecording:(BOOL)value { if (value) - [self recordUserAction:"Options_MetricsReportingCheckbox_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_MetricsReportingCheckbox_Enable")]; else - [self recordUserAction:"Options_MetricsReportingCheckbox_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_MetricsReportingCheckbox_Disable")]; bool enabled = value ? true : false; GoogleUpdateSettings::SetCollectStatsConsent(enabled); @@ -1618,9 +1636,11 @@ const int kDisabledIndex = 1; - (void)setAskForSaveLocation:(BOOL)value { if (value) { - [self recordUserAction:"Options_AskForSaveLocation_Enable"]; + [self recordUserAction:UserMetricsAction( + "Options_AskForSaveLocation_Enable")]; } else { - [self recordUserAction:"Options_AskForSaveLocation_Disable"]; + [self recordUserAction:UserMetricsAction( + "Options_AskForSaveLocation_Disable")]; } askForSaveLocation_.SetValue(value); } @@ -1631,9 +1651,9 @@ const int kDisabledIndex = 1; - (void)setTranslateEnabled:(BOOL)value { if (value) { - [self recordUserAction:"Options_Translate_Enable"]; + [self recordUserAction:UserMetricsAction("Options_Translate_Enable")]; } else { - [self recordUserAction:"Options_Translate_Disable"]; + [self recordUserAction:UserMetricsAction("Options_Translate_Disable")]; } translateEnabled_.SetValue(value); } @@ -1662,7 +1682,7 @@ const int kDisabledIndex = 1; // certificates. Note there's no way to script the app to auto-select the // certificates. - (IBAction)showCertificates:(id)sender { - [self recordUserAction:"Options_ManagerCerts"]; + [self recordUserAction:UserMetricsAction("Options_ManagerCerts")]; [self launchKeychainAccess]; } diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 9a661e4..cf340bb 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -573,7 +573,8 @@ private: TabContents* contents = tabStripModel_->GetTabContentsAt(index); if (contents) - UserMetrics::RecordAction("CloseTab_Mouse", contents->profile()); + UserMetrics::RecordAction(UserMetricsAction("CloseTab_Mouse"), + contents->profile()); const NSInteger numberOfOpenTabs = [self numberOfOpenTabs]; if (numberOfOpenTabs > 1) { bool isClosingLastTab = index == numberOfOpenTabs - 1; @@ -1567,12 +1568,14 @@ private: // Either insert a new tab or open in a current tab. switch (disposition) { case NEW_FOREGROUND_TAB: - UserMetrics::RecordAction("Tab_DropURLBetweenTabs", browser_->profile()); + UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs"), + browser_->profile()); browser_->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, index, true, NULL); break; case CURRENT_TAB: - UserMetrics::RecordAction("Tab_DropURLOnTab", browser_->profile()); + UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLOnTab"), + browser_->profile()); tabStripModel_->GetTabContentsAt(index)->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); tabStripModel_->SelectTabContentsAt(index, true); diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index fd4a48b..1b675d6 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -996,7 +996,8 @@ void BookmarkBarGtk::OnClicked(GtkWidget* sender) { gtk_util::DispositionForCurrentButtonPressEvent(), PageTransition::AUTO_BOOKMARK); - UserMetrics::RecordAction("ClickedBookmarkBarURLButton", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton"), + profile_); } void BookmarkBarGtk::OnButtonDragBegin(GtkWidget* button, diff --git a/chrome/browser/gtk/bookmark_bubble_gtk.cc b/chrome/browser/gtk/bookmark_bubble_gtk.cc index 3e09a4a..19c7374 100644 --- a/chrome/browser/gtk/bookmark_bubble_gtk.cc +++ b/chrome/browser/gtk/bookmark_bubble_gtk.cc @@ -287,7 +287,8 @@ void BookmarkBubbleGtk::OnNameActivate(GtkWidget* widget) { void BookmarkBubbleGtk::OnFolderChanged(GtkWidget* widget) { size_t cur_folder = gtk_combo_box_get_active(GTK_COMBO_BOX(folder_combo_)); if (cur_folder == folder_nodes_.size()) { - UserMetrics::RecordAction("BookmarkBubble_EditFromCombobox", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_EditFromCombobox"), profile_); // GTK doesn't handle having the combo box destroyed from the changed // signal. Since showing the editor also closes the bubble, delay this // so that GTK can unwind. Specifically gtk_menu_shell_button_release @@ -310,7 +311,8 @@ void BookmarkBubbleGtk::OnFolderPopupShown(GtkWidget* widget, } void BookmarkBubbleGtk::OnEditClicked(GtkWidget* widget) { - UserMetrics::RecordAction("BookmarkBubble_Edit", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Edit"), + profile_); ShowEditor(); } @@ -319,7 +321,8 @@ void BookmarkBubbleGtk::OnCloseClicked(GtkWidget* widget) { } void BookmarkBubbleGtk::OnRemoveClicked(GtkWidget* widget) { - UserMetrics::RecordAction("BookmarkBubble_Unstar", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"), + profile_); apply_edits_ = false; remove_bookmark_ = true; @@ -340,8 +343,9 @@ void BookmarkBubbleGtk::ApplyEdits() { if (new_title != node->GetTitle()) { model->SetTitle(node, new_title); - UserMetrics::RecordAction("BookmarkBubble_ChangeTitleInBubble", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"), + profile_); } size_t cur_folder = gtk_combo_box_get_active(GTK_COMBO_BOX(folder_combo_)); @@ -350,7 +354,8 @@ void BookmarkBubbleGtk::ApplyEdits() { if (cur_folder < folder_nodes_.size()) { const BookmarkNode* new_parent = folder_nodes_[cur_folder]; if (new_parent != node->GetParent()) { - UserMetrics::RecordAction("BookmarkBubble_ChangeParent", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_ChangeParent"), profile_); model->Move(node, new_parent, new_parent->GetChildCount()); } } diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index d585ed5..9a1f01b 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -295,8 +295,9 @@ void DownloadSection::OnDownloadLocationChanged(GtkFileChooser* widget, // metric if something actually changed. if (path.ToWStringHack() != section->default_download_location_.GetValue()) { section->default_download_location_.SetValue(path.ToWStringHack()); - section->UserMetricsRecordAction("Options_SetDownloadDirectory", - section->profile()->GetPrefs()); + section->UserMetricsRecordAction( + UserMetricsAction("Options_SetDownloadDirectory"), + section->profile()->GetPrefs()); } } @@ -307,11 +308,13 @@ void DownloadSection::OnDownloadAskForSaveLocationChanged( return; bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if (enabled) { - section->UserMetricsRecordAction("Options_AskForSaveLocation_Enable", - section->profile()->GetPrefs()); + section->UserMetricsRecordAction( + UserMetricsAction("Options_AskForSaveLocation_Enable"), + section->profile()->GetPrefs()); } else { - section->UserMetricsRecordAction("Options_AskForSaveLocation_Disable", - section->profile()->GetPrefs()); + section->UserMetricsRecordAction( + UserMetricsAction("Options_AskForSaveLocation_Disable"), + section->profile()->GetPrefs()); } section->ask_for_save_location_.SetValue(enabled); } @@ -320,8 +323,9 @@ void DownloadSection::OnDownloadAskForSaveLocationChanged( void DownloadSection::OnResetFileHandlersClicked(GtkButton *button, DownloadSection* section) { section->profile()->GetDownloadManager()->ResetAutoOpenFiles(); - section->UserMetricsRecordAction("Options_ResetAutoOpenFiles", - section->profile()->GetPrefs()); + section->UserMetricsRecordAction( + UserMetricsAction("Options_ResetAutoOpenFiles"), + section->profile()->GetPrefs()); } /////////////////////////////////////////////////////////////////////////////// @@ -386,7 +390,8 @@ NetworkSection::NetworkSection(Profile* profile) // static void NetworkSection::OnChangeProxiesButtonClicked(GtkButton *button, NetworkSection* section) { - section->UserMetricsRecordAction("Options_ChangeProxies", NULL); + section->UserMetricsRecordAction(UserMetricsAction("Options_ChangeProxies"), + NULL); scoped_ptr<base::EnvironmentVariableGetter> env_getter( base::EnvironmentVariableGetter::Create()); @@ -547,7 +552,9 @@ void TranslateSection::OnTranslateClicked(GtkWidget* widget) { return; bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); UserMetricsRecordAction( - enabled ? "Options_Translate_Enable" : "Options_Translate_Disable", + enabled ? + UserMetricsAction("Options_Translate_Enable") : + UserMetricsAction("Options_Translate_Disable"), profile()->GetPrefs()); enable_translate_.SetValue(enabled); } @@ -761,8 +768,8 @@ void PrivacySection::OnEnableLinkDoctorChange(GtkWidget* widget, bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); privacy_section->UserMetricsRecordAction( enabled ? - "Options_LinkDoctorCheckbox_Enable" : - "Options_LinkDoctorCheckbox_Disable", + UserMetricsAction("Options_LinkDoctorCheckbox_Enable") : + UserMetricsAction("Options_LinkDoctorCheckbox_Disable"), privacy_section->profile()->GetPrefs()); privacy_section->alternate_error_pages_.SetValue(enabled); } @@ -775,8 +782,8 @@ void PrivacySection::OnEnableSuggestChange(GtkWidget* widget, bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); privacy_section->UserMetricsRecordAction( enabled ? - "Options_UseSuggestCheckbox_Enable" : - "Options_UseSuggestCheckbox_Disable", + UserMetricsAction("Options_UseSuggestCheckbox_Enable") : + UserMetricsAction("Options_UseSuggestCheckbox_Disable"), privacy_section->profile()->GetPrefs()); privacy_section->use_suggest_.SetValue(enabled); } @@ -789,8 +796,8 @@ void PrivacySection::OnDNSPrefetchingChange(GtkWidget* widget, bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); privacy_section->UserMetricsRecordAction( enabled ? - "Options_DnsPrefetchCheckbox_Enable" : - "Options_DnsPrefetchCheckbox_Disable", + UserMetricsAction("Options_DnsPrefetchCheckbox_Enable") : + UserMetricsAction("Options_DnsPrefetchCheckbox_Disable"), privacy_section->profile()->GetPrefs()); privacy_section->dns_prefetch_enabled_.SetValue(enabled); chrome_browser_net::EnableDnsPrefetch(enabled); @@ -804,8 +811,8 @@ void PrivacySection::OnSafeBrowsingChange(GtkWidget* widget, bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); privacy_section->UserMetricsRecordAction( enabled ? - "Options_SafeBrowsingCheckbox_Enable" : - "Options_SafeBrowsingCheckbox_Disable", + UserMetricsAction("Options_SafeBrowsingCheckbox_Enable") : + UserMetricsAction("Options_SafeBrowsingCheckbox_Disable"), privacy_section->profile()->GetPrefs()); privacy_section->safe_browsing_.SetValue(enabled); SafeBrowsingService* safe_browsing_service = @@ -822,8 +829,8 @@ void PrivacySection::OnLoggingChange(GtkWidget* widget, bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); privacy_section->UserMetricsRecordAction( enabled ? - "Options_MetricsReportingCheckbox_Enable" : - "Options_MetricsReportingCheckbox_Disable", + UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : + UserMetricsAction("Options_MetricsReportingCheckbox_Disable"), privacy_section->profile()->GetPrefs()); // Prevent us from being called again by ResolveMetricsReportingEnabled // resetting the checkbox if there was a problem. @@ -1046,11 +1053,13 @@ void SecuritySection::OnRevCheckingEnabledToggled(GtkToggleButton* togglebutton, bool enabled = gtk_toggle_button_get_active(togglebutton); if (enabled) { - section->UserMetricsRecordAction("Options_CheckCertRevocation_Enable", - NULL); + section->UserMetricsRecordAction( + UserMetricsAction("Options_CheckCertRevocation_Enable"), + NULL); } else { - section->UserMetricsRecordAction("Options_CheckCertRevocation_Disable", - NULL); + section->UserMetricsRecordAction( + UserMetricsAction("Options_CheckCertRevocation_Disable"), + NULL); } section->rev_checking_enabled_.SetValue(enabled); } @@ -1063,9 +1072,11 @@ void SecuritySection::OnSSL2EnabledToggled(GtkToggleButton* togglebutton, bool enabled = gtk_toggle_button_get_active(togglebutton); if (enabled) { - section->UserMetricsRecordAction("Options_SSL2_Enable", NULL); + section->UserMetricsRecordAction(UserMetricsAction("Options_SSL2_Enable"), + NULL); } else { - section->UserMetricsRecordAction("Options_SSL2_Disable", NULL); + section->UserMetricsRecordAction(UserMetricsAction("Options_SSL2_Disable"), + NULL); } section->ssl2_enabled_.SetValue(enabled); } @@ -1078,9 +1089,11 @@ void SecuritySection::OnSSL3EnabledToggled(GtkToggleButton* togglebutton, bool enabled = gtk_toggle_button_get_active(togglebutton); if (enabled) { - section->UserMetricsRecordAction("Options_SSL3_Enable", NULL); + section->UserMetricsRecordAction(UserMetricsAction("Options_SSL3_Enable"), + NULL); } else { - section->UserMetricsRecordAction("Options_SSL3_Disable", NULL); + section->UserMetricsRecordAction(UserMetricsAction("Options_SSL3_Disable"), + NULL); } section->ssl3_enabled_.SetValue(enabled); } @@ -1093,9 +1106,11 @@ void SecuritySection::OnTLS1EnabledToggled(GtkToggleButton* togglebutton, bool enabled = gtk_toggle_button_get_active(togglebutton); if (enabled) { - section->UserMetricsRecordAction("Options_TLS1_Enable", NULL); + section->UserMetricsRecordAction(UserMetricsAction("Options_TLS1_Enable"), + NULL); } else { - section->UserMetricsRecordAction("Options_TLS1_Disable", NULL); + section->UserMetricsRecordAction(UserMetricsAction("Options_TLS1_Disable"), + NULL); } section->tls1_enabled_.SetValue(enabled); } diff --git a/chrome/browser/gtk/options/advanced_page_gtk.cc b/chrome/browser/gtk/options/advanced_page_gtk.cc index c09d27e..8efb338 100644 --- a/chrome/browser/gtk/options/advanced_page_gtk.cc +++ b/chrome/browser/gtk/options/advanced_page_gtk.cc @@ -47,7 +47,7 @@ void AdvancedPageGtk::Init() { } void AdvancedPageGtk::OnResetToDefaultsClicked(GtkWidget* button) { - UserMetricsRecordAction("Options_ResetToDefaults", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ResetToDefaults"), NULL); GtkWidget* dialog_ = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(page_)), static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL), diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc index 26951ac..45ccd26 100644 --- a/chrome/browser/gtk/options/content_page_gtk.cc +++ b/chrome/browser/gtk/options/content_page_gtk.cc @@ -422,17 +422,20 @@ void ContentPageGtk::OnImportButtonClicked(GtkWidget* widget) { } void ContentPageGtk::OnGtkThemeButtonClicked(GtkWidget* widget) { - UserMetricsRecordAction("Options_GtkThemeSet", profile()->GetPrefs()); + UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet"), + profile()->GetPrefs()); profile()->SetNativeTheme(); } void ContentPageGtk::OnResetDefaultThemeButtonClicked(GtkWidget* widget) { - UserMetricsRecordAction("Options_ThemesReset", profile()->GetPrefs()); + UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"), + profile()->GetPrefs()); profile()->ClearTheme(); } void ContentPageGtk::OnGetThemesButtonClicked(GtkWidget* widget) { - UserMetricsRecordAction("Options_ThemesGallery", profile()->GetPrefs()); + UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"), + profile()->GetPrefs()); BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate(); } @@ -450,10 +453,10 @@ void ContentPageGtk::OnSystemTitleBarRadioToggled(GtkWidget* widget) { bool use_custom = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(system_title_bar_hide_radio_)); if (use_custom) { - UserMetricsRecordAction("Options_CustomFrame_Enable", + UserMetricsRecordAction(UserMetricsAction("Options_CustomFrame_Enable"), profile()->GetPrefs()); } else { - UserMetricsRecordAction("Options_CustomFrame_Disable", + UserMetricsRecordAction(UserMetricsAction("Options_CustomFrame_Disable"), profile()->GetPrefs()); } @@ -477,11 +480,12 @@ void ContentPageGtk::OnPasswordRadioToggled(GtkWidget* widget) { bool enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(passwords_asktosave_radio_)); if (enabled) { - UserMetricsRecordAction("Options_PasswordManager_Enable", - profile()->GetPrefs()); - } else { - UserMetricsRecordAction("Options_PasswordManager_Disable", + UserMetricsRecordAction(UserMetricsAction("Options_PasswordManager_Enable"), profile()->GetPrefs()); + } else { + UserMetricsRecordAction( + UserMetricsAction("Options_PasswordManager_Disable"), + profile()->GetPrefs()); } ask_to_save_passwords_.SetValue(enabled); } @@ -499,11 +503,11 @@ void ContentPageGtk::OnAutoFillRadioToggled(GtkWidget* widget) { bool enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(form_autofill_enable_radio_)); if (enabled) { - UserMetricsRecordAction("Options_FormAutofill_Enable", - profile()->GetPrefs()); + UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Enable"), + profile()->GetPrefs()); gtk_widget_set_sensitive(autofill_button_, TRUE); } else { - UserMetricsRecordAction("Options_FormAutofill_Disable", + UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Disable"), profile()->GetPrefs()); gtk_widget_set_sensitive(autofill_button_, FALSE); } diff --git a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc index 512dd22..726c1f3 100644 --- a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc +++ b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc @@ -192,7 +192,7 @@ void CookieFilterPageGtk::OnClearOnCloseToggled(GtkWidget* toggle_button) { } void CookieFilterPageGtk::OnShowCookiesClicked(GtkWidget* button) { - UserMetricsRecordAction("Options_ShowCookies", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ShowCookies"), NULL); CookiesView::Show(GTK_WINDOW(gtk_widget_get_toplevel(button)), profile(), new BrowsingDataDatabaseHelper( diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc index 15db49f..3aaba5c 100644 --- a/chrome/browser/gtk/options/general_page_gtk.cc +++ b/chrome/browser/gtk/options/general_page_gtk.cc @@ -394,13 +394,13 @@ void GeneralPageGtk::OnStartupRadioToggled(GtkWidget* toggle_button) { } SaveStartupPref(); if (toggle_button == startup_homepage_radio_) { - UserMetricsRecordAction("Options_Startup_Homepage", + UserMetricsRecordAction(UserMetricsAction("Options_Startup_Homepage"), profile()->GetPrefs()); } else if (toggle_button == startup_last_session_radio_) { - UserMetricsRecordAction("Options_Startup_LastSession", + UserMetricsRecordAction(UserMetricsAction("Options_Startup_LastSession"), profile()->GetPrefs()); } else if (toggle_button == startup_custom_radio_) { - UserMetricsRecordAction("Options_Startup_Custom", + UserMetricsRecordAction(UserMetricsAction("Options_Startup_Custom"), profile()->GetPrefs()); } } @@ -435,12 +435,12 @@ void GeneralPageGtk::OnNewTabIsHomePageToggled(GtkWidget* toggle_button) { } if (toggle_button == homepage_use_newtab_radio_) { SetHomepage(GURL()); - UserMetricsRecordAction("Options_Homepage_UseNewTab", + UserMetricsRecordAction(UserMetricsAction("Options_Homepage_UseNewTab"), profile()->GetPrefs()); gtk_widget_set_sensitive(homepage_use_url_entry_, FALSE); } else if (toggle_button == homepage_use_url_radio_) { SetHomepageFromEntry(); - UserMetricsRecordAction("Options_Homepage_UseURL", + UserMetricsRecordAction(UserMetricsAction("Options_Homepage_UseURL"), profile()->GetPrefs()); gtk_widget_set_sensitive(homepage_use_url_entry_, TRUE); } @@ -458,11 +458,13 @@ void GeneralPageGtk::OnShowHomeButtonToggled(GtkWidget* toggle_button) { bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button)); show_home_button_.SetValue(enabled); if (enabled) { - UserMetricsRecordAction("Options_Homepage_ShowHomeButton", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_Homepage_ShowHomeButton"), + profile()->GetPrefs()); } else { - UserMetricsRecordAction("Options_Homepage_HideHomeButton", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_Homepage_HideHomeButton"), + profile()->GetPrefs()); } } @@ -481,7 +483,7 @@ void GeneralPageGtk::OnBrowserUseAsDefaultClicked(GtkWidget* button) { // If the user made Chrome the default browser, then he/she arguably wants // to be notified when that changes. profile()->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true); - UserMetricsRecordAction("Options_SetAsDefaultBrowser", + UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"), profile()->GetPrefs()); } diff --git a/chrome/browser/gtk/options/languages_page_gtk.cc b/chrome/browser/gtk/options/languages_page_gtk.cc index 543538f..506c263 100644 --- a/chrome/browser/gtk/options/languages_page_gtk.cc +++ b/chrome/browser/gtk/options/languages_page_gtk.cc @@ -453,7 +453,7 @@ void LanguagesPageGtk::OnDictionaryLanguageChanged(GtkWidget* widget) { spellcheck_language_added_ = ""; } - UserMetricsRecordAction("Options_DictionaryLanguage", + UserMetricsRecordAction(UserMetricsAction("Options_DictionaryLanguage"), profile()->GetPrefs()); dictionary_language_.SetValue(ASCIIToWide(language)); } diff --git a/chrome/browser/metrics/user_metrics.cc b/chrome/browser/metrics/user_metrics.cc index 79b4dee..3bdb544 100644 --- a/chrome/browser/metrics/user_metrics.cc +++ b/chrome/browser/metrics/user_metrics.cc @@ -6,14 +6,21 @@ #include "chrome/browser/profile.h" #include "chrome/common/notification_service.h" -void UserMetrics::RecordAction(const char* action, Profile* profile) { - NotificationService::current()->Notify( - NotificationType::USER_ACTION, - Source<Profile>(profile), - Details<const char*>(&action)); +void UserMetrics::RecordAction(const UserMetricsAction& action, + Profile* profile) { + Record(action.str_, profile); } void UserMetrics::RecordComputedAction(const std::string& action, Profile* profile) { - RecordAction(action.c_str(), profile); + Record(action.c_str(), profile); } + +void UserMetrics::Record(const char *action, Profile *profile) { + NotificationService::current()->Notify(NotificationType::USER_ACTION, + Source<Profile>(profile), + Details<const char*>(&action)); +} + + + diff --git a/chrome/browser/metrics/user_metrics.h b/chrome/browser/metrics/user_metrics.h index 4329fcc..6b7c0d3 100644 --- a/chrome/browser/metrics/user_metrics.h +++ b/chrome/browser/metrics/user_metrics.h @@ -12,6 +12,17 @@ class Profile; // This module provides some helper functions for logging actions tracked by // the user metrics system. + +// UserMetricsAction exist purely to standardize on the paramters passed to +// UserMetrics. That way, our toolset can scan the sourcecode reliable for +// constructors and extract the associated string constants +struct UserMetricsAction { + const char* str_; + explicit UserMetricsAction(const char* str) : str_(str) {} +}; + + + class UserMetrics { public: // Record that the user performed an action. @@ -27,7 +38,7 @@ class UserMetrics { // // For more complicated situations (like when there are many different // possible actions), see RecordComputedAction. - static void RecordAction(const char* action, Profile* profile); + static void RecordAction(const UserMetricsAction& action, Profile* profile); // This function has identical input and behavior to RecordAction, but is // not automatically found by the action-processing scripts. It can be used @@ -35,6 +46,9 @@ class UserMetrics { // you need to also update the rules for extracting known actions. static void RecordComputedAction(const std::string& action, Profile* profile); + + private: + static void Record(const char *action, Profile *profile); }; #endif // CHROME_BROWSER_METRICS_USER_METRICS_H_ diff --git a/chrome/browser/options_page_base.cc b/chrome/browser/options_page_base.cc index f46b74e..260fb5b 100644 --- a/chrome/browser/options_page_base.cc +++ b/chrome/browser/options_page_base.cc @@ -18,9 +18,9 @@ OptionsPageBase::OptionsPageBase(Profile* profile) OptionsPageBase::~OptionsPageBase() { } -void OptionsPageBase::UserMetricsRecordAction(const char* action, +void OptionsPageBase::UserMetricsRecordAction(const UserMetricsAction& action, PrefService* prefs) { - UserMetrics::RecordComputedAction(action, profile()); + UserMetrics::RecordAction(action, profile()); if (prefs) prefs->ScheduleSavePersistentPrefs(); } diff --git a/chrome/browser/options_page_base.h b/chrome/browser/options_page_base.h index fee43d0..013a26c 100644 --- a/chrome/browser/options_page_base.h +++ b/chrome/browser/options_page_base.h @@ -10,9 +10,11 @@ #include "base/basictypes.h" #include "chrome/browser/options_window.h" #include "chrome/common/notification_observer.h" +#include "chrome/browser/metrics/user_metrics.h" class PrefService; class Profile; +struct UserMetricsAction; /////////////////////////////////////////////////////////////////////////////// // OptionsPageBase @@ -40,7 +42,8 @@ class OptionsPageBase : public NotificationObserver { Profile* profile() const { return profile_; } // Records a user action and schedules the prefs file to be saved. - void UserMetricsRecordAction(const char* action, PrefService* prefs); + void UserMetricsRecordAction(const UserMetricsAction &action, + PrefService* prefs); // Allows the UI to update when a preference value changes. The parameter is // the specific pref that changed, or NULL if all pref UI should be diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index ed12fda..548410b 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -1467,7 +1467,7 @@ void RenderViewHost::OnDevToolsRuntimeFeatureStateChanged( } void RenderViewHost::OnUserMetricsRecordAction(const std::string& action) { - UserMetrics::RecordComputedAction(action.c_str(), process()->profile()); + UserMetrics::RecordComputedAction(action, process()->profile()); } bool RenderViewHost::PreHandleKeyboardEvent( diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index b413239..96b314c 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -36,6 +36,7 @@ struct ViewHostMsg_DidPrintPage_Params; struct ViewMsg_Navigate_Params; struct WebDropData; struct WebPreferences; +struct UserMetricsAction; namespace gfx { class Point; diff --git a/chrome/browser/search_engines/edit_search_engine_controller.cc b/chrome/browser/search_engines/edit_search_engine_controller.cc index 58fb95b..f79bce1 100644 --- a/chrome/browser/search_engines/edit_search_engine_controller.cc +++ b/chrome/browser/search_engines/edit_search_engine_controller.cc @@ -100,7 +100,8 @@ void EditSearchEngineController::AcceptAddOrEdit( modifiable_url->SetURL(url_string, 0, 0); // TemplateURLModel takes ownership of template_url_. profile_->GetTemplateURLModel()->Add(modifiable_url); - UserMetrics::RecordAction("KeywordEditor_AddKeywordJS", profile_); + UserMetrics::RecordAction(UserMetricsAction("KeywordEditor_AddKeywordJS"), + profile_); } else { // Adding or modifying an entry via the Delegate. edit_keyword_delegate_->OnEditedKeyword(template_url_, diff --git a/chrome/browser/search_engines/keyword_editor_controller.cc b/chrome/browser/search_engines/keyword_editor_controller.cc index 997f37c..3e8ff11 100644 --- a/chrome/browser/search_engines/keyword_editor_controller.cc +++ b/chrome/browser/search_engines/keyword_editor_controller.cc @@ -32,7 +32,8 @@ int KeywordEditorController::AddTemplateURL(const std::wstring& title, const std::wstring& url) { DCHECK(!url.empty()); - UserMetrics::RecordAction("KeywordEditor_AddKeyword", profile_); + UserMetrics::RecordAction(UserMetricsAction("KeywordEditor_AddKeyword"), + profile_); TemplateURL* template_url = new TemplateURL(); template_url->set_short_name(title); @@ -72,7 +73,8 @@ void KeywordEditorController::ModifyTemplateURL(const TemplateURL* template_url, table_model_->ModifyTemplateURL(index, title, keyword, url); - UserMetrics::RecordAction("KeywordEditor_ModifiedKeyword", profile_); + UserMetrics::RecordAction(UserMetricsAction("KeywordEditor_ModifiedKeyword"), + profile_); } bool KeywordEditorController::CanMakeDefault(const TemplateURL* url) const { @@ -87,7 +89,8 @@ bool KeywordEditorController::CanRemove(const TemplateURL* url) const { void KeywordEditorController::RemoveTemplateURL(int index) { table_model_->Remove(index); - UserMetrics::RecordAction("KeywordEditor_RemoveKeyword", profile_); + UserMetrics::RecordAction(UserMetricsAction("KeywordEditor_RemoveKeyword"), + profile_); } int KeywordEditorController::MakeDefaultTemplateURL(int index) { diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 30f7e32..1011fa9 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -923,35 +923,40 @@ void RenderViewContextMenu::ExecuteItemCommand(int id) { break; case IDS_CONTENT_CONTEXT_PLAY: - UserMetrics::RecordAction("MediaContextMenu_Play", profile_); + UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Play"), + profile_); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), WebMediaPlayerAction( WebMediaPlayerAction::Play, true)); break; case IDS_CONTENT_CONTEXT_PAUSE: - UserMetrics::RecordAction("MediaContextMenu_Pause", profile_); + UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Pause"), + profile_); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), WebMediaPlayerAction( WebMediaPlayerAction::Play, false)); break; case IDS_CONTENT_CONTEXT_MUTE: - UserMetrics::RecordAction("MediaContextMenu_Mute", profile_); + UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Mute"), + profile_); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), WebMediaPlayerAction( WebMediaPlayerAction::Mute, true)); break; case IDS_CONTENT_CONTEXT_UNMUTE: - UserMetrics::RecordAction("MediaContextMenu_Unmute", profile_); + UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Unmute"), + profile_); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), WebMediaPlayerAction( WebMediaPlayerAction::Mute, false)); break; case IDS_CONTENT_CONTEXT_LOOP: - UserMetrics::RecordAction("MediaContextMenu_Loop", profile_); + UserMetrics::RecordAction(UserMetricsAction("MediaContextMenu_Loop"), + profile_); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), WebMediaPlayerAction( WebMediaPlayerAction::Loop, @@ -1204,7 +1209,8 @@ void RenderViewContextMenu::CopyImageAt(int x, int y) { } void RenderViewContextMenu::Inspect(int x, int y) { - UserMetrics::RecordAction("DevTools_InspectElement", profile_); + UserMetrics::RecordAction(UserMetricsAction("DevTools_InspectElement"), + profile_); DevToolsManager::GetInstance()->InspectElement( source_tab_contents_->render_view_host(), x, y); } diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 2fba4b5..ebebb463 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -588,23 +588,29 @@ void TabStripModel::ExecuteContextMenuCommand( DCHECK(command_id > CommandFirst && command_id < CommandLast); switch (command_id) { case CommandNewTab: - UserMetrics::RecordAction("TabContextMenu_NewTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("TabContextMenu_NewTab"), + profile_); delegate()->AddBlankTabAt(context_index + 1, true); break; case CommandReload: - UserMetrics::RecordAction("TabContextMenu_Reload", profile_); + UserMetrics::RecordAction(UserMetricsAction("TabContextMenu_Reload"), + profile_); GetContentsAt(context_index)->controller().Reload(true); break; case CommandDuplicate: - UserMetrics::RecordAction("TabContextMenu_Duplicate", profile_); + UserMetrics::RecordAction(UserMetricsAction("TabContextMenu_Duplicate"), + profile_); delegate_->DuplicateContentsAt(context_index); break; case CommandCloseTab: - UserMetrics::RecordAction("TabContextMenu_CloseTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("TabContextMenu_CloseTab"), + profile_); CloseTabContentsAt(context_index); break; case CommandCloseOtherTabs: { - UserMetrics::RecordAction("TabContextMenu_CloseOtherTabs", profile_); + UserMetrics::RecordAction( + UserMetricsAction("TabContextMenu_CloseOtherTabs"), + profile_); TabContents* contents = GetTabContentsAt(context_index); std::vector<int> closing_tabs; for (int i = count() - 1; i >= 0; --i) { @@ -615,7 +621,9 @@ void TabStripModel::ExecuteContextMenuCommand( break; } case CommandCloseTabsToRight: { - UserMetrics::RecordAction("TabContextMenu_CloseTabsToRight", profile_); + UserMetrics::RecordAction( + UserMetricsAction("TabContextMenu_CloseTabsToRight"), + profile_); std::vector<int> closing_tabs; for (int i = count() - 1; i > context_index; --i) { if (!IsMiniTab(i)) @@ -625,7 +633,9 @@ void TabStripModel::ExecuteContextMenuCommand( break; } case CommandCloseTabsOpenedBy: { - UserMetrics::RecordAction("TabContextMenu_CloseTabsOpenedBy", profile_); + UserMetrics::RecordAction( + UserMetricsAction("TabContextMenu_CloseTabsOpenedBy"), + profile_); std::vector<int> closing_tabs = GetIndexesOpenedBy(context_index); for (std::vector<int>::iterator i = closing_tabs.begin(); i != closing_tabs.end();) { @@ -638,12 +648,15 @@ void TabStripModel::ExecuteContextMenuCommand( break; } case CommandRestoreTab: { - UserMetrics::RecordAction("TabContextMenu_RestoreTab", profile_); + UserMetrics::RecordAction(UserMetricsAction("TabContextMenu_RestoreTab"), + profile_); delegate_->RestoreTab(); break; } case CommandTogglePinned: { - UserMetrics::RecordAction("TabContextMenu_TogglePinned", profile_); + UserMetrics::RecordAction( + UserMetricsAction("TabContextMenu_TogglePinned"), + profile_); SelectTabContentsAt(context_index, true); SetTabPinned(context_index, !IsTabPinned(context_index)); @@ -651,7 +664,9 @@ void TabStripModel::ExecuteContextMenuCommand( } case CommandBookmarkAllTabs: { - UserMetrics::RecordAction("TabContextMenu_BookmarkAllTabs", profile_); + UserMetrics::RecordAction( + UserMetricsAction("TabContextMenu_BookmarkAllTabs"), + profile_); delegate_->BookmarkAllTabs(); break; diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index 331ba14..a698d21 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -829,19 +829,21 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, switch (result) { case UPGRADE_STARTED: - UserMetrics::RecordAction("Upgrade_Started", profile_); + UserMetrics::RecordAction(UserMetricsAction("Upgrade_Started"), profile_); check_button_status_ = CHECKBUTTON_DISABLED; show_throbber = true; update_label_.SetText(l10n_util::GetString(IDS_UPGRADE_STARTED)); break; case UPGRADE_CHECK_STARTED: - UserMetrics::RecordAction("UpgradeCheck_Started", profile_); + UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Started"), + profile_); check_button_status_ = CHECKBUTTON_HIDDEN; show_throbber = true; update_label_.SetText(l10n_util::GetString(IDS_UPGRADE_CHECK_STARTED)); break; case UPGRADE_IS_AVAILABLE: - UserMetrics::RecordAction("UpgradeCheck_UpgradeIsAvailable", profile_); + UserMetrics::RecordAction( + UserMetricsAction("UpgradeCheck_UpgradeIsAvailable"), profile_); check_button_status_ = CHECKBUTTON_ENABLED; update_label_.SetText( l10n_util::GetStringF(IDS_UPGRADE_AVAILABLE, @@ -865,7 +867,8 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, if (!installed_version.get() || !installed_version->IsHigherThan(running_version.get())) { #endif - UserMetrics::RecordAction("UpgradeCheck_AlreadyUpToDate", profile_); + UserMetrics::RecordAction( + UserMetricsAction("UpgradeCheck_AlreadyUpToDate"), profile_); check_button_status_ = CHECKBUTTON_HIDDEN; std::wstring update_label_text = l10n_util::GetStringF(IDS_UPGRADE_ALREADY_UP_TO_DATE, @@ -885,9 +888,11 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, } case UPGRADE_SUCCESSFUL: { if (result == UPGRADE_ALREADY_UP_TO_DATE) - UserMetrics::RecordAction("UpgradeCheck_AlreadyUpgraded", profile_); + UserMetrics::RecordAction( + UserMetricsAction("UpgradeCheck_AlreadyUpgraded"), profile_); else - UserMetrics::RecordAction("UpgradeCheck_Upgraded", profile_); + UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded"), + profile_); check_button_status_ = CHECKBUTTON_HIDDEN; const std::wstring& update_string = new_version_available_.empty() ? l10n_util::GetStringF(IDS_UPGRADE_SUCCESSFUL_NOVERSION, @@ -905,7 +910,8 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, break; } case UPGRADE_ERROR: - UserMetrics::RecordAction("UpgradeCheck_Error", profile_); + UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Error"), + profile_); check_button_status_ = CHECKBUTTON_HIDDEN; update_label_.SetText(l10n_util::GetStringF(IDS_UPGRADE_ERROR, IntToWString(error_code))); diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 03a4a9c..a887487 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -1098,7 +1098,8 @@ void BookmarkBarView::BookmarkNodeFavIconLoaded(BookmarkModel* model, void BookmarkBarView::WriteDragData(View* sender, const gfx::Point& press_pt, OSExchangeData* data) { - UserMetrics::RecordAction("BookmarkBar_DragButton", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragButton"), + profile_); for (int i = 0; i < GetBookmarkButtonCount(); ++i) { if (sender == GetBookmarkButton(i)) { @@ -1217,7 +1218,8 @@ void BookmarkBarView::ButtonPressed(views::Button* sender, bookmark_utils::OpenAll(GetWindow()->GetNativeWindow(), profile_, GetPageNavigator(), node, disposition_from_event_flags); } - UserMetrics::RecordAction("ClickedBookmarkBarURLButton", profile_); + UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton"), + profile_); } void BookmarkBarView::ShowContextMenu(View* source, diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc index ef9d5a4..ec4db98 100644 --- a/chrome/browser/views/bookmark_bubble_view.cc +++ b/chrome/browser/views/bookmark_bubble_view.cc @@ -331,7 +331,8 @@ void BookmarkBubbleView::ButtonPressed( void BookmarkBubbleView::LinkActivated(Link* source, int event_flags) { DCHECK(source == remove_link_); - UserMetrics::RecordAction("BookmarkBubble_Unstar", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"), + profile_); // Set this so we remove the bookmark after the window closes. remove_bookmark_ = true; @@ -344,7 +345,8 @@ void BookmarkBubbleView::ItemChanged(Combobox* combobox, int prev_index, int new_index) { if (new_index + 1 == parent_model_.GetItemCount()) { - UserMetrics::RecordAction("BookmarkBubble_EditFromCombobox", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_EditFromCombobox"), profile_); ShowEditor(); return; @@ -381,7 +383,8 @@ void BookmarkBubbleView::Close() { void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { if (sender == edit_button_) { - UserMetrics::RecordAction("BookmarkBubble_Edit", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Edit"), + profile_); ShowEditor(); } else { DCHECK(sender == close_button_); @@ -436,8 +439,9 @@ void BookmarkBubbleView::ApplyEdits() { const std::wstring new_title = UTF16ToWide(title_tf_->text()); if (new_title != node->GetTitle()) { model->SetTitle(node, new_title); - UserMetrics::RecordAction("BookmarkBubble_ChangeTitleInBubble", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"), + profile_); } // Last index means 'Choose another folder...' if (parent_combobox_->selected_item() < @@ -445,7 +449,8 @@ void BookmarkBubbleView::ApplyEdits() { const BookmarkNode* new_parent = parent_model_.GetNodeAt(parent_combobox_->selected_item()); if (new_parent != node->GetParent()) { - UserMetrics::RecordAction("BookmarkBubble_ChangeParent", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBubble_ChangeParent"), profile_); model->Move(node, new_parent, new_parent->GetChildCount()); } } diff --git a/chrome/browser/views/bookmark_context_menu_controller_views.cc b/chrome/browser/views/bookmark_context_menu_controller_views.cc index 9b8a8e8..1cae184 100644 --- a/chrome/browser/views/bookmark_context_menu_controller_views.cc +++ b/chrome/browser/views/bookmark_context_menu_controller_views.cc @@ -285,16 +285,19 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { WindowOpenDisposition initial_disposition; if (id == IDS_BOOMARK_BAR_OPEN_ALL) { initial_disposition = NEW_FOREGROUND_TAB; - UserMetrics::RecordAction("BookmarkBar_ContextMenu_OpenAll", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_OpenAll"), + profile_); } else if (id == IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW) { initial_disposition = NEW_WINDOW; - UserMetrics::RecordAction("BookmarkBar_ContextMenu_OpenAllInNewWindow", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_OpenAllInNewWindow"), + profile_); } else { initial_disposition = OFF_THE_RECORD; - UserMetrics::RecordAction("BookmarkBar_ContextMenu_OpenAllIncognito", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_OpenAllIncognito"), + profile_); } bookmark_utils::OpenAll(parent_window_, profile_, navigator_, selection_, initial_disposition); @@ -303,7 +306,8 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { case IDS_BOOKMARK_BAR_RENAME_FOLDER: case IDS_BOOKMARK_BAR_EDIT: - UserMetrics::RecordAction("BookmarkBar_ContextMenu_Edit", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_Edit"), profile_); if (selection_.size() != 1) { NOTREACHED(); @@ -326,7 +330,8 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { break; case IDS_BOOKMARK_BAR_REMOVE: { - UserMetrics::RecordAction("BookmarkBar_ContextMenu_Remove", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_Remove"), profile_); delegate_->WillRemoveBookmarks(selection_); for (size_t i = 0; i < selection_.size(); ++i) { @@ -339,7 +344,8 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { } case IDS_BOOMARK_BAR_ADD_NEW_BOOKMARK: { - UserMetrics::RecordAction("BookmarkBar_ContextMenu_Add", profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_Add"), profile_); BookmarkEditor::Configuration editor_config; BookmarkEditor::Handler* handler = NULL; @@ -357,8 +363,9 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { } case IDS_BOOMARK_BAR_NEW_FOLDER: { - UserMetrics::RecordAction("BookmarkBar_ContextMenu_NewFolder", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_NewFolder"), + profile_); EditFolderController::Show(profile_, parent_window_, GetParentForNewNodes(), true, configuration_ != BOOKMARK_BAR); @@ -370,8 +377,9 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { break; case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: - UserMetrics::RecordAction("BookmarkBar_ContextMenu_ShowInFolder", - profile_); + UserMetrics::RecordAction( + UserMetricsAction("BookmarkBar_ContextMenu_ShowInFolder"), + profile_); if (selection_.size() != 1) { NOTREACHED(); @@ -382,7 +390,8 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { break; case IDS_BOOKMARK_MANAGER: - UserMetrics::RecordAction("ShowBookmarkManager", profile_); + UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), + profile_); { Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); if (browser) @@ -393,7 +402,8 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { break; case IDS_BOOKMARK_MANAGER_SORT: - UserMetrics::RecordAction("BookmarkManager_Sort", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Sort"), + profile_); model->SortChildren(parent_); break; diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc index 43e3c75..2a99fdf 100644 --- a/chrome/browser/views/bookmark_manager_view.cc +++ b/chrome/browser/views/bookmark_manager_view.cc @@ -521,7 +521,8 @@ void BookmarkManagerView::ButtonPressed(views::Button* sender, DCHECK(sync_service_); sync_service_->ShowLoginDialog(); } else { - UserMetrics::RecordAction("BookmarkManager_Sync", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Sync"), + profile_); sync_ui_util::OpenSyncMyBookmarksDialog( profile_, ProfileSyncService::START_FROM_BOOKMARK_MANAGER); } @@ -585,12 +586,14 @@ void BookmarkManagerView::RunMenu(views::View* source, const gfx::Point& pt) { void BookmarkManagerView::ExecuteCommand(int id) { switch (id) { case IDS_BOOKMARK_MANAGER_IMPORT_MENU: - UserMetrics::RecordAction("BookmarkManager_Import", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Import"), + profile_); ShowImportBookmarksFileChooser(); break; case IDS_BOOKMARK_MANAGER_EXPORT_MENU: - UserMetrics::RecordAction("BookmarkManager_Export", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Export"), + profile_); ShowExportBookmarksFileChooser(); break; diff --git a/chrome/browser/views/bookmark_menu_button.cc b/chrome/browser/views/bookmark_menu_button.cc index fc4fd85..c16b7fc 100644 --- a/chrome/browser/views/bookmark_menu_button.cc +++ b/chrome/browser/views/bookmark_menu_button.cc @@ -129,7 +129,8 @@ void BookmarkMenuButton::RunMenu(views::View* source, bool for_drop) { Profile* profile = browser_->profile(); - UserMetrics::RecordAction("BookmarkMenu_clicked", profile); + UserMetrics::RecordAction(UserMetricsAction("BookmarkMenu_clicked"), + profile); BookmarkMenuController* menu = new BookmarkMenuController( browser_, profile, browser_->GetSelectedTabContents(), hwnd, diff --git a/chrome/browser/views/bookmark_menu_controller_views.cc b/chrome/browser/views/bookmark_menu_controller_views.cc index 2437d7f..a5b9b03 100644 --- a/chrome/browser/views/bookmark_menu_controller_views.cc +++ b/chrome/browser/views/bookmark_menu_controller_views.cc @@ -227,7 +227,8 @@ void BookmarkMenuController::WriteDragData(MenuItemView* sender, OSExchangeData* data) { DCHECK(sender && data); - UserMetrics::RecordAction("BookmarkBar_DragFromFolder", profile_); + UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragFromFolder"), + profile_); BookmarkDragData drag_data(menu_id_to_node_map_[sender->GetCommand()]); drag_data.Write(profile_, data); diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc index 913956b..b4f73b1 100644 --- a/chrome/browser/views/first_run_bubble.cc +++ b/chrome/browser/views/first_run_bubble.cc @@ -157,10 +157,13 @@ void FirstRunBubbleView::BubbleShown() { void FirstRunBubbleView::ButtonPressed(views::Button* sender, const views::Event& event) { - UserMetrics::RecordAction("FirstRunBubbleView_Clicked", profile_); + UserMetrics::RecordAction(UserMetricsAction("FirstRunBubbleView_Clicked"), + profile_); bubble_window_->Close(); if (change_button_ == sender) { - UserMetrics::RecordAction("FirstRunBubbleView_ChangeButton", profile_); + UserMetrics::RecordAction( + UserMetricsAction("FirstRunBubbleView_ChangeButton"), + profile_); Browser* browser = BrowserList::GetLastActive(); if (browser) { ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, @@ -310,7 +313,8 @@ void FirstRunOEMBubbleView::BubbleShown() { void FirstRunOEMBubbleView::ButtonPressed(views::Button* sender, const views::Event& event) { - UserMetrics::RecordAction("FirstRunOEMBubbleView_Clicked", profile_); + UserMetrics::RecordAction(UserMetricsAction("FirstRunOEMBubbleView_Clicked"), + profile_); bubble_window_->Close(); } diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc index aad06a7..263be85 100644 --- a/chrome/browser/views/first_run_customize_view.cc +++ b/chrome/browser/views/first_run_customize_view.cc @@ -199,15 +199,18 @@ bool FirstRunCustomizeView::Accept() { quick_shortcut_cbox_->SetEnabled(false); if (desktop_shortcut_cbox_->checked()) { - UserMetrics::RecordAction("FirstRunCustom_Do_DesktopShortcut", profile_); + UserMetrics::RecordAction( + UserMetricsAction("FirstRunCustom_Do_DesktopShortcut"), profile_); CreateDesktopShortcut(); } if (quick_shortcut_cbox_->checked()) { - UserMetrics::RecordAction("FirstRunCustom_Do_QuickLShortcut", profile_); + UserMetrics::RecordAction( + UserMetricsAction("FirstRunCustom_Do_QuickLShortcut"), profile_); CreateQuickLaunchShortcut(); } if (!import_cbox_->checked()) { - UserMetrics::RecordAction("FirstRunCustom_No_Import", profile_); + UserMetrics::RecordAction(UserMetricsAction("FirstRunCustom_No_Import"), + profile_); } else { int browser_selected = import_from_combo_->selected_item(); FirstRun::ImportSettings(profile_, diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc index 8a0ffe9..2ba4bcd 100644 --- a/chrome/browser/views/first_run_view.cc +++ b/chrome/browser/views/first_run_view.cc @@ -190,7 +190,7 @@ bool FirstRunView::Accept() { FirstRun::ImportSettings(profile_, importer_host_->GetSourceProfileInfoAt(0).browser_type, GetImportItems(), window()->GetNativeWindow()); - UserMetrics::RecordAction("FirstRunDef_Accept", profile_); + UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept"), profile_); if (default_browser_ && default_browser_->checked()) SetDefaultBrowser(); @@ -201,7 +201,7 @@ bool FirstRunView::Accept() { } bool FirstRunView::Cancel() { - UserMetrics::RecordAction("FirstRunDef_Cancel", profile_); + UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Cancel"), profile_); MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); return true; } @@ -215,5 +215,6 @@ void FirstRunView::CustomizeAccepted() { // Notification from the customize dialog that the user cancelled. void FirstRunView::CustomizeCanceled() { - UserMetrics::RecordAction("FirstRunCustom_Cancel", profile_); + UserMetrics::RecordAction(UserMetricsAction("FirstRunCustom_Cancel"), + profile_); } diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc index c29ab39..c83b20e 100644 --- a/chrome/browser/views/first_run_view_base.cc +++ b/chrome/browser/views/first_run_view_base.cc @@ -241,7 +241,8 @@ bool FirstRunViewBase::CreateQuickLaunchShortcut() { } bool FirstRunViewBase::SetDefaultBrowser() { - UserMetrics::RecordAction("FirstRun_Do_DefBrowser", profile_); + UserMetrics::RecordAction(UserMetricsAction("FirstRun_Do_DefBrowser"), + profile_); return ShellIntegration::SetAsDefaultBrowser(); } diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index 977c425..4594165 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -506,31 +506,31 @@ void PrivacySection::ButtonPressed( views::Button* sender, const views::Event& event) { if (sender == enable_link_doctor_checkbox_) { bool enabled = enable_link_doctor_checkbox_->checked(); - UserMetricsRecordAction(enabled ? + UserMetricsRecordAction(UserMetricsAction(enabled ? "Options_LinkDoctorCheckbox_Enable" : - "Options_LinkDoctorCheckbox_Disable", + "Options_LinkDoctorCheckbox_Disable"), profile()->GetPrefs()); alternate_error_pages_.SetValue(enabled); } else if (sender == enable_suggest_checkbox_) { bool enabled = enable_suggest_checkbox_->checked(); - UserMetricsRecordAction(enabled ? + UserMetricsRecordAction(UserMetricsAction(enabled ? "Options_UseSuggestCheckbox_Enable" : - "Options_UseSuggestCheckbox_Disable", + "Options_UseSuggestCheckbox_Disable"), profile()->GetPrefs()); use_suggest_.SetValue(enabled); } else if (sender == enable_dns_prefetching_checkbox_) { bool enabled = enable_dns_prefetching_checkbox_->checked(); - UserMetricsRecordAction(enabled ? + UserMetricsRecordAction(UserMetricsAction(enabled ? "Options_DnsPrefetchCheckbox_Enable" : - "Options_DnsPrefetchCheckbox_Disable", + "Options_DnsPrefetchCheckbox_Disable"), profile()->GetPrefs()); dns_prefetch_enabled_.SetValue(enabled); chrome_browser_net::EnableDnsPrefetch(enabled); } else if (sender == enable_safe_browsing_checkbox_) { bool enabled = enable_safe_browsing_checkbox_->checked(); - UserMetricsRecordAction(enabled ? + UserMetricsRecordAction(UserMetricsAction(enabled ? "Options_SafeBrowsingCheckbox_Enable" : - "Options_SafeBrowsingCheckbox_Disable", + "Options_SafeBrowsingCheckbox_Disable"), profile()->GetPrefs()); safe_browsing_.SetValue(enabled); SafeBrowsingService* safe_browsing_service = @@ -540,20 +540,20 @@ void PrivacySection::ButtonPressed( } else if (reporting_enabled_checkbox_ && (sender == reporting_enabled_checkbox_)) { bool enabled = reporting_enabled_checkbox_->checked(); - UserMetricsRecordAction(enabled ? + UserMetricsRecordAction(UserMetricsAction(enabled ? "Options_MetricsReportingCheckbox_Enable" : - "Options_MetricsReportingCheckbox_Disable", + "Options_MetricsReportingCheckbox_Disable"), profile()->GetPrefs()); ResolveMetricsReportingEnabled(); if (enabled == reporting_enabled_checkbox_->checked()) RestartMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow()); enable_metrics_recording_.SetValue(enabled); } else if (sender == content_settings_button_) { - UserMetricsRecordAction("Options_ContentSettings", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ContentSettings"), NULL); browser::ShowContentSettingsWindow(GetWindow()->GetNativeWindow(), CONTENT_SETTINGS_TYPE_DEFAULT, profile()); } else if (sender == clear_data_button_) { - UserMetricsRecordAction("Options_ClearData", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ClearData"), NULL); views::Window::CreateChromeWindow( GetWindow()->GetNativeWindow(), gfx::Rect(), @@ -744,7 +744,7 @@ WebContentSection::WebContentSection(Profile* profile) void WebContentSection::ButtonPressed( views::Button* sender, const views::Event& event) { if (sender == gears_settings_button_) { - UserMetricsRecordAction("Options_GearsSettings", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_GearsSettings"), NULL); GearsSettingsPressed(GetAncestor(GetWidget()->GetNativeView(), GA_ROOT)); } else if (sender == change_content_fonts_button_) { views::Window::CreateChromeWindow( @@ -845,21 +845,23 @@ void SecuritySection::ButtonPressed( if (sender == enable_ssl2_checkbox_) { bool enabled = enable_ssl2_checkbox_->checked(); if (enabled) { - UserMetricsRecordAction("Options_SSL2_Enable", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_SSL2_Enable"), NULL); } else { - UserMetricsRecordAction("Options_SSL2_Disable", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_SSL2_Disable"), NULL); } net::SSLConfigServiceWin::SetSSL2Enabled(enabled); } else if (sender == check_for_cert_revocation_checkbox_) { bool enabled = check_for_cert_revocation_checkbox_->checked(); if (enabled) { - UserMetricsRecordAction("Options_CheckCertRevocation_Enable", NULL); + UserMetricsRecordAction( + UserMetricsAction("Options_CheckCertRevocation_Enable"), NULL); } else { - UserMetricsRecordAction("Options_CheckCertRevocation_Disable", NULL); + UserMetricsRecordAction( + UserMetricsAction("Options_CheckCertRevocation_Disable"), NULL); } net::SSLConfigServiceWin::SetRevCheckingEnabled(enabled); } else if (sender == manage_certificates_button_) { - UserMetricsRecordAction("Options_ManagerCerts", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ManagerCerts"), NULL); CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 }; cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); cert_mgr.hwndParent = GetWindow()->GetNativeWindow(); @@ -995,7 +997,7 @@ NetworkSection::NetworkSection(Profile* profile) void NetworkSection::ButtonPressed( views::Button* sender, const views::Event& event) { if (sender == change_proxies_button_) { - UserMetricsRecordAction("Options_ChangeProxies", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ChangeProxies"), NULL); base::Thread* thread = g_browser_process->file_thread(); DCHECK(thread); thread->message_loop()->PostTask(FROM_HERE, new OpenConnectionDialogTask); @@ -1112,23 +1114,25 @@ void DownloadSection::ButtonPressed( } else if (sender == download_ask_for_save_location_checkbox_) { bool enabled = download_ask_for_save_location_checkbox_->checked(); if (enabled) { - UserMetricsRecordAction("Options_AskForSaveLocation_Enable", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_AskForSaveLocation_Enable"), + profile()->GetPrefs()); } else { - UserMetricsRecordAction("Options_AskForSaveLocation_Disable", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_AskForSaveLocation_Disable"), + profile()->GetPrefs()); } ask_for_save_location_.SetValue(enabled); } else if (sender == reset_file_handlers_button_) { profile()->GetDownloadManager()->ResetAutoOpenFiles(); - UserMetricsRecordAction("Options_ResetAutoOpenFiles", + UserMetricsRecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"), profile()->GetPrefs()); } } void DownloadSection::FileSelected(const FilePath& path, int index, void* params) { - UserMetricsRecordAction("Options_SetDownloadDirectory", + UserMetricsRecordAction(UserMetricsAction("Options_SetDownloadDirectory"), profile()->GetPrefs()); default_download_location_.SetValue(path.ToWStringHack()); // We need to call this manually here since because we're setting the value @@ -1252,7 +1256,7 @@ class TranslateSection : public AdvancedSection, // Preferences for this section: BooleanPrefMember enable_translate_; - DISALLOW_COPY_AND_ASSIGN(TranslateSection ); + DISALLOW_COPY_AND_ASSIGN(TranslateSection); }; TranslateSection::TranslateSection(Profile* profile) @@ -1265,8 +1269,9 @@ void TranslateSection::ButtonPressed( views::Button* sender, const views::Event& event) { DCHECK(sender == enable_translate_checkbox_); bool enabled = enable_translate_checkbox_->checked(); - UserMetricsRecordAction(enabled ? "Options_Translate_Enable" : - "Options_Translate_Disable", + UserMetricsRecordAction(enabled ? + UserMetricsAction("Options_Translate_Enable") : + UserMetricsAction("Options_Translate_Disable"), profile()->GetPrefs()); enable_translate_.SetValue(enabled); } diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc index 65114e7..6d98fdd 100644 --- a/chrome/browser/views/options/advanced_page_view.cc +++ b/chrome/browser/views/options/advanced_page_view.cc @@ -105,9 +105,10 @@ void AdvancedPageView::ResetToDefaults() { void AdvancedPageView::ButtonPressed( views::Button* sender, const views::Event& event) { if (sender == reset_to_default_button_) { - UserMetricsRecordAction("Options_ResetToDefaults", NULL); - ResetDefaultsConfirmBox::ShowConfirmBox( - GetWindow()->GetNativeWindow(), this); + UserMetricsRecordAction(UserMetricsAction("Options_ResetToDefaults"), + NULL); + ResetDefaultsConfirmBox::ShowConfirmBox( + GetWindow()->GetNativeWindow(), this); } } diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index addd3af..3db7163 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -87,26 +87,29 @@ void ContentPageView::ButtonPressed( sender == passwords_neversave_radio_) { bool enabled = passwords_asktosave_radio_->checked(); if (enabled) { - UserMetricsRecordAction("Options_PasswordManager_Enable", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_PasswordManager_Enable"), + profile()->GetPrefs()); } else { - UserMetricsRecordAction("Options_PasswordManager_Disable", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_PasswordManager_Disable"), + profile()->GetPrefs()); } ask_to_save_passwords_.SetValue(enabled); } else if (sender == form_autofill_enable_radio_ || sender == form_autofill_disable_radio_) { bool enabled = form_autofill_enable_radio_->checked(); if (enabled) { - UserMetricsRecordAction("Options_FormAutofill_Enable", + UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Enable"), profile()->GetPrefs()); } else { - UserMetricsRecordAction("Options_FormAutofill_Disable", + UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Disable"), profile()->GetPrefs()); } ask_to_save_form_autofill_.SetValue(enabled); } else if (sender == show_passwords_button_) { - UserMetricsRecordAction("Options_ShowPasswordsExceptions", NULL); + UserMetricsRecordAction( + UserMetricsAction("Options_ShowPasswordsExceptions"), NULL); PasswordsExceptionsWindowView::Show(profile()); } else if (sender == change_autofill_settings_button_) { // This button should be disabled if we lack PersonalDataManager. @@ -115,7 +118,8 @@ void ContentPageView::ButtonPressed( profile()->GetPersonalDataManager(), profile()); } else if (sender == themes_reset_button_) { - UserMetricsRecordAction("Options_ThemesReset", profile()->GetPrefs()); + UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"), + profile()->GetPrefs()); profile()->ClearTheme(); } else if (sender == import_button_) { views::Window::CreateChromeWindow( @@ -146,7 +150,8 @@ void ContentPageView::ButtonPressed( void ContentPageView::LinkActivated(views::Link* source, int event_flags) { if (source == themes_gallery_link_) { - UserMetricsRecordAction("Options_ThemesGallery", profile()->GetPrefs()); + UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"), + profile()->GetPrefs()); BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate(); return; } diff --git a/chrome/browser/views/options/cookie_filter_page_view.cc b/chrome/browser/views/options/cookie_filter_page_view.cc index 9bdef63..10efde1 100644 --- a/chrome/browser/views/options/cookie_filter_page_view.cc +++ b/chrome/browser/views/options/cookie_filter_page_view.cc @@ -186,7 +186,7 @@ void CookieFilterPageView::ButtonPressed( clear_site_data_on_exit_.SetValue(clear_on_close_check_->checked()); } else { DCHECK_EQ(sender, show_cookies_button_); - UserMetricsRecordAction("Options_ShowCookies", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ShowCookies"), NULL); CookiesView::ShowCookiesWindow(profile()); } } diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index ecd0a1d..9cfc14f 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -437,13 +437,13 @@ void GeneralPageView::ButtonPressed( sender == startup_custom_radio_) { SaveStartupPref(); if (sender == startup_homepage_radio_) { - UserMetricsRecordAction("Options_Startup_Homepage", + UserMetricsRecordAction(UserMetricsAction("Options_Startup_Homepage"), profile()->GetPrefs()); } else if (sender == startup_last_session_radio_) { - UserMetricsRecordAction("Options_Startup_LastSession", + UserMetricsRecordAction(UserMetricsAction("Options_Startup_LastSession"), profile()->GetPrefs()); } else if (sender == startup_custom_radio_) { - UserMetricsRecordAction("Options_Startup_Custom", + UserMetricsRecordAction(UserMetricsAction("Options_Startup_Custom"), profile()->GetPrefs()); } } else if (sender == startup_add_custom_page_button_) { @@ -453,33 +453,37 @@ void GeneralPageView::ButtonPressed( } else if (sender == startup_use_current_page_button_) { SetStartupURLToCurrentPage(); } else if (sender == homepage_use_newtab_radio_) { - UserMetricsRecordAction("Options_Homepage_UseNewTab", + UserMetricsRecordAction(UserMetricsAction("Options_Homepage_UseNewTab"), profile()->GetPrefs()); SetHomepage(GetNewTabUIURLString()); EnableHomepageURLField(false); } else if (sender == homepage_use_url_radio_) { - UserMetricsRecordAction("Options_Homepage_UseURL", + UserMetricsRecordAction(UserMetricsAction("Options_Homepage_UseURL"), profile()->GetPrefs()); SetHomepage(homepage_use_url_textfield_->text()); EnableHomepageURLField(true); } else if (sender == homepage_show_home_button_checkbox_) { bool show_button = homepage_show_home_button_checkbox_->checked(); if (show_button) { - UserMetricsRecordAction("Options_Homepage_ShowHomeButton", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_Homepage_ShowHomeButton"), + profile()->GetPrefs()); } else { - UserMetricsRecordAction("Options_Homepage_HideHomeButton", - profile()->GetPrefs()); + UserMetricsRecordAction( + UserMetricsAction("Options_Homepage_HideHomeButton"), + profile()->GetPrefs()); } show_home_button_.SetValue(show_button); } else if (sender == default_browser_use_as_default_button_) { default_browser_worker_->StartSetAsDefaultBrowser(); - UserMetricsRecordAction("Options_SetAsDefaultBrowser", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"), + NULL); // If the user made Chrome the default browser, then he/she arguably wants // to be notified when that changes. profile()->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true); } else if (sender == default_search_manage_engines_button_) { - UserMetricsRecordAction("Options_ManageSearchEngines", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_ManageSearchEngines"), + NULL); KeywordEditorView::Show(profile()); } } @@ -491,7 +495,8 @@ void GeneralPageView::ItemChanged(views::Combobox* combobox, int prev_index, int new_index) { if (combobox == default_search_engine_combobox_) { SetDefaultSearchProvider(); - UserMetricsRecordAction("Options_SearchEngineChanged", NULL); + UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged"), + NULL); } } diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc index cb76b39..13dbb20 100644 --- a/chrome/browser/views/options/languages_page_view.cc +++ b/chrome/browser/views/options/languages_page_view.cc @@ -551,7 +551,7 @@ void LanguagesPageView::SaveChanges() { } if (ui_language_index_selected_ != -1) { - UserMetricsRecordAction("Options_AppLanguage", + UserMetricsRecordAction(UserMetricsAction("Options_AppLanguage"), g_browser_process->local_state()); app_locale_.SetValue(ASCIIToWide(ui_language_model_-> GetLocaleFromIndex(ui_language_index_selected_))); @@ -563,7 +563,7 @@ void LanguagesPageView::SaveChanges() { } if (spellcheck_language_index_selected_ != -1) { - UserMetricsRecordAction("Options_DictionaryLanguage", + UserMetricsRecordAction(UserMetricsAction("Options_DictionaryLanguage"), profile()->GetPrefs()); dictionary_language_.SetValue(ASCIIToWide(dictionary_language_model_-> GetLocaleFromIndex(spellcheck_language_index_selected_))); diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index dde0267..ce26ac7 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -1086,43 +1086,45 @@ bool DraggedTabController::CompleteDrag() { if (dock_info_.type() != DockInfo::NONE) { switch (dock_info_.type()) { case DockInfo::LEFT_OF_WINDOW: - UserMetrics::RecordAction("DockingWindow_Left", + UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Left"), source_tabstrip_->model()->profile()); break; case DockInfo::RIGHT_OF_WINDOW: - UserMetrics::RecordAction("DockingWindow_Right", + UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Right"), source_tabstrip_->model()->profile()); break; case DockInfo::BOTTOM_OF_WINDOW: - UserMetrics::RecordAction("DockingWindow_Bottom", + UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Bottom"), source_tabstrip_->model()->profile()); break; case DockInfo::TOP_OF_WINDOW: - UserMetrics::RecordAction("DockingWindow_Top", + UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Top"), source_tabstrip_->model()->profile()); break; case DockInfo::MAXIMIZE: - UserMetrics::RecordAction("DockingWindow_Maximize", + UserMetrics::RecordAction(UserMetricsAction("DockingWindow_Maximize"), source_tabstrip_->model()->profile()); break; case DockInfo::LEFT_HALF: - UserMetrics::RecordAction("DockingWindow_LeftHalf", + UserMetrics::RecordAction(UserMetricsAction("DockingWindow_LeftHalf"), source_tabstrip_->model()->profile()); break; case DockInfo::RIGHT_HALF: - UserMetrics::RecordAction("DockingWindow_RightHalf", - source_tabstrip_->model()->profile()); + UserMetrics::RecordAction( + UserMetricsAction("DockingWindow_RightHalf"), + source_tabstrip_->model()->profile()); break; case DockInfo::BOTTOM_HALF: - UserMetrics::RecordAction("DockingWindow_BottomHalf", - source_tabstrip_->model()->profile()); + UserMetrics::RecordAction( + UserMetricsAction("DockingWindow_BottomHalf"), + source_tabstrip_->model()->profile()); break; default: diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 6edd1e4..c3da175 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -1043,7 +1043,8 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) { return DragDropTypes::DRAG_NONE; if (drop_before) { - UserMetrics::RecordAction("Tab_DropURLBetweenTabs", model_->profile()); + UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs"), + model_->profile()); // Insert a new tab. TabContents* contents = @@ -1053,7 +1054,8 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) { model_->AddTabContents(contents, drop_index, false, PageTransition::GENERATED, true); } else { - UserMetrics::RecordAction("Tab_DropURLOnTab", model_->profile()); + UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLOnTab"), + model_->profile()); model_->GetTabContentsAt(drop_index)->controller().LoadURL( url, GURL(), PageTransition::GENERATED); @@ -1295,7 +1297,8 @@ void TabStrip::CloseTab(Tab* tab) { if (model_->ContainsIndex(tab_index)) { TabContents* contents = model_->GetTabContentsAt(tab_index); if (contents) - UserMetrics::RecordAction("CloseTab_Mouse", contents->profile()); + UserMetrics::RecordAction(UserMetricsAction("CloseTab_Mouse"), + contents->profile()); Tab* last_tab = GetTabAt(GetTabCount() - 1); // Limit the width available to the TabStrip for laying out Tabs, so that // Tabs are not resized until a later time (when the mouse pointer leaves @@ -1417,7 +1420,8 @@ void TabStrip::ButtonPressed(views::Button* sender, const views::Event& event) { AppLauncher::Show(Browser::GetBrowserForController(&controller, NULL)); return; } - UserMetrics::RecordAction("NewTab_Button", model_->profile()); + UserMetrics::RecordAction(UserMetricsAction("NewTab_Button"), + model_->profile()); model_->delegate()->AddBlankTab(true); } } diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index a771c98..a640442 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -483,7 +483,7 @@ void ToolbarView::WriteDragData(views::View* sender, OSExchangeData* data) { DCHECK(GetDragOperations(sender, press_pt) != DragDropTypes::DRAG_NONE); - UserMetrics::RecordAction("Toolbar_DragStar", profile_); + UserMetrics::RecordAction(UserMetricsAction("Toolbar_DragStar"), profile_); // If there is a bookmark for the URL, add the bookmark drag data for it. We // do this to ensure the bookmark is moved, rather than creating an new diff --git a/chrome/tools/extract_actions.py b/chrome/tools/extract_actions.py index 8b6a9bf..a2bb529 100755 --- a/chrome/tools/extract_actions.py +++ b/chrome/tools/extract_actions.py @@ -37,8 +37,11 @@ KNOWN_COMPUTED_USERS = [ 'render_view_host.cc', # called using webkit identifiers 'user_metrics.cc', # method definition 'new_tab_ui.cc', # most visited clicks 1-9 + 'extension_metrics_module.cc', # extensions hook for user metrics ] +number_of_files_total = 0 + def AddComputedActions(actions): """Add computed actions to the actions list. @@ -67,7 +70,7 @@ def AddWebKitEditorActions(actions): action_re = re.compile(r'''\{ [\w']+, +\w+, +"(.*)" +\},''') editor_file = os.path.join(path_utils.ScriptDir(), '..', '..', 'webkit', - 'glue', 'editor_client_impl.cc') + 'api', 'src','EditorClientImpl.cc') for line in open(editor_file): match = action_re.search(line) if match: # Plain call to RecordAction @@ -80,22 +83,23 @@ def GrepForActions(path, actions): path: path to the file actions: set of actions to add to """ - - action_re = re.compile(r'[> ]UserMetrics:?:?RecordAction\(L"(.*)"') - other_action_re = re.compile(r'[> ]UserMetrics:?:?RecordAction\(') + global number_of_files_total + number_of_files_total = number_of_files_total + 1 + # we look for the UserMetricsAction structur constructor + # this should be on one line + action_re = re.compile(r'UserMetricsAction\("([^"]*)') computed_action_re = re.compile(r'UserMetrics::RecordComputedAction') + line_number = 0 for line in open(path): + line_number = line_number + 1 match = action_re.search(line) if match: # Plain call to RecordAction actions.add(match.group(1)) - elif other_action_re.search(line): - # Warn if this file shouldn't be mentioning RecordAction. - if os.path.basename(path) != 'user_metrics.cc': - print >>sys.stderr, 'WARNING: %s has funny RecordAction' % path elif computed_action_re.search(line): # Warn if this file shouldn't be calling RecordComputedAction. if os.path.basename(path) not in KNOWN_COMPUTED_USERS: - print >>sys.stderr, 'WARNING: %s has RecordComputedAction' % path + print >>sys.stderr, 'WARNING: {0} has RecordComputedAction at {1}'.\ + format(path, line_number) def WalkDirectory(root_path, actions): for path, dirs, files in os.walk(root_path): @@ -103,13 +107,14 @@ def WalkDirectory(root_path, actions): dirs.remove('.svn') for file in files: ext = os.path.splitext(file)[1] - if ext == '.cc': + if ext in ('.cc', '.mm', '.c', '.m'): GrepForActions(os.path.join(path, file), actions) def main(argv): actions = set() AddComputedActions(actions) - AddWebKitEditorActions(actions) + # TODO(fmantek): bring back webkit editor actions. + # AddWebKitEditorActions(actions) # Walk the source tree to process all .cc files. chrome_root = os.path.join(path_utils.ScriptDir(), '..') @@ -118,6 +123,10 @@ def main(argv): WalkDirectory(os.path.join(webkit_root, 'glue'), actions) WalkDirectory(os.path.join(webkit_root, 'port'), actions) + # print "Scanned {0} number of files".format(number_of_files_total) + # print "Found {0} entries".format(len(actions)) + + # Print out the actions as a sorted list. for action in sorted(actions): print action |