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

Unified Diff: ui/webui/resources/cr_elements/policy/cr_policy_network_behavior.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_behavior.js
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_network_behavior.js b/ui/webui/resources/cr_elements/policy/cr_policy_network_behavior.js
new file mode 100644
index 0000000000000000000000000000000000000000..ec3f38e341eb957cc73e2f48b33ab9e355dd10dd
--- /dev/null
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_network_behavior.js
@@ -0,0 +1,51 @@
+// 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 Behavior for policy controlled network properties.
+ */
+
+/** @polymerBehavior */
+var CrPolicyNetworkBehavior = {
+ /**
+ * @param {!CrOnc.ManagedProperty|undefined} property
+ * @return {boolean} True if the network property is controlled by a policy
+ * (either enforced or recommended).
+ */
+ isNetworkPolicyControlled: function(property) {
+ // If the property is not a dictionary, or does not have an Effective
+ // sub-property set, then the property is not policy controlled.
+ if (typeof property != 'object' || !property.Effective)
+ return false;
+ // Enforced
+ var effective = property.Effective;
+ if (effective == 'UserPolicy' || effective == 'DevicePolicy')
+ return true;
+ // Recommended
+ if (property.UserPolicy || property.DevicePolicy)
+ return true;
+ // Neither enforced nor recommended = not policy controlled.
+ return false;
+ },
+
+ /**
+ * @param {!CrOnc.ManagedProperty|undefined} property
+ * @return {boolean} True if the network property is enforced by a policy.
+ */
+ isNetworkPolicyEnforced: function(property) {
+ if (!this.isNetworkPolicyControlled(property))
+ return false;
+ // If the property has a UserEditable sub-property, that determines whether
+ // or not it is editable (not enforced).
+ if (typeof property.UserEditable != 'undefined')
+ return !property.UserEditable;
+
+ // Otherwise if the property has a DeviceEditable sub-property, check that.
+ if (typeof property.DeviceEditable != 'undefined')
+ return !property.DeviceEditable;
+
+ // If no 'Editable' sub-property exists, the policy value is enforced.
+ return true;
+ },
+};

Powered by Google App Engine
This is Rietveld 408576698