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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 this.options_ = this.appendMenuItem_('appoptions'); | 66 this.options_ = this.appendMenuItem_('appoptions'); |
67 this.details_ = this.appendMenuItem_('appdetails'); | 67 this.details_ = this.appendMenuItem_('appdetails'); |
68 this.uninstall_ = this.appendMenuItem_('appuninstall'); | 68 this.uninstall_ = this.appendMenuItem_('appuninstall'); |
69 this.options_.addEventListener('activate', | 69 this.options_.addEventListener('activate', |
70 this.onShowOptions_.bind(this)); | 70 this.onShowOptions_.bind(this)); |
71 this.details_.addEventListener('activate', | 71 this.details_.addEventListener('activate', |
72 this.onShowDetails_.bind(this)); | 72 this.onShowDetails_.bind(this)); |
73 this.uninstall_.addEventListener('activate', | 73 this.uninstall_.addEventListener('activate', |
74 this.onUninstall_.bind(this)); | 74 this.onUninstall_.bind(this)); |
75 | 75 |
76 if (!(cr.isChromeOS || cr.isMac)) { | 76 if (!cr.isChromeOS) { |
77 this.createShortcutSeparator_ = | 77 this.createShortcutSeparator_ = |
78 menu.appendChild(cr.ui.MenuItem.createSeparator()); | 78 menu.appendChild(cr.ui.MenuItem.createSeparator()); |
79 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); | 79 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); |
80 this.createShortcut_.addEventListener( | 80 this.createShortcut_.addEventListener( |
81 'activate', this.onCreateShortcut_.bind(this)); | 81 'activate', this.onCreateShortcut_.bind(this)); |
82 } | 82 } |
83 | 83 |
84 document.body.appendChild(menu); | 84 document.body.appendChild(menu); |
85 }, | 85 }, |
86 | 86 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 launchTypeButton.checked = app.appData.launch_type == id; | 133 launchTypeButton.checked = app.appData.launch_type == id; |
134 launchTypeButton.hidden = app.appData.packagedApp; | 134 launchTypeButton.hidden = app.appData.packagedApp; |
135 }); | 135 }); |
136 | 136 |
137 this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; | 137 this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; |
138 | 138 |
139 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; | 139 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; |
140 this.details_.disabled = !app.appData.detailsUrl; | 140 this.details_.disabled = !app.appData.detailsUrl; |
141 this.uninstall_.disabled = !app.appData.mayDisable; | 141 this.uninstall_.disabled = !app.appData.mayDisable; |
142 | 142 |
143 if (this.createShortcut_ && cr.isMac) { | 143 if (cr.isMac) { |
144 // On Windows and Linux, these should always be visible. On ChromeOS, | 144 // On Windows and Linux, these should always be visible. On ChromeOS, |
145 // they are never created. On Mac, shortcuts can only be created for | 145 // they are never created. On Mac, shortcuts can only be created for |
146 // new-style packaged apps, so hide the menu item. | 146 // new-style packaged apps, so hide the menu item. Also check if |
| 147 // loadTimeData explicitly disables this as the feature is not yet |
| 148 // enabled by default on Mac. |
147 this.createShortcutSeparator_.hidden = this.createShortcut_.hidden = | 149 this.createShortcutSeparator_.hidden = this.createShortcut_.hidden = |
148 !app.appData.packagedApp; | 150 !app.appData.packagedApp || |
| 151 loadTimeData.getBoolean('disableCreateAppShortcut'); |
149 } | 152 } |
150 }, | 153 }, |
151 | 154 |
152 /** | 155 /** |
153 * Handlers for menu item activation. | 156 * Handlers for menu item activation. |
154 * @param {Event} e The activation event. | 157 * @param {Event} e The activation event. |
155 * @private | 158 * @private |
156 */ | 159 */ |
157 onLaunch_: function(e) { | 160 onLaunch_: function(e) { |
158 chrome.send('launchApp', [this.app_.appId, APP_LAUNCH.NTP_APPS_MENU]); | 161 chrome.send('launchApp', [this.app_.appId, APP_LAUNCH.NTP_APPS_MENU]); |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 function launchAppAfterEnable(appId) { | 752 function launchAppAfterEnable(appId) { |
750 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); | 753 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); |
751 } | 754 } |
752 | 755 |
753 return { | 756 return { |
754 APP_LAUNCH: APP_LAUNCH, | 757 APP_LAUNCH: APP_LAUNCH, |
755 AppsPage: AppsPage, | 758 AppsPage: AppsPage, |
756 launchAppAfterEnable: launchAppAfterEnable, | 759 launchAppAfterEnable: launchAppAfterEnable, |
757 }; | 760 }; |
758 }); | 761 }); |
OLD | NEW |