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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 | 60 |
61 var self = this; | 61 var self = this; |
62 this.forAllLaunchTypes_(function(launchTypeButton, id) { | 62 this.forAllLaunchTypes_(function(launchTypeButton, id) { |
63 launchTypeButton.addEventListener('activate', | 63 launchTypeButton.addEventListener('activate', |
64 self.onLaunchTypeChanged_.bind(self)); | 64 self.onLaunchTypeChanged_.bind(self)); |
65 }); | 65 }); |
66 | 66 |
67 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); | 67 this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); |
68 menu.appendChild(this.launchTypeMenuSeparator_); | 68 menu.appendChild(this.launchTypeMenuSeparator_); |
69 this.options_ = this.appendMenuItem_('appoptions'); | 69 this.options_ = this.appendMenuItem_('appoptions'); |
70 this.details_ = this.appendMenuItem_('appdetails'); | |
71 this.uninstall_ = this.appendMenuItem_('appuninstall'); | 70 this.uninstall_ = this.appendMenuItem_('appuninstall'); |
71 | |
72 if (loadTimeData.getBoolean('enableAppInfoDialog')) { | |
sashab
2015/02/06 16:23:00
I'd rename this to 'canShowAppInfoDialog' ('enable
tsergeant
2015/02/09 03:10:49
Done.
| |
73 this.appinfo_ = this.appendMenuItem_('appinfodialog'); | |
74 this.appinfo_.addEventListener('activate', | |
75 this.onShowAppInfo_.bind(this)); | |
76 } else { | |
77 this.details_ = this.appendMenuItem_('appdetails'); | |
sashab
2015/02/06 16:23:00
If they're actually replacing each other, why not
| |
78 this.details_.addEventListener('activate', | |
79 this.onShowDetails_.bind(this)); | |
80 } | |
81 | |
72 this.options_.addEventListener('activate', | 82 this.options_.addEventListener('activate', |
73 this.onShowOptions_.bind(this)); | 83 this.onShowOptions_.bind(this)); |
74 this.details_.addEventListener('activate', | 84 |
75 this.onShowDetails_.bind(this)); | |
76 this.uninstall_.addEventListener('activate', | 85 this.uninstall_.addEventListener('activate', |
77 this.onUninstall_.bind(this)); | 86 this.onUninstall_.bind(this)); |
78 | 87 |
79 if (!cr.isChromeOS) { | 88 if (!cr.isChromeOS) { |
80 this.createShortcutSeparator_ = | 89 this.createShortcutSeparator_ = |
81 menu.appendChild(cr.ui.MenuItem.createSeparator()); | 90 menu.appendChild(cr.ui.MenuItem.createSeparator()); |
82 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); | 91 this.createShortcut_ = this.appendMenuItem_('appcreateshortcut'); |
83 this.createShortcut_.addEventListener( | 92 this.createShortcut_.addEventListener( |
84 'activate', this.onCreateShortcut_.bind(this)); | 93 'activate', this.onCreateShortcut_.bind(this)); |
85 } | 94 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 launchTypeButton.checked = app.appData.launch_type == id; | 146 launchTypeButton.checked = app.appData.launch_type == id; |
138 // If bookmark apps are enabled, only show the "Open as tab" button. | 147 // If bookmark apps are enabled, only show the "Open as tab" button. |
139 launchTypeButton.hidden = app.appData.packagedApp || | 148 launchTypeButton.hidden = app.appData.packagedApp || |
140 (loadTimeData.getBoolean('enableNewBookmarkApps') && | 149 (loadTimeData.getBoolean('enableNewBookmarkApps') && |
141 launchTypeButton != launchTypeRegularTab); | 150 launchTypeButton != launchTypeRegularTab); |
142 }); | 151 }); |
143 | 152 |
144 this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; | 153 this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; |
145 | 154 |
146 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; | 155 this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; |
147 this.details_.disabled = !app.appData.detailsUrl; | 156 if (this.details_) |
157 this.details_.disabled = !app.appData.detailsUrl; | |
sashab
2015/02/06 16:23:00
Yeah... I don't like this. I think maybe create th
tsergeant
2015/02/09 03:10:49
Creating the link and then disabling it means that
sashab
2015/02/09 11:47:07
Ohh I didn't realise - yes having it disabled on m
| |
148 this.uninstall_.disabled = !app.appData.mayDisable; | 158 this.uninstall_.disabled = !app.appData.mayDisable; |
149 | 159 |
150 if (cr.isMac) { | 160 if (cr.isMac) { |
151 // On Windows and Linux, these should always be visible. On ChromeOS, | 161 // On Windows and Linux, these should always be visible. On ChromeOS, |
152 // they are never created. On Mac, shortcuts can only be created for | 162 // they are never created. On Mac, shortcuts can only be created for |
153 // new-style packaged apps, so hide the menu item. | 163 // new-style packaged apps, so hide the menu item. |
154 this.createShortcutSeparator_.hidden = this.createShortcut_.hidden = | 164 this.createShortcutSeparator_.hidden = this.createShortcut_.hidden = |
155 !app.appData.packagedApp; | 165 !app.appData.packagedApp; |
156 } | 166 } |
157 }, | 167 }, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 var url = this.app_.appData.detailsUrl; | 200 var url = this.app_.appData.detailsUrl; |
191 url = appendParam(url, 'utm_source', 'chrome-ntp-launcher'); | 201 url = appendParam(url, 'utm_source', 'chrome-ntp-launcher'); |
192 window.location = url; | 202 window.location = url; |
193 }, | 203 }, |
194 onUninstall_: function(e) { | 204 onUninstall_: function(e) { |
195 chrome.send('uninstallApp', [this.app_.appData.id]); | 205 chrome.send('uninstallApp', [this.app_.appData.id]); |
196 }, | 206 }, |
197 onCreateShortcut_: function(e) { | 207 onCreateShortcut_: function(e) { |
198 chrome.send('createAppShortcut', [this.app_.appData.id]); | 208 chrome.send('createAppShortcut', [this.app_.appData.id]); |
199 }, | 209 }, |
210 onShowAppInfo_: function(e) { | |
211 chrome.send('showAppInfo', [this.app_.appData.id]); | |
212 } | |
200 }; | 213 }; |
201 | 214 |
202 /** | 215 /** |
203 * Creates a new App object. | 216 * Creates a new App object. |
204 * @param {Object} appData The data object that describes the app. | 217 * @param {Object} appData The data object that describes the app. |
205 * @constructor | 218 * @constructor |
206 * @extends {HTMLDivElement} | 219 * @extends {HTMLDivElement} |
207 */ | 220 */ |
208 function App(appData) { | 221 function App(appData) { |
209 var el = cr.doc.createElement('div'); | 222 var el = cr.doc.createElement('div'); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 function launchAppAfterEnable(appId) { | 783 function launchAppAfterEnable(appId) { |
771 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); | 784 chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]); |
772 } | 785 } |
773 | 786 |
774 return { | 787 return { |
775 APP_LAUNCH: APP_LAUNCH, | 788 APP_LAUNCH: APP_LAUNCH, |
776 AppsPage: AppsPage, | 789 AppsPage: AppsPage, |
777 launchAppAfterEnable: launchAppAfterEnable, | 790 launchAppAfterEnable: launchAppAfterEnable, |
778 }; | 791 }; |
779 }); | 792 }); |
OLD | NEW |