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

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: 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_page_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/suggestions_page_handler.cc
===================================================================
--- chrome/browser/ui/webui/ntp/suggestions_page_handler.cc (revision 130614)
+++ 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,53 @@
#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;
+namespace {
+
+enum SuggestedSitesActions {
+ SUGGESTED_SITES_ACTION_OTHER = 0,
+ SUGGESTED_SITES_ACTION_CLICKED_SUGGESTED_TILE,
Evan Stade 2012/04/04 20:33:35 comments for these. I'm also still a bit confused
macourteau 2012/04/04 21:00:36 Done.
+ SUGGESTED_SITES_ACTION_CLICKED_OTHER_NTP_PANE,
+ SUGGESTED_SITES_ACTION_OMNIBOX_NAVIGATION
+};
+
+} // namespace
+
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 = SUGGESTED_SITES_ACTION_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 = SUGGESTED_SITES_ACTION_OMNIBOX_NAVIGATION;
+ }
+ }
+
+ UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, 4);
+ }
}
void SuggestionsHandler::RegisterMessages() {
@@ -81,6 +117,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 +177,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());
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_page_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698