| OLD | NEW |
| 1 /* Copyright 2015 The Chromium Authors. All rights reserved. | 1 /* Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. */ | 3 * found in the LICENSE file. */ |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-prefs' exposes a singleton model of Chrome settings and | 7 * 'settings-prefs' exposes a singleton model of Chrome settings and |
| 8 * preferences, which listens to changes to Chrome prefs whitelisted in | 8 * preferences, which listens to changes to Chrome prefs whitelisted in |
| 9 * chrome.settingsPrivate. When changing prefs in this element's 'prefs' | 9 * chrome.settingsPrivate. When changing prefs in this element's 'prefs' |
| 10 * property via the UI, the singleton model tries to set those preferences in | 10 * property via the UI, the singleton model tries to set those preferences in |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 CrSettingsPrefs.setInitialized(); | 220 CrSettingsPrefs.setInitialized(); |
| 221 }, | 221 }, |
| 222 | 222 |
| 223 /** | 223 /** |
| 224 * Checks the result of calling settingsPrivate.setPref. | 224 * Checks the result of calling settingsPrivate.setPref. |
| 225 * @param {string} key The key used in the call to setPref. | 225 * @param {string} key The key used in the call to setPref. |
| 226 * @param {boolean} success True if setting the pref succeeded. | 226 * @param {boolean} success True if setting the pref succeeded. |
| 227 * @private | 227 * @private |
| 228 */ | 228 */ |
| 229 setPrefCallback_: function(key, success) { | 229 setPrefCallback_: function(key, success) { |
| 230 if (success) | 230 if (!success) |
| 231 return; | 231 this.refresh(key); |
| 232 }, |
| 232 | 233 |
| 233 // Get the current pref value from chrome.settingsPrivate to ensure the | 234 /** |
| 234 // UI stays up to date. | 235 * Get the current pref value from chrome.settingsPrivate to ensure the UI |
| 236 * stays up to date. |
| 237 * @param {string} key |
| 238 */ |
| 239 refresh: function(key) { |
| 235 this.settingsApi_.getPref(key, function(pref) { | 240 this.settingsApi_.getPref(key, function(pref) { |
| 236 this.updatePrefs_([pref]); | 241 this.updatePrefs_([pref]); |
| 237 }.bind(this)); | 242 }.bind(this)); |
| 238 }, | 243 }, |
| 239 | 244 |
| 240 /** | 245 /** |
| 241 * Updates the prefs model with the given prefs. | 246 * Updates the prefs model with the given prefs. |
| 242 * @param {!Array<!chrome.settingsPrivate.PrefObject>} newPrefs | 247 * @param {!Array<!chrome.settingsPrivate.PrefObject>} newPrefs |
| 243 * @private | 248 * @private |
| 244 */ | 249 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 this.prefs = undefined; | 299 this.prefs = undefined; |
| 295 this.lastPrefValues_ = {}; | 300 this.lastPrefValues_ = {}; |
| 296 this.initialized_ = false; | 301 this.initialized_ = false; |
| 297 // Remove the listener added in initialize(). | 302 // Remove the listener added in initialize(). |
| 298 this.settingsApi_.onPrefsChanged.removeListener(this.boundPrefsChanged_); | 303 this.settingsApi_.onPrefsChanged.removeListener(this.boundPrefsChanged_); |
| 299 this.settingsApi_ = | 304 this.settingsApi_ = |
| 300 /** @type {SettingsPrivate} */(chrome.settingsPrivate); | 305 /** @type {SettingsPrivate} */(chrome.settingsPrivate); |
| 301 }, | 306 }, |
| 302 }); | 307 }); |
| 303 })(); | 308 })(); |
| OLD | NEW |