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

Unified 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: review 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/pref_ui.js
diff --git a/chrome/browser/resources/options/pref_ui.js b/chrome/browser/resources/options/pref_ui.js
index 3b85d137cd5072b8244daf125c64d44c7273a6eb..b7b471105ecc64ce4a51889e2bfffe6e21bf94ce 100644
--- a/chrome/browser/resources/options/pref_ui.js
+++ b/chrome/browser/resources/options/pref_ui.js
@@ -13,18 +13,34 @@ cr.define('options', function() {
* @param {!Event} event The pref change event.
*/
function updateElementState_(el, event) {
- el.managed = event.value && event.value['managed'] != undefined ?
- event.value['managed'] : false;
-
- // Managed UI elements can only be disabled as a result of being
- // managed. They cannot be enabled as a result of a pref being
- // unmanaged.
- if (el.managed)
- el.disabled = true;
-
- // Disable UI elements if backend says so.
- if (!el.disabled && event.value && event.value['disabled'])
- el.disabled = true;
+ el.managed = false;
+
+ if (!event.value)
+ return;
+
+ el.managed = event.value['managed'];
+
+ // If the value is controlled by an extension, set an explanatory title
+ // attribute on the nearest containing <label> element.
+ var label = findAncestor(el, function(node) {
+ return (node instanceof HTMLLabelElement);
+ });
+ if (label) {
+ label.title = event.value['extensionControlled'] ?
+ templateData.extensionManagedPrefsTitle :
+ null;
Evan Stade 2011/07/07 20:06:45 this will overwrite whatever other title the label
Bernhard Bauer 2011/07/07 20:45:14 Per the UI leads, we're going to add an infobar li
+ }
+
+ // Disable UI elements if the backend says so.
+ // |reenable| is a flag that tells us if the element is disabled because the
+ // preference is not modifiable by the user. If the element is disabled but
+ // the flag is not set, it means that the element has been disabled
+ // somewhere else, so we don't do anything.
+ if (el.disabled && !el.reenable)
+ return;
+
+ el.disabled = event.value['disabled'];
Evan Stade 2011/07/07 20:06:45 this still doesn't seem very foolproof. reenable c
Bernhard Bauer 2011/07/07 20:45:14 I know :-/ This seemed like the easiest way withou
Evan Stade 2011/07/07 21:09:16 but how could the code check if it were disabled f
+ el.reenable = event.value['disabled'];
}
/////////////////////////////////////////////////////////////////////////////
« 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