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

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

Issue 1369403006: Add cr-policy-network-indicator and add to internet settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate policy indicator strings 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/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, '');
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698