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

Side by Side Diff: chrome/browser/resources/options/pref_ui.js

Issue 7310003: Disable chrome://options UI elements if the corresponding preference is not user-modifiable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('options', function() { 5 cr.define('options', function() {
6 6
7 var Preferences = options.Preferences; 7 var Preferences = options.Preferences;
8 8
9 /** 9 /**
10 * Helper function update element's state from pref change event. 10 * Helper function update element's state from pref change event.
11 * @private 11 * @private
12 * @param {!HTMLElement} el The element to update. 12 * @param {!HTMLElement} el The element to update.
13 * @param {!Event} event The pref change event. 13 * @param {!Event} event The pref change event.
14 */ 14 */
15 function updateElementState_(el, event) { 15 function updateElementState_(el, event) {
16 el.managed = event.value && event.value['managed'] != undefined ? 16 el.managed = false;
17 event.value['managed'] : false;
18 17
19 // Managed UI elements can only be disabled as a result of being 18 if (!event.value)
20 // managed. They cannot be enabled as a result of a pref being 19 return;
21 // unmanaged. 20
22 if (el.managed) 21 el.managed = event.value['managed'];
23 el.disabled = true; 22
23 if (event.value['extensionControlled']) {
24 // Set an explanatory title attribute on the nearest containing <label>
25 // element.
26 var node = el;
27 while (node) {
Evan Stade 2011/07/06 19:44:57 use findAncestor from util.js
Bernhard Bauer 2011/07/06 19:55:57 Ahh, nice. Done.
28 if (node instanceof HTMLLabelElement) {
29 node.title = templateData.extensionManagedPrefsTitle;
30 break;
31 }
32 node = node.parentNode;
33 }
34 }
24 35
25 // Disable UI elements if backend says so. 36 // Disable UI elements if backend says so.
26 if (!el.disabled && event.value && event.value['disabled']) 37 if (event.value['disabled'])
27 el.disabled = true; 38 el.disabled = true;
Evan Stade 2011/07/06 19:44:57 does this work? el.disabled = event.value['disabl
Bernhard Bauer 2011/07/06 19:55:57 I think elements could already be disabled for oth
Evan Stade 2011/07/06 20:12:43 true, but what if a user uninstalls an extension -
Bernhard Bauer 2011/07/07 08:45:56 Done.
28 } 39 }
29 40
30 ///////////////////////////////////////////////////////////////////////////// 41 /////////////////////////////////////////////////////////////////////////////
31 // PrefCheckbox class: 42 // PrefCheckbox class:
32 // TODO(jhawkins): Refactor all this copy-pasted code! 43 // TODO(jhawkins): Refactor all this copy-pasted code!
33 44
34 // Define a constructor that uses an input element as its underlying element. 45 // Define a constructor that uses an input element as its underlying element.
35 var PrefCheckbox = cr.ui.define('input'); 46 var PrefCheckbox = cr.ui.define('input');
36 47
37 PrefCheckbox.prototype = { 48 PrefCheckbox.prototype = {
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 PrefCheckbox: PrefCheckbox, 532 PrefCheckbox: PrefCheckbox,
522 PrefNumber: PrefNumber, 533 PrefNumber: PrefNumber,
523 PrefNumeric: PrefNumeric, 534 PrefNumeric: PrefNumeric,
524 PrefRadio: PrefRadio, 535 PrefRadio: PrefRadio,
525 PrefRange: PrefRange, 536 PrefRange: PrefRange,
526 PrefSelect: PrefSelect, 537 PrefSelect: PrefSelect,
527 PrefTextField: PrefTextField 538 PrefTextField: PrefTextField
528 }; 539 };
529 540
530 }); 541 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings.js ('k') | chrome/browser/ui/webui/options/content_settings_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698