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

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

Issue 2529083002: Make extensions developer mode adhere to policy (Closed)
Patch Set: Reviewers' comments 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 developerModeControlledByPolicy =
200 profileInfo.isDeveloperModeControlledByPolicy;
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 || developerModeControlledByPolicy;
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_(false);
214 this.updateDevToggleControlledIndicator_(developerModeControlledByPolicy);
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} devModeControlledByPolicy true if the indicator
233 * should be showing.
234 * @private
235 */
236 updateDevToggleControlledIndicator_: function(devModeControlledByPolicy) {
237 var controlledIndicator = document.querySelector(
238 '#dev-toggle .controlled-setting-indicator');
239
240 if (!(controlledIndicator instanceof cr.ui.ControlledIndicator))
241 cr.ui.ControlledIndicator.decorate(controlledIndicator);
242
243 // We control the visibility of the ControlledIndicator by setting or
244 // removing the 'controlled-by' attribute (see controlled_indicator.css).
245 var isVisible = controlledIndicator.getAttribute('controlled-by');
246 if (devModeControlledByPolicy && !isVisible) {
247 var controlledBy = 'policy';
248 controlledIndicator.setAttribute(
249 'controlled-by', controlledBy);
250 controlledIndicator.setAttribute(
251 'text' + controlledBy,
252 loadTimeData.getString('extensionControlledSettingPolicy'));
253 } else if (!devModeControlledByPolicy && isVisible) {
254 // This hides the element - see above.
255 controlledIndicator.removeAttribute('controlled-by');
Andrew T Wilson (Slow) 2016/12/04 14:54:54 BTW, are the checks for isVisible/!isVisible neede
Devlin 2016/12/04 16:07:11 I requested it change from that. I slightly prefe
pmarko 2016/12/07 16:12:11 Acknowledged.
256 }
257 },
258
259 /**
222 * Shows the loading spinner and hides elements that shouldn't be visible 260 * Shows the loading spinner and hides elements that shouldn't be visible
223 * while loading. 261 * while loading.
224 * @param {boolean} isLoading 262 * @param {boolean} isLoading
225 * @private 263 * @private
226 */ 264 */
227 setLoading_: function(isLoading) { 265 setLoading_: function(isLoading) {
228 document.documentElement.classList.toggle('loading', isLoading); 266 document.documentElement.classList.toggle('loading', isLoading);
229 $('loading-spinner').hidden = !isLoading; 267 $('loading-spinner').hidden = !isLoading;
230 $('dev-controls').hidden = isLoading; 268 $('dev-controls').hidden = isLoading;
231 this.updateDevControlsVisibility_(false); 269 this.updateDevControlsVisibility_(false);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 463
426 // Export 464 // Export
427 return { 465 return {
428 ExtensionSettings: ExtensionSettings 466 ExtensionSettings: ExtensionSettings
429 }; 467 };
430 }); 468 });
431 469
432 window.addEventListener('load', function(e) { 470 window.addEventListener('load', function(e) {
433 extensions.ExtensionSettings.getInstance().initialize(); 471 extensions.ExtensionSettings.getInstance().initialize();
434 }); 472 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698