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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 prefs.forEach(function(prefObj) { | 76 prefs.forEach(function(prefObj) { |
77 let root = this.settings; | 77 let root = this.settings; |
78 let tokens = prefObj.key.split('.'); | 78 let tokens = prefObj.key.split('.'); |
79 | 79 |
80 assert(tokens.length > 0); | 80 assert(tokens.length > 0); |
81 | 81 |
82 for (let i = 0; i < tokens.length; i++) { | 82 for (let i = 0; i < tokens.length; i++) { |
83 let token = tokens[i]; | 83 let token = tokens[i]; |
84 | 84 |
85 if (!root.hasOwnProperty(token)) { | 85 if (!root.hasOwnProperty(token)) { |
86 root[token] = {}; | 86 let path = 'settings.' + tokens.slice(0, i + 1).join('.'); |
87 this.setPathValue(path, {}); | |
87 } | 88 } |
88 root = root[token]; | 89 root = root[token]; |
89 } | 90 } |
90 | 91 |
91 // NOTE: Do this copy rather than just a re-assignment, so that the | 92 // NOTE: Do this copy rather than just a re-assignment, so that the |
92 // ObjectObserver fires. | 93 // ObjectObserver fires. |
michaelpg
2015/05/13 19:38:30
is this logic still valid, or can we just use this
Jeremy Klein
2015/05/13 21:13:56
Hard to say for sure until all this binding logic
| |
93 for (let objKey in prefObj) { | 94 for (let objKey in prefObj) { |
94 root[objKey] = prefObj[objKey]; | 95 let path = 'settings.' + prefObj.key + '.' + objKey; |
96 this.setPathValue(path, prefObj[objKey]); | |
95 } | 97 } |
96 | 98 |
97 if (shouldObserve) { | 99 if (shouldObserve) { |
98 let keyObserver = new ObjectObserver(root); | 100 let keyObserver = new ObjectObserver(root); |
99 keyObserver.open( | 101 keyObserver.open( |
100 this.propertyChangeCallback_.bind(this, prefObj.key)); | 102 this.propertyChangeCallback_.bind(this, prefObj.key)); |
101 } | 103 } |
102 }, this); | 104 }, this); |
103 }, | 105 }, |
104 | 106 |
(...skipping 20 matching lines...) Expand all Loading... | |
125 | 127 |
126 chrome.settingsPrivate.setPref( | 128 chrome.settingsPrivate.setPref( |
127 propertyPath, | 129 propertyPath, |
128 newValue, | 130 newValue, |
129 /* pageId */ '', | 131 /* pageId */ '', |
130 /* callback */ function() {}); | 132 /* callback */ function() {}); |
131 } | 133 } |
132 }, | 134 }, |
133 }); | 135 }); |
134 })(); | 136 })(); |
OLD | NEW |