Index: ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_behavior.js |
diff --git a/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_behavior.js b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_behavior.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fc9b097ba8dc9c90329666805a81a82ba2fa3a74 |
--- /dev/null |
+++ b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_network_behavior.js |
@@ -0,0 +1,46 @@ |
+// 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.NetworkProperty|undefined} property |
+ * @return {boolean} True if the network propety is controlled by a policy |
+ * (either enforced or recommended). |
+ */ |
+ isNetworkPolicyControlled: function(property) { |
+ if (typeof property != 'object' || !property.Effective) |
+ return false; |
+ // Enforced |
+ var effective = property.Effective; |
+ if (effective == 'UserPolicy' || effective == 'DevicePolicy') |
+ return true; |
+ // Recommended |
+ if (property.hasOwnProperty('UserPolicy') || |
+ property.hasOwnProperty('DevicePolicy')) { |
+ return true; |
+ } |
+ return false; |
+ }, |
+ |
+ /** |
+ * @param {!CrOnc.NetworkProperty|undefined} property |
+ * @return {boolean} True if the network propety is controlled by a policy. |
+ */ |
+ isNetworkPolicyEnforced: function(property) { |
+ if (!this.isNetworkPolicyControlled(property)) |
+ return false; |
+ if (property.hasOwnProperty('UserEditable')) |
+ return !property.UserEditable; |
+ if (property.hasOwnProperty('DeviceEditable')) |
+ return !property.DeviceEditable; |
+ return true; |
+ }, |
+ |
+ |
+}; |