Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js

Issue 2708013003: [MD settings] show icon when content settings are controlled by an extension (Closed)
Patch Set: ignore-extensions Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /** 9 /**
10 * Strings required for policy indicators. These must be set at runtime. 10 * Strings required for policy indicators. These must be set at runtime.
11 * Chrome OS only strings may be undefined. 11 * Chrome OS only strings may be undefined.
12 * @type {{ 12 * @type {{
13 * controlledSettingExtension: string,
13 * controlledSettingPolicy: string, 14 * controlledSettingPolicy: string,
14 * controlledSettingRecommendedMatches: string, 15 * controlledSettingRecommendedMatches: string,
15 * controlledSettingRecommendedDiffers: string, 16 * controlledSettingRecommendedDiffers: string,
16 * controlledSettingShared: (string|undefined), 17 * controlledSettingShared: (string|undefined),
17 * controlledSettingOwner: (string|undefined), 18 * controlledSettingOwner: (string|undefined),
18 * }} 19 * }}
19 */ 20 */
20 var CrPolicyStrings; 21 var CrPolicyStrings;
21 22
22 /** @enum {string} */ 23 /** @enum {string} */
23 var CrPolicyIndicatorType = { 24 var CrPolicyIndicatorType = {
24 DEVICE_POLICY: 'devicePolicy', 25 DEVICE_POLICY: 'devicePolicy',
25 EXTENSION: 'extension', 26 EXTENSION: 'extension',
26 NONE: 'none', 27 NONE: 'none',
27 OWNER: 'owner', 28 OWNER: 'owner',
28 PRIMARY_USER: 'primary_user', 29 PRIMARY_USER: 'primary_user',
29 RECOMMENDED: 'recommended', 30 RECOMMENDED: 'recommended',
30 USER_POLICY: 'userPolicy', 31 USER_POLICY: 'userPolicy',
31 }; 32 };
32 33
33 /** @polymerBehavior */ 34 /** @polymerBehavior */
34 var CrPolicyIndicatorBehavior = { 35 var CrPolicyIndicatorBehavior = {
35 /** 36 /**
36 * @param {CrPolicyIndicatorType} type 37 * @param {CrPolicyIndicatorType} type
37 * @return {boolean} True if the indicator should be shown. 38 * @return {boolean} True if the indicator should be shown.
38 * @private 39 * @private
39 */ 40 */
40 isIndicatorVisible: function(type) { 41 isIndicatorVisible: function(type) {
41 return type != CrPolicyIndicatorType.NONE && 42 return type != CrPolicyIndicatorType.NONE;
42 type != CrPolicyIndicatorType.EXTENSION;
dschuyler 2017/02/28 00:15:18 This is now accounted for in cr_policy_pref_behavi
43 }, 43 },
44 44
45 /** 45 /**
46 * @param {CrPolicyIndicatorType} type 46 * @param {CrPolicyIndicatorType} type
47 * @return {string} The iron-icon icon name. 47 * @return {string} The iron-icon icon name.
48 * @private 48 * @private
49 */ 49 */
50 getPolicyIndicatorIcon: function(type) { 50 getPolicyIndicatorIcon: function(type) {
51 var icon = '';
52 switch (type) { 51 switch (type) {
52 case CrPolicyIndicatorType.NONE:
53 return '';
53 case CrPolicyIndicatorType.EXTENSION: 54 case CrPolicyIndicatorType.EXTENSION:
54 case CrPolicyIndicatorType.NONE: 55 return 'cr:extension';
55 return icon;
56 case CrPolicyIndicatorType.PRIMARY_USER: 56 case CrPolicyIndicatorType.PRIMARY_USER:
57 icon = 'cr:group'; 57 return 'cr:group';
58 break;
59 case CrPolicyIndicatorType.OWNER: 58 case CrPolicyIndicatorType.OWNER:
60 icon = 'cr:person'; 59 return 'cr:person';
61 break;
62 case CrPolicyIndicatorType.USER_POLICY: 60 case CrPolicyIndicatorType.USER_POLICY:
63 case CrPolicyIndicatorType.DEVICE_POLICY: 61 case CrPolicyIndicatorType.DEVICE_POLICY:
64 case CrPolicyIndicatorType.RECOMMENDED: 62 case CrPolicyIndicatorType.RECOMMENDED:
65 icon = 'cr20:domain'; 63 return 'cr20:domain';
66 break;
67 default: 64 default:
68 assertNotReached(); 65 assertNotReached();
69 } 66 }
70 return icon;
71 }, 67 },
72 68
73 /** 69 /**
74 * @param {!CrPolicyIndicatorType} type 70 * @param {!CrPolicyIndicatorType} type
75 * @param {string} name The name associated with the indicator. See 71 * @param {string} name The name associated with the indicator. See
76 * chrome.settingsPrivate.PrefObject.controlledByName 72 * chrome.settingsPrivate.PrefObject.controlledByName
77 * @param {boolean=} opt_matches For RECOMMENDED only, whether the indicator 73 * @param {boolean=} opt_matches For RECOMMENDED only, whether the indicator
78 * value matches the recommended value. 74 * value matches the recommended value.
79 * @return {string} The tooltip text for |type|. 75 * @return {string} The tooltip text for |type|.
80 */ 76 */
81 getPolicyIndicatorTooltip: function(type, name, opt_matches) { 77 getPolicyIndicatorTooltip: function(type, name, opt_matches) {
82 if (!CrPolicyStrings) 78 if (!CrPolicyStrings)
83 return ''; // Tooltips may not be defined, e.g. in OOBE. 79 return ''; // Tooltips may not be defined, e.g. in OOBE.
84 switch (type) { 80 switch (type) {
81 case CrPolicyIndicatorType.EXTENSION:
82 return CrPolicyStrings.controlledSettingExtension;
85 case CrPolicyIndicatorType.PRIMARY_USER: 83 case CrPolicyIndicatorType.PRIMARY_USER:
86 return CrPolicyStrings.controlledSettingShared.replace('$1', name); 84 return CrPolicyStrings.controlledSettingShared.replace('$1', name);
87 case CrPolicyIndicatorType.OWNER: 85 case CrPolicyIndicatorType.OWNER:
88 return CrPolicyStrings.controlledSettingOwner.replace('$1', name); 86 return CrPolicyStrings.controlledSettingOwner.replace('$1', name);
89 case CrPolicyIndicatorType.USER_POLICY: 87 case CrPolicyIndicatorType.USER_POLICY:
90 case CrPolicyIndicatorType.DEVICE_POLICY: 88 case CrPolicyIndicatorType.DEVICE_POLICY:
91 return CrPolicyStrings.controlledSettingPolicy; 89 return CrPolicyStrings.controlledSettingPolicy;
92 case CrPolicyIndicatorType.RECOMMENDED: 90 case CrPolicyIndicatorType.RECOMMENDED:
93 return opt_matches ? 91 return opt_matches ?
94 CrPolicyStrings.controlledSettingRecommendedMatches : 92 CrPolicyStrings.controlledSettingRecommendedMatches :
95 CrPolicyStrings.controlledSettingRecommendedDiffers; 93 CrPolicyStrings.controlledSettingRecommendedDiffers;
96 } 94 }
97 return ''; 95 return '';
98 }, 96 },
99 }; 97 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698