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

Unified Diff: chrome/browser/resources/settings/prefs/prefs_types.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 | « chrome/browser/resources/settings/prefs/prefs.js ('k') | chrome/test/data/webui/settings/prefs_tests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/prefs/prefs_types.js
diff --git a/chrome/browser/resources/settings/prefs/prefs_types.js b/chrome/browser/resources/settings/prefs/prefs_types.js
index 3ac53ba967be5c3193a1b6b8a7087894c368ba4d..96c8649f1624b2a80306c15e12d304ed0d1d7453 100644
--- a/chrome/browser/resources/settings/prefs/prefs_types.js
+++ b/chrome/browser/resources/settings/prefs/prefs_types.js
@@ -6,22 +6,44 @@
* @fileoverview Types for CrSettingsPrefsElement.
*/
-/** @type {{INITIALIZED: string, isInitialized: boolean}} */
-var CrSettingsPrefs;
+/**
+ * Global state for prefs status.
+ */
+var CrSettingsPrefs = (function() {
+ var CrSettingsPrefsInternal = {
+ /**
+ * Resolves the CrSettingsPrefs.initialized promise.
+ */
+ setInitialized: function() {
+ /** @public {boolean} */
+ CrSettingsPrefsInternal.isInitialized = true;
+ CrSettingsPrefsInternal.resolve_();
+ },
-// TODO(michaelpg): provide a Promise for initialization.
-if (CrSettingsPrefs === undefined) {
- CrSettingsPrefs = {
/**
- * The name of the event fired when prefs have been fetched and initialized.
- * @const {string}
+ * Restores state for testing.
*/
- INITIALIZED: 'cr-settings-prefs-initialized',
+ resetForTesting: function() {
+ CrSettingsPrefsInternal.setup_();
+ },
/**
- * Global boolean set to true when all settings have been initialized.
- * @type {boolean}
+ * Called to set up the promise and resolve methods.
+ * @private
*/
- isInitialized: false,
+ setup_: function() {
+ CrSettingsPrefsInternal.isInitialized = false;
+ /**
+ * Promise to be resolved when all settings have been initialized.
+ * @type {!Promise}
+ */
+ CrSettingsPrefsInternal.initialized = new Promise(function(resolve) {
+ CrSettingsPrefsInternal.resolve_ = resolve;
+ });
+ },
};
-}
+
+ CrSettingsPrefsInternal.setup_();
+
+ return CrSettingsPrefsInternal;
+})();
« no previous file with comments | « chrome/browser/resources/settings/prefs/prefs.js ('k') | chrome/test/data/webui/settings/prefs_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698