| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 this.showUndoNotification_(); | 161 this.showUndoNotification_(); |
| 162 chrome.send('blacklistURLFromMostVisited', [this.data_.url]); | 162 chrome.send('blacklistURLFromMostVisited', [this.data_.url]); |
| 163 this.reset(); | 163 this.reset(); |
| 164 chrome.send('getMostVisited'); | 164 chrome.send('getMostVisited'); |
| 165 this.classList.add('blacklisted'); | 165 this.classList.add('blacklisted'); |
| 166 }, | 166 }, |
| 167 | 167 |
| 168 showUndoNotification_: function() { | 168 showUndoNotification_: function() { |
| 169 var data = this.data_; | 169 var data = this.data_; |
| 170 var self = this; | 170 var self = this; |
| 171 var doUndo = function () { | 171 var doUndo = function() { |
| 172 chrome.send('removeURLsFromMostVisitedBlacklist', [data.url]); | 172 chrome.send('removeURLsFromMostVisitedBlacklist', [data.url]); |
| 173 self.updateForData(data); | 173 self.updateForData(data); |
| 174 } | 174 } |
| 175 | 175 |
| 176 var undo = { | 176 var undo = { |
| 177 action: doUndo, | 177 action: doUndo, |
| 178 text: templateData.undothumbnailremove, | 178 text: templateData.undothumbnailremove, |
| 179 } | 179 }; |
| 180 | 180 |
| 181 var undoAll = { | 181 var undoAll = { |
| 182 action: function() { | 182 action: function() { |
| 183 chrome.send('clearMostVisitedURLsBlacklist', []); | 183 chrome.send('clearMostVisitedURLsBlacklist', []); |
| 184 }, | 184 }, |
| 185 text: templateData.restoreThumbnailsShort, | 185 text: templateData.restoreThumbnailsShort, |
| 186 } | 186 }; |
| 187 | 187 |
| 188 ntp4.showNotification(templateData.thumbnailremovednotification, | 188 ntp4.showNotification(templateData.thumbnailremovednotification, |
| 189 [undo, undoAll]); | 189 [undo, undoAll]); |
| 190 }, | 190 }, |
| 191 | 191 |
| 192 /** | 192 /** |
| 193 * Set the size and position of the most visited tile. | 193 * Set the size and position of the most visited tile. |
| 194 * @param {number} size The total size of |this|. | 194 * @param {number} size The total size of |this|. |
| 195 * @param {number} x The x-position. | 195 * @param {number} x The x-position. |
| 196 * @param {number} y The y-position. | 196 * @param {number} y The y-position. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 }, | 344 }, |
| 345 | 345 |
| 346 /** @inheritDoc */ | 346 /** @inheritDoc */ |
| 347 heightForWidth: heightForWidth, | 347 heightForWidth: heightForWidth, |
| 348 }; | 348 }; |
| 349 | 349 |
| 350 /** | 350 /** |
| 351 * We've gotten additional Most Visited data. Update our old data with the | 351 * We've gotten additional Most Visited data. Update our old data with the |
| 352 * new data. The ordering of the new data is not important, except when a | 352 * new data. The ordering of the new data is not important, except when a |
| 353 * page is pinned. Thus we try to minimize re-ordering. | 353 * page is pinned. Thus we try to minimize re-ordering. |
| 354 * @param {Object} oldData The current Most Visited page list. | 354 * @param {Array} oldData The current Most Visited page list. |
| 355 * @param {Object} newData The new Most Visited page list. | 355 * @param {Array} newData The new Most Visited page list. |
| 356 * @return The merged page list that should replace the current page list. | 356 * @return {Array} The merged page list that should replace the current page |
| 357 * list. |
| 357 */ | 358 */ |
| 358 function refreshData(oldData, newData) { | 359 function refreshData(oldData, newData) { |
| 359 oldData = oldData.slice(0, THUMBNAIL_COUNT); | 360 oldData = oldData.slice(0, THUMBNAIL_COUNT); |
| 360 newData = newData.slice(0, THUMBNAIL_COUNT); | 361 newData = newData.slice(0, THUMBNAIL_COUNT); |
| 361 | 362 |
| 362 // Copy over pinned sites directly. | 363 // Copy over pinned sites directly. |
| 363 for (var j = 0; j < newData.length; j++) { | 364 for (var j = 0; j < newData.length; j++) { |
| 364 if (newData[j].pinned) { | 365 if (newData[j].pinned) { |
| 365 oldData[j] = newData[j]; | 366 oldData[j] = newData[j]; |
| 366 // Mark the entry as 'updated' so we don't try to update again. | 367 // Mark the entry as 'updated' so we don't try to update again. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 417 } |
| 417 | 418 |
| 418 return oldData; | 419 return oldData; |
| 419 }; | 420 }; |
| 420 | 421 |
| 421 return { | 422 return { |
| 422 MostVisitedPage: MostVisitedPage, | 423 MostVisitedPage: MostVisitedPage, |
| 423 refreshData: refreshData, | 424 refreshData: refreshData, |
| 424 }; | 425 }; |
| 425 }); | 426 }); |
| OLD | NEW |