| 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('ntp', function() { | 5 cr.define('ntp', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 var localStrings = new LocalStrings; | |
| 9 | |
| 10 var APP_LAUNCH = { | 8 var APP_LAUNCH = { |
| 11 // The histogram buckets (keep in sync with extension_constants.h). | 9 // The histogram buckets (keep in sync with extension_constants.h). |
| 12 NTP_APPS_MAXIMIZED: 0, | 10 NTP_APPS_MAXIMIZED: 0, |
| 13 NTP_APPS_COLLAPSED: 1, | 11 NTP_APPS_COLLAPSED: 1, |
| 14 NTP_APPS_MENU: 2, | 12 NTP_APPS_MENU: 2, |
| 15 NTP_MOST_VISITED: 3, | 13 NTP_MOST_VISITED: 3, |
| 16 NTP_RECENTLY_CLOSED: 4, | 14 NTP_RECENTLY_CLOSED: 4, |
| 17 NTP_APP_RE_ENABLE: 16, | 15 NTP_APP_RE_ENABLE: 16, |
| 18 NTP_WEBSTORE_FOOTER: 18, | 16 NTP_WEBSTORE_FOOTER: 18, |
| 19 NTP_WEBSTORE_PLUS_ICON: 19, | 17 NTP_WEBSTORE_PLUS_ICON: 19, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 /** | 88 /** |
| 91 * Appends a menu item to |this.menu|. | 89 * Appends a menu item to |this.menu|. |
| 92 * @param {?String} textId If non-null, the ID for the localized string | 90 * @param {?String} textId If non-null, the ID for the localized string |
| 93 * that acts as the item's label. | 91 * that acts as the item's label. |
| 94 */ | 92 */ |
| 95 appendMenuItem_: function(textId) { | 93 appendMenuItem_: function(textId) { |
| 96 var button = cr.doc.createElement('button'); | 94 var button = cr.doc.createElement('button'); |
| 97 this.menu.appendChild(button); | 95 this.menu.appendChild(button); |
| 98 cr.ui.decorate(button, cr.ui.MenuItem); | 96 cr.ui.decorate(button, cr.ui.MenuItem); |
| 99 if (textId) | 97 if (textId) |
| 100 button.textContent = localStrings.getString(textId); | 98 button.textContent = loadTimeData.getString(textId); |
| 101 return button; | 99 return button; |
| 102 }, | 100 }, |
| 103 | 101 |
| 104 /** | 102 /** |
| 105 * Iterates over all the launch type menu items. | 103 * Iterates over all the launch type menu items. |
| 106 * @param {function(cr.ui.MenuItem, number)} f The function to call for each | 104 * @param {function(cr.ui.MenuItem, number)} f The function to call for each |
| 107 * menu item. The parameters to the function include the menu item and | 105 * menu item. The parameters to the function include the menu item and |
| 108 * the associated launch ID. | 106 * the associated launch ID. |
| 109 */ | 107 */ |
| 110 forAllLaunchTypes_: function(f) { | 108 forAllLaunchTypes_: function(f) { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 | 641 |
| 644 return el; | 642 return el; |
| 645 } | 643 } |
| 646 | 644 |
| 647 AppsPage.prototype = { | 645 AppsPage.prototype = { |
| 648 __proto__: TilePage.prototype, | 646 __proto__: TilePage.prototype, |
| 649 | 647 |
| 650 initialize: function() { | 648 initialize: function() { |
| 651 this.classList.add('apps-page'); | 649 this.classList.add('apps-page'); |
| 652 | 650 |
| 653 if (templateData.appInstallHintEnabled) { | 651 if (loadTimeData.getBoolean('appInstallHintEnabled')) { |
| 654 this.appInstallHint_ = $('app-install-hint-template').cloneNode(true); | 652 this.appInstallHint_ = $('app-install-hint-template').cloneNode(true); |
| 655 this.appInstallHint_.addEventListener('click', function(e) { | 653 this.appInstallHint_.addEventListener('click', function(e) { |
| 656 chrome.send('recordAppLaunchByURL', | 654 chrome.send('recordAppLaunchByURL', |
| 657 [encodeURIComponent(this.href), | 655 [encodeURIComponent(this.href), |
| 658 APP_LAUNCH.NTP_WEBSTORE_PLUS_ICON]); | 656 APP_LAUNCH.NTP_WEBSTORE_PLUS_ICON]); |
| 659 }); | 657 }); |
| 660 this.content_.appendChild(this.appInstallHint_); | 658 this.content_.appendChild(this.appInstallHint_); |
| 661 } | 659 } |
| 662 | 660 |
| 663 this.addEventListener('cardselected', this.onCardSelected_); | 661 this.addEventListener('cardselected', this.onCardSelected_); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 app.setupNotification_(notification); | 1004 app.setupNotification_(notification); |
| 1007 } | 1005 } |
| 1008 | 1006 |
| 1009 return { | 1007 return { |
| 1010 APP_LAUNCH: APP_LAUNCH, | 1008 APP_LAUNCH: APP_LAUNCH, |
| 1011 appNotificationChanged: appNotificationChanged, | 1009 appNotificationChanged: appNotificationChanged, |
| 1012 AppsPage: AppsPage, | 1010 AppsPage: AppsPage, |
| 1013 launchAppAfterEnable: launchAppAfterEnable, | 1011 launchAppAfterEnable: launchAppAfterEnable, |
| 1014 }; | 1012 }; |
| 1015 }); | 1013 }); |
| OLD | NEW |