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

Unified Diff: chrome/browser/resources/ntp4/most_visited_page.js

Issue 10182006: Adds the MostVisitedAction stat. This stat will provide a baseline to compare (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « no previous file | chrome/browser/resources/ntp4/new_tab.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/most_visited_page.js
===================================================================
--- chrome/browser/resources/ntp4/most_visited_page.js (revision 134120)
+++ chrome/browser/resources/ntp4/most_visited_page.js (working copy)
@@ -141,6 +141,8 @@
// Records the index of this tile.
chrome.send('metricsHandler:recordInHistogram',
['NewTabPage.MostVisited', this.index, 8]);
+ chrome.send('mostVisitedAction',
+ [ntp.NtpFollowAction.CLICKED_TILE]);
}
},
@@ -289,6 +291,9 @@
this.classList.add('most-visited-page');
this.data_ = null;
this.mostVisitedTiles_ = this.getElementsByClassName('most-visited real');
+
+ this.addEventListener('carddeselected', this.handleCardDeselected_);
+ this.addEventListener('cardselected', this.handleCardSelected_);
},
/**
@@ -317,6 +322,28 @@
},
/**
+ * Handles the 'card deselected' event (i.e. the user clicked to another
+ * pane).
+ * @param {Event} e The CardChanged event.
+ */
+ handleCardDeselected_: function(e) {
+ if (!document.documentElement.classList.contains('starting-up')) {
+ chrome.send('mostVisitedAction',
+ [ntp.NtpFollowAction.CLICKED_OTHER_NTP_PANE]);
+ }
+ },
+
+ /**
+ * Handles the 'card selected' event (i.e. the user clicked to select the
+ * Most Visited pane).
+ * @param {Event} e The CardChanged event.
+ */
+ handleCardSelected_: function(e) {
+ if (!document.documentElement.classList.contains('starting-up'))
+ chrome.send('mostVisitedSelected');
+ },
+
+ /**
* Array of most visited data objects.
* @type {Array}
*/
@@ -348,6 +375,20 @@
};
/**
+ * Executed once the NTP has loaded. Checks if the Most Visited pane is
+ * shown or not. If it is shown, the 'mostVisitedSelected' message is sent
+ * to the C++ code, to record the fact that the user has seen this pane.
+ */
+ MostVisitedPage.onLoaded = function() {
+ if (ntp.getCardSlider() &&
+ ntp.getCardSlider().currentCardValue &&
+ ntp.getCardSlider().currentCardValue.classList
+ .contains('most-visited-page')) {
+ chrome.send('mostVisitedSelected');
+ }
+ }
+
+ /**
* We've gotten additional Most Visited data. Update our old data with the
* new data. The ordering of the new data is not important, except when a
* page is pinned. Thus we try to minimize re-ordering.
@@ -424,3 +465,5 @@
refreshData: refreshData,
};
});
+
+document.addEventListener('ntpLoaded', ntp.MostVisitedPage.onLoaded);
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/new_tab.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698