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

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

Issue 7342009: Show a different banner in chrome://settings for extension-controlled settings. (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 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 = false; 16 el.controlledBy = null;
17 17
18 if (!event.value) 18 if (!event.value)
19 return; 19 return;
20 20
21 el.managed = event.value['managed']; 21 el.controlledBy = event.value['controlledBy'];
22 22
23 // Disable UI elements if the backend says so. 23 // Disable UI elements if the backend says so.
24 // |reenable| is a flag that tells us if the element is disabled because the 24 // |reenable| is a flag that tells us if the element is disabled because the
25 // preference is not modifiable by the user. If the element is disabled but 25 // preference is not modifiable by the user. If the element is disabled but
26 // the flag is not set, it means that the element has been disabled 26 // the flag is not set, it means that the element has been disabled
27 // somewhere else, so we don't do anything. 27 // somewhere else, so we don't do anything.
28 if (el.disabled && !el.notUserModifiable) 28 if (el.disabled && !el.notUserModifiable)
29 return; 29 return;
30 30
31 el.disabled = event.value['disabled']; 31 el.disabled = event.value['disabled'];
32 el.notUserModifiable = event.value['disabled']; 32 el.notUserModifiable = event.value['disabled'];
33
34 OptionsPage.updateManagedBannerVisibility();
33 } 35 }
34 36
35 ///////////////////////////////////////////////////////////////////////////// 37 /////////////////////////////////////////////////////////////////////////////
36 // PrefCheckbox class: 38 // PrefCheckbox class:
37 // TODO(jhawkins): Refactor all this copy-pasted code! 39 // TODO(jhawkins): Refactor all this copy-pasted code!
38 40
39 // Define a constructor that uses an input element as its underlying element. 41 // Define a constructor that uses an input element as its underlying element.
40 var PrefCheckbox = cr.ui.define('input'); 42 var PrefCheckbox = cr.ui.define('input');
41 43
42 PrefCheckbox.prototype = { 44 PrefCheckbox.prototype = {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 }, 97 },
96 }; 98 };
97 99
98 /** 100 /**
99 * The preference name. 101 * The preference name.
100 * @type {string} 102 * @type {string}
101 */ 103 */
102 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR); 104 cr.defineProperty(PrefCheckbox, 'pref', cr.PropertyKind.ATTR);
103 105
104 /** 106 /**
107 * Whether the preference is controlled by something else than the user's
108 * settings (either 'policy' or 'extension').
109 * @type {string}
110 */
111 cr.defineProperty(PrefCheckbox, 'controlledBy', cr.PropertyKind.ATTR);
112
113 /**
105 * The user metric string. 114 * The user metric string.
106 * @type {string} 115 * @type {string}
107 */ 116 */
108 cr.defineProperty(PrefCheckbox, 'metric', cr.PropertyKind.ATTR); 117 cr.defineProperty(PrefCheckbox, 'metric', cr.PropertyKind.ATTR);
109 118
110 /** 119 /**
111 * Whether to use inverted pref value. 120 * Whether to use inverted pref value.
112 * @type {boolean} 121 * @type {boolean}
113 */ 122 */
114 cr.defineProperty(PrefCheckbox, 'inverted_pref', cr.PropertyKind.BOOL_ATTR); 123 cr.defineProperty(PrefCheckbox, 'inverted_pref', cr.PropertyKind.BOOL_ATTR);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 }, 163 },
155 }; 164 };
156 165
157 /** 166 /**
158 * The preference name. 167 * The preference name.
159 * @type {string} 168 * @type {string}
160 */ 169 */
161 cr.defineProperty(PrefRadio, 'pref', cr.PropertyKind.ATTR); 170 cr.defineProperty(PrefRadio, 'pref', cr.PropertyKind.ATTR);
162 171
163 /** 172 /**
173 * Whether the preference is controlled by something else than the user's
174 * settings (either 'policy' or 'extension').
175 * @type {string}
176 */
177 cr.defineProperty(PrefRadio, 'controlledBy', cr.PropertyKind.ATTR);
178
179 /**
164 * The user metric string. 180 * The user metric string.
165 * @type {string} 181 * @type {string}
166 */ 182 */
167 cr.defineProperty(PrefRadio, 'metric', cr.PropertyKind.ATTR); 183 cr.defineProperty(PrefRadio, 'metric', cr.PropertyKind.ATTR);
168 184
169 ///////////////////////////////////////////////////////////////////////////// 185 /////////////////////////////////////////////////////////////////////////////
170 // PrefNumeric class: 186 // PrefNumeric class:
171 187
172 // Define a constructor that uses an input element as its underlying element. 188 // Define a constructor that uses an input element as its underlying element.
173 var PrefNumeric = function() {}; 189 var PrefNumeric = function() {};
(...skipping 26 matching lines...) Expand all
200 } 216 }
201 }; 217 };
202 218
203 /** 219 /**
204 * The preference name. 220 * The preference name.
205 * @type {string} 221 * @type {string}
206 */ 222 */
207 cr.defineProperty(PrefNumeric, 'pref', cr.PropertyKind.ATTR); 223 cr.defineProperty(PrefNumeric, 'pref', cr.PropertyKind.ATTR);
208 224
209 /** 225 /**
226 * Whether the preference is controlled by something else than the user's
227 * settings (either 'policy' or 'extension').
228 * @type {string}
229 */
230 cr.defineProperty(PrefNumeric, 'controlledBy', cr.PropertyKind.ATTR);
231
232 /**
210 * The user metric string. 233 * The user metric string.
211 * @type {string} 234 * @type {string}
212 */ 235 */
213 cr.defineProperty(PrefNumeric, 'metric', cr.PropertyKind.ATTR); 236 cr.defineProperty(PrefNumeric, 'metric', cr.PropertyKind.ATTR);
214 237
215 ///////////////////////////////////////////////////////////////////////////// 238 /////////////////////////////////////////////////////////////////////////////
216 // PrefNumber class: 239 // PrefNumber class:
217 240
218 // Define a constructor that uses an input element as its underlying element. 241 // Define a constructor that uses an input element as its underlying element.
219 var PrefNumber = cr.ui.define('input'); 242 var PrefNumber = cr.ui.define('input');
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 }, 369 },
347 }; 370 };
348 371
349 /** 372 /**
350 * The preference name. 373 * The preference name.
351 * @type {string} 374 * @type {string}
352 */ 375 */
353 cr.defineProperty(PrefRange, 'pref', cr.PropertyKind.ATTR); 376 cr.defineProperty(PrefRange, 'pref', cr.PropertyKind.ATTR);
354 377
355 /** 378 /**
379 * Whether the preference is controlled by something else than the user's
380 * settings (either 'policy' or 'extension').
381 * @type {string}
382 */
383 cr.defineProperty(PrefRange, 'controlledBy', cr.PropertyKind.ATTR);
384
385 /**
356 * The user metric string. 386 * The user metric string.
357 * @type {string} 387 * @type {string}
358 */ 388 */
359 cr.defineProperty(PrefRange, 'metric', cr.PropertyKind.ATTR); 389 cr.defineProperty(PrefRange, 'metric', cr.PropertyKind.ATTR);
360 390
361 ///////////////////////////////////////////////////////////////////////////// 391 /////////////////////////////////////////////////////////////////////////////
362 // PrefSelect class: 392 // PrefSelect class:
363 393
364 // Define a constructor that uses a select element as its underlying element. 394 // Define a constructor that uses a select element as its underlying element.
365 var PrefSelect = cr.ui.define('select'); 395 var PrefSelect = cr.ui.define('select');
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 }, 466 },
437 }; 467 };
438 468
439 /** 469 /**
440 * The preference name. 470 * The preference name.
441 * @type {string} 471 * @type {string}
442 */ 472 */
443 cr.defineProperty(PrefSelect, 'pref', cr.PropertyKind.ATTR); 473 cr.defineProperty(PrefSelect, 'pref', cr.PropertyKind.ATTR);
444 474
445 /** 475 /**
476 * Whether the preference is controlled by something else than the user's
477 * settings (either 'policy' or 'extension').
478 * @type {string}
479 */
480 cr.defineProperty(PrefSelect, 'controlledBy', cr.PropertyKind.ATTR);
481
482 /**
446 * The user metric string. 483 * The user metric string.
447 * @type {string} 484 * @type {string}
448 */ 485 */
449 cr.defineProperty(PrefSelect, 'metric', cr.PropertyKind.ATTR); 486 cr.defineProperty(PrefSelect, 'metric', cr.PropertyKind.ATTR);
450 487
451 /** 488 /**
452 * The data type for the preference options. 489 * The data type for the preference options.
453 * @type {string} 490 * @type {string}
454 */ 491 */
455 cr.defineProperty(PrefSelect, 'dataType', cr.PropertyKind.ATTR); 492 cr.defineProperty(PrefSelect, 'dataType', cr.PropertyKind.ATTR);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 540 }
504 }; 541 };
505 542
506 /** 543 /**
507 * The preference name. 544 * The preference name.
508 * @type {string} 545 * @type {string}
509 */ 546 */
510 cr.defineProperty(PrefTextField, 'pref', cr.PropertyKind.ATTR); 547 cr.defineProperty(PrefTextField, 'pref', cr.PropertyKind.ATTR);
511 548
512 /** 549 /**
550 * Whether the preference is controlled by something else than the user's
551 * settings (either 'policy' or 'extension').
552 * @type {string}
553 */
554 cr.defineProperty(PrefTextField, 'controlledBy', cr.PropertyKind.ATTR);
555
556 /**
513 * The user metric string. 557 * The user metric string.
514 * @type {string} 558 * @type {string}
515 */ 559 */
516 cr.defineProperty(PrefTextField, 'metric', cr.PropertyKind.ATTR); 560 cr.defineProperty(PrefTextField, 'metric', cr.PropertyKind.ATTR);
517 561
518 /** 562 /**
519 * The data type for the preference options. 563 * The data type for the preference options.
520 * @type {string} 564 * @type {string}
521 */ 565 */
522 cr.defineProperty(PrefTextField, 'dataType', cr.PropertyKind.ATTR); 566 cr.defineProperty(PrefTextField, 'dataType', cr.PropertyKind.ATTR);
523 567
524 // Export 568 // Export
525 return { 569 return {
526 PrefCheckbox: PrefCheckbox, 570 PrefCheckbox: PrefCheckbox,
527 PrefNumber: PrefNumber, 571 PrefNumber: PrefNumber,
528 PrefNumeric: PrefNumeric, 572 PrefNumeric: PrefNumeric,
529 PrefRadio: PrefRadio, 573 PrefRadio: PrefRadio,
530 PrefRange: PrefRange, 574 PrefRange: PrefRange,
531 PrefSelect: PrefSelect, 575 PrefSelect: PrefSelect,
532 PrefTextField: PrefTextField 576 PrefTextField: PrefTextField
533 }; 577 };
534 578
535 }); 579 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/personal_options.js ('k') | chrome/browser/ui/webui/options/advanced_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698