| 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 APP_LAUNCH = { | 8 var APP_LAUNCH = { |
| 9 // The histogram buckets (keep in sync with extension_constants.h). | 9 // The histogram buckets (keep in sync with extension_constants.h). |
| 10 NTP_APPS_MAXIMIZED: 0, | 10 NTP_APPS_MAXIMIZED: 0, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 this.uninstall_ = this.appendMenuItem_('appuninstall'); | 70 this.uninstall_ = this.appendMenuItem_('appuninstall'); |
| 71 this.options_.addEventListener('activate', | 71 this.options_.addEventListener('activate', |
| 72 this.onShowOptions_.bind(this)); | 72 this.onShowOptions_.bind(this)); |
| 73 this.details_.addEventListener('activate', | 73 this.details_.addEventListener('activate', |
| 74 this.onShowDetails_.bind(this)); | 74 this.onShowDetails_.bind(this)); |
| 75 this.disableNotifications_.addEventListener( | 75 this.disableNotifications_.addEventListener( |
| 76 'activate', this.onDisableNotifications_.bind(this)); | 76 'activate', this.onDisableNotifications_.bind(this)); |
| 77 this.uninstall_.addEventListener('activate', | 77 this.uninstall_.addEventListener('activate', |
| 78 this.onUninstall_.bind(this)); | 78 this.onUninstall_.bind(this)); |
| 79 | 79 |
| 80 if (!cr.isMac && !cr.isChromeOS) { | 80 if (!cr.isChromeOS) { |
| 81 menu.appendChild(cr.ui.MenuItem.createSeparator()); | 81 this.createShortcutSeparator_ = |
| 82 menu.appendChild(cr.ui.MenuItem.createSeparator()); |
| 82 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); | 83 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); |
| 83 this.createShortcut_.addEventListener( | 84 this.createShortcut_.addEventListener( |
| 84 'activate', this.onCreateShortcut_.bind(this)); | 85 'activate', this.onCreateShortcut_.bind(this)); |
| 85 } | 86 } |
| 86 | 87 |
| 87 document.body.appendChild(menu); | 88 document.body.appendChild(menu); |
| 88 }, | 89 }, |
| 89 | 90 |
| 90 /** | 91 /** |
| 91 * Appends a menu item to |this.menu|. | 92 * Appends a menu item to |this.menu|. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; | 143 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; |
| 143 this.details_.disabled = !app.appData.detailsUrl; | 144 this.details_.disabled = !app.appData.detailsUrl; |
| 144 this.uninstall_.disabled = !app.appData.mayDisable; | 145 this.uninstall_.disabled = !app.appData.mayDisable; |
| 145 | 146 |
| 146 this.disableNotifications_.hidden = true; | 147 this.disableNotifications_.hidden = true; |
| 147 var notificationsDisabled = app.appData.notifications_disabled; | 148 var notificationsDisabled = app.appData.notifications_disabled; |
| 148 if (typeof notificationsDisabled != 'undefined') { | 149 if (typeof notificationsDisabled != 'undefined') { |
| 149 this.disableNotifications_.hidden = false; | 150 this.disableNotifications_.hidden = false; |
| 150 this.disableNotifications_.checked = notificationsDisabled; | 151 this.disableNotifications_.checked = notificationsDisabled; |
| 151 } | 152 } |
| 153 this.createShortcutSeparator_.hidden = this.createShortcut_.hidden = |
| 154 !app.appData.packagedApp; |
| 152 }, | 155 }, |
| 153 | 156 |
| 154 /** | 157 /** |
| 155 * Handlers for menu item activation. | 158 * Handlers for menu item activation. |
| 156 * @param {Event} e The activation event. | 159 * @param {Event} e The activation event. |
| 157 * @private | 160 * @private |
| 158 */ | 161 */ |
| 159 onLaunch_: function(e) { | 162 onLaunch_: function(e) { |
| 160 chrome.send('launchApp', [this.app_.appId, APP_LAUNCH.NTP_APPS_MENU]); | 163 chrome.send('launchApp', [this.app_.appId, APP_LAUNCH.NTP_APPS_MENU]); |
| 161 }, | 164 }, |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 app.setupNotification_(notification); | 894 app.setupNotification_(notification); |
| 892 } | 895 } |
| 893 | 896 |
| 894 return { | 897 return { |
| 895 APP_LAUNCH: APP_LAUNCH, | 898 APP_LAUNCH: APP_LAUNCH, |
| 896 appNotificationChanged: appNotificationChanged, | 899 appNotificationChanged: appNotificationChanged, |
| 897 AppsPage: AppsPage, | 900 AppsPage: AppsPage, |
| 898 launchAppAfterEnable: launchAppAfterEnable, | 901 launchAppAfterEnable: launchAppAfterEnable, |
| 899 }; | 902 }; |
| 900 }); | 903 }); |
| OLD | NEW |