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

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

Issue 2529083002: Make extensions developer mode adhere to policy (Closed)
Patch Set: Get rid of busy loop in test Created 4 years 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="drag_and_drop_handler.js"> 8 <include src="drag_and_drop_handler.js">
9 <include src="extension_code.js"> 9 <include src="extension_code.js">
10 <include src="extension_commands_overlay.js"> 10 <include src="extension_commands_overlay.js">
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 update_: function(profileInfo) { 189 update_: function(profileInfo) {
190 // We only set the page to be loading if we haven't already finished an 190 // We only set the page to be loading if we haven't already finished an
191 // initial load, because otherwise the updates are all incremental and 191 // initial load, because otherwise the updates are all incremental and
192 // don't need to display the interstitial spinner. 192 // don't need to display the interstitial spinner.
193 if (!this.hasLoaded_) 193 if (!this.hasLoaded_)
194 this.setLoading_(true); 194 this.setLoading_(true);
195 webuiResponded = true; 195 webuiResponded = true;
196 196
197 /** @const */ 197 /** @const */
198 var supervised = profileInfo.isSupervised; 198 var supervised = profileInfo.isSupervised;
199 var developerModeDisabledByPolicy = profileInfo.
Bernhard Bauer 2016/11/25 15:43:35 Ugh. Can you break after the equals sign?
pmarko 2016/11/28 14:19:30 Done.
200 isDeveloperModeDisabledByPolicy;
199 201
200 var pageDiv = $('extension-settings'); 202 var pageDiv = $('extension-settings');
201 pageDiv.classList.toggle('profile-is-supervised', supervised); 203 pageDiv.classList.toggle('profile-is-supervised', supervised);
202 pageDiv.classList.toggle('showing-banner', supervised); 204 pageDiv.classList.toggle('showing-banner', supervised);
203 205
204 var devControlsCheckbox = $('toggle-dev-on'); 206 var devControlsCheckbox = $('toggle-dev-on');
205 devControlsCheckbox.checked = profileInfo.inDeveloperMode; 207 devControlsCheckbox.checked = profileInfo.inDeveloperMode;
206 devControlsCheckbox.disabled = supervised; 208 devControlsCheckbox.disabled =
209 supervised || developerModeDisabledByPolicy;
210
211 // This is necessary e.g. if developer mode is now disabled by policy
212 // but extension developer tools were visible
213 this.updateDevControlsVisibility_(true);
214 this.setDevToggleControlledIndicator_(developerModeDisabledByPolicy);
207 215
208 $('load-unpacked').disabled = !profileInfo.canLoadUnpacked; 216 $('load-unpacked').disabled = !profileInfo.canLoadUnpacked;
209 var extensionList = $('extension-settings-list'); 217 var extensionList = $('extension-settings-list');
210 extensionList.updateExtensionsData( 218 extensionList.updateExtensionsData(
211 profileInfo.isIncognitoAvailable, 219 profileInfo.isIncognitoAvailable,
212 profileInfo.appInfoDialogEnabled).then(function() { 220 profileInfo.appInfoDialogEnabled).then(function() {
213 if (!this.hasLoaded_) { 221 if (!this.hasLoaded_) {
214 this.hasLoaded_ = true; 222 this.hasLoaded_ = true;
215 this.setLoading_(false); 223 this.setLoading_(false);
216 } 224 }
217 this.onExtensionCountChanged(); 225 this.onExtensionCountChanged();
218 }.bind(this)); 226 }.bind(this));
219 }, 227 },
220 228
221 /** 229 /**
230 * Shows or hides the 'controlled by policy' indicator on the dev-toggle
231 * checkbox.
232 * @param {boolean} developerModeDisabledByPolicy true if the indicator
233 * should be showing.
234 * @private
235 */
236 setDevToggleControlledIndicator_: function(developerModeDisabledByPolicy) {
237 var devToggleControlledIndicator = document.querySelector(
238 '#dev-toggle .controlled-setting-indicator');
239
240 if (!(devToggleControlledIndicator instanceof cr.ui.ControlledIndicator))
241 cr.ui.ControlledIndicator.decorate(devToggleControlledIndicator);
242
243 if (developerModeDisabledByPolicy) {
244 var controlledBy = 'policy';
245 devToggleControlledIndicator.setAttribute('controlled-by',
246 controlledBy);
247 devToggleControlledIndicator.setAttribute('text' + controlledBy,
248 loadTimeData.getString('controlledSettingPolicy'));
249 }
250 else
Bernhard Bauer 2016/11/25 15:43:35 If the if-clause uses braces, so should the else.
pmarko 2016/11/28 14:19:30 Done.
251 devToggleControlledIndicator.removeAttribute('controlled-by');
252 },
253
254 /**
222 * Shows the loading spinner and hides elements that shouldn't be visible 255 * Shows the loading spinner and hides elements that shouldn't be visible
223 * while loading. 256 * while loading.
224 * @param {boolean} isLoading 257 * @param {boolean} isLoading
225 * @private 258 * @private
226 */ 259 */
227 setLoading_: function(isLoading) { 260 setLoading_: function(isLoading) {
228 document.documentElement.classList.toggle('loading', isLoading); 261 document.documentElement.classList.toggle('loading', isLoading);
229 $('loading-spinner').hidden = !isLoading; 262 $('loading-spinner').hidden = !isLoading;
230 $('dev-controls').hidden = isLoading; 263 $('dev-controls').hidden = isLoading;
231 this.updateDevControlsVisibility_(false); 264 this.updateDevControlsVisibility_(false);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 458
426 // Export 459 // Export
427 return { 460 return {
428 ExtensionSettings: ExtensionSettings 461 ExtensionSettings: ExtensionSettings
429 }; 462 };
430 }); 463 });
431 464
432 window.addEventListener('load', function(e) { 465 window.addEventListener('load', function(e) {
433 extensions.ExtensionSettings.getInstance().initialize(); 466 extensions.ExtensionSettings.getInstance().initialize();
434 }); 467 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698