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. TODO(stevenjb/michaelpg): Create a separate indicator for | |
29 * non-pref (i.e. explicitly set) indicators (see languyage_detail_page). | |
30 */ | |
31 controllingUser: {type: String, value: ''}, | |
32 | |
33 /** | |
34 * Which indicator type to show (or NONE). | |
35 * @type {CrPolicyIndicatorType} | |
36 */ | |
37 indicatorType: { | |
38 type: String, | |
39 value: CrPolicyIndicatorType.NONE, | |
40 computed: 'getIndicatorType(pref.policySource, pref.policyEnforcement)', | |
41 }, | |
42 }, | |
43 | |
44 /** | |
45 * @param {CrPolicyIndicatorType} type | |
46 * @param {?chrome.settingsPrivate.PrefObject} pref | |
47 * @return {string} The tooltip text for |type|. | |
48 * @private | |
49 */ | |
50 getTooltip_: function(type, pref, controllingUser) { | |
51 if (type == CrPolicyIndicatorType.RECOMMENDED) { | |
52 if (pref && pref.value == pref.recommendedValue) | |
53 return this.i18n_('controlledSettingRecommendedMatches'); | |
54 return this.i18n_('controlledSettingRecommendedDiffers'); | |
55 } | |
56 var name = pref ? pref.policySourceName : controllingUser; | |
57 return this.getPolicyIndicatorTooltip(type, name); | |
58 } | |
59 }); | |
OLD | NEW |