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

Unified Diff: chrome/browser/ui/webui/ntp/suggestions_page_handler.cc

Issue 9958116: Adds the NewTabPage.SuggestedSitesAction stat. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Removed static variable that required an exit-time destructor. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/ntp/suggestions_page_handler.cc
===================================================================
--- chrome/browser/ui/webui/ntp/suggestions_page_handler.cc (revision 130353)
+++ chrome/browser/ui/webui/ntp/suggestions_page_handler.cc (working copy)
@@ -11,6 +11,7 @@
#include "base/md5.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/singleton.h"
+#include "base/metrics/histogram.h"
#include "base/string16.h"
#include "base/string_number_conversions.h"
#include "base/threading/thread.h"
@@ -27,18 +28,42 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/user_metrics.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
+#include "content/public/common/page_transition_types.h"
#include "googleurl/src/gurl.h"
using content::UserMetricsAction;
SuggestionsHandler::SuggestionsHandler()
- : got_first_suggestions_request_(false) {
+ : got_first_suggestions_request_(false),
+ suggestions_viewed_(false),
+ valid_user_action_(false) {
}
SuggestionsHandler::~SuggestionsHandler() {
+ // TODO(macourteau): ensure that |suggestions_viewed_| gets set correctly,
+ // once the Suggestions pane gets be statically included into the NTP (e.g.,
+ // if the Suggestions pane is the one shown by default, the
+ // |suggestions_viewed_| flag might not get set).
+ if (!valid_user_action_ && suggestions_viewed_) {
+ const GURL ntp_url = GURL(chrome::kChromeUINewTabURL);
+ int action_id = 0; // "0" means "Other".
+ content::NavigationEntry* entry =
+ web_ui()->GetWebContents()->GetController().GetActiveEntry();
+ if (entry && (entry->GetURL() != ntp_url)) {
+ if (content::PageTransitionStripQualifier(entry->GetTransitionType()) ==
+ content::PAGE_TRANSITION_TYPED) {
+ action_id = 3; // "3" means "Navigation via omnibox".
+ }
+ }
+
+ UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, 4);
+ }
}
void SuggestionsHandler::RegisterMessages() {
@@ -81,6 +106,12 @@
web_ui()->RegisterMessageCallback("clearSuggestionsURLsBlacklist",
base::Bind(&SuggestionsHandler::HandleClearBlacklist,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("suggestedSitesAction",
+ base::Bind(&SuggestionsHandler::HandleSuggestedSitesAction,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("suggestedSitesSelected",
+ base::Bind(&SuggestionsHandler::HandleSuggestedSitesSelected,
+ base::Unretained(this)));
}
void SuggestionsHandler::HandleGetSuggestions(const ListValue* args) {
@@ -135,6 +166,25 @@
// TODO(georgey) clear blacklist.
}
+void SuggestionsHandler::HandleSuggestedSitesAction(
+ const base::ListValue* args) {
+ DCHECK(args);
+
+ double action_id;
+ if (!args->GetDouble(0, &action_id))
+ NOTREACHED();
+
+ UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction",
+ static_cast<int>(action_id), 4);
+ suggestions_viewed_ = true;
+ valid_user_action_ = true;
+}
+
+void SuggestionsHandler::HandleSuggestedSitesSelected(
+ const base::ListValue* args) {
+ suggestions_viewed_ = true;
+}
+
void SuggestionsHandler::SetPagesValueFromTopSites(
const history::MostVisitedURLList& data) {
pages_value_.reset(new ListValue());

Powered by Google App Engine
This is Rietveld 408576698