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

Unified Diff: ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js

Issue 1376383003: Add cr-policy-network-indicator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_521791_network_indicators_b
Patch Set: Rebase + fix WS Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js b/ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js
new file mode 100644
index 0000000000000000000000000000000000000000..d036c06973ba619599314849e9858b2be0a2acc8
--- /dev/null
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.js
@@ -0,0 +1,91 @@
+// 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.ManagedProperty|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];
+
+ if (property.UserEditable === true &&
+ property.hasOwnProperty('UserPolicy')) {
+ // We ignore UserEditable unless there is a UserPolicy.
+ this.indicatorType = CrPolicyIndicatorType.RECOMMENDED;
+ this.recommended =
+ /** @type {CrOnc.NetworkPropertyType} */(property.UserPolicy);
+ } else if (property.DeviceEditable === true &&
+ property.hasOwnProperty('DevicePolicy')) {
+ // We ignore DeviceEditable unless there is a DevicePolicy.
+ this.indicatorType = CrPolicyIndicatorType.RECOMMENDED;
+ this.recommended =
+ /** @type {CrOnc.NetworkPropertyType} */(property.DevicePolicy);
+ } else if (effective == 'UserPolicy') {
+ this.indicatorType = CrPolicyIndicatorType.USER_POLICY;
+ } else if (effective == 'DevicePolicy') {
+ this.indicatorType = CrPolicyIndicatorType.DEVICE_POLICY;
+ } else {
+ this.indicatorType = CrPolicyIndicatorType.NONE;
+ }
+ },
+
+ /**
+ * @param {CrPolicyIndicatorType} type
+ * @param {!CrOnc.ManagedProperty} 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.getPolicyIndicatorTooltip(type, '');
+ }
+});
« no previous file with comments | « ui/webui/resources/cr_elements/policy/cr_policy_network_indicator.html ('k') | ui/webui/resources/cr_elements_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698