OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Behavior for policy controlled indicators. | 6 * @fileoverview Behavior for policy controlled indicators. |
7 */ | 7 */ |
8 | 8 |
9 /** @enum {string} */ | 9 /** @enum {string} */ |
10 var CrPolicyIndicatorType = { | 10 var CrPolicyIndicatorType = { |
11 DEVICE_POLICY: 'devicePolicy', | 11 DEVICE_POLICY: 'devicePolicy', |
12 EXTENSION: 'extension', | |
13 NONE: 'none', | 12 NONE: 'none', |
14 OWNER: 'owner', | 13 OWNER: 'owner', |
15 PRIMARY_USER: 'primary_user', | 14 PRIMARY_USER: 'primary_user', |
16 RECOMMENDED: 'recommended', | 15 RECOMMENDED: 'recommended', |
17 USER_POLICY: 'userPolicy', | 16 USER_POLICY: 'userPolicy', |
18 }; | 17 }; |
19 | 18 |
20 /** @polymerBehavior */ | 19 /** @polymerBehavior */ |
21 var CrPolicyIndicatorBehavior = { | 20 var CrPolicyIndicatorBehavior = { |
22 /** | 21 /** |
(...skipping 19 matching lines...) Expand all Loading... |
42 icon = 'group'; | 41 icon = 'group'; |
43 break; | 42 break; |
44 case CrPolicyIndicatorType.OWNER: | 43 case CrPolicyIndicatorType.OWNER: |
45 icon = 'person'; | 44 icon = 'person'; |
46 break; | 45 break; |
47 case CrPolicyIndicatorType.USER_POLICY: | 46 case CrPolicyIndicatorType.USER_POLICY: |
48 case CrPolicyIndicatorType.DEVICE_POLICY: | 47 case CrPolicyIndicatorType.DEVICE_POLICY: |
49 case CrPolicyIndicatorType.RECOMMENDED: | 48 case CrPolicyIndicatorType.RECOMMENDED: |
50 icon = 'domain'; | 49 icon = 'domain'; |
51 break; | 50 break; |
52 case CrPolicyIndicatorType.EXTENSION: | |
53 icon = 'extension'; | |
54 break; | |
55 default: | 51 default: |
56 assertNotReached(); | 52 assertNotReached(); |
57 } | 53 } |
58 return 'cr:' + icon; | 54 return 'cr:' + icon; |
59 }, | 55 }, |
60 | 56 |
61 /** | 57 /** |
62 * @param {string} id The id of the string to translate. | 58 * @param {string} id The id of the string to translate. |
63 * @param {string=} opt_name An optional name argument. | 59 * @param {string=} opt_name An optional name argument. |
64 * @return The translated string. | 60 * @return The translated string. |
65 */ | 61 */ |
66 i18n_: function (id, opt_name) { | 62 i18n_: function (id, opt_name) { |
67 return loadTimeData.getStringF(id, opt_name); | 63 return loadTimeData.getStringF(id, opt_name); |
68 }, | 64 }, |
69 | 65 |
70 /** | 66 /** |
71 * @param {CrPolicyIndicatorType} type | 67 * @param {CrPolicyIndicatorType} type |
72 * @param {string} name The name associated with the controllable. See | 68 * @param {string} name The name associated with the controllable. See |
73 * chrome.settingsPrivate.PrefObject.policySourceName | 69 * chrome.settingsPrivate.PrefObject.controlledByName |
74 * @return {string} The tooltip text for |type|. | 70 * @return {string} The tooltip text for |type|. |
75 */ | 71 */ |
76 getPolicyIndicatorTooltip: function(type, name) { | 72 getPolicyIndicatorTooltip: function(type, name) { |
77 switch (type) { | 73 switch (type) { |
78 case CrPolicyIndicatorType.PRIMARY_USER: | 74 case CrPolicyIndicatorType.PRIMARY_USER: |
79 return this.i18n_('controlledSettingShared', name); | 75 return this.i18n_('controlledSettingShared', name); |
80 case CrPolicyIndicatorType.OWNER: | 76 case CrPolicyIndicatorType.OWNER: |
81 return this.i18n_('controlledSettingOwner', name); | 77 return this.i18n_('controlledSettingOwner', name); |
82 case CrPolicyIndicatorType.USER_POLICY: | 78 case CrPolicyIndicatorType.USER_POLICY: |
83 case CrPolicyIndicatorType.DEVICE_POLICY: | 79 case CrPolicyIndicatorType.DEVICE_POLICY: |
84 return this.i18n_('controlledSettingPolicy'); | 80 return this.i18n_('controlledSettingPolicy'); |
85 case CrPolicyIndicatorType.EXTENSION: | |
86 return this.i18n_('controlledSettingExtension', name); | |
87 case CrPolicyIndicatorType.RECOMMENDED: | 81 case CrPolicyIndicatorType.RECOMMENDED: |
88 // This case is not handled here since it requires knowledge of the | 82 // This case is not handled here since it requires knowledge of the |
89 // value and recommended value associated with the controllable. | 83 // value and recommended value associated with the controllable. |
90 assertNotReached(); | 84 assertNotReached(); |
91 } | 85 } |
92 return ''; | 86 return ''; |
93 } | 87 } |
94 }; | 88 }; |
OLD | NEW |