Commit 3937c527 authored by michaelpg's avatar michaelpg Committed by Commit bot

MD Settings: Expose CrPolicyIndicator.Type

Allow MD Settings pages to specify policy indicator icon types.

BUG=521791

Review URL: https://codereview.chromium.org/1376553002

Cr-Commit-Position: refs/heads/master@{#351206}
parent 91585690
...@@ -7,19 +7,21 @@ ...@@ -7,19 +7,21 @@
* element controlling a settings preference. * element controlling a settings preference.
*/ */
(function() { var CrPolicyIndicator = {
/** @enum {string} */
/** @enum {string} */ Type: {
var IndicatorType = { DEVICE_POLICY: 'devicePolicy',
DEVICE_POLICY: 'devicePolicy', EXTENSION: 'extension',
EXTENSION: 'extension', NONE: 'none',
NONE: 'none', OWNER: 'owner',
OWNER: 'owner', PRIMARY_USER: 'primary_user',
PRIMARY_USER: 'primary_user', RECOMMENDED: 'recommended',
RECOMMENDED: 'recommended', USER_POLICY: 'userPolicy',
USER_POLICY: 'userPolicy', },
}; };
(function() {
/** @element cr-policy-indicator */ /** @element cr-policy-indicator */
Polymer({ Polymer({
is: 'cr-policy-indicator', is: 'cr-policy-indicator',
...@@ -33,9 +35,9 @@ Polymer({ ...@@ -33,9 +35,9 @@ Polymer({
/** /**
* Which indicator type to show (or NONE). * Which indicator type to show (or NONE).
* @type {IndicatorType} * @type {CrPolicyIndicator.Type}
*/ */
indicatorType: {type: String, value: IndicatorType.NONE}, indicatorType: {type: String, value: CrPolicyIndicator.Type.NONE},
}, },
observers: ['prefPolicyChanged_(pref.policySource, pref.policyEnforcement)'], observers: ['prefPolicyChanged_(pref.policySource, pref.policyEnforcement)'],
...@@ -47,51 +49,53 @@ Polymer({ ...@@ -47,51 +49,53 @@ Polymer({
* @private * @private
*/ */
prefPolicyChanged_: function(source, enforcement) { prefPolicyChanged_: function(source, enforcement) {
var type = IndicatorType.NONE; var type = CrPolicyIndicator.Type.NONE;
if (enforcement == chrome.settingsPrivate.PolicyEnforcement.ENFORCED) { if (enforcement == chrome.settingsPrivate.PolicyEnforcement.ENFORCED) {
if (source == chrome.settingsPrivate.PolicySource.PRIMARY_USER) if (source == chrome.settingsPrivate.PolicySource.PRIMARY_USER)
type = IndicatorType.PRIMARY_USER; type = CrPolicyIndicator.Type.PRIMARY_USER;
else if (source == chrome.settingsPrivate.PolicySource.OWNER) else if (source == chrome.settingsPrivate.PolicySource.OWNER)
type = IndicatorType.OWNER; type = CrPolicyIndicator.Type.OWNER;
else if (source == chrome.settingsPrivate.PolicySource.USER_POLICY) else if (source == chrome.settingsPrivate.PolicySource.USER_POLICY)
type = IndicatorType.USER_POLICY; type = CrPolicyIndicator.Type.USER_POLICY;
else if (source == chrome.settingsPrivate.PolicySource.DEVICE_POLICY) else if (source == chrome.settingsPrivate.PolicySource.DEVICE_POLICY)
type = IndicatorType.DEVICE_POLICY; type = CrPolicyIndicator.Type.DEVICE_POLICY;
else if (source == chrome.settingsPrivate.PolicySource.EXTENSION) else if (source == chrome.settingsPrivate.PolicySource.EXTENSION)
type = IndicatorType.EXTENSION; type = CrPolicyIndicator.Type.EXTENSION;
} else if (enforcement == } else if (enforcement ==
chrome.settingsPrivate.PolicyEnforcement.RECOMMENDED) { chrome.settingsPrivate.PolicyEnforcement.RECOMMENDED) {
type = IndicatorType.RECOMMENDED; type = CrPolicyIndicator.Type.RECOMMENDED;
} }
this.indicatorType = type; this.indicatorType = type;
}, },
/** /**
* @param {IndicatorType} type * @param {CrPolicyIndicator.Type} type
* @return {boolean} True if the indicator should be shown. * @return {boolean} True if the indicator should be shown.
* @private * @private
*/ */
isIndicatorVisible_: function(type) { return type != IndicatorType.NONE; }, isIndicatorVisible_: function(type) {
return type != CrPolicyIndicator.Type.NONE;
},
/** /**
* @param {IndicatorType} type * @param {CrPolicyIndicator.Type} type
* @return {string} The iron-icons icon name. * @return {string} The iron-icons icon name.
* @private * @private
*/ */
getIcon_: function(type) { getIcon_: function(type) {
switch (type) { switch (type) {
case IndicatorType.NONE: case CrPolicyIndicator.Type.NONE:
return ''; return '';
case IndicatorType.PRIMARY_USER: case CrPolicyIndicator.Type.PRIMARY_USER:
return 'social:group'; return 'social:group';
case IndicatorType.OWNER: case CrPolicyIndicator.Type.OWNER:
return 'social:person'; return 'social:person';
case IndicatorType.USER_POLICY: case CrPolicyIndicator.Type.USER_POLICY:
case IndicatorType.DEVICE_POLICY: case CrPolicyIndicator.Type.DEVICE_POLICY:
return 'social:domain'; return 'social:domain';
case IndicatorType.EXTENSION: case CrPolicyIndicator.Type.EXTENSION:
return 'extension'; return 'extension';
case IndicatorType.RECOMMENDED: case CrPolicyIndicator.Type.RECOMMENDED:
return 'social:domain'; return 'social:domain';
} }
assertNotReached(); assertNotReached();
...@@ -107,24 +111,25 @@ Polymer({ ...@@ -107,24 +111,25 @@ Polymer({
}, },
/** /**
* @param {IndicatorType} type The type of indicator. * @param {CrPolicyIndicator.Type} type The type of indicator.
* @param {!chrome.settingsPrivate.PrefObject} pref * @param {?chrome.settingsPrivate.PrefObject} pref
* @return {string} The tooltip text for |type|. * @return {string} The tooltip text for |type|.
* @private * @private
*/ */
getTooltipText_: function(type, pref) { getTooltipText_: function(type, pref) {
var name = pref.policySourceName || ''; var name = pref.policySourceName || '';
switch (type) { switch (type) {
case IndicatorType.PRIMARY_USER: case CrPolicyIndicator.Type.PRIMARY_USER:
return this.i18n_('controlledSettingShared', name); return this.i18n_('controlledSettingShared', name);
case IndicatorType.OWNER: case CrPolicyIndicator.Type.OWNER:
return this.i18n_('controlledSettingOwner', name); return this.i18n_('controlledSettingOwner', name);
case IndicatorType.USER_POLICY: case CrPolicyIndicator.Type.USER_POLICY:
case IndicatorType.DEVICE_POLICY: case CrPolicyIndicator.Type.DEVICE_POLICY:
return this.i18n_('controlledSettingPolicy'); return this.i18n_('controlledSettingPolicy');
case IndicatorType.EXTENSION: case CrPolicyIndicator.Type.EXTENSION:
return this.i18n_('controlledSettingExtension', name); return this.i18n_('controlledSettingExtension', name);
case IndicatorType.RECOMMENDED: case CrPolicyIndicator.Type.RECOMMENDED:
if (pref.value == pref.recommendedValue) if (pref.value == pref.recommendedValue)
return this.i18n_('controlledSettingRecommendedMatches'); return this.i18n_('controlledSettingRecommendedMatches');
return this.i18n_('controlledSettingRecommendedDiffers'); return this.i18n_('controlledSettingRecommendedDiffers');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment