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 cr.define('cr.onc', function() { | 10 cr.define('cr.onc', function() { |
11 'use strict'; | 11 'use strict'; |
12 | 12 |
| 13 /** |
| 14 * @constructor |
| 15 */ |
13 function OncData(data) { | 16 function OncData(data) { |
14 this.data_ = data; | 17 this.data_ = data; |
15 } | 18 } |
16 | 19 |
17 OncData.prototype = { | 20 OncData.prototype = { |
18 | 21 |
19 /** | 22 /** |
20 * Returns either a managed property dictionary or an unmanaged value. | 23 * Returns either a managed property dictionary or an unmanaged value. |
21 * @param {string} key The property key. | 24 * @param {string} key The property key. |
22 * @return {*} The property value or dictionary if it exists, otherwise | 25 * @return {*} The property value or dictionary if it exists, otherwise |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 */ | 168 */ |
166 updateData: function(update) { | 169 updateData: function(update) { |
167 for (var prop in update) { | 170 for (var prop in update) { |
168 if (prop in this.data_) | 171 if (prop in this.data_) |
169 this.data_[prop] = update[prop]; | 172 this.data_[prop] = update[prop]; |
170 } | 173 } |
171 }, | 174 }, |
172 | 175 |
173 /** | 176 /** |
174 * Get the effective value from a Managed property ONC dictionary. | 177 * Get the effective value from a Managed property ONC dictionary. |
175 * @param {object} property The managed property ONC dictionary. | 178 * @param {Object} property The managed property ONC dictionary. |
176 * @return {*} The effective value or undefined. | 179 * @return {*} The effective value or undefined. |
177 * @private | 180 * @private |
178 */ | 181 */ |
179 getEffectiveValueFromProperty_: function(property) { | 182 getEffectiveValueFromProperty_: function(property) { |
180 if ('Effective' in property) { | 183 if ('Effective' in property) { |
181 var effective = property.Effective; | 184 var effective = property.Effective; |
182 if (effective in property) | 185 if (effective in property) |
183 return property[effective]; | 186 return property[effective]; |
184 } | 187 } |
185 return undefined; | 188 return undefined; |
186 } | 189 } |
187 }; | 190 }; |
188 | 191 |
189 return { | 192 return { |
190 OncData: OncData | 193 OncData: OncData |
191 }; | 194 }; |
192 }); | 195 }); |
OLD | NEW |