From fa128ea8bdf3fd751a7689e544eeebd51ee528e7 Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Tue, 20 Apr 2010 12:03:42 +0000 Subject: Adds support to collect UMA data for the mostvisited feature TEST=Covered by standard UI tests BUG=none Review URL: http://codereview.chromium.org/1574032 Patch from Frank Mantek . git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45024 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/dom_ui/most_visited_handler.cc | 6 ++++ chrome/browser/dom_ui/shown_sections_handler.cc | 38 +++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/dom_ui/most_visited_handler.cc b/chrome/browser/dom_ui/most_visited_handler.cc index 5ce3c18..cc6ed7f 100644 --- a/chrome/browser/dom_ui/most_visited_handler.cc +++ b/chrome/browser/dom_ui/most_visited_handler.cc @@ -20,6 +20,7 @@ #include "chrome/browser/dom_ui/new_tab_ui.h" #include "chrome/browser/history/page_usage_data.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/common/notification_type.h" @@ -177,12 +178,17 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const Value* urls) { NOTREACHED(); return; } + UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlRemoved"), + dom_ui_->GetProfile()); r = url_blacklist_->Remove(GetDictionaryKeyForURL(WideToUTF8(url)), NULL); DCHECK(r) << "Unknown URL removed from the NTP Most Visited blacklist."; } } void MostVisitedHandler::HandleClearBlacklist(const Value* value) { + UserMetrics::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"), + dom_ui_->GetProfile()); + url_blacklist_->Clear(); } diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc index 6b92a9a..d9b0bc2 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.cc +++ b/chrome/browser/dom_ui/shown_sections_handler.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. @@ -7,10 +7,35 @@ #include "base/callback.h" #include "base/string_util.h" #include "base/values.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/common/pref_names.h" +namespace { + +// Will cause an UMA notification if the mode of the new tab page +// was changed to hide/show the most visited thumbnails. +void NotifySectionDisabled(int new_mode, int old_mode, Profile *profile) { + // If the oldmode HAD either thumbs or lists visible. + bool old_had_it = (old_mode & THUMB) || (old_mode & LIST); + bool new_has_it = (new_mode & THUMB) || (new_mode & LIST); + + if (old_had_it && !new_has_it) { + UserMetrics::RecordAction( + UserMetricsAction("ShowSections_RecentSitesDisabled"), + profile); + } + + if (new_has_it && !old_had_it) { + UserMetrics::RecordAction( + UserMetricsAction("ShowSections_RecentSitesEnabled"), + profile); + } +} + +} // namespace + void ShownSectionsHandler::RegisterMessages() { dom_ui_->RegisterMessageCallback("getShownSections", NewCallback(this, &ShownSectionsHandler::HandleGetShownSections)); @@ -42,8 +67,15 @@ void ShownSectionsHandler::HandleSetShownSections(const Value* value) { bool r = list->GetString(0, &mode_string); DCHECK(r) << "Missing value in setShownSections from the NTP Most Visited."; - dom_ui_->GetProfile()->GetPrefs()->SetInteger( - prefs::kNTPShownSections, StringToInt(mode_string)); + int mode = StringToInt(mode_string); + int old_mode = dom_ui_->GetProfile()->GetPrefs()->GetInteger( + prefs::kNTPShownSections); + + if (old_mode != mode) { + NotifySectionDisabled(mode, old_mode, dom_ui_->GetProfile()); + dom_ui_->GetProfile()->GetPrefs()->SetInteger( + prefs::kNTPShownSections, mode); + } } // static -- cgit v1.1