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('apps_dev_tool', function() { | 5 cr.define('apps_dev_tool', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 // The list of all apps & extensions. | 8 // The list of all packed/unpacked apps and extensions. |
9 var completeList = []; | 9 var completeList = []; |
10 | 10 |
11 // The list of all apps. | 11 // The list of all packed apps. |
12 var appList = []; | 12 var packedAppList = []; |
13 | 13 |
14 // The list of all extensions. | 14 // The list of all packed extensions. |
15 var extensionList = []; | 15 var packedExtensionList = []; |
| 16 |
| 17 // The list of all unpacked apps or extensions. |
| 18 var unpackedList = []; |
16 | 19 |
17 /** const*/ var AppsDevTool = apps_dev_tool.AppsDevTool; | 20 /** const*/ var AppsDevTool = apps_dev_tool.AppsDevTool; |
18 | 21 |
19 /** | 22 /** |
20 * @param {string} a first string. | 23 * @param {string} a first string. |
21 * @param {string} b second string. | 24 * @param {string} b second string. |
22 * @return {number} 1, 0, -1 if |a| is lexicographically greater, equal or | 25 * @return {number} 1, 0, -1 if |a| is lexicographically greater, equal or |
23 * lesser than |b| respectively. | 26 * lesser than |b| respectively. |
24 */ | 27 */ |
25 function compare(a, b) { | 28 function compare(a, b) { |
(...skipping 19 matching lines...) Expand all Loading... |
45 * @param {string} app2 second app_name. | 48 * @param {string} app2 second app_name. |
46 */ | 49 */ |
47 function compareByName(app1, app2) { | 50 function compareByName(app1, app2) { |
48 return compare(app1.name.toLowerCase(), app2.name.toLowerCase()); | 51 return compare(app1.name.toLowerCase(), app2.name.toLowerCase()); |
49 } | 52 } |
50 | 53 |
51 /** | 54 /** |
52 * Refreshes the app. | 55 * Refreshes the app. |
53 */ | 56 */ |
54 function reloadAppDisplay() { | 57 function reloadAppDisplay() { |
55 var extensions = new ItemsList($('extension-settings-list'), extensionList); | 58 var extensions = new ItemsList($('packed-extension-list'), |
56 var apps = new ItemsList($('app-settings-list'), appList); | 59 packedExtensionList); |
| 60 var apps = new ItemsList($('packed-app-list'), packedAppList); |
| 61 var unpacked = new ItemsList($('unpacked-list'), unpackedList); |
57 extensions.showItemNodes(); | 62 extensions.showItemNodes(); |
58 apps.showItemNodes(); | 63 apps.showItemNodes(); |
| 64 unpacked.showItemNodes(); |
59 } | 65 } |
60 | 66 |
61 /** | 67 /** |
62 * Applies the given |filter| to the items list. | 68 * Applies the given |filter| to the items list. |
63 * @param {string} filter Curent string in the search box. | 69 * @param {string} filter Curent string in the search box. |
64 */ | 70 */ |
65 function rebuildAppList(filter) { | 71 function rebuildAppList(filter) { |
66 appList = []; | 72 packedAppList = []; |
67 extensionList = []; | 73 packedExtensionList = []; |
| 74 unpackedList = []; |
68 | 75 |
69 for (var i = 0; i < completeList.length; i++) { | 76 for (var i = 0; i < completeList.length; i++) { |
70 var item = completeList[i]; | 77 var item = completeList[i]; |
71 if (filter && item.name.toLowerCase().search(filter.toLowerCase()) < 0) | 78 if (filter && item.name.toLowerCase().search(filter.toLowerCase()) < 0) |
72 continue; | 79 continue; |
73 if (item.isApp) | 80 if (item.is_unpacked) |
74 appList.push(item); | 81 unpackedList.push(item); |
| 82 else if (item.isApp) |
| 83 packedAppList.push(item); |
75 else | 84 else |
76 extensionList.push(item); | 85 packedExtensionList.push(item); |
77 } | 86 } |
78 } | 87 } |
79 | 88 |
80 /** | 89 /** |
81 * Create item nodes from the metadata. | 90 * Create item nodes from the metadata. |
82 * @constructor | 91 * @constructor |
83 */ | 92 */ |
84 function ItemsList(itemsTabNode, items) { | 93 function ItemsList(itemsTabNode, items) { |
85 this.items_ = items; | 94 this.items_ = items; |
86 this.itemsTabNode_ = itemsTabNode; | 95 this.itemsTabNode_ = itemsTabNode; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 ItemsList.launchApp = function(id) { | 430 ItemsList.launchApp = function(id) { |
422 chrome.management.launchApp(id, function() { | 431 chrome.management.launchApp(id, function() { |
423 ItemsList.loadItemsInfo(); | 432 ItemsList.loadItemsInfo(); |
424 }); | 433 }); |
425 }; | 434 }; |
426 | 435 |
427 return { | 436 return { |
428 ItemsList: ItemsList, | 437 ItemsList: ItemsList, |
429 }; | 438 }; |
430 }); | 439 }); |
OLD | NEW |