summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/resources/ntp_android/ntp_android.js26
-rw-r--r--chrome/browser/ui/webui/ntp/android/navigation_handler.cc89
-rw-r--r--chrome/browser/ui/webui/ntp/android/navigation_handler.h65
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_ui.cc4
-rw-r--r--chrome/chrome_browser_ui.gypi2
-rw-r--r--tools/metrics/histograms/histograms.xml19
6 files changed, 201 insertions, 4 deletions
diff --git a/chrome/browser/resources/ntp_android/ntp_android.js b/chrome/browser/resources/ntp_android/ntp_android.js
index e276677..9ec3a10 100644
--- a/chrome/browser/resources/ntp_android/ntp_android.js
+++ b/chrome/browser/resources/ntp_android/ntp_android.js
@@ -535,6 +535,7 @@ cr.define('ntp', function() {
* reopen a tab.
*/
function openRecentlyClosedTab(item, evt) {
+ chrome.send('openedRecentlyClosed');
chrome.send('reopenTab', [item.sessionId]);
}
@@ -946,7 +947,7 @@ cr.define('ntp', function() {
return;
var clickFunction = function(item) {
- chrome.send('metricsHandler:recordAction', ['MobileNTPMostVisited']);
+ chrome.send('openedMostVisited');
window.location = item.url;
};
populateData(findList('most_visited'), SectionType.MOST_VISITED, data,
@@ -1018,7 +1019,7 @@ cr.define('ntp', function() {
if (item['folder']) {
browseToBookmarkFolder(item.id);
} else if (!!item.url) {
- chrome.send('metricsHandler:recordAction', ['MobileNTPBookmark']);
+ chrome.send('openedBookmark');
window.location = item.url;
}
};
@@ -1195,6 +1196,25 @@ cr.define('ntp', function() {
* when chrome.send('showContextMenu') was called.
*/
function onCustomMenuSelected(itemId) {
+ if (contextMenuUrl != null) {
+ switch (itemId) {
+ case ContextMenuItemIds.BOOKMARK_OPEN_IN_NEW_TAB:
+ case ContextMenuItemIds.BOOKMARK_OPEN_IN_INCOGNITO_TAB:
+ chrome.send('openedBookmark');
+ break;
+
+ case ContextMenuItemIds.MOST_VISITED_OPEN_IN_NEW_TAB:
+ case ContextMenuItemIds.MOST_VISITED_OPEN_IN_INCOGNITO_TAB:
+ chrome.send('openedMostVisited');
+ break;
+
+ case ContextMenuItemIds.RECENTLY_CLOSED_OPEN_IN_NEW_TAB:
+ case ContextMenuItemIds.RECENTLY_CLOSED_OPEN_IN_INCOGNITO_TAB:
+ chrome.send('openedRecentlyClosed');
+ break;
+ }
+ }
+
switch (itemId) {
case ContextMenuItemIds.BOOKMARK_OPEN_IN_NEW_TAB:
case ContextMenuItemIds.MOST_VISITED_OPEN_IN_NEW_TAB:
@@ -1835,7 +1855,7 @@ cr.define('ntp', function() {
metaKeyPressed = evt.metaKey;
shiftKeyPressed = evt.shiftKey;
}
- chrome.send('metricsHandler:recordAction', ['MobileNTPForeignSession']);
+ chrome.send('openedForeignSession');
chrome.send('openForeignSession', [String(item.sessionTag),
String(item.winNum), String(item.sessionId), buttonIndex,
altKeyPressed, ctrlKeyPressed, metaKeyPressed, shiftKeyPressed]);
diff --git a/chrome/browser/ui/webui/ntp/android/navigation_handler.cc b/chrome/browser/ui/webui/ntp/android/navigation_handler.cc
new file mode 100644
index 0000000..d5c9a2e
--- /dev/null
+++ b/chrome/browser/ui/webui/ntp/android/navigation_handler.cc
@@ -0,0 +1,89 @@
+// Copyright 2013 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/ui/webui/ntp/android/navigation_handler.h"
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/metrics/histogram.h"
+#include "base/values.h"
+#include "chrome/browser/google/google_util.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/common/page_transition_types.h"
+
+NavigationHandler::NavigationHandler() {}
+
+NavigationHandler::~NavigationHandler() {
+ // Record an omnibox-based navigation, if there is one.
+ content::NavigationEntry* entry =
+ web_ui()->GetWebContents()->GetController().GetActiveEntry();
+ if (!entry)
+ return;
+
+ if (!(entry->GetTransitionType() &
+ content::PAGE_TRANSITION_FROM_ADDRESS_BAR) ||
+ entry->GetTransitionType() & content::PAGE_TRANSITION_FORWARD_BACK) {
+ return;
+ }
+
+ if (entry->GetURL().SchemeIs(chrome::kChromeUIScheme) &&
+ entry->GetURL().host() == chrome::kChromeUINewTabHost) {
+ return;
+ }
+
+ Action action;
+ if ((entry->GetTransitionType() & content::PAGE_TRANSITION_CORE_MASK) ==
+ content::PAGE_TRANSITION_GENERATED) {
+ action = ACTION_SEARCHED_USING_OMNIBOX;
+ } else if (google_util::IsGoogleHomePageUrl(entry->GetURL())) {
+ action = ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE;
+ } else {
+ action = ACTION_NAVIGATED_USING_OMNIBOX;
+ }
+ RecordAction(action);
+}
+
+void NavigationHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "openedMostVisited",
+ base::Bind(&NavigationHandler::HandleOpenedMostVisited,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "openedRecentlyClosed",
+ base::Bind(&NavigationHandler::HandleOpenedRecentlyClosed,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "openedBookmark",
+ base::Bind(&NavigationHandler::HandleOpenedBookmark,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "openedForeignSession",
+ base::Bind(&NavigationHandler::HandleOpenedForeignSession,
+ base::Unretained(this)));
+}
+
+void NavigationHandler::HandleOpenedMostVisited(const base::ListValue* args) {
+ RecordAction(ACTION_OPENED_MOST_VISITED_ENTRY);
+}
+
+void NavigationHandler::HandleOpenedRecentlyClosed(
+ const base::ListValue* args) {
+ RecordAction(ACTION_OPENED_RECENTLY_CLOSED_ENTRY);
+}
+
+void NavigationHandler::HandleOpenedBookmark(const base::ListValue* args) {
+ RecordAction(ACTION_OPENED_BOOKMARK);
+}
+
+void NavigationHandler::HandleOpenedForeignSession(
+ const base::ListValue* args) {
+ RecordAction(ACTION_OPENED_FOREIGN_SESSION);
+}
+
+void NavigationHandler::RecordAction(Action action) {
+ UMA_HISTOGRAM_ENUMERATION("NewTabPage.ActionAndroid", action, NUM_ACTIONS);
+}
diff --git a/chrome/browser/ui/webui/ntp/android/navigation_handler.h b/chrome/browser/ui/webui/ntp/android/navigation_handler.h
new file mode 100644
index 0000000..fc45d86
--- /dev/null
+++ b/chrome/browser/ui/webui/ntp/android/navigation_handler.h
@@ -0,0 +1,65 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_
+
+#include "base/compiler_specific.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace base {
+class ListValue;
+}
+
+// Records a UMA stat ("NewTabPage.ActionAndroid") for the action the user takes
+// to navigate away from the NTP.
+class NavigationHandler : public content::WebUIMessageHandler {
+ public:
+ NavigationHandler();
+ virtual ~NavigationHandler();
+
+ // WebUIMessageHandler implementation.
+ virtual void RegisterMessages() OVERRIDE;
+
+ // Callback for "openedMostVisited".
+ void HandleOpenedMostVisited(const base::ListValue* args);
+
+ // Callback for "openedRecentlyClosed".
+ void HandleOpenedRecentlyClosed(const base::ListValue* args);
+
+ // Callback for "openedBookmark".
+ void HandleOpenedBookmark(const base::ListValue* args);
+
+ // Callback for "openedForeignSession".
+ void HandleOpenedForeignSession(const base::ListValue* args);
+
+ private:
+ // Possible actions taken by the user on the NTP. This enum is also defined in
+ // histograms.xml. WARNING: these values must stay in sync with histograms.xml
+ // and new actions can be added only at the end of the enum.
+ enum Action {
+ // User performed a search using the omnibox
+ ACTION_SEARCHED_USING_OMNIBOX = 0,
+ // User navigated to Google search homepage using the omnibox
+ ACTION_NAVIGATED_TO_GOOGLE_HOMEPAGE = 1,
+ // User navigated to any other page using the omnibox
+ ACTION_NAVIGATED_USING_OMNIBOX = 2,
+ // User opened a most visited page
+ ACTION_OPENED_MOST_VISITED_ENTRY = 3,
+ // User opened a recently closed tab
+ ACTION_OPENED_RECENTLY_CLOSED_ENTRY = 4,
+ // User opened a bookmark
+ ACTION_OPENED_BOOKMARK = 5,
+ // User opened a foreign session (from other devices section)
+ ACTION_OPENED_FOREIGN_SESSION = 6,
+ // The number of possible actions
+ NUM_ACTIONS = 7
+ };
+
+ void RecordAction(Action action);
+
+ DISALLOW_COPY_AND_ASSIGN(NavigationHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_NAVIGATION_HANDLER_H_
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
index 35ac6b5..0d4836a 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -45,6 +45,7 @@
#else
#include "chrome/browser/ui/webui/ntp/android/bookmarks_handler.h"
#include "chrome/browser/ui/webui/ntp/android/context_menu_handler.h"
+#include "chrome/browser/ui/webui/ntp/android/navigation_handler.h"
#include "chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.h"
#include "chrome/browser/ui/webui/ntp/android/promo_handler.h"
#endif
@@ -104,8 +105,8 @@ NewTabUI::NewTabUI(content::WebUI* web_ui)
web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
web_ui->AddMessageHandler(new MostVisitedHandler());
web_ui->AddMessageHandler(new RecentlyClosedTabsHandler());
- web_ui->AddMessageHandler(new MetricsHandler());
#if !defined(OS_ANDROID)
+ web_ui->AddMessageHandler(new MetricsHandler());
web_ui->AddMessageHandler(new NewTabPageHandler());
if (NewTabUI::IsDiscoveryInNTPEnabled())
web_ui->AddMessageHandler(new SuggestionsHandler());
@@ -128,6 +129,7 @@ NewTabUI::NewTabUI(content::WebUI* web_ui)
// These handlers are specific to the Android NTP page.
web_ui->AddMessageHandler(new BookmarksHandler());
web_ui->AddMessageHandler(new ContextMenuHandler());
+ web_ui->AddMessageHandler(new NavigationHandler());
web_ui->AddMessageHandler(new NewTabPageReadyHandler());
if (!GetProfile()->IsOffTheRecord())
web_ui->AddMessageHandler(new PromoHandler());
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 0d8a9b0..ee61dee 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -2764,6 +2764,8 @@
'browser/ui/webui/ntp/android/bookmarks_handler.h',
'browser/ui/webui/ntp/android/context_menu_handler.cc',
'browser/ui/webui/ntp/android/context_menu_handler.h',
+ 'browser/ui/webui/ntp/android/navigation_handler.cc',
+ 'browser/ui/webui/ntp/android/navigation_handler.h',
'browser/ui/webui/ntp/android/new_tab_page_ready_handler.cc',
'browser/ui/webui/ntp/android/new_tab_page_ready_handler.h',
'browser/ui/webui/ntp/android/partner_bookmarks_shim.cc',
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 53a581f..3b58faa 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -8824,6 +8824,15 @@ other types of suffix sets.
</summary>
</histogram>
+<histogram name="NewTabPage.ActionAndroid" enum="NewTabPageActionAndroid">
+ <summary>
+ Actions taken by users from the new tab page on Android. These actions may
+ navigate away from the NTP (e.g. searching in the omnibox or opening a
+ bookmark), but can also happen without navigating away from the NTP (e.g.
+ opening a bookmark in a new tab).
+ </summary>
+</histogram>
+
<histogram name="NewTabPage.AppsPageDragSource" enum="AppsPageDragSource">
<summary>
Histogram for the source of app page drags. For any succesful drop onto an
@@ -19231,6 +19240,16 @@ other types of suffix sets.
<int value="14" label="HTTP_GET_FAILED"/>
</enum>
+<enum name="NewTabPageActionAndroid" type="int">
+ <int value="0" label="Searched using the omnibox"/>
+ <int value="1" label="Navigated to Google search homepage using the omnibox"/>
+ <int value="2" label="Navigated to any other page using the omnibox"/>
+ <int value="3" label="Opened a most visited page"/>
+ <int value="4" label="Opened a recently closed tab"/>
+ <int value="5" label="Opened a bookmark"/>
+ <int value="6" label="Opened a foreign session (from other devices section)"/>
+</enum>
+
<enum name="NewTabPageMobilePromo" type="int">
<summary>
These values are defined inside the PromoImpressionBuckets enum in