OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Polymer element for indicating policies that apply to an |
| 7 * element controlling a settings preference. |
| 8 * |
| 9 * @element cr-policy-pref-indicator |
| 10 */ |
| 11 Polymer({ |
| 12 is: 'cr-policy-pref-indicator', |
| 13 |
| 14 behaviors: [CrPolicyIndicatorBehavior, CrPolicyPrefBehavior], |
| 15 |
| 16 properties: { |
| 17 /** |
| 18 * Optional preference object associated with the indicator. Initialized to |
| 19 * null so that computed functions will get called if this is never set. |
| 20 * @type {?chrome.settingsPrivate.PrefObject} |
| 21 */ |
| 22 pref: {type: Object, value: null}, |
| 23 |
| 24 /** |
| 25 * Optional email of the user controlling the setting when the setting does |
| 26 * not correspond to a pref (Chrome OS only). Only used when pref is null. |
| 27 * Initialized to '' so that computed functions will get called if this is |
| 28 * never set. |
| 29 */ |
| 30 controllingUser: {type: String, value: ''}, |
| 31 |
| 32 /** |
| 33 * Which indicator type to show (or NONE). |
| 34 * @type {CrPolicyIndicatorType} |
| 35 */ |
| 36 indicatorType: {type: String, value: CrPolicyIndicatorType.NONE}, |
| 37 }, |
| 38 |
| 39 observers: ['prefPolicyChanged_(pref.policySource, pref.policyEnforcement)'], |
| 40 |
| 41 /** |
| 42 * Polymer observer for pref. |
| 43 * @param {chrome.settingsPrivate.PolicySource} source |
| 44 * @param {chrome.settingsPrivate.PolicyEnforcement} enforcement |
| 45 * @private |
| 46 */ |
| 47 prefPolicyChanged_: function(source, enforcement) { |
| 48 this.indicatorType = this.getIndicatorType(source, enforcement); |
| 49 }, |
| 50 |
| 51 /** |
| 52 * @param {CrPolicyIndicatorType} type |
| 53 * @param {?chrome.settingsPrivate.PrefObject} pref |
| 54 * @return {string} The tooltip text for |type|. |
| 55 * @private |
| 56 */ |
| 57 getTooltip_: function(type, pref, controllingUser) { |
| 58 if (type == CrPolicyIndicatorType.RECOMMENDED) { |
| 59 if (pref && pref.value == pref.recommendedValue) |
| 60 return this.i18n('controlledSettingRecommendedMatches'); |
| 61 return this.i18n('controlledSettingRecommendedDiffers'); |
| 62 } |
| 63 var name = pref ? pref.policySourceName : controllingUser; |
| 64 return this.getTooltipText(type, name); |
| 65 } |
| 66 }); |
OLD | NEW |