| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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('extensions', function() { | 5 cr.define('extensions', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Compares two extensions to determine which should come first in the list. | 9 * Compares two extensions to determine which should come first in the list. |
| 10 * @param {chrome.developerPrivate.ExtensionInfo} a | 10 * @param {chrome.developerPrivate.ExtensionInfo} a |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 }, | 91 }, |
| 92 }, | 92 }, |
| 93 | 93 |
| 94 /** @type {!Array<!chrome.developerPrivate.ExtensionInfo>} */ | 94 /** @type {!Array<!chrome.developerPrivate.ExtensionInfo>} */ |
| 95 apps: { | 95 apps: { |
| 96 type: Array, | 96 type: Array, |
| 97 value: function() { | 97 value: function() { |
| 98 return []; | 98 return []; |
| 99 }, | 99 }, |
| 100 }, | 100 }, |
| 101 |
| 102 /** |
| 103 * Prevents page content from showing before data is first loaded. |
| 104 * @private |
| 105 */ |
| 106 didInitPage_: { |
| 107 type: Boolean, |
| 108 value: false, |
| 109 }, |
| 101 }, | 110 }, |
| 102 | 111 |
| 103 listeners: { | 112 listeners: { |
| 104 'items-list.extension-item-show-details': 'onShouldShowItemDetails_', | 113 'items-list.extension-item-show-details': 'onShouldShowItemDetails_', |
| 105 'items-list.extension-item-show-errors': 'onShouldShowItemErrors_', | 114 'items-list.extension-item-show-errors': 'onShouldShowItemErrors_', |
| 106 }, | 115 }, |
| 107 | 116 |
| 108 created: function() { | 117 created: function() { |
| 109 this.readyPromiseResolver = new PromiseResolver(); | 118 this.readyPromiseResolver = new PromiseResolver(); |
| 110 }, | 119 }, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 */ | 173 */ |
| 165 showItemDetails: function(data) { | 174 showItemDetails: function(data) { |
| 166 this.changePage({page: Page.DETAILS, extensionId: data.id}); | 175 this.changePage({page: Page.DETAILS, extensionId: data.id}); |
| 167 }, | 176 }, |
| 168 | 177 |
| 169 /** | 178 /** |
| 170 * Initializes the page to reflect what's specified in the url so that if | 179 * Initializes the page to reflect what's specified in the url so that if |
| 171 * the user visits chrome://extensions/?id=..., we land on the proper page. | 180 * the user visits chrome://extensions/?id=..., we land on the proper page. |
| 172 */ | 181 */ |
| 173 initPage: function() { | 182 initPage: function() { |
| 183 this.didInitPage_ = true; |
| 174 this.changePage(this.navigationHelper_.getCurrentPage(), true); | 184 this.changePage(this.navigationHelper_.getCurrentPage(), true); |
| 175 }, | 185 }, |
| 176 | 186 |
| 177 /** | 187 /** |
| 178 * @param {!CustomEvent} event | 188 * @param {!CustomEvent} event |
| 179 * @private | 189 * @private |
| 180 */ | 190 */ |
| 181 onFilterChanged_: function(event) { | 191 onFilterChanged_: function(event) { |
| 182 this.filter = /** @type {string} */ (event.detail); | 192 this.filter = /** @type {string} */ (event.detail); |
| 183 }, | 193 }, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 /** | 239 /** |
| 230 * @return {?chrome.developerPrivate.ExtensionInfo} | 240 * @return {?chrome.developerPrivate.ExtensionInfo} |
| 231 * @private | 241 * @private |
| 232 */ | 242 */ |
| 233 getData_: function(id) { | 243 getData_: function(id) { |
| 234 return this.extensions[this.getIndexInList_('extensions', id)] || | 244 return this.extensions[this.getIndexInList_('extensions', id)] || |
| 235 this.apps[this.getIndexInList_('apps', id)]; | 245 this.apps[this.getIndexInList_('apps', id)]; |
| 236 }, | 246 }, |
| 237 | 247 |
| 238 /** | 248 /** |
| 239 * @return {boolean} Whether the list should be visible. | |
| 240 * @private | |
| 241 */ | |
| 242 computeListHidden_: function() { | |
| 243 return this.$['items-list'].items.length == 0; | |
| 244 }, | |
| 245 | |
| 246 /** | |
| 247 * Creates and adds a new extensions-item element to the list, inserting it | 249 * Creates and adds a new extensions-item element to the list, inserting it |
| 248 * into its sorted position in the relevant section. | 250 * into its sorted position in the relevant section. |
| 249 * @param {!chrome.developerPrivate.ExtensionInfo} item The extension | 251 * @param {!chrome.developerPrivate.ExtensionInfo} item The extension |
| 250 * the new element is representing. | 252 * the new element is representing. |
| 251 */ | 253 */ |
| 252 addItem: function(item) { | 254 addItem: function(item) { |
| 253 var listId = this.getListId_(item.type); | 255 var listId = this.getListId_(item.type); |
| 254 // We should never try and add an existing item. | 256 // We should never try and add an existing item. |
| 255 assert(this.getIndexInList_(listId, item.id) == -1); | 257 assert(this.getIndexInList_(listId, item.id) == -1); |
| 256 var insertBeforeChild = this[listId].findIndex(function(listEl) { | 258 var insertBeforeChild = this[listId].findIndex(function(listEl) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 448 } |
| 447 | 449 |
| 448 /** @override */ | 450 /** @override */ |
| 449 showKeyboardShortcuts() { | 451 showKeyboardShortcuts() { |
| 450 this.manager_.changePage({page: Page.SHORTCUTS}); | 452 this.manager_.changePage({page: Page.SHORTCUTS}); |
| 451 } | 453 } |
| 452 } | 454 } |
| 453 | 455 |
| 454 return {Manager: Manager}; | 456 return {Manager: Manager}; |
| 455 }); | 457 }); |
| OLD | NEW |