Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / ntp / android / navigation_handler.cc
blob2a99dc0f7b19b916f5db8cf08bb3d528a2d1e887
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/ntp/android/navigation_handler.h"
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/metrics/histogram.h"
10 #include "base/values.h"
11 #include "chrome/browser/google/google_util.h"
12 #include "chrome/common/url_constants.h"
13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/user_metrics.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_ui.h"
17 #include "content/public/common/page_transition_types.h"
19 using base::UserMetricsAction;
21 NavigationHandler::NavigationHandler() {}
23 NavigationHandler::~NavigationHandler() {}
25 void NavigationHandler::RegisterMessages() {
26 web_ui()->RegisterMessageCallback(
27 "openedMostVisited",
28 base::Bind(&NavigationHandler::HandleOpenedMostVisited,
29 base::Unretained(this)));
30 web_ui()->RegisterMessageCallback(
31 "openedRecentlyClosed",
32 base::Bind(&NavigationHandler::HandleOpenedRecentlyClosed,
33 base::Unretained(this)));
34 web_ui()->RegisterMessageCallback(
35 "openedBookmark",
36 base::Bind(&NavigationHandler::HandleOpenedBookmark,
37 base::Unretained(this)));
38 web_ui()->RegisterMessageCallback(
39 "openedForeignSession",
40 base::Bind(&NavigationHandler::HandleOpenedForeignSession,
41 base::Unretained(this)));
44 void NavigationHandler::HandleOpenedMostVisited(const base::ListValue* args) {
45 content::RecordAction(UserMetricsAction("MobileNTPMostVisited"));
46 RecordAction(ACTION_OPENED_MOST_VISITED_ENTRY);
49 void NavigationHandler::HandleOpenedRecentlyClosed(
50 const base::ListValue* args) {
51 content::RecordAction(UserMetricsAction("MobileNTPRecentlyClosed"));
52 RecordAction(ACTION_OPENED_RECENTLY_CLOSED_ENTRY);
55 void NavigationHandler::HandleOpenedBookmark(const base::ListValue* args) {
56 content::RecordAction(UserMetricsAction("MobileNTPBookmark"));
57 RecordAction(ACTION_OPENED_BOOKMARK);
60 void NavigationHandler::HandleOpenedForeignSession(
61 const base::ListValue* args) {
62 content::RecordAction(UserMetricsAction("MobileNTPForeignSession"));
63 RecordAction(ACTION_OPENED_FOREIGN_SESSION);
66 // static
67 void NavigationHandler::RecordAction(Action action) {
68 UMA_HISTOGRAM_ENUMERATION("NewTabPage.ActionAndroid", action, NUM_ACTIONS);