| Index: ui/webui/resources/cr_elements/v1_0/policy/cr_policy_pref_indicator.js
|
| diff --git a/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_pref_indicator.js b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_pref_indicator.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1f01d5a96deb0297792707e12f726d2807358092
|
| --- /dev/null
|
| +++ b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_pref_indicator.js
|
| @@ -0,0 +1,66 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +/**
|
| + * @fileoverview Polymer element for indicating policies that apply to an
|
| + * element controlling a settings preference.
|
| + *
|
| + * @element cr-policy-pref-indicator
|
| + */
|
| +Polymer({
|
| + is: 'cr-policy-pref-indicator',
|
| +
|
| + behaviors: [CrPolicyIndicatorBehavior, CrPolicyPrefBehavior],
|
| +
|
| + properties: {
|
| + /**
|
| + * Optional preference object associated with the indicator. Initialized to
|
| + * null so that computed functions will get called if this is never set.
|
| + * @type {?chrome.settingsPrivate.PrefObject}
|
| + */
|
| + pref: {type: Object, value: null},
|
| +
|
| + /**
|
| + * Optional email of the user controlling the setting when the setting does
|
| + * not correspond to a pref (Chrome OS only). Only used when pref is null.
|
| + * Initialized to '' so that computed functions will get called if this is
|
| + * never set.
|
| + */
|
| + controllingUser: {type: String, value: ''},
|
| +
|
| + /**
|
| + * Which indicator type to show (or NONE).
|
| + * @type {CrPolicyIndicatorType}
|
| + */
|
| + indicatorType: {type: String, value: CrPolicyIndicatorType.NONE},
|
| + },
|
| +
|
| + observers: ['prefPolicyChanged_(pref.policySource, pref.policyEnforcement)'],
|
| +
|
| + /**
|
| + * Polymer observer for pref.
|
| + * @param {chrome.settingsPrivate.PolicySource} source
|
| + * @param {chrome.settingsPrivate.PolicyEnforcement} enforcement
|
| + * @private
|
| + */
|
| + prefPolicyChanged_: function(source, enforcement) {
|
| + this.indicatorType = this.getIndicatorType(source, enforcement);
|
| + },
|
| +
|
| + /**
|
| + * @param {CrPolicyIndicatorType} type
|
| + * @param {?chrome.settingsPrivate.PrefObject} pref
|
| + * @return {string} The tooltip text for |type|.
|
| + * @private
|
| + */
|
| + getTooltip_: function(type, pref, controllingUser) {
|
| + if (type == CrPolicyIndicatorType.RECOMMENDED) {
|
| + if (pref && pref.value == pref.recommendedValue)
|
| + return this.i18n('controlledSettingRecommendedMatches');
|
| + return this.i18n('controlledSettingRecommendedDiffers');
|
| + }
|
| + var name = pref ? pref.policySourceName : controllingUser;
|
| + return this.getTooltipText(type, name);
|
| + }
|
| +});
|
|
|