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', | 12 EXTENSION: 'extension', |
13 NONE: 'none', | 13 NONE: 'none', |
14 OWNER: 'owner', | 14 OWNER: 'owner', |
15 PRIMARY_USER: 'primary_user', | 15 PRIMARY_USER: 'primary_user', |
16 RECOMMENDED: 'recommended', | 16 RECOMMENDED: 'recommended', |
17 USER_POLICY: 'userPolicy', | 17 USER_POLICY: 'userPolicy', |
18 }; | 18 }; |
19 | 19 |
20 /** @polymerBehavior */ | 20 /** @polymerBehavior */ |
21 var CrPolicyIndicatorBehavior = { | 21 var CrPolicyIndicatorBehavior = { |
22 /** | 22 /** |
23 * @param {CrPolicyIndicatorType} type | 23 * @param {CrPolicyIndicatorType} type |
24 * @return {boolean} True if the indicator should be shown. | 24 * @return {boolean} True if the indicator should be shown. |
25 * @private | 25 * @private |
26 */ | 26 */ |
27 isIndicatorVisible: function(type) { | 27 isIndicatorVisible: function(type) { |
28 return type != CrPolicyIndicatorType.NONE && | 28 return type != CrPolicyIndicatorType.NONE && |
29 type != CrPolicyIndicatorType.EXTENSION; | 29 type != CrPolicyIndicatorType.EXTENSION; |
30 }, | 30 }, |
31 | 31 |
32 /** | 32 /** |
33 * @param {CrPolicyIndicatorType} type | 33 * @param {CrPolicyIndicatorType} type |
34 * @return {string} The iron-icon icon name. | 34 * @return {string} The iron-icon icon name. |
35 * @private | 35 * @private |
36 */ | 36 */ |
37 getPolicyIndicatorIcon: function(type) { | 37 getPolicyIndicatorIcon: function(type) { |
38 var icon = ''; | 38 var icon = ''; |
39 switch (type) { | 39 switch (type) { |
(...skipping 15 matching lines...) Expand all Loading... |
55 assertNotReached(); | 55 assertNotReached(); |
56 } | 56 } |
57 return 'cr:' + icon; | 57 return 'cr:' + icon; |
58 }, | 58 }, |
59 | 59 |
60 /** | 60 /** |
61 * @param {string} id The id of the string to translate. | 61 * @param {string} id The id of the string to translate. |
62 * @param {string=} opt_name An optional name argument. | 62 * @param {string=} opt_name An optional name argument. |
63 * @return The translated string. | 63 * @return The translated string. |
64 */ | 64 */ |
65 i18n_: function (id, opt_name) { | 65 i18n_: function(id, opt_name) { |
66 return loadTimeData.getStringF(id, opt_name); | 66 return loadTimeData.getStringF(id, opt_name); |
67 }, | 67 }, |
68 | 68 |
69 /** | 69 /** |
70 * @param {CrPolicyIndicatorType} type | 70 * @param {CrPolicyIndicatorType} type |
71 * @param {string} name The name associated with the controllable. See | 71 * @param {string} name The name associated with the controllable. See |
72 * chrome.settingsPrivate.PrefObject.controlledByName | 72 * chrome.settingsPrivate.PrefObject.controlledByName |
73 * @return {string} The tooltip text for |type|. | 73 * @return {string} The tooltip text for |type|. |
74 */ | 74 */ |
75 getPolicyIndicatorTooltip: function(type, name) { | 75 getPolicyIndicatorTooltip: function(type, name) { |
76 switch (type) { | 76 switch (type) { |
77 case CrPolicyIndicatorType.PRIMARY_USER: | 77 case CrPolicyIndicatorType.PRIMARY_USER: |
78 return this.i18n_('controlledSettingShared', name); | 78 return this.i18n_('controlledSettingShared', name); |
79 case CrPolicyIndicatorType.OWNER: | 79 case CrPolicyIndicatorType.OWNER: |
80 return this.i18n_('controlledSettingOwner', name); | 80 return this.i18n_('controlledSettingOwner', name); |
81 case CrPolicyIndicatorType.USER_POLICY: | 81 case CrPolicyIndicatorType.USER_POLICY: |
82 case CrPolicyIndicatorType.DEVICE_POLICY: | 82 case CrPolicyIndicatorType.DEVICE_POLICY: |
83 return this.i18n_('controlledSettingPolicy'); | 83 return this.i18n_('controlledSettingPolicy'); |
84 case CrPolicyIndicatorType.RECOMMENDED: | 84 case CrPolicyIndicatorType.RECOMMENDED: |
85 // This case is not handled here since it requires knowledge of the | 85 // This case is not handled here since it requires knowledge of the |
86 // value and recommended value associated with the controllable. | 86 // value and recommended value associated with the controllable. |
87 assertNotReached(); | 87 assertNotReached(); |
88 } | 88 } |
89 return ''; | 89 return ''; |
90 } | 90 } |
91 }; | 91 }; |
OLD | NEW |