Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: chrome/browser/resources/extensions/extension_list.js

Issue 1025703003: [Extensions Page] Fix the flicker of "No extensions" before extension data loads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <include src="extension_error.js"> 5 <include src="extension_error.js">
6 6
7 /////////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////////
8 // ExtensionFocusRow: 8 // ExtensionFocusRow:
9 9
10 /** 10 /**
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 * @private {boolean} 181 * @private {boolean}
182 */ 182 */
183 permissionsPromptIsShowing_: false, 183 permissionsPromptIsShowing_: false,
184 184
185 /** 185 /**
186 * Necessary to only show the butterbar once. 186 * Necessary to only show the butterbar once.
187 * @private {boolean} 187 * @private {boolean}
188 */ 188 */
189 butterbarShown_: false, 189 butterbarShown_: false,
190 190
191 decorate: function() { 191 /**
192 chrome.developerPrivate.getExtensionsInfo( 192 * Whether or not incognito mode is available.
193 {includeDisabled: true, includeTerminated: true}, 193 * @private {boolean}
194 function(extensions) { 194 */
195 // Sort in order of unpacked vs. packed, followed by name, followed by 195 incognitoAvailable_: false,
196 // id. 196
197 extensions.sort(function(a, b) { 197 /**
198 function compare(x, y) { 198 * Whether or not the app info dialog is enabled.
199 return x < y ? -1 : (x > y ? 1 : 0); 199 * @private {boolean}
200 } 200 */
201 function compareLocation(x, y) { 201 enableAppInfoDialog_: false,
202 return x.location == chrome.developerPrivate.Location.UNPACKED ? 202
203 -1 : (x.location == y.location ? 0 : 1); 203 /** Needed because we use cr.ui.define. */
204 } 204 decorate: function() {},
205 return compareLocation(a, b) || 205
206 compare(a.name.toLowerCase(), b.name.toLowerCase()) || 206 /**
207 compare(a.id, b.id); 207 * Updates the extensions on the page.
208 }); 208 * @param {boolean} incognitoAvailable Whether or not incognito is allowed.
209 this.extensions_ = extensions; 209 * @param {boolean} enableAppInfoDialog Whether or not the app info dialog
210 this.showExtensionNodes_(); 210 * is enabled.
211 * @return {Promise} A promise that is resolved once the extensions data is
212 * fully updated.
213 */
214 updateExtensionsData: function(incognitoAvailable, enableAppInfoDialog) {
215 // If we start to need more information about the extension configuration,
216 // consider passing in the full object from the ExtensionSettings.
217 this.incognitoAvailable_ = incognitoAvailable;
218 this.enableAppInfoDialog_ = enableAppInfoDialog;
219 return new Promise(function(resolve, reject) {
220 chrome.developerPrivate.getExtensionsInfo(
221 {includeDisabled: true, includeTerminated: true},
222 function(extensions) {
223 // Sort in order of unpacked vs. packed, followed by name, followed by
224 // id.
225 extensions.sort(function(a, b) {
226 function compare(x, y) {
227 return x < y ? -1 : (x > y ? 1 : 0);
228 }
229 function compareLocation(x, y) {
230 return x.location == chrome.developerPrivate.Location.UNPACKED ?
231 -1 : (x.location == y.location ? 0 : 1);
232 }
233 return compareLocation(a, b) ||
234 compare(a.name.toLowerCase(), b.name.toLowerCase()) ||
235 compare(a.id, b.id);
236 });
237 this.extensions_ = extensions;
238 this.showExtensionNodes_();
239 resolve();
240 }.bind(this));
211 }.bind(this)); 241 }.bind(this));
212 }, 242 },
213 243
244 /** @return {number} The number of extensions being displayed. */
245 getNumExtensions: function() {
246 return this.extensions_ ? this.extensions_.length : 0;
Dan Beam 2015/03/21 01:14:10 this isn't the end of the world, but maybe just ad
Devlin 2015/03/21 01:32:23 Done in the decorator (since we use cr.ui.define,
247 },
248
214 getIdQueryParam_: function() { 249 getIdQueryParam_: function() {
215 return parseQueryParams(document.location)['id']; 250 return parseQueryParams(document.location)['id'];
216 }, 251 },
217 252
218 getOptionsQueryParam_: function() { 253 getOptionsQueryParam_: function() {
219 return parseQueryParams(document.location)['options']; 254 return parseQueryParams(document.location)['options'];
220 }, 255 },
221 256
222 /** 257 /**
223 * Creates or updates all extension items from scratch. 258 * Creates or updates all extension items from scratch.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 296 }
262 } 297 }
263 298
264 var idToHighlight = this.getIdQueryParam_(); 299 var idToHighlight = this.getIdQueryParam_();
265 if (idToHighlight && $(idToHighlight)) 300 if (idToHighlight && $(idToHighlight))
266 this.scrollToNode_(idToHighlight); 301 this.scrollToNode_(idToHighlight);
267 302
268 var idToOpenOptions = this.getOptionsQueryParam_(); 303 var idToOpenOptions = this.getOptionsQueryParam_();
269 if (idToOpenOptions && $(idToOpenOptions)) 304 if (idToOpenOptions && $(idToOpenOptions))
270 this.showEmbeddedExtensionOptions_(idToOpenOptions, true); 305 this.showEmbeddedExtensionOptions_(idToOpenOptions, true);
271
272 var noExtensions = this.extensions_.length == 0;
273 this.classList.toggle('empty-extension-list', noExtensions);
274 }, 306 },
275 307
276 /** Updates each row's focusable elements without rebuilding the grid. */ 308 /** Updates each row's focusable elements without rebuilding the grid. */
277 updateFocusableElements: function() { 309 updateFocusableElements: function() {
278 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); 310 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]');
279 for (var i = 0; i < rows.length; ++i) { 311 for (var i = 0; i < rows.length; ++i) {
280 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); 312 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements();
281 } 313 }
282 }, 314 },
283 315
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 this.setText_(row, '.location-text', extension.locationText || ''); 570 this.setText_(row, '.location-text', extension.locationText || '');
539 this.setText_(row, '.blacklist-text', extension.blacklistText || ''); 571 this.setText_(row, '.blacklist-text', extension.blacklistText || '');
540 this.setText_(row, '.extension-description', extension.description); 572 this.setText_(row, '.extension-description', extension.description);
541 573
542 // The 'Show Browser Action' button. 574 // The 'Show Browser Action' button.
543 this.updateVisibility_(row, '.show-button', 575 this.updateVisibility_(row, '.show-button',
544 isActive && extension.actionButtonHidden); 576 isActive && extension.actionButtonHidden);
545 577
546 // The 'allow in incognito' checkbox. 578 // The 'allow in incognito' checkbox.
547 this.updateVisibility_(row, '.incognito-control', 579 this.updateVisibility_(row, '.incognito-control',
548 isActive && this.data_.incognitoAvailable, 580 isActive && this.incognitoAvailable_,
549 function(item) { 581 function(item) {
550 var incognito = item.querySelector('input'); 582 var incognito = item.querySelector('input');
551 incognito.disabled = !extension.incognitoAccess.isEnabled; 583 incognito.disabled = !extension.incognitoAccess.isEnabled;
552 incognito.checked = extension.incognitoAccess.isActive; 584 incognito.checked = extension.incognitoAccess.isActive;
553 }); 585 });
554 586
555 // Hide butterBar if incognito is not enabled for the extension. 587 // Hide butterBar if incognito is not enabled for the extension.
556 var butterBar = row.querySelector('.butter-bar'); 588 var butterBar = row.querySelector('.butter-bar');
557 butterBar.hidden = 589 butterBar.hidden =
558 butterBar.hidden || !extension.incognitoAccess.isEnabled; 590 butterBar.hidden || !extension.incognitoAccess.isEnabled;
(...skipping 28 matching lines...) Expand all
587 619
588 // The 'Options' button or link, depending on its behaviour. 620 // The 'Options' button or link, depending on its behaviour.
589 var optionsEnabled = isActive && !!extension.optionsPage; 621 var optionsEnabled = isActive && !!extension.optionsPage;
590 this.updateVisibility_(row, '.options-link', optionsEnabled && 622 this.updateVisibility_(row, '.options-link', optionsEnabled &&
591 extension.optionsPage.openInTab); 623 extension.optionsPage.openInTab);
592 this.updateVisibility_(row, '.options-button', optionsEnabled && 624 this.updateVisibility_(row, '.options-button', optionsEnabled &&
593 !extension.optionsPage.openInTab); 625 !extension.optionsPage.openInTab);
594 626
595 // The 'View in Web Store/View Web Site' link. 627 // The 'View in Web Store/View Web Site' link.
596 var siteLinkEnabled = !!extension.homepageUrl && 628 var siteLinkEnabled = !!extension.homepageUrl &&
597 !this.data_.enableAppInfoDialog; 629 !this.enableAppInfoDialog_;
598 this.updateVisibility_(row, '.site-link', siteLinkEnabled, 630 this.updateVisibility_(row, '.site-link', siteLinkEnabled,
599 function(item) { 631 function(item) {
600 item.href = extension.homepageUrl; 632 item.href = extension.homepageUrl;
601 item.textContent = loadTimeData.getString( 633 item.textContent = loadTimeData.getString(
602 extension.homepageProvided ? 'extensionSettingsVisitWebsite' : 634 extension.homepageProvided ? 'extensionSettingsVisitWebsite' :
603 'extensionSettingsVisitWebStore'); 635 'extensionSettingsVisitWebStore');
604 }); 636 });
605 637
606 var isUnpacked = 638 var isUnpacked =
607 extension.location == chrome.developerPrivate.Location.UNPACKED; 639 extension.location == chrome.developerPrivate.Location.UNPACKED;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 746 }
715 if (!dependentExtension) 747 if (!dependentExtension)
716 return; 748 return;
717 749
718 var depNode = dependentTemplate.cloneNode(true); 750 var depNode = dependentTemplate.cloneNode(true);
719 depNode.querySelector('.dep-extension-title').textContent = 751 depNode.querySelector('.dep-extension-title').textContent =
720 dependentExtension.name; 752 dependentExtension.name;
721 depNode.querySelector('.dep-extension-id').textContent = 753 depNode.querySelector('.dep-extension-id').textContent =
722 dependentExtension.id; 754 dependentExtension.id;
723 dependentList.appendChild(depNode); 755 dependentList.appendChild(depNode);
724 }); 756 }, this);
725 }); 757 });
726 758
727 // The active views. 759 // The active views.
728 this.updateVisibility_(row, '.active-views', extension.views.length > 0, 760 this.updateVisibility_(row, '.active-views', extension.views.length > 0,
729 function(item) { 761 function(item) {
730 var link = item.querySelector('a'); 762 var link = item.querySelector('a');
731 763
732 // Link needs to be an only child before the list is updated. 764 // Link needs to be an only child before the list is updated.
733 while (link.nextElementSibling) 765 while (link.nextElementSibling)
734 item.removeChild(link.nextElementSibling); 766 item.removeChild(link.nextElementSibling);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // TODO(dbeam): why do we need to focus <extensionoptions> before and 972 // TODO(dbeam): why do we need to focus <extensionoptions> before and
941 // after its showing animation? Makes very little sense to me. 973 // after its showing animation? Makes very little sense to me.
942 overlay.setInitialFocus(); 974 overlay.setInitialFocus();
943 }, 975 },
944 }; 976 };
945 977
946 return { 978 return {
947 ExtensionList: ExtensionList 979 ExtensionList: ExtensionList
948 }; 980 };
949 }); 981 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/extensions/extensions.css » ('j') | chrome/browser/resources/extensions/extensions.css » ('J')

Powered by Google App Engine
This is Rietveld 408576698