OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 ONC Data support class. Wraps a dictionary object containing | 6 * @fileoverview ONC Data support class. Wraps a dictionary object containing |
7 * ONC managed or unmanaged dictionaries. Supports nested dictionaries, | 7 * ONC managed or unmanaged dictionaries. Supports nested dictionaries, |
8 * e.g. data.getManagedProperty('VPN.Type'). | 8 * e.g. data.getManagedProperty('VPN.Type'). |
9 */ | 9 */ |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 return data[key]; | 43 return data[key]; |
44 }, | 44 }, |
45 | 45 |
46 /** | 46 /** |
47 * Sets the value of a property. Currently only supports unmanaged | 47 * Sets the value of a property. Currently only supports unmanaged |
48 * properties. | 48 * properties. |
49 * @param {string} key The property key. | 49 * @param {string} key The property key. |
50 * @param {Object} value The property value to set. | 50 * @param {Object} value The property value to set. |
51 */ | 51 */ |
52 setManagedProperty: function(key, value) { | 52 setProperty: function(key, value) { |
53 var data = this.data_; | 53 var data = this.data_; |
54 while (true) { | 54 while (true) { |
55 var index = key.indexOf('.'); | 55 var index = key.indexOf('.'); |
56 if (index < 0) | 56 if (index < 0) |
57 break; | 57 break; |
58 var keyComponent = key.substr(0, index); | 58 var keyComponent = key.substr(0, index); |
59 if (!(keyComponent in data)) | 59 if (!(keyComponent in data)) |
60 data[keyComponent] = {}; | 60 data[keyComponent] = {}; |
61 data = data[keyComponent]; | 61 data = data[keyComponent]; |
62 key = key.substr(index + 1); | 62 key = key.substr(index + 1); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 * @return {?} The effective value or undefined. | 170 * @return {?} The effective value or undefined. |
171 * @private | 171 * @private |
172 */ | 172 */ |
173 getEffectiveValueFromProperty_: function(property) { | 173 getEffectiveValueFromProperty_: function(property) { |
174 if ('Effective' in property) { | 174 if ('Effective' in property) { |
175 var effective = property.Effective; | 175 var effective = property.Effective; |
176 if (effective in property) | 176 if (effective in property) |
177 return property[effective]; | 177 return property[effective]; |
178 } | 178 } |
179 return undefined; | 179 return undefined; |
| 180 }, |
| 181 |
| 182 /** |
| 183 * Returns the complete ONC dictionary. |
| 184 */ |
| 185 getData: function() { |
| 186 return this.data_; |
180 } | 187 } |
181 }; | 188 }; |
182 | 189 |
183 return { | 190 return { |
184 OncData: OncData | 191 OncData: OncData |
185 }; | 192 }; |
186 }); | 193 }); |
OLD | NEW |