OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('ntp4', function() { | 5 cr.define('ntp4', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var TilePage = ntp4.TilePage; | 8 var TilePage = ntp4.TilePage; |
9 | 9 |
10 /** | 10 /** |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 /** | 112 /** |
113 * Handles a click on the tile. | 113 * Handles a click on the tile. |
114 * @param {Event} e The click event. | 114 * @param {Event} e The click event. |
115 */ | 115 */ |
116 handleClick_: function(e) { | 116 handleClick_: function(e) { |
117 if (e.target.classList.contains('close-button')) { | 117 if (e.target.classList.contains('close-button')) { |
118 this.blacklist_(); | 118 this.blacklist_(); |
119 e.preventDefault(); | 119 e.preventDefault(); |
120 } else { | 120 } else { |
| 121 // Records an app launch from the most visited page (Chrome will decide |
| 122 // whether the url is an app). TODO(estade): this only works for clicks; |
| 123 // other actions like "open in new tab" from the context menu won't be |
| 124 // recorded. Can this be fixed? |
| 125 chrome.send('recordAppLaunchByURL', |
| 126 [encodeURIComponent(this.href), |
| 127 ntp4.APP_LAUNCH.NTP_MOST_VISITED]); |
| 128 // Records the index of this tile. |
121 chrome.send('recordInHistogram', ['NTP_MostVisited', this.index, 8]); | 129 chrome.send('recordInHistogram', ['NTP_MostVisited', this.index, 8]); |
122 } | 130 } |
123 }, | 131 }, |
124 | 132 |
125 /** | 133 /** |
126 * Allow blacklisting most visited site using the keyboard. | 134 * Allow blacklisting most visited site using the keyboard. |
127 */ | 135 */ |
128 handleKeyDown_: function(e) { | 136 handleKeyDown_: function(e) { |
129 if (!IS_MAC && e.keyCode == 46 || // Del | 137 if (!IS_MAC && e.keyCode == 46 || // Del |
130 IS_MAC && e.metaKey && e.keyCode == 8) { // Cmd + Backspace | 138 IS_MAC && e.metaKey && e.keyCode == 8) { // Cmd + Backspace |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if (tile) | 371 if (tile) |
364 tile.setStripeColor(color); | 372 tile.setStripeColor(color); |
365 }; | 373 }; |
366 | 374 |
367 return { | 375 return { |
368 MostVisitedPage: MostVisitedPage, | 376 MostVisitedPage: MostVisitedPage, |
369 refreshData: refreshData, | 377 refreshData: refreshData, |
370 setFaviconDominantColor: setFaviconDominantColor, | 378 setFaviconDominantColor: setFaviconDominantColor, |
371 }; | 379 }; |
372 }); | 380 }); |
OLD | NEW |