Index: chrome/browser/resources/settings/checkbox/checkbox.js |
diff --git a/chrome/browser/resources/settings/checkbox/checkbox.js b/chrome/browser/resources/settings/checkbox/checkbox.js |
index 6e0860cf00b7b85554b4f9d0faabd3654c8daf14..2bdb4130bd8f04acdc70ed050f4ac86b24fa176c 100644 |
--- a/chrome/browser/resources/settings/checkbox/checkbox.js |
+++ b/chrome/browser/resources/settings/checkbox/checkbox.js |
@@ -24,6 +24,18 @@ Polymer({ |
pref: { |
type: Object, |
notify: true, |
+ value: function() { return {}; } |
Jeremy Klein
2015/06/04 00:49:54
Why do we need this? Doesn't it break the pref-tra
Oren Blasberg
2015/06/04 16:10:04
Oddly, without the initial value, I get an error i
Jeremy Klein
2015/06/04 17:20:16
Sorry, by "breaking" I mean preventing real errors
Oren Blasberg
2015/06/04 18:26:11
Oh, I see. Yes, the validation would always succee
|
+ }, |
+ |
+ inverted: { |
+ type: Boolean, |
+ value: false |
+ }, |
+ |
+ checked: { |
+ type: Boolean, |
+ value: false, |
+ observer: 'checkedChanged' |
}, |
label: { |
@@ -37,8 +49,26 @@ Polymer({ |
}, |
}, |
+ observers: [ |
+ 'prefValueChanged(pref.value)' |
+ ], |
+ |
/** @override */ |
ready: function() { |
this.$.events.forward(this.$.checkbox, ['change']); |
}, |
+ |
+ prefValueChanged: function(prefValue) { |
Jeremy Klein
2015/06/04 00:49:54
This and the other 2 new functions can be private.
Oren Blasberg
2015/06/04 16:10:04
Done.
|
+ if (this.pref) { |
+ this.checked = this.computeValue(prefValue); |
+ } |
+ }, |
+ |
+ checkedChanged: function() { |
+ this.pref.value = this.computeValue(this.checked); |
+ }, |
+ |
+ computeValue: function(val) { |
Jeremy Klein
2015/06/04 00:49:54
For some reason the name computeValue confuses me
Oren Blasberg
2015/06/04 16:10:04
Ah ok. It's not actually inverting though; it's ju
Jeremy Klein
2015/06/04 17:20:16
The this is that it doesn't only get the prefValue
Oren Blasberg
2015/06/04 18:26:11
Ok, how about "getUpdatedValue_"? "getValueBased
|
+ return this.inverted ? !val : val; |
+ } |
}); |