OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 var MAX_APPS_PER_ROW = []; | 5 var MAX_APPS_PER_ROW = []; |
6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; | 6 MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; |
7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; | 7 MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; |
8 | 8 |
9 // The URL prefix used in the app link 'ping' attributes. | 9 // The URL prefix used in the app link 'ping' attributes. |
10 var PING_APP_LAUNCH_PREFIX = 'record-app-launch'; | 10 var PING_APP_LAUNCH_PREFIX = 'record-app-launch'; |
11 | 11 |
12 // The URL prefix used in the webstore link 'ping' attributes. | 12 // The URL prefix used in the webstore link 'ping' attributes. |
13 var PING_WEBSTORE_LAUNCH_PREFIX = 'record-webstore-launch'; | 13 var PING_WEBSTORE_LAUNCH_PREFIX = 'record-webstore-launch'; |
14 | 14 |
15 function getAppsCallback(data) { | 15 function getAppsCallback(data) { |
16 logEvent('received apps'); | 16 logEvent('received apps'); |
17 var appsSection = $('apps'); | 17 var appsSection = $('apps'); |
18 var appsSectionContent = $('apps-content'); | 18 var appsSectionContent = $('apps-content'); |
19 var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; | 19 var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; |
20 var appsPromo = $('apps-promo'); | 20 var appsPromo = $('apps-promo'); |
21 var appsPromoPing = PING_WEBSTORE_LAUNCH_PREFIX + '+' + data.showPromo; | 21 var appsPromoPing = PING_WEBSTORE_LAUNCH_PREFIX + '+' + data.showPromo; |
22 var webStoreEntry; | 22 var webStoreEntry; |
23 | 23 |
24 // Hide the app window menu option on platforms that do not support it. | |
25 $('apps-launch-type-window-menu-item').style.display = | |
Aaron Boodman
2010/11/18 07:49:03
I think it would be a little neater to just do thi
Sam Kerner (Chrome)
2010/11/18 15:34:01
What if the user changes the user agent? This is
Aaron Boodman
2010/11/18 16:16:00
Good point.
arv (Not doing code reviews)
2010/11/18 19:02:49
If they change the user agent they are opening the
arv (Not doing code reviews)
2010/11/18 19:02:49
cr.isMac
| |
26 (data.disableAppWindowLaunch ? 'none' : 'inline'); | |
27 | |
24 appsMiniview.textContent = ''; | 28 appsMiniview.textContent = ''; |
25 appsSectionContent.textContent = ''; | 29 appsSectionContent.textContent = ''; |
26 | 30 |
27 apps.showPromo = data.showPromo; | 31 apps.showPromo = data.showPromo; |
28 | 32 |
29 data.apps.sort(function(a,b) { | 33 data.apps.sort(function(a,b) { |
30 return a.app_launch_index - b.app_launch_index; | 34 return a.app_launch_index - b.app_launch_index; |
31 }); | 35 }); |
32 | 36 |
33 clearClosedMenu(apps.menu); | 37 clearClosedMenu(apps.menu); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 function handleClick(e) { | 147 function handleClick(e) { |
144 var appId = e.currentTarget.getAttribute('app-id'); | 148 var appId = e.currentTarget.getAttribute('app-id'); |
145 launchApp(appId); | 149 launchApp(appId); |
146 return false; | 150 return false; |
147 } | 151 } |
148 | 152 |
149 // Keep in sync with LaunchType in extension_prefs.h | 153 // Keep in sync with LaunchType in extension_prefs.h |
150 var LaunchType = { | 154 var LaunchType = { |
151 LAUNCH_PINNED: 0, | 155 LAUNCH_PINNED: 0, |
152 LAUNCH_REGULAR: 1, | 156 LAUNCH_REGULAR: 1, |
153 LAUNCH_FULLSCREEN: 2 | 157 LAUNCH_FULLSCREEN: 2, |
158 LAUNCH_WINDOW: 3 | |
154 }; | 159 }; |
155 | 160 |
156 // Keep in sync with LaunchContainer in extension.h | 161 // Keep in sync with LaunchContainer in extension_constants.h |
157 var LaunchContainer = { | 162 var LaunchContainer = { |
158 LAUNCH_WINDOW: 0, | 163 LAUNCH_WINDOW: 0, |
159 LAUNCH_PANEL: 1, | 164 LAUNCH_PANEL: 1, |
160 LAUNCH_TAB: 2 | 165 LAUNCH_TAB: 2 |
161 }; | 166 }; |
162 | 167 |
163 var currentApp; | 168 var currentApp; |
164 | 169 |
165 function addContextMenu(el, app) { | 170 function addContextMenu(el, app) { |
166 el.addEventListener('contextmenu', cr.ui.contextMenuHandler); | 171 el.addEventListener('contextmenu', cr.ui.contextMenuHandler); |
(...skipping 10 matching lines...) Expand all Loading... | |
177 var appLinkSel = '.app a[app-id=' + app['id'] + ']'; | 182 var appLinkSel = '.app a[app-id=' + app['id'] + ']'; |
178 var launchType = | 183 var launchType = |
179 el.querySelector(appLinkSel).getAttribute('launch-type'); | 184 el.querySelector(appLinkSel).getAttribute('launch-type'); |
180 | 185 |
181 var launchContainer = app['launch_container']; | 186 var launchContainer = app['launch_container']; |
182 var isPanel = launchContainer == LaunchContainer.LAUNCH_PANEL; | 187 var isPanel = launchContainer == LaunchContainer.LAUNCH_PANEL; |
183 | 188 |
184 // Update the commands related to the launch type. | 189 // Update the commands related to the launch type. |
185 var launchTypeIds = ['apps-launch-type-pinned', | 190 var launchTypeIds = ['apps-launch-type-pinned', |
186 'apps-launch-type-regular', | 191 'apps-launch-type-regular', |
187 'apps-launch-type-fullscreen']; | 192 'apps-launch-type-fullscreen', |
193 'apps-launch-type-window']; | |
188 launchTypeIds.forEach(function(id) { | 194 launchTypeIds.forEach(function(id) { |
189 var command = $(id); | 195 var command = $(id); |
190 command.disabled = isPanel; | 196 command.disabled = isPanel; |
191 command.checked = !isPanel && | 197 command.checked = !isPanel && |
192 launchType == command.getAttribute('launch-type'); | 198 launchType == command.getAttribute('launch-type'); |
193 }); | 199 }); |
194 | 200 |
195 return $('app-context-menu'); | 201 return $('app-context-menu'); |
196 } | 202 } |
197 }); | 203 }); |
(...skipping 10 matching lines...) Expand all Loading... | |
208 break; | 214 break; |
209 case 'apps-launch-command': | 215 case 'apps-launch-command': |
210 launchApp(currentApp['id']); | 216 launchApp(currentApp['id']); |
211 break; | 217 break; |
212 case 'apps-uninstall-command': | 218 case 'apps-uninstall-command': |
213 chrome.send('uninstallApp', [currentApp['id']]); | 219 chrome.send('uninstallApp', [currentApp['id']]); |
214 break; | 220 break; |
215 case 'apps-launch-type-pinned': | 221 case 'apps-launch-type-pinned': |
216 case 'apps-launch-type-regular': | 222 case 'apps-launch-type-regular': |
217 case 'apps-launch-type-fullscreen': | 223 case 'apps-launch-type-fullscreen': |
224 case 'apps-launch-type-window': | |
218 chrome.send('setLaunchType', | 225 chrome.send('setLaunchType', |
219 [currentApp['id'], e.command.getAttribute('launch-type')]); | 226 [currentApp['id'], e.command.getAttribute('launch-type')]); |
220 break; | 227 break; |
221 } | 228 } |
222 }); | 229 }); |
223 | 230 |
224 document.addEventListener('canExecute', function(e) { | 231 document.addEventListener('canExecute', function(e) { |
225 switch (e.command.id) { | 232 switch (e.command.id) { |
226 case 'apps-options-command': | 233 case 'apps-options-command': |
227 e.canExecute = currentApp && currentApp['options_url']; | 234 e.canExecute = currentApp && currentApp['options_url']; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 var elm = createElement({ | 318 var elm = createElement({ |
312 'id': 'web-store-entry', | 319 'id': 'web-store-entry', |
313 'name': localStrings.getString('web_store_title'), | 320 'name': localStrings.getString('web_store_title'), |
314 'launch_url': localStrings.getString('web_store_url') | 321 'launch_url': localStrings.getString('web_store_url') |
315 }); | 322 }); |
316 elm.setAttribute('app-id', 'web-store-entry'); | 323 elm.setAttribute('app-id', 'web-store-entry'); |
317 return elm; | 324 return elm; |
318 } | 325 } |
319 }; | 326 }; |
320 })(); | 327 })(); |
OLD | NEW |