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

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

Issue 2696903005: Move common cr-policy-indicator behavior into CrPolicyIndicatorBehavior (Closed)
Patch Set: rename hasPolicy Created 3 years, 10 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_indicator_behavior.js
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js b/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js
index fb6eb7cb3f490586d4bfa5a073f2c24f680b62e1..d0d3b9314dcf586f747e77efbcfec21ecb986c67 100644
--- a/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js
@@ -32,12 +32,51 @@ var CrPolicyIndicatorType = {
/** @polymerBehavior */
var CrPolicyIndicatorBehavior = {
+ // Properties exposed to all policy indicators.
+ properties: {
+ /**
+ * Which indicator type to show (or NONE).
+ * @type {CrPolicyIndicatorType}
+ */
+ indicatorType: {
+ type: String,
+ value: CrPolicyIndicatorType.NONE,
+ },
+
+ /**
+ * The name associated with the policy source. See
+ * chrome.settingsPrivate.PrefObject.controlledByName.
+ */
+ indicatorSourceName: {
+ type: String,
+ value: '',
+ },
+
+ // Computed properties based on indicatorType and indicatorSourceName.
+ // Override to provide different values.
+
+ indicatorVisible: {
+ type: Boolean,
+ computed: 'getIndicatorVisible_(indicatorType)',
+ },
+
+ indicatorIcon: {
+ type: String,
+ computed: 'getIndicatorIcon_(indicatorType)',
+ },
+
+ indicatorTooltip: {
+ type: String,
+ computed: 'getIndicatorTooltip(indicatorType, indicatorSourceName)',
+ },
+ },
+
/**
* @param {CrPolicyIndicatorType} type
* @return {boolean} True if the indicator should be shown.
* @private
*/
- isIndicatorVisible: function(type) {
+ getIndicatorVisible_: function(type) {
return type != CrPolicyIndicatorType.NONE &&
type != CrPolicyIndicatorType.EXTENSION;
},
@@ -47,7 +86,7 @@ var CrPolicyIndicatorBehavior = {
* @return {string} The iron-icon icon name.
* @private
*/
- getPolicyIndicatorIcon: function(type) {
+ getIndicatorIcon_: function(type) {
var icon = '';
switch (type) {
case CrPolicyIndicatorType.EXTENSION:
@@ -78,7 +117,7 @@ var CrPolicyIndicatorBehavior = {
* value matches the recommended value.
* @return {string} The tooltip text for |type|.
*/
- getPolicyIndicatorTooltip: function(type, name, opt_matches) {
+ getIndicatorTooltip: function(type, name, opt_matches) {
if (!CrPolicyStrings)
return ''; // Tooltips may not be defined, e.g. in OOBE.
switch (type) {

Powered by Google App Engine
This is Rietveld 408576698