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

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

Issue 1391433003: Extract policy indicator behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_521791_network_indicators_a
Patch Set: Feedback 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_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..dc474f0a72d1ffb9795e31ce80ad14e4987e356f
--- /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
+ */
+ getPolicyIndicatorIcon: 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|.
+ */
+ getPolicyIndicatorTooltip: 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 knowledge of the
+ // value and recommended value associated with the controllable.
+ assertNotReached();
+ }
+ return '';
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698