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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 * @param {*} val Value to copy. Should be a primitive or only contain | 81 * @param {*} val Value to copy. Should be a primitive or only contain |
82 * serializable data (primitives, serializable arrays and | 82 * serializable data (primitives, serializable arrays and |
83 * serializable objects). | 83 * serializable objects). |
84 * @return {*} A deep copy of the value. | 84 * @return {*} A deep copy of the value. |
85 */ | 85 */ |
86 function deepCopy(val) { | 86 function deepCopy(val) { |
87 if (!(val instanceof Object)) | 87 if (!(val instanceof Object)) |
88 return val; | 88 return val; |
89 return Array.isArray(val) ? deepCopyArray(/** @type {!Array} */(val)) : | 89 return Array.isArray(val) ? deepCopyArray(/** @type {!Array} */(val)) : |
90 deepCopyObject(val); | 90 deepCopyObject(val); |
91 }; | 91 } |
92 | 92 |
93 /** | 93 /** |
94 * @param {!Array} arr | 94 * @param {!Array} arr |
95 * @return {!Array} Deep copy of the array. | 95 * @return {!Array} Deep copy of the array. |
96 */ | 96 */ |
97 function deepCopyArray(arr) { | 97 function deepCopyArray(arr) { |
98 var copy = []; | 98 var copy = []; |
99 for (var i = 0; i < arr.length; i++) | 99 for (var i = 0; i < arr.length; i++) |
100 copy.push(deepCopy(arr[i])); | 100 copy.push(deepCopy(arr[i])); |
101 return copy; | 101 return copy; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 this.prefs = undefined; | 305 this.prefs = undefined; |
306 this.lastPrefValues_ = {}; | 306 this.lastPrefValues_ = {}; |
307 this.initialized_ = false; | 307 this.initialized_ = false; |
308 // Remove the listener added in initialize(). | 308 // Remove the listener added in initialize(). |
309 this.settingsApi_.onPrefsChanged.removeListener(this.boundPrefsChanged_); | 309 this.settingsApi_.onPrefsChanged.removeListener(this.boundPrefsChanged_); |
310 this.settingsApi_ = | 310 this.settingsApi_ = |
311 /** @type {SettingsPrivate} */(chrome.settingsPrivate); | 311 /** @type {SettingsPrivate} */(chrome.settingsPrivate); |
312 }, | 312 }, |
313 }); | 313 }); |
314 })(); | 314 })(); |
OLD | NEW |