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

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

Issue 1105683003: [Extensions Page] Add a listener on extension list for "hasExtensions" changing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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="../../../../ui/webui/resources/js/cr/ui/focus_row.js"> 5 <include src="../../../../ui/webui/resources/js/cr/ui/focus_row.js">
6 <include src="../../../../ui/webui/resources/js/cr/ui/focus_grid.js"> 6 <include src="../../../../ui/webui/resources/js/cr/ui/focus_grid.js">
7 <include src="../uber/uber_utils.js"> 7 <include src="../uber/uber_utils.js">
8 <include src="extension_code.js"> 8 <include src="extension_code.js">
9 <include src="extension_commands_overlay.js"> 9 <include src="extension_commands_overlay.js">
10 <include src="extension_error_overlay.js"> 10 <include src="extension_error_overlay.js">
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 hideDropTargetOverlay_: function() { 91 hideDropTargetOverlay_: function() {
92 var currentOverlay = ExtensionSettings.getCurrentOverlay(); 92 var currentOverlay = ExtensionSettings.getCurrentOverlay();
93 if (currentOverlay && currentOverlay.id === 'drop-target-overlay') 93 if (currentOverlay && currentOverlay.id === 'drop-target-overlay')
94 ExtensionSettings.showOverlay(null); 94 ExtensionSettings.showOverlay(null);
95 } 95 }
96 }; 96 };
97 97
98 /** 98 /**
99 * ExtensionSettings class 99 * ExtensionSettings class
100 * @class 100 * @class
101 * @constructor
102 * @implements {ExtensionListDelegate}
101 */ 103 */
102 function ExtensionSettings() {} 104 function ExtensionSettings() {}
103 105
104 cr.addSingletonGetter(ExtensionSettings); 106 cr.addSingletonGetter(ExtensionSettings);
105 107
106 ExtensionSettings.prototype = { 108 ExtensionSettings.prototype = {
107 __proto__: HTMLDivElement.prototype, 109 __proto__: HTMLDivElement.prototype,
108 110
109 /** 111 /**
110 * The drag-drop wrapper for installing external Extensions, if available. 112 * The drag-drop wrapper for installing external Extensions, if available.
(...skipping 15 matching lines...) Expand all
126 * Perform initial setup. 128 * Perform initial setup.
127 */ 129 */
128 initialize: function() { 130 initialize: function() {
129 uber.onContentFrameLoaded(); 131 uber.onContentFrameLoaded();
130 cr.ui.FocusOutlineManager.forDocument(document); 132 cr.ui.FocusOutlineManager.forDocument(document);
131 measureCheckboxStrings(); 133 measureCheckboxStrings();
132 134
133 // Set the title. 135 // Set the title.
134 uber.setTitle(loadTimeData.getString('extensionSettings')); 136 uber.setTitle(loadTimeData.getString('extensionSettings'));
135 137
136 var extensionList = new ExtensionList(); 138 var extensionList = new ExtensionList(this);
137 extensionList.id = 'extension-settings-list'; 139 extensionList.id = 'extension-settings-list';
138 var wrapper = $('extension-list-wrapper'); 140 var wrapper = $('extension-list-wrapper');
139 wrapper.insertBefore(extensionList, wrapper.firstChild); 141 wrapper.insertBefore(extensionList, wrapper.firstChild);
140 142
141 this.update_(); 143 this.update_();
142 // TODO(devlin): Remove this once all notifications are moved to events on 144 // TODO(devlin): Remove this once all notifications are moved to events on
143 // the developerPrivate api. 145 // the developerPrivate api.
144 chrome.send('extensionSettingsRegister'); 146 chrome.send('extensionSettingsRegister');
145 147
146 var extensionLoader = extensions.ExtensionLoader.getInstance(); 148 var extensionLoader = extensions.ExtensionLoader.getInstance();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 profileInfo.appInfoDialogEnabled).then(function() { 269 profileInfo.appInfoDialogEnabled).then(function() {
268 // We can get called many times in short order, thus we need to 270 // We can get called many times in short order, thus we need to
269 // be careful to remove the 'finished loading' timeout. 271 // be careful to remove the 'finished loading' timeout.
270 if (this.loadingTimeout_) 272 if (this.loadingTimeout_)
271 window.clearTimeout(this.loadingTimeout_); 273 window.clearTimeout(this.loadingTimeout_);
272 document.documentElement.classList.add('loading'); 274 document.documentElement.classList.add('loading');
273 this.loadingTimeout_ = window.setTimeout(function() { 275 this.loadingTimeout_ = window.setTimeout(function() {
274 document.documentElement.classList.remove('loading'); 276 document.documentElement.classList.remove('loading');
275 }, 0); 277 }, 0);
276 278
277 /** @const */ 279 this.onExtensionCountChanged();
278 var hasExtensions = extensionList.getNumExtensions() != 0;
279 $('no-extensions').hidden = hasExtensions;
280 $('extension-list-wrapper').hidden = !hasExtensions;
281 }.bind(this)); 280 }.bind(this));
282 }, 281 },
283 282
284 /** 283 /**
285 * Handles the Pack Extension button. 284 * Handles the Pack Extension button.
286 * @param {Event} e Change event. 285 * @param {Event} e Change event.
287 * @private 286 * @private
288 */ 287 */
289 handlePackExtension_: function(e) { 288 handlePackExtension_: function(e) {
290 ExtensionSettings.showOverlay($('pack-extension-overlay')); 289 ExtensionSettings.showOverlay($('pack-extension-overlay'));
291 chrome.send('metricsHandler:recordAction', ['Options_PackExtension']); 290 chrome.send('metricsHandler:recordAction', ['Options_PackExtension']);
292 }, 291 },
293 292
294 /** 293 /**
295 * Shows the Extension Commands configuration UI. 294 * Shows the Extension Commands configuration UI.
296 * @param {Event} e Change event.
297 * @private 295 * @private
298 */ 296 */
299 showExtensionCommandsConfigUi_: function(e) { 297 showExtensionCommandsConfigUi_: function() {
300 ExtensionSettings.showOverlay($('extension-commands-overlay')); 298 ExtensionSettings.showOverlay($('extension-commands-overlay'));
301 chrome.send('metricsHandler:recordAction', 299 chrome.send('metricsHandler:recordAction',
302 ['Options_ExtensionCommands']); 300 ['Options_ExtensionCommands']);
303 }, 301 },
304 302
305 /** 303 /**
306 * Handles the Configure (Extension) Commands link. 304 * Handles the Configure (Extension) Commands link.
307 * @param {Event} e Change event. 305 * @param {Event} e Change event.
308 * @private 306 * @private
309 */ 307 */
(...skipping 30 matching lines...) Expand all
340 function(control) { 338 function(control) {
341 control.tabIndex = showDevControls ? 0 : -1; 339 control.tabIndex = showDevControls ? 0 : -1;
342 }); 340 });
343 buttons.setAttribute('aria-hidden', !showDevControls); 341 buttons.setAttribute('aria-hidden', !showDevControls);
344 342
345 window.requestAnimationFrame(function() { 343 window.requestAnimationFrame(function() {
346 devControls.style.height = !showDevControls ? '' : 344 devControls.style.height = !showDevControls ? '' :
347 buttons.offsetHeight + 'px'; 345 buttons.offsetHeight + 'px';
348 }.bind(this)); 346 }.bind(this));
349 }, 347 },
348
349 /** @override */
350 onExtensionCountChanged: function() {
351 /** @const */
352 var hasExtensions = $('extension-settings-list').getNumExtensions() != 0;
353 $('no-extensions').hidden = hasExtensions;
354 $('extension-list-wrapper').hidden = !hasExtensions;
355 },
350 }; 356 };
351 357
358 /**
359 * Called by the WebUI when something has changed and the extensions UI needs
360 * to be updated.
361 */
352 ExtensionSettings.onExtensionsChanged = function() { 362 ExtensionSettings.onExtensionsChanged = function() {
353 ExtensionSettings.getInstance().update_(); 363 ExtensionSettings.getInstance().update_();
354 }; 364 };
355 365
356 /** 366 /**
357 * Returns the current overlay or null if one does not exist. 367 * Returns the current overlay or null if one does not exist.
358 * @return {Element} The overlay element. 368 * @return {Element} The overlay element.
359 */ 369 */
360 ExtensionSettings.getCurrentOverlay = function() { 370 ExtensionSettings.getCurrentOverlay = function() {
361 return document.querySelector('#overlay .page.showing'); 371 return document.querySelector('#overlay .page.showing');
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // Export 468 // Export
459 return { 469 return {
460 ExtensionSettings: ExtensionSettings 470 ExtensionSettings: ExtensionSettings
461 }; 471 };
462 }); 472 });
463 473
464 window.addEventListener('load', function(e) { 474 window.addEventListener('load', function(e) {
465 document.documentElement.classList.add('loading'); 475 document.documentElement.classList.add('loading');
466 extensions.ExtensionSettings.getInstance().initialize(); 476 extensions.ExtensionSettings.getInstance().initialize();
467 }); 477 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698