OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 * Class to manage user preferences. | 6 * Class to manage user preferences. |
7 * | 7 * |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function SwitchAccessPrefs() { | 10 function SwitchAccessPrefs() { |
11 /** | 11 /** |
12 * User preferences, initially set to the default preference values. | 12 * User preferences, initially set to the default preference values. |
13 * | 13 * |
14 * @private | 14 * @private |
15 */ | 15 */ |
16 this.prefs_ = Object.assign({}, this.DEFAULT_PREFS); | 16 this.prefs_ = Object.assign({}, this.DEFAULT_PREFS); |
17 | 17 |
18 this.loadPrefs_(); | 18 this.loadPrefs_(); |
19 chrome.storage.onChanged.addListener(this.handleStorageChange_.bind(this)); | 19 chrome.storage.onChanged.addListener(this.handleStorageChange_.bind(this)); |
20 }; | 20 } |
21 | 21 |
22 SwitchAccessPrefs.prototype = { | 22 SwitchAccessPrefs.prototype = { |
23 /** | 23 /** |
24 * Asynchronously load the current preferences from chrome.storage.sync and | 24 * Asynchronously load the current preferences from chrome.storage.sync and |
25 * store them in this.prefs_, if this.prefs_ is not already set to that value. | 25 * store them in this.prefs_, if this.prefs_ is not already set to that value. |
26 * If this.prefs_ changes, fire a prefsUpdate event. | 26 * If this.prefs_ changes, fire a prefsUpdate event. |
27 * | 27 * |
28 * @private | 28 * @private |
29 */ | 29 */ |
30 loadPrefs_: function() { | 30 loadPrefs_: function() { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 * The default value of all preferences. All preferences should be primitives | 129 * The default value of all preferences. All preferences should be primitives |
130 * to prevent changes to default values. | 130 * to prevent changes to default values. |
131 * | 131 * |
132 * @const | 132 * @const |
133 */ | 133 */ |
134 DEFAULT_PREFS: { | 134 DEFAULT_PREFS: { |
135 'enableAutoScan': false, | 135 'enableAutoScan': false, |
136 'autoScanTime': 800 | 136 'autoScanTime': 800 |
137 } | 137 } |
138 }; | 138 }; |
OLD | NEW |