Chromium Code Reviews| 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 getIcon: function(type) { | |
|
Dan Beam
2015/10/07 18:40:58
remember, these are mixed in with |this| on anythi
stevenjb
2015/10/07 23:37:14
Fair point. -> getPolicyIndicatorIcon
| |
| 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 }, | |
|
Dan Beam
2015/10/07 18:40:58
nit: this is probably generic enough to be it's ow
stevenjb
2015/10/07 23:37:14
Agreed, and it's on my TODO list. In the meanwhile
| |
| 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 getTooltipText: function(type, name) { | |
|
stevenjb
2015/10/07 23:37:14
Also renamed -> getPolicyIndicatorTooltip
| |
| 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 knowlede of the | |
|
michaelpg
2015/10/07 18:18:35
knowledge
stevenjb
2015/10/07 18:33:38
Done.
| |
| 84 // value and recommended value associated with the controllable. | |
| 85 assertNotReached(); | |
| 86 } | |
| 87 return ''; | |
| 88 } | |
| 89 }; | |
| OLD | NEW |