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

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

Issue 1146693004: [Extensions] Move remaining notifications out of ExtensionSettingsHandler (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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 measureCheckboxStrings(); 141 measureCheckboxStrings();
142 142
143 // Set the title. 143 // Set the title.
144 uber.setTitle(loadTimeData.getString('extensionSettings')); 144 uber.setTitle(loadTimeData.getString('extensionSettings'));
145 145
146 var extensionList = new ExtensionList(this); 146 var extensionList = new ExtensionList(this);
147 extensionList.id = 'extension-settings-list'; 147 extensionList.id = 'extension-settings-list';
148 var wrapper = $('extension-list-wrapper'); 148 var wrapper = $('extension-list-wrapper');
149 wrapper.insertBefore(extensionList, wrapper.firstChild); 149 wrapper.insertBefore(extensionList, wrapper.firstChild);
150 150
151 this.update_(); 151 // Get the initial profile state, and register to be notified of any
152 // TODO(devlin): Remove this once all notifications are moved to events on 152 // future changes.
153 // the developerPrivate api. 153 chrome.developerPrivate.getProfileConfiguration(
154 chrome.send('extensionSettingsRegister'); 154 this.update_.bind(this));
155 chrome.developerPrivate.onProfileStateChanged.addListener(
156 this.update_.bind(this));
155 157
156 var extensionLoader = extensions.ExtensionLoader.getInstance(); 158 var extensionLoader = extensions.ExtensionLoader.getInstance();
157 159
158 $('toggle-dev-on').addEventListener('change', function(e) { 160 $('toggle-dev-on').addEventListener('change', function(e) {
159 this.updateDevControlsVisibility_(true); 161 this.updateDevControlsVisibility_(true);
160 extensionList.updateFocusableElements(); 162 extensionList.updateFocusableElements();
161 chrome.developerPrivate.updateProfileConfiguration( 163 chrome.developerPrivate.updateProfileConfiguration(
162 {inDeveloperMode: e.target.checked}); 164 {inDeveloperMode: e.target.checked});
163 var suffix = $('toggle-dev-on').checked ? 'Enabled' : 'Disabled'; 165 var suffix = $('toggle-dev-on').checked ? 'Enabled' : 'Disabled';
164 chrome.send('metricsHandler:recordAction', 166 chrome.send('metricsHandler:recordAction',
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 var path = document.location.pathname; 235 var path = document.location.pathname;
234 if (path.length > 1) { 236 if (path.length > 1) {
235 // Skip starting slash and remove trailing slash (if any). 237 // Skip starting slash and remove trailing slash (if any).
236 var overlayName = path.slice(1).replace(/\/$/, ''); 238 var overlayName = path.slice(1).replace(/\/$/, '');
237 if (overlayName == 'configureCommands') 239 if (overlayName == 'configureCommands')
238 this.showExtensionCommandsConfigUi_(); 240 this.showExtensionCommandsConfigUi_();
239 } 241 }
240 }, 242 },
241 243
242 /** 244 /**
243 * Updates the extensions page to the latest profile and extensions
244 * configuration.
245 * @private
246 */
247 update_: function() {
248 chrome.developerPrivate.getProfileConfiguration(
249 this.returnProfileConfiguration_.bind(this));
250 },
251
252 /**
253 * [Re]-Populates the page with data representing the current state of 245 * [Re]-Populates the page with data representing the current state of
254 * installed extensions. 246 * installed extensions.
255 * @param {ProfileInfo} profileInfo 247 * @param {ProfileInfo} profileInfo
256 * @private 248 * @private
257 */ 249 */
258 returnProfileConfiguration_: function(profileInfo) { 250 update_: function(profileInfo) {
259 webuiResponded = true; 251 webuiResponded = true;
252
260 /** @const */ 253 /** @const */
261 var supervised = profileInfo.isSupervised; 254 var supervised = profileInfo.isSupervised;
262 255
263 var pageDiv = $('extension-settings'); 256 var pageDiv = $('extension-settings');
264 pageDiv.classList.toggle('profile-is-supervised', supervised); 257 pageDiv.classList.toggle('profile-is-supervised', supervised);
265 pageDiv.classList.toggle('showing-banner', supervised); 258 pageDiv.classList.toggle('showing-banner', supervised);
266 259
267 var devControlsCheckbox = $('toggle-dev-on'); 260 var devControlsCheckbox = $('toggle-dev-on');
268 devControlsCheckbox.checked = profileInfo.inDeveloperMode; 261 devControlsCheckbox.checked = profileInfo.inDeveloperMode;
269 devControlsCheckbox.disabled = supervised; 262 devControlsCheckbox.disabled = supervised;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 /** @override */ 353 /** @override */
361 onExtensionCountChanged: function() { 354 onExtensionCountChanged: function() {
362 /** @const */ 355 /** @const */
363 var hasExtensions = $('extension-settings-list').getNumExtensions() != 0; 356 var hasExtensions = $('extension-settings-list').getNumExtensions() != 0;
364 $('no-extensions').hidden = hasExtensions; 357 $('no-extensions').hidden = hasExtensions;
365 $('extension-list-wrapper').hidden = !hasExtensions; 358 $('extension-list-wrapper').hidden = !hasExtensions;
366 }, 359 },
367 }; 360 };
368 361
369 /** 362 /**
370 * Called by the WebUI when something has changed and the extensions UI needs
371 * to be updated.
372 */
373 ExtensionSettings.onExtensionsChanged = function() {
374 ExtensionSettings.getInstance().update_();
375 };
376
377 /**
378 * Returns the current overlay or null if one does not exist. 363 * Returns the current overlay or null if one does not exist.
379 * @return {Element} The overlay element. 364 * @return {Element} The overlay element.
380 */ 365 */
381 ExtensionSettings.getCurrentOverlay = function() { 366 ExtensionSettings.getCurrentOverlay = function() {
382 return document.querySelector('#overlay .page.showing'); 367 return document.querySelector('#overlay .page.showing');
383 }; 368 };
384 369
385 /** 370 /**
386 * Sets the given overlay to show. If the overlay is already showing, this is 371 * Sets the given overlay to show. If the overlay is already showing, this is
387 * a no-op; otherwise, hides any currently-showing overlay. 372 * a no-op; otherwise, hides any currently-showing overlay.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // Export 464 // Export
480 return { 465 return {
481 ExtensionSettings: ExtensionSettings 466 ExtensionSettings: ExtensionSettings
482 }; 467 };
483 }); 468 });
484 469
485 window.addEventListener('load', function(e) { 470 window.addEventListener('load', function(e) {
486 document.documentElement.classList.add('loading'); 471 document.documentElement.classList.add('loading');
487 extensions.ExtensionSettings.getInstance().initialize(); 472 extensions.ExtensionSettings.getInstance().initialize();
488 }); 473 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698