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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 */ | 145 */ |
143 updateData: function(update) { | 146 updateData: function(update) { |
144 for (var prop in update) { | 147 for (var prop in update) { |
145 if (prop in this.data_) | 148 if (prop in this.data_) |
146 this.data_[prop] = update[prop]; | 149 this.data_[prop] = update[prop]; |
147 } | 150 } |
148 }, | 151 }, |
149 | 152 |
150 /** | 153 /** |
151 * Get the effective value from a Managed property ONC dictionary. | 154 * Get the effective value from a Managed property ONC dictionary. |
152 * @param {object} property The managed property ONC dictionary. | 155 * @param {Object} property The managed property ONC dictionary. |
153 * @return {*} The effective value or undefined. | 156 * @return {*} The effective value or undefined. |
154 * @private | 157 * @private |
155 */ | 158 */ |
156 getEffectiveValueFromProperty_: function(property) { | 159 getEffectiveValueFromProperty_: function(property) { |
157 if ('Effective' in property) { | 160 if ('Effective' in property) { |
158 var effective = property.Effective; | 161 var effective = property.Effective; |
159 if (effective in property) | 162 if (effective in property) |
160 return property[effective]; | 163 return property[effective]; |
161 } | 164 } |
162 return undefined; | 165 return undefined; |
163 } | 166 } |
164 }; | 167 }; |
165 | 168 |
166 return { | 169 return { |
167 OncData: OncData | 170 OncData: OncData |
168 }; | 171 }; |
169 }); | 172 }); |
OLD | NEW |