| Index: ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_indicator.js
|
| diff --git a/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_indicator.js b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_indicator.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9e03fcd977caacb0780252636ac16b3173021a3e
|
| --- /dev/null
|
| +++ b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_indicator.js
|
| @@ -0,0 +1,89 @@
|
| +// 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 based on network
|
| + * properties.
|
| + */
|
| +
|
| +/** @element cr-policy-network-indicator */
|
| +Polymer({
|
| + is: 'cr-policy-network-indicator',
|
| +
|
| + behaviors: [CrPolicyIndicatorBehavior, CrPolicyNetworkBehavior],
|
| +
|
| + properties: {
|
| + /**
|
| + * Network property associated with the indicator.
|
| + * @type {!CrOnc.NetworkProperty|undefined}
|
| + */
|
| + property: {type: Object, observer: 'propertyChanged_'},
|
| +
|
| + /**
|
| + * Which indicator type to show (or NONE).
|
| + * @type {!CrPolicyIndicatorType}
|
| + */
|
| + indicatorType: {type: String, value: CrPolicyIndicatorType.NONE},
|
| +
|
| + /**
|
| + * Recommended value for non enforced properties.
|
| + * @type {?CrOnc.NetworkPropertyType}
|
| + */
|
| + recommended: {type: Object, value: null},
|
| + },
|
| +
|
| + /**
|
| + * @param {!CrOnc.ManagedProperty} property Always defined property value.
|
| + * @private
|
| + */
|
| + propertyChanged_: function(property) {
|
| + if (!this.isNetworkPolicyControlled(property)) {
|
| + this.indicatorType = CrPolicyIndicatorType.NONE;
|
| + return;
|
| + }
|
| + var effective = property.Effective;
|
| + var active = property.Active;
|
| + if (active == undefined)
|
| + active = property[effective];
|
| +
|
| + var indicatorType = this.indicatorType = CrPolicyIndicatorType.NONE;
|
| + if (property.hasOwnProperty('UserPolicy') &&
|
| + property.UserEditable === true) {
|
| + indicatorType = CrPolicyIndicatorType.RECOMMENDED;
|
| + this.recommended =
|
| + /** @type {CrOnc.NetworkPropertyType} */(property.UserPolicy);
|
| + } else if (property.hasOwnProperty('DevicePolicy') &&
|
| + property.DeviceEditable === true) {
|
| + indicatorType = CrPolicyIndicatorType.RECOMMENDED;
|
| + this.recommended =
|
| + /** @type {CrOnc.NetworkPropertyType} */(property.DevicePolicy);
|
| + } else if (effective == 'UserPolicy') {
|
| + indicatorType = CrPolicyIndicatorType.USER_POLICY;
|
| + } else if (effective == 'DevicePolicy') {
|
| + indicatorType = CrPolicyIndicatorType.DEVICE_POLICY;
|
| + }
|
| + this.indicatorType = indicatorType;
|
| + },
|
| +
|
| + /**
|
| + * @param {CrPolicyIndicatorType} type
|
| + * @param {!CrOnc.NetworkProperty} property
|
| + * @param {!CrOnc.NetworkPropertyType} recommended
|
| + * @return {string} The tooltip text for |type|.
|
| + * @private
|
| + */
|
| + getTooltip_: function(type, property, recommended) {
|
| + if (type == CrPolicyIndicatorType.NONE || typeof property != 'object')
|
| + return '';
|
| + if (type == CrPolicyIndicatorType.RECOMMENDED) {
|
| + var value = property.Active;
|
| + if (value == undefined && property.Effective)
|
| + value = property[property.Effective];
|
| + if (value == recommended)
|
| + return this.i18n('controlledSettingRecommendedMatches');
|
| + return this.i18n('controlledSettingRecommendedDiffers');
|
| + }
|
| + return this.getTooltipText(type, '');
|
| + }
|
| +});
|
|
|