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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (!success) | 238 if (!success) |
239 this.refresh(key); | 239 this.refresh(key); |
240 }, | 240 }, |
241 | 241 |
242 /** | 242 /** |
243 * Get the current pref value from chrome.settingsPrivate to ensure the UI | 243 * Get the current pref value from chrome.settingsPrivate to ensure the UI |
244 * stays up to date. | 244 * stays up to date. |
245 * @param {string} key | 245 * @param {string} key |
246 */ | 246 */ |
247 refresh: function(key) { | 247 refresh: function(key) { |
248 this.settingsApi_.getPref(key, function(pref) { | 248 this.settingsApi_.getPref(key, pref => { |
249 this.updatePrefs_([pref]); | 249 this.updatePrefs_([pref]); |
250 }.bind(this)); | 250 }); |
251 }, | 251 }, |
252 | 252 |
253 /** | 253 /** |
254 * Updates the prefs model with the given prefs. | 254 * Updates the prefs model with the given prefs. |
255 * @param {!Array<!chrome.settingsPrivate.PrefObject>} newPrefs | 255 * @param {!Array<!chrome.settingsPrivate.PrefObject>} newPrefs |
256 * @private | 256 * @private |
257 */ | 257 */ |
258 updatePrefs_: function(newPrefs) { | 258 updatePrefs_: function(newPrefs) { |
259 // Use the existing prefs object or create it. | 259 // Use the existing prefs object or create it. |
260 var prefs = this.prefs || {}; | 260 var prefs = this.prefs || {}; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 this.prefs = undefined; | 307 this.prefs = undefined; |
308 this.lastPrefValues_ = {}; | 308 this.lastPrefValues_ = {}; |
309 this.initialized_ = false; | 309 this.initialized_ = false; |
310 // Remove the listener added in initialize(). | 310 // Remove the listener added in initialize(). |
311 this.settingsApi_.onPrefsChanged.removeListener(this.boundPrefsChanged_); | 311 this.settingsApi_.onPrefsChanged.removeListener(this.boundPrefsChanged_); |
312 this.settingsApi_ = | 312 this.settingsApi_ = |
313 /** @type {SettingsPrivate} */ (chrome.settingsPrivate); | 313 /** @type {SettingsPrivate} */ (chrome.settingsPrivate); |
314 }, | 314 }, |
315 }); | 315 }); |
316 })(); | 316 })(); |
OLD | NEW |