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 = |
| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 function handleClick(e) { | 142 function handleClick(e) { |
139 var appId = e.currentTarget.getAttribute('app-id'); | 143 var appId = e.currentTarget.getAttribute('app-id'); |
140 launchApp(appId); | 144 launchApp(appId); |
141 return false; | 145 return false; |
142 } | 146 } |
143 | 147 |
144 // Keep in sync with LaunchType in extension_prefs.h | 148 // Keep in sync with LaunchType in extension_prefs.h |
145 var LaunchType = { | 149 var LaunchType = { |
146 LAUNCH_PINNED: 0, | 150 LAUNCH_PINNED: 0, |
147 LAUNCH_REGULAR: 1, | 151 LAUNCH_REGULAR: 1, |
148 LAUNCH_FULLSCREEN: 2 | 152 LAUNCH_FULLSCREEN: 2, |
| 153 LAUNCH_WINDOW: 3 |
149 }; | 154 }; |
150 | 155 |
151 // Keep in sync with LaunchContainer in extension.h | 156 // Keep in sync with LaunchContainer in extension_constants.h |
152 var LaunchContainer = { | 157 var LaunchContainer = { |
153 LAUNCH_WINDOW: 0, | 158 LAUNCH_WINDOW: 0, |
154 LAUNCH_PANEL: 1, | 159 LAUNCH_PANEL: 1, |
155 LAUNCH_TAB: 2 | 160 LAUNCH_TAB: 2 |
156 }; | 161 }; |
157 | 162 |
158 var currentApp; | 163 var currentApp; |
159 | 164 |
160 function addContextMenu(el, app) { | 165 function addContextMenu(el, app) { |
161 el.addEventListener('contextmenu', cr.ui.contextMenuHandler); | 166 el.addEventListener('contextmenu', cr.ui.contextMenuHandler); |
(...skipping 15 matching lines...) Expand all Loading... |
177 launchTypeEl = el.querySelector(appLinkSel); | 182 launchTypeEl = el.querySelector(appLinkSel); |
178 } | 183 } |
179 | 184 |
180 var launchType = launchTypeEl.getAttribute('launch-type'); | 185 var launchType = launchTypeEl.getAttribute('launch-type'); |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 var elm = createElement({ | 321 var elm = createElement({ |
315 'id': 'web-store-entry', | 322 'id': 'web-store-entry', |
316 'name': localStrings.getString('web_store_title'), | 323 'name': localStrings.getString('web_store_title'), |
317 'launch_url': localStrings.getString('web_store_url') | 324 'launch_url': localStrings.getString('web_store_url') |
318 }); | 325 }); |
319 elm.setAttribute('app-id', 'web-store-entry'); | 326 elm.setAttribute('app-id', 'web-store-entry'); |
320 return elm; | 327 return elm; |
321 } | 328 } |
322 }; | 329 }; |
323 })(); | 330 })(); |
OLD | NEW |