| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 get data() { | 271 get data() { |
| 272 return this.data_; | 272 return this.data_; |
| 273 }, | 273 }, |
| 274 set data(data) { | 274 set data(data) { |
| 275 var startTime = Date.now(); | 275 var startTime = Date.now(); |
| 276 | 276 |
| 277 // The first time data is set, create the tiles. | 277 // The first time data is set, create the tiles. |
| 278 if (!this.data_) { | 278 if (!this.data_) { |
| 279 this.createTiles_(); | 279 this.createTiles_(); |
| 280 this.data_ = data.slice(0, THUMBNAIL_COUNT); | 280 this.data_ = data.slice(0, THUMBNAIL_COUNT); |
| 281 // Display the sync notification when the page is first initialized - we |
| 282 // don't want to display the notification multiple times, so we do this |
| 283 // here instead of refreshData(). |
| 284 if (templateData.syncNotification) |
| 285 this.showSyncNotification_(); |
| 281 } else { | 286 } else { |
| 282 this.data_ = refreshData(this.data_, data); | 287 this.data_ = refreshData(this.data_, data); |
| 283 } | 288 } |
| 284 | 289 |
| 285 this.updateTiles_(); | 290 this.updateTiles_(); |
| 286 logEvent('mostVisited.layout: ' + (Date.now() - startTime)); | 291 logEvent('mostVisited.layout: ' + (Date.now() - startTime)); |
| 287 }, | 292 }, |
| 288 | 293 |
| 294 /** |
| 295 * Displays a sync-related notification on the NTP. |
| 296 * @private |
| 297 */ |
| 298 showSyncNotification_: function() { |
| 299 var advancedOptionsLink = { |
| 300 action: function() { |
| 301 chrome.send('SyncTypeLinkClicked'); |
| 302 }, |
| 303 text: templateData.syncLinkText |
| 304 }; |
| 305 ntp4.showNotification(templateData.syncNotification, |
| 306 [advancedOptionsLink], |
| 307 function() { |
| 308 chrome.send('closeSyncNotification'); |
| 309 }); |
| 310 }, |
| 311 |
| 289 /** @inheritDoc */ | 312 /** @inheritDoc */ |
| 290 shouldAcceptDrag: function(e) { | 313 shouldAcceptDrag: function(e) { |
| 291 return false; | 314 return false; |
| 292 }, | 315 }, |
| 293 | 316 |
| 294 /** @inheritDoc */ | 317 /** @inheritDoc */ |
| 295 heightForWidth: heightForWidth, | 318 heightForWidth: heightForWidth, |
| 296 }; | 319 }; |
| 297 | 320 |
| 298 /** | 321 /** |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 if (tile) | 394 if (tile) |
| 372 tile.setStripeColor(color); | 395 tile.setStripeColor(color); |
| 373 }; | 396 }; |
| 374 | 397 |
| 375 return { | 398 return { |
| 376 MostVisitedPage: MostVisitedPage, | 399 MostVisitedPage: MostVisitedPage, |
| 377 refreshData: refreshData, | 400 refreshData: refreshData, |
| 378 setFaviconDominantColor: setFaviconDominantColor, | 401 setFaviconDominantColor: setFaviconDominantColor, |
| 379 }; | 402 }; |
| 380 }); | 403 }); |
| OLD | NEW |