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 Behavior for policy controlled indicators. |
| 7 */ |
| 8 |
| 9 /** @enum {string} */ |
| 10 var CrPolicyIndicatorType = { |
| 11 DEVICE_POLICY: 'devicePolicy', |
| 12 EXTENSION: 'extension', |
| 13 NONE: 'none', |
| 14 OWNER: 'owner', |
| 15 PRIMARY_USER: 'primary_user', |
| 16 RECOMMENDED: 'recommended', |
| 17 USER_POLICY: 'userPolicy', |
| 18 }; |
| 19 |
| 20 /** @polymerBehavior */ |
| 21 var CrPolicyIndicatorBehavior = { |
| 22 /** |
| 23 * @param {CrPolicyIndicatorType} type |
| 24 * @return {boolean} True if the indicator should be shown. |
| 25 * @private |
| 26 */ |
| 27 isIndicatorVisible: function(type) { |
| 28 return type != CrPolicyIndicatorType.NONE; |
| 29 }, |
| 30 |
| 31 /** |
| 32 * @param {CrPolicyIndicatorType} type |
| 33 * @return {string} The iron-icons icon name. |
| 34 * @private |
| 35 */ |
| 36 getPolicyIndicatorIcon: function(type) { |
| 37 switch (type) { |
| 38 case CrPolicyIndicatorType.NONE: |
| 39 return ''; |
| 40 case CrPolicyIndicatorType.PRIMARY_USER: |
| 41 return 'social:group'; |
| 42 case CrPolicyIndicatorType.OWNER: |
| 43 return 'social:person'; |
| 44 case CrPolicyIndicatorType.USER_POLICY: |
| 45 case CrPolicyIndicatorType.DEVICE_POLICY: |
| 46 return 'social:domain'; |
| 47 case CrPolicyIndicatorType.EXTENSION: |
| 48 return 'extension'; |
| 49 case CrPolicyIndicatorType.RECOMMENDED: |
| 50 return 'social:domain'; |
| 51 } |
| 52 assertNotReached(); |
| 53 return ''; |
| 54 }, |
| 55 |
| 56 /** |
| 57 * @param {string} id The id of the string to translate. |
| 58 * @param {string=} opt_name An optional name argument. |
| 59 * @return The translated string. |
| 60 */ |
| 61 i18n_: function (id, opt_name) { |
| 62 return loadTimeData.getStringF(id, opt_name); |
| 63 }, |
| 64 |
| 65 /** |
| 66 * @param {CrPolicyIndicatorType} type |
| 67 * @param {string} name The name associated with the controllable. See |
| 68 * chrome.settingsPrivate.PrefObject.policySourceName |
| 69 * @return {string} The tooltip text for |type|. |
| 70 */ |
| 71 getPolicyIndicatorTooltip: function(type, name) { |
| 72 switch (type) { |
| 73 case CrPolicyIndicatorType.PRIMARY_USER: |
| 74 return this.i18n_('controlledSettingShared', name); |
| 75 case CrPolicyIndicatorType.OWNER: |
| 76 return this.i18n_('controlledSettingOwner', name); |
| 77 case CrPolicyIndicatorType.USER_POLICY: |
| 78 case CrPolicyIndicatorType.DEVICE_POLICY: |
| 79 return this.i18n_('controlledSettingPolicy'); |
| 80 case CrPolicyIndicatorType.EXTENSION: |
| 81 return this.i18n_('controlledSettingExtension', name); |
| 82 case CrPolicyIndicatorType.RECOMMENDED: |
| 83 // This case is not handled here since it requires knowledge of the |
| 84 // value and recommended value associated with the controllable. |
| 85 assertNotReached(); |
| 86 } |
| 87 return ''; |
| 88 } |
| 89 }; |
OLD | NEW |