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

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

Issue 1310373008: Add cr_policy_indicator for settings controls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md_settings_compiled_resources_3
Patch Set: Revert unrelated changes Created 5 years, 3 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.js
diff --git a/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_indicator.js b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_indicator.js
new file mode 100644
index 0000000000000000000000000000000000000000..2cc669384651bcebec6d02704a204637efce4838
--- /dev/null
+++ b/ui/webui/resources/cr_elements/v1_0/policy/cr_policy_indicator.js
@@ -0,0 +1,105 @@
+// 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
+ * @element cr-policy-indicator
+ */
+
+/** @enum {string} */
+var IndicatorType = {
+ DEVICE_POLICY: 'devicePolicy',
+ EXTENSION: 'extension',
+ NONE: 'none',
+ OWNER: 'owner',
+ PRIMARY_USER: 'primary_user',
+ RECOMMENDED: 'recommended',
+ USER_POLICY: 'userPolicy',
+};
+
+Polymer({
+ is: 'cr-policy-indicator',
+
+ properties: {
+ /**
+ * The preference object to show an indicator for.
+ * @type {?chrome.settingsPrivate.PrefObject}
+ */
+ pref: {type: Object, value: null},
+
+ /**
+ * Which indicator type to show (or NONE).
+ * @type {IndicatorType}
+ */
+ indicatorType: {type: Object, value: IndicatorType.NONE},
michaelpg 2015/09/14 05:14:51 type: String
stevenjb 2015/09/14 23:05:31 Done.
+ },
+
+ observers: ['prefPropertyChanged_(pref.*)'],
+
+ /**
+ * Polymer observer for pref.
+ * @param {?{path: string, value: *}} change
michaelpg 2015/09/14 05:14:51 o rly?
stevenjb 2015/09/14 23:05:31 ??
michaelpg 2015/09/16 18:58:52 I don't think change can ever be null: {!{path: s
stevenjb 2015/09/16 21:33:53 This got removed entirely in response to Dan's fee
+ * @private
+ */
+ prefPropertyChanged_: function(change) {
+ if (!this.pref)
+ return;
+ var path = change.path;
+ if (path != 'pref' && path != 'pref.policySource' &&
+ path != 'pref.policyEnforcement') {
+ return;
+ }
+ var source = this.pref.policySource;
+ var enforcement = this.pref.policyEnforcement;
+ var type = IndicatorType.NONE;
+ if (enforcement == chrome.settingsPrivate.PolicyEnforcement.ENFORCED) {
+ if (source == chrome.settingsPrivate.PolicySource.PRIMARY_USER)
+ type = IndicatorType.PRIMARY_USER;
+ else if (source == chrome.settingsPrivate.PolicySource.OWNER)
+ type = IndicatorType.OWNER;
+ else if (source == chrome.settingsPrivate.PolicySource.USER_POLICY)
+ type = IndicatorType.USER_POLICY;
+ else if (source == chrome.settingsPrivate.PolicySource.DEVICE_POLICY)
+ type = IndicatorType.DEVICE_POLICY;
+ else if (source == chrome.settingsPrivate.PolicySource.EXTENSION)
+ type = IndicatorType.EXTENSION;
+ } else if (enforcement ==
+ chrome.settingsPrivate.PolicyEnforcement.RECOMMENDED) {
+ type = IndicatorType.RECOMMENDED;
+ }
+ this.indicatorType = type;
+ },
+
+ /**
+ * @param {IndicatorType} type
+ * @return {boolean} True if the indicator should be shown.
+ * @private
+ */
+ isIndicatorVisible_: function(type) { return type != IndicatorType.NONE; },
+
+ /**
+ * @param {IndicatorType} type
+ * @return {string} The iron-icons icon name.
+ * @private
+ */
+ getIcon_: function(type) {
+ switch (type) {
+ case IndicatorType.NONE:
+ return '';
+ case IndicatorType.PRIMARY_USER:
+ return 'social:group';
+ case IndicatorType.OWNER:
+ return 'social:person';
+ case IndicatorType.USER_POLICY:
+ case IndicatorType.DEVICE_POLICY:
+ return 'social:domain';
+ case IndicatorType.EXTENSION:
+ return 'extension';
+ case IndicatorType.RECOMMENDED:
+ return 'social:domain';
+ }
+ assertNotReached();
+ return '';
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698