| 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 /** | 5 /** |
| 6 * @fileoverview New tab page | 6 * @fileoverview New tab page |
| 7 * This is the main code for the new tab page used by touch-enabled Chrome | 7 * This is the main code for the new tab page used by touch-enabled Chrome |
| 8 * browsers. For now this is still a prototype. | 8 * browsers. For now this is still a prototype. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 * Given a theme resource name, construct a URL for it. | 238 * Given a theme resource name, construct a URL for it. |
| 239 * @param {string} resourceName The name of the resource. | 239 * @param {string} resourceName The name of the resource. |
| 240 * @return {string} A url which can be used to load the resource. | 240 * @return {string} A url which can be used to load the resource. |
| 241 */ | 241 */ |
| 242 function getThemeUrl(resourceName) { | 242 function getThemeUrl(resourceName) { |
| 243 return 'chrome://theme/' + resourceName; | 243 return 'chrome://theme/' + resourceName; |
| 244 } | 244 } |
| 245 | 245 |
| 246 /** | 246 /** |
| 247 * Callback invoked by chrome whenever an app preference changes. | 247 * Callback invoked by chrome whenever an app preference changes. |
| 248 * The normal NTP uses this to keep track of the current launch-type of an | |
| 249 * app, updating the choices in the context menu. We don't have such a menu | |
| 250 * so don't use this at all (but it still needs to be here for chrome to | |
| 251 * call). | |
| 252 * @param {Object} data An object with all the data on available | 248 * @param {Object} data An object with all the data on available |
| 253 * applications. | 249 * applications. |
| 254 */ | 250 */ |
| 255 function appsPrefChangeCallback(data) { | 251 function appsPrefChangeCallback(data) { |
| 252 var apps = document.querySelectorAll('.app'); |
| 253 |
| 254 // This is an expensive operation. We minimize how frequently it's called |
| 255 // by only calling it for changes across different instances of the NTP |
| 256 // (i.e. two separate tabs both showing NTP). |
| 257 for (var j = 0; j < data.apps.length; ++j) { |
| 258 for (var i = 0; i < apps.length; ++i) { |
| 259 if (data.apps[j]['id'] == apps[i].appId) |
| 260 apps[i].appData = data.apps[j]; |
| 261 } |
| 262 } |
| 256 } | 263 } |
| 257 | 264 |
| 258 function getCardSlider() { | 265 function getCardSlider() { |
| 259 return cardSlider; | 266 return cardSlider; |
| 260 } | 267 } |
| 261 | 268 |
| 262 /** | 269 /** |
| 263 * Invoked whenever the pages in apps-page-list have changed so that | 270 * Invoked whenever the pages in apps-page-list have changed so that |
| 264 * the Slider knows about the new elements. | 271 * the Slider knows about the new elements. |
| 265 */ | 272 */ |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // TODO(estade): update the content handlers to use ntp namespace instead of | 456 // TODO(estade): update the content handlers to use ntp namespace instead of |
| 450 // making these global. | 457 // making these global. |
| 451 var assert = ntp4.assert; | 458 var assert = ntp4.assert; |
| 452 var getAppsCallback = ntp4.getAppsCallback; | 459 var getAppsCallback = ntp4.getAppsCallback; |
| 453 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; | 460 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; |
| 454 var themeChanged = ntp4.themeChanged; | 461 var themeChanged = ntp4.themeChanged; |
| 455 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; | 462 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; |
| 456 var setMostVisitedPages = ntp4.setMostVisitedPages; | 463 var setMostVisitedPages = ntp4.setMostVisitedPages; |
| 457 | 464 |
| 458 document.addEventListener('DOMContentLoaded', ntp4.initialize); | 465 document.addEventListener('DOMContentLoaded', ntp4.initialize); |
| OLD | NEW |