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

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

Issue 2624003003: WebUI: Add cr-policy-pref-indicator tests (Closed)
Patch Set: Elim registerTests Created 3 years, 11 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_pref_indicator.js
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js b/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js
index dcb58c425f3253a9db5dc88c38f1dc26607f2ced..90466143c0c38c4c3585b66140ed24322ad7c11a 100644
--- a/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_pref_indicator.js
@@ -15,30 +15,43 @@ Polymer({
/**
* Optional preference object associated with the indicator. Initialized to
* null so that computed functions will get called if this is never set.
- * @type {!chrome.settingsPrivate.PrefObject|undefined}
+ * @type {?chrome.settingsPrivate.PrefObject}
*/
- pref: Object,
+ pref: {
+ type: Object,
+ value: null,
+ },
/**
- * Which indicator type to show (or NONE).
+ * Which indicator type to show (or NONE). This may be set explicitly, or
+ * computed if |pref| is set.
* @type {CrPolicyIndicatorType}
*/
indicatorType: {
type: String,
value: CrPolicyIndicatorType.NONE,
- computed: 'getIndicatorType(pref.controlledBy, pref.enforcement)',
},
},
+ observers: ['prefChanged_(pref.*)'],
+
+ /** @private */
+ prefChanged_() {
Dan Beam 2017/01/18 01:06:34 prefChanged_: function
stevenjb 2017/01/18 23:13:03 Sigh. Sorry. Done.
+ if (!this.pref)
+ return;
+ this.indicatorType =
+ this.getIndicatorType(this.pref.controlledBy, this.pref.enforcement);
+ },
+
/**
* @param {CrPolicyIndicatorType} type
- * @param {!chrome.settingsPrivate.PrefObject} pref
* @return {string} The tooltip text for |type|.
* @private
*/
- getTooltip_: function(type, pref) {
- var matches = pref && pref.value == pref.recommendedValue;
+ getTooltip_: function(type) {
+ var pref = this.pref;
+ var matches = !!pref && pref.value == pref.recommendedValue;
return this.getPolicyIndicatorTooltip(
- type, pref.controlledByName || '', matches);
+ type, (pref && pref.controlledByName) || '', matches);
}
});

Powered by Google App Engine
This is Rietveld 408576698