 Chromium Code Reviews
 Chromium Code Reviews Issue 10182006:
  Adds the MostVisitedAction stat. This stat will provide a baseline to compare  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/
    
  
    Issue 10182006:
  Adds the MostVisitedAction stat. This stat will provide a baseline to compare  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/| Index: chrome/browser/resources/ntp4/most_visited_page.js | 
| =================================================================== | 
| --- chrome/browser/resources/ntp4/most_visited_page.js (revision 133422) | 
| +++ chrome/browser/resources/ntp4/most_visited_page.js (working copy) | 
| @@ -8,6 +8,16 @@ | 
| var TilePage = ntp.TilePage; | 
| /** | 
| + * See description for these values in ntp_stats.h. | 
| + * @enum {number} | 
| + */ | 
| + var NtpFollowAction = { | 
| + CLICKED_TILE: 11, | 
| + CLICKED_OTHER_NTP_PANE: 12, | 
| + OTHER: 13 | 
| + }; | 
| + | 
| + /** | 
| * A counter for generating unique tile IDs. | 
| */ | 
| var tileID = 0; | 
| @@ -141,6 +151,8 @@ | 
| // Records the index of this tile. | 
| chrome.send('metricsHandler:recordInHistogram', | 
| ['NewTabPage.MostVisited', this.index, 8]); | 
| + chrome.send('mostVisitedAction', | 
| + [NtpFollowAction.CLICKED_TILE]); | 
| } | 
| }, | 
| @@ -289,6 +301,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_); | 
| 
beaudoin
2012/04/23 16:46:52
handleCard* methods will not have |this| correctly
 
macourteau
2012/04/23 19:49:41
We've discussed this (no pun intended) -- 'this' a
 | 
| }, | 
| /** | 
| @@ -317,6 +332,29 @@ | 
| }, | 
| /** | 
| + * 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', | 
| + [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} | 
| */ | 
| @@ -343,6 +381,19 @@ | 
| return false; | 
| }, | 
| + /** | 
| + * Executed once the NTP has loaded. Checks if the Most Visited pane is | 
| + * shown or not. | 
| + */ | 
| + onLoaded: function() { | 
| + if (ntp.getCardSlider() && ntp.getCardSlider().currentCardValue) { | 
| + if (ntp.getCardSlider().currentCardValue.classList | 
| + .contains('most-visited-page')) { | 
| + chrome.send('mostVisitedSelected'); | 
| + } | 
| + } | 
| + }, | 
| + | 
| /** @inheritDoc */ | 
| heightForWidth: heightForWidth, | 
| }; | 
| @@ -424,3 +475,5 @@ | 
| refreshData: refreshData, | 
| }; | 
| }); | 
| + | 
| +document.addEventListener('ntploaded', ntp.MostVisitedPage.prototype.onLoaded); | 
| 
beaudoin
2012/04/23 16:46:52
The onLoaded method cannot have access to a valid
 
macourteau
2012/04/23 19:49:41
Done.
 |