 Chromium Code Reviews
 Chromium Code Reviews Issue 2624003003:
  WebUI: Add cr-policy-pref-indicator tests  (Closed)
    
  
    Issue 2624003003:
  WebUI: Add cr-policy-pref-indicator tests  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** | 
| 6 * @fileoverview Polymer element for indicating policies that apply to an | 6 * @fileoverview Polymer element for indicating policies that apply to an | 
| 7 * element controlling a settings preference. | 7 * element controlling a settings preference. | 
| 8 */ | 8 */ | 
| 9 Polymer({ | 9 Polymer({ | 
| 10 is: 'cr-policy-pref-indicator', | 10 is: 'cr-policy-pref-indicator', | 
| 11 | 11 | 
| 12 behaviors: [CrPolicyIndicatorBehavior, CrPolicyPrefBehavior], | 12 behaviors: [CrPolicyIndicatorBehavior, CrPolicyPrefBehavior], | 
| 13 | 13 | 
| 14 properties: { | 14 properties: { | 
| 15 /** | 15 /** | 
| 16 * Optional preference object associated with the indicator. Initialized to | 16 * Optional preference object associated with the indicator. Initialized to | 
| 17 * null so that computed functions will get called if this is never set. | 17 * null so that computed functions will get called if this is never set. | 
| 18 * @type {!chrome.settingsPrivate.PrefObject|undefined} | 18 * @type {?chrome.settingsPrivate.PrefObject} | 
| 19 */ | 19 */ | 
| 20 pref: Object, | 20 pref: { | 
| 21 type: Object, | |
| 22 value: null, | |
| 23 }, | |
| 21 | 24 | 
| 22 /** | 25 /** | 
| 23 * Which indicator type to show (or NONE). | 26 * Which indicator type to show (or NONE). This may be set explicitly, or | 
| 27 * computed if |pref| is set. | |
| 24 * @type {CrPolicyIndicatorType} | 28 * @type {CrPolicyIndicatorType} | 
| 25 */ | 29 */ | 
| 26 indicatorType: { | 30 indicatorType: { | 
| 27 type: String, | 31 type: String, | 
| 28 value: CrPolicyIndicatorType.NONE, | 32 value: CrPolicyIndicatorType.NONE, | 
| 29 computed: 'getIndicatorType(pref.controlledBy, pref.enforcement)', | |
| 30 }, | 33 }, | 
| 31 }, | 34 }, | 
| 32 | 35 | 
| 36 observers: ['prefChanged_(pref.*)'], | |
| 37 | |
| 38 /** @private */ | |
| 39 prefChanged_() { | |
| 
Dan Beam
2017/01/18 01:06:34
prefChanged_: function
 
stevenjb
2017/01/18 23:13:03
Sigh. Sorry. Done.
 | |
| 40 if (!this.pref) | |
| 41 return; | |
| 42 this.indicatorType = | |
| 43 this.getIndicatorType(this.pref.controlledBy, this.pref.enforcement); | |
| 44 }, | |
| 45 | |
| 33 /** | 46 /** | 
| 34 * @param {CrPolicyIndicatorType} type | 47 * @param {CrPolicyIndicatorType} type | 
| 35 * @param {!chrome.settingsPrivate.PrefObject} pref | |
| 36 * @return {string} The tooltip text for |type|. | 48 * @return {string} The tooltip text for |type|. | 
| 37 * @private | 49 * @private | 
| 38 */ | 50 */ | 
| 39 getTooltip_: function(type, pref) { | 51 getTooltip_: function(type) { | 
| 40 var matches = pref && pref.value == pref.recommendedValue; | 52 var pref = this.pref; | 
| 53 var matches = !!pref && pref.value == pref.recommendedValue; | |
| 41 return this.getPolicyIndicatorTooltip( | 54 return this.getPolicyIndicatorTooltip( | 
| 42 type, pref.controlledByName || '', matches); | 55 type, (pref && pref.controlledByName) || '', matches); | 
| 43 } | 56 } | 
| 44 }); | 57 }); | 
| OLD | NEW |