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 based on network |
| 7 * properties. |
| 8 */ |
| 9 |
| 10 /** @element cr-policy-network-indicator */ |
| 11 Polymer({ |
| 12 is: 'cr-policy-network-indicator', |
| 13 |
| 14 behaviors: [CrPolicyIndicatorBehavior, CrPolicyNetworkBehavior], |
| 15 |
| 16 properties: { |
| 17 /** |
| 18 * Network property associated with the indicator. |
| 19 * @type {!CrOnc.NetworkProperty|undefined} |
| 20 */ |
| 21 property: {type: Object, observer: 'propertyChanged_'}, |
| 22 |
| 23 /** |
| 24 * Which indicator type to show (or NONE). |
| 25 * @type {!CrPolicyIndicatorType} |
| 26 */ |
| 27 indicatorType: {type: String, value: CrPolicyIndicatorType.NONE}, |
| 28 |
| 29 /** |
| 30 * Recommended value for non enforced properties. |
| 31 * @type {?CrOnc.NetworkPropertyType} |
| 32 */ |
| 33 recommended: {type: Object, value: null}, |
| 34 }, |
| 35 |
| 36 /** |
| 37 * @param {!CrOnc.ManagedProperty} property Always defined property value. |
| 38 * @private |
| 39 */ |
| 40 propertyChanged_: function(property) { |
| 41 if (!this.isNetworkPolicyControlled(property)) { |
| 42 this.indicatorType = CrPolicyIndicatorType.NONE; |
| 43 return; |
| 44 } |
| 45 var effective = property.Effective; |
| 46 var active = property.Active; |
| 47 if (active == undefined) |
| 48 active = property[effective]; |
| 49 |
| 50 var indicatorType = this.indicatorType = CrPolicyIndicatorType.NONE; |
| 51 if (property.hasOwnProperty('UserPolicy') && |
| 52 property.UserEditable === true) { |
| 53 indicatorType = CrPolicyIndicatorType.RECOMMENDED; |
| 54 this.recommended = |
| 55 /** @type {CrOnc.NetworkPropertyType} */(property.UserPolicy); |
| 56 } else if (property.hasOwnProperty('DevicePolicy') && |
| 57 property.DeviceEditable === true) { |
| 58 indicatorType = CrPolicyIndicatorType.RECOMMENDED; |
| 59 this.recommended = |
| 60 /** @type {CrOnc.NetworkPropertyType} */(property.DevicePolicy); |
| 61 } else if (effective == 'UserPolicy') { |
| 62 indicatorType = CrPolicyIndicatorType.USER_POLICY; |
| 63 } else if (effective == 'DevicePolicy') { |
| 64 indicatorType = CrPolicyIndicatorType.DEVICE_POLICY; |
| 65 } |
| 66 this.indicatorType = indicatorType; |
| 67 }, |
| 68 |
| 69 /** |
| 70 * @param {CrPolicyIndicatorType} type |
| 71 * @param {!CrOnc.NetworkProperty} property |
| 72 * @param {!CrOnc.NetworkPropertyType} recommended |
| 73 * @return {string} The tooltip text for |type|. |
| 74 * @private |
| 75 */ |
| 76 getTooltip_: function(type, property, recommended) { |
| 77 if (type == CrPolicyIndicatorType.NONE || typeof property != 'object') |
| 78 return ''; |
| 79 if (type == CrPolicyIndicatorType.RECOMMENDED) { |
| 80 var value = property.Active; |
| 81 if (value == undefined && property.Effective) |
| 82 value = property[property.Effective]; |
| 83 if (value == recommended) |
| 84 return this.i18n('controlledSettingRecommendedMatches'); |
| 85 return this.i18n('controlledSettingRecommendedDiffers'); |
| 86 } |
| 87 return this.getTooltipText(type, ''); |
| 88 } |
| 89 }); |
OLD | NEW |