| 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 * 'cr-settings-prefs' is an element which serves as a model for | 7 * 'cr-settings-prefs' is an element which serves as a model for |
| 8 * interaction with settings which are stored in Chrome's | 8 * interaction with settings which are stored in Chrome's |
| 9 * Preferences. | 9 * Preferences. |
| 10 * | 10 * |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 created: function() { | 37 created: function() { |
| 38 CrSettingsPrefs.isInitialized = false; | 38 CrSettingsPrefs.isInitialized = false; |
| 39 | 39 |
| 40 chrome.settingsPrivate.onPrefsChanged.addListener( | 40 chrome.settingsPrivate.onPrefsChanged.addListener( |
| 41 this.onPrefsChanged_.bind(this)); | 41 this.onPrefsChanged_.bind(this)); |
| 42 chrome.settingsPrivate.getAllPrefs(this.onPrefsFetched_.bind(this)); | 42 chrome.settingsPrivate.getAllPrefs(this.onPrefsFetched_.bind(this)); |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Called when prefs in the underlying Chrome pref store are changed. | 46 * Called when prefs in the underlying Chrome pref store are changed. |
| 47 * @param {!Array<!PrefObject>} prefs The prefs that changed. | 47 * @param {!Array<!PrefData>} prefs The prefs that changed. |
| 48 * @private | 48 * @private |
| 49 */ | 49 */ |
| 50 onPrefsChanged_: function(prefs) { | 50 onPrefsChanged_: function(prefs) { |
| 51 this.updatePrefs_(prefs, false); | 51 this.updatePrefs_(prefs, false); |
| 52 }, | 52 }, |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Called when prefs are fetched from settingsPrivate. | 55 * Called when prefs are fetched from settingsPrivate. |
| 56 * @param {!Array<!PrefObject>} prefs | 56 * @param {!Array<!PrefData>} prefs |
| 57 * @private | 57 * @private |
| 58 */ | 58 */ |
| 59 onPrefsFetched_: function(prefs) { | 59 onPrefsFetched_: function(prefs) { |
| 60 this.updatePrefs_(prefs, true); | 60 this.updatePrefs_(prefs, true); |
| 61 | 61 |
| 62 CrSettingsPrefs.isInitialized = true; | 62 CrSettingsPrefs.isInitialized = true; |
| 63 document.dispatchEvent(new Event(CrSettingsPrefs.INITIALIZED)); | 63 document.dispatchEvent(new Event(CrSettingsPrefs.INITIALIZED)); |
| 64 }, | 64 }, |
| 65 | 65 |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Updates the settings model with the given prefs. | 68 * Updates the settings model with the given prefs. |
| 69 * @param {!Array<!PrefObject>} prefs | 69 * @param {!Array<!PrefData>} prefs |
| 70 * @param {boolean} shouldObserve Whether each of the prefs should be | 70 * @param {boolean} shouldObserve Whether each of the prefs should be |
| 71 * observed. | 71 * observed. |
| 72 * @private | 72 * @private |
| 73 */ | 73 */ |
| 74 updatePrefs_: function(prefs, shouldObserve) { | 74 updatePrefs_: function(prefs, shouldObserve) { |
| 75 prefs.forEach(function(prefObj) { | 75 prefs.forEach(function(prefObj) { |
| 76 let root = this.prefStore; | 76 let root = this.prefStore; |
| 77 let tokens = prefObj.key.split('.'); | 77 let tokens = prefObj.key.split('.'); |
| 78 | 78 |
| 79 assert(tokens.length > 0); | 79 assert(tokens.length > 0); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 chrome.settingsPrivate.setPref( | 153 chrome.settingsPrivate.setPref( |
| 154 change.object['key'], | 154 change.object['key'], |
| 155 newValue, | 155 newValue, |
| 156 /* pageId */ '', | 156 /* pageId */ '', |
| 157 /* callback */ function() {}); | 157 /* callback */ function() {}); |
| 158 }); | 158 }); |
| 159 }, | 159 }, |
| 160 }); | 160 }); |
| 161 })(); | 161 })(); |
| OLD | NEW |