| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 var self = this; | 58 var self = this; |
| 59 this.forAllLaunchTypes_(function(launchTypeButton, id) { | 59 this.forAllLaunchTypes_(function(launchTypeButton, id) { |
| 60 launchTypeButton.addEventListener('activate', | 60 launchTypeButton.addEventListener('activate', |
| 61 self.onLaunchTypeChanged_.bind(self)); | 61 self.onLaunchTypeChanged_.bind(self)); |
| 62 }); | 62 }); |
| 63 | 63 |
| 64 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); | 64 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); |
| 65 menu.appendChild(this.launchTypeMenuSeparator_); | 65 menu.appendChild(this.launchTypeMenuSeparator_); |
| 66 this.options_ = this.appendMenuItem_('appoptions'); | 66 this.options_ = this.appendMenuItem_('appoptions'); |
| 67 this.details_ = this.appendMenuItem_('appdetails'); | |
| 68 this.uninstall_ = this.appendMenuItem_('appuninstall'); | 67 this.uninstall_ = this.appendMenuItem_('appuninstall'); |
| 68 |
| 69 if (loadTimeData.getBoolean('canShowAppInfoDialog')) { |
| 70 this.appinfo_ = this.appendMenuItem_('appinfodialog'); |
| 71 this.appinfo_.addEventListener('activate', |
| 72 this.onShowAppInfo_.bind(this)); |
| 73 } else { |
| 74 this.details_ = this.appendMenuItem_('appdetails'); |
| 75 this.details_.addEventListener('activate', |
| 76 this.onShowDetails_.bind(this)); |
| 77 } |
| 78 |
| 69 this.options_.addEventListener('activate', | 79 this.options_.addEventListener('activate', |
| 70 this.onShowOptions_.bind(this)); | 80 this.onShowOptions_.bind(this)); |
| 71 this.details_.addEventListener('activate', | |
| 72 this.onShowDetails_.bind(this)); | |
| 73 this.uninstall_.addEventListener('activate', | 81 this.uninstall_.addEventListener('activate', |
| 74 this.onUninstall_.bind(this)); | 82 this.onUninstall_.bind(this)); |
| 75 | 83 |
| 76 if (!cr.isChromeOS) { | 84 if (!cr.isChromeOS) { |
| 77 this.createShortcutSeparator_ = | 85 this.createShortcutSeparator_ = |
| 78 menu.appendChild(cr.ui.MenuItem.createSeparator()); | 86 menu.appendChild(cr.ui.MenuItem.createSeparator()); |
| 79 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); | 87 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); |
| 80 this.createShortcut_.addEventListener( | 88 this.createShortcut_.addEventListener( |
| 81 'activate', this.onCreateShortcut_.bind(this)); | 89 'activate', this.onCreateShortcut_.bind(this)); |
| 82 } | 90 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 launchTypeButton.checked = app.appData.launch_type == id; | 142 launchTypeButton.checked = app.appData.launch_type == id; |
| 135 // If bookmark apps are enabled, only show the "Open as window" button. | 143 // If bookmark apps are enabled, only show the "Open as window" button. |
| 136 launchTypeButton.hidden = app.appData.packagedApp || | 144 launchTypeButton.hidden = app.appData.packagedApp || |
| 137 (loadTimeData.getBoolean('enableNewBookmarkApps') && | 145 (loadTimeData.getBoolean('enableNewBookmarkApps') && |
| 138 launchTypeButton != launchTypeWindow); | 146 launchTypeButton != launchTypeWindow); |
| 139 }); | 147 }); |
| 140 | 148 |
| 141 this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; | 149 this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; |
| 142 | 150 |
| 143 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; | 151 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; |
| 144 this.details_.disabled = !app.appData.detailsUrl; | 152 if (this.details_) |
| 153 this.details_.disabled = !app.appData.detailsUrl; |
| 145 this.uninstall_.disabled = !app.appData.mayDisable; | 154 this.uninstall_.disabled = !app.appData.mayDisable; |
| 146 | 155 |
| 147 if (cr.isMac) { | 156 if (cr.isMac) { |
| 148 // On Windows and Linux, these should always be visible. On ChromeOS, | 157 // On Windows and Linux, these should always be visible. On ChromeOS, |
| 149 // they are never created. On Mac, shortcuts can only be created for | 158 // they are never created. On Mac, shortcuts can only be created for |
| 150 // new-style packaged apps, so hide the menu item. | 159 // new-style packaged apps, so hide the menu item. |
| 151 this.createShortcutSeparator_.hidden = this.createShortcut_.hidden = | 160 this.createShortcutSeparator_.hidden = this.createShortcut_.hidden = |
| 152 !app.appData.packagedApp; | 161 !app.appData.packagedApp; |
| 153 } | 162 } |
| 154 }, | 163 }, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 var url = this.app_.appData.detailsUrl; | 196 var url = this.app_.appData.detailsUrl; |
| 188 url = appendParam(url, 'utm_source', 'chrome-ntp-launcher'); | 197 url = appendParam(url, 'utm_source', 'chrome-ntp-launcher'); |
| 189 window.location = url; | 198 window.location = url; |
| 190 }, | 199 }, |
| 191 onUninstall_: function(e) { | 200 onUninstall_: function(e) { |
| 192 chrome.send('uninstallApp', [this.app_.appData.id]); | 201 chrome.send('uninstallApp', [this.app_.appData.id]); |
| 193 }, | 202 }, |
| 194 onCreateShortcut_: function(e) { | 203 onCreateShortcut_: function(e) { |
| 195 chrome.send('createAppShortcut', [this.app_.appData.id]); | 204 chrome.send('createAppShortcut', [this.app_.appData.id]); |
| 196 }, | 205 }, |
| 206 onShowAppInfo_: function(e) { |
| 207 chrome.send('showAppInfo', [this.app_.appData.id]); |
| 208 } |
| 197 }; | 209 }; |
| 198 | 210 |
| 199 /** | 211 /** |
| 200 * Creates a new App object. | 212 * Creates a new App object. |
| 201 * @param {Object} appData The data object that describes the app. | 213 * @param {Object} appData The data object that describes the app. |
| 202 * @constructor | 214 * @constructor |
| 203 * @extends {HTMLDivElement} | 215 * @extends {HTMLDivElement} |
| 204 */ | 216 */ |
| 205 function App(appData) { | 217 function App(appData) { |
| 206 var el = cr.doc.createElement('div'); | 218 var el = cr.doc.createElement('div'); |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 function launchAppAfterEnable(appId) { | 779 function launchAppAfterEnable(appId) { |
| 768 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); | 780 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); |
| 769 } | 781 } |
| 770 | 782 |
| 771 return { | 783 return { |
| 772 APP_LAUNCH: APP_LAUNCH, | 784 APP_LAUNCH: APP_LAUNCH, |
| 773 AppsPage: AppsPage, | 785 AppsPage: AppsPage, |
| 774 launchAppAfterEnable: launchAppAfterEnable, | 786 launchAppAfterEnable: launchAppAfterEnable, |
| 775 }; | 787 }; |
| 776 }); | 788 }); |
| OLD | NEW |