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

Unified Diff: chrome/browser/resources/settings/pref_tracker/pref_tracker.js

Issue 1357183002: MD-Settings: convert cr-settings-prefs to a singleton model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clarify singleton/private/model language 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
« no previous file with comments | « no previous file | chrome/browser/resources/settings/prefs/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/pref_tracker/pref_tracker.js
diff --git a/chrome/browser/resources/settings/pref_tracker/pref_tracker.js b/chrome/browser/resources/settings/pref_tracker/pref_tracker.js
index 1d692abdadef906c608475d0f2446b1e3829fceb..b7124759a8c0d7310ffe9ccc7f3cf46cb18128a1 100644
--- a/chrome/browser/resources/settings/pref_tracker/pref_tracker.js
+++ b/chrome/browser/resources/settings/pref_tracker/pref_tracker.js
@@ -17,24 +17,6 @@
*/
(function() {
- /**
- * An array of all the tracker instances.
- * @type {!Array<!CrSettingsPrefTrackerElement>}
- */
- var instances = [];
-
- /**
- * Validates all tracker instances.
- * @private
- */
- var validateAll_ = function() {
- instances.forEach(function(tracker) {
- tracker.validate_();
- });
- };
-
- document.addEventListener(CrSettingsPrefs.INITIALIZED, validateAll_);
-
Polymer({
is: 'cr-settings-pref-tracker',
@@ -52,29 +34,26 @@
/** @override */
ready: function() {
this.validate_();
-
- instances.push(this);
},
/**
- * Throws an error if prefs are initialized and the tracked pref is not
- * found.
+ * Logs an error once prefs are initialized if the tracked pref is
+ * not found.
* @private
*/
validate_: function() {
- this.async(function() {
+ CrSettingsPrefs.initialized.then(function() {
// Note that null == undefined.
- if (CrSettingsPrefs.isInitialized && this.pref == null) {
+ if (this.pref == null) {
// HACK ALERT: This is the best clue we have as to the pref key for
// this tracker. This value should not be relied upon anywhere or
// actually used besides for this error message.
- var parentControlHTML = this.parentNode && this.parentNode.host &&
- this.parentNode.host.outerHTML;
+ var parentControlHTML = this.domHost && this.domHost.outerHTML;
- throw new Error('Pref not found. Parent control:' +
+ console.error('Pref not found. Parent control:' +
(parentControlHTML || 'Unknown'));
}
- });
+ }.bind(this));
},
});
})();
« no previous file with comments | « no previous file | chrome/browser/resources/settings/prefs/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698