Index: ui/webui/resources/cr_elements/v1_0/policy/cr_policy_indicator_behavior.js |
diff --git a/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_indicator_behavior.js b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_indicator_behavior.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d9a9357414258d1bc43e92878e5ccab0d2dce7c |
--- /dev/null |
+++ b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_indicator_behavior.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 Behavior for policy controlled indicators. |
+ */ |
+ |
+/** @enum {string} */ |
+var CrPolicyIndicatorType = { |
+ DEVICE_POLICY: 'devicePolicy', |
+ EXTENSION: 'extension', |
+ NONE: 'none', |
+ OWNER: 'owner', |
+ PRIMARY_USER: 'primary_user', |
+ RECOMMENDED: 'recommended', |
+ USER_POLICY: 'userPolicy', |
+}; |
+ |
+/** @polymerBehavior */ |
+var CrPolicyIndicatorBehavior = { |
+ /** |
+ * @param {CrPolicyIndicatorType} type |
+ * @return {boolean} True if the indicator should be shown. |
+ * @private |
+ */ |
+ isIndicatorVisible: function(type) { |
+ return type != CrPolicyIndicatorType.NONE; |
+ }, |
+ |
+ /** |
+ * @param {CrPolicyIndicatorType} type |
+ * @return {string} The iron-icons icon name. |
+ * @private |
+ */ |
+ getIcon: function(type) { |
+ switch (type) { |
+ case CrPolicyIndicatorType.NONE: |
+ return ''; |
+ case CrPolicyIndicatorType.PRIMARY_USER: |
+ return 'social:group'; |
+ case CrPolicyIndicatorType.OWNER: |
+ return 'social:person'; |
+ case CrPolicyIndicatorType.USER_POLICY: |
+ case CrPolicyIndicatorType.DEVICE_POLICY: |
+ return 'social:domain'; |
+ case CrPolicyIndicatorType.EXTENSION: |
+ return 'extension'; |
+ case CrPolicyIndicatorType.RECOMMENDED: |
+ return 'social:domain'; |
+ } |
+ assertNotReached(); |
+ return ''; |
+ }, |
+ |
+ /** |
+ * @param {string} id The id of the string to translate. |
+ * @param {string=} opt_name An optional name argument. |
+ * @return The translated string. |
+ */ |
+ i18n: function (id, opt_name) { |
+ return loadTimeData.getStringF(id, opt_name); |
+ }, |
+ |
+ /** |
+ * @param {CrPolicyIndicatorType} type |
+ * @param {string} name The name associated with the controllable. See |
+ * chrome.settingsPrivate.PrefObject.policySourceName |
+ * @return {string} The tooltip text for |type|. |
+ */ |
+ getTooltipText: function(type, name) { |
+ switch (type) { |
+ case CrPolicyIndicatorType.PRIMARY_USER: |
+ return this.i18n('controlledSettingShared', name); |
+ case CrPolicyIndicatorType.OWNER: |
+ return this.i18n('controlledSettingOwner', name); |
+ case CrPolicyIndicatorType.USER_POLICY: |
+ case CrPolicyIndicatorType.DEVICE_POLICY: |
+ return this.i18n('controlledSettingPolicy'); |
+ case CrPolicyIndicatorType.EXTENSION: |
+ return this.i18n('controlledSettingExtension', name); |
+ case CrPolicyIndicatorType.RECOMMENDED: |
+ // This case is not handled here since it requires knowlede of the |
+ // value and recommended value associated with the controllable. |
+ assertNotReached(); |
+ } |
+ return ''; |
+ } |
+}; |