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

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: 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..f20eab20cd845c9f0d67e7befb01509b21d45d2b 100644
--- a/chrome/browser/resources/options/pref_ui.js
+++ b/chrome/browser/resources/options/pref_ui.js
@@ -13,17 +13,28 @@ 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;
+ el.managed = false;
+
+ if (!event.value)
+ return;
+
+ el.managed = event.value['managed'];
+
+ if (event.value['extensionControlled']) {
+ // Set an explanatory title attribute on the nearest containing <label>
+ // element.
+ var node = el;
+ 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.
+ if (node instanceof HTMLLabelElement) {
+ node.title = templateData.extensionManagedPrefsTitle;
+ break;
+ }
+ node = node.parentNode;
+ }
+ }
// Disable UI elements if backend says so.
- if (!el.disabled && event.value && event.value['disabled'])
+ if (event.value['disabled'])
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.
}
« 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