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 |
11 cr.exportPath('cr.onc'); | 11 cr.exportPath('cr.onc'); |
12 | 12 |
13 /** | 13 /** |
14 * @typedef {(Object|Array|string|undefined)} | 14 * @typedef {(Object|Array|string|number|undefined)} |
15 */ | 15 */ |
16 cr.onc.OncValue; | 16 cr.onc.OncValue; |
17 | 17 |
18 cr.define('cr.onc', function() { | 18 cr.define('cr.onc', function() { |
19 'use strict'; | 19 'use strict'; |
20 | 20 |
21 /** | 21 /** |
22 * @constructor | 22 * @constructor |
23 */ | 23 */ |
24 function OncData(data) { | 24 function OncData(data) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 /** | 148 /** |
149 * Returns the Source of this configuration. If undefined returns 'None'. | 149 * Returns the Source of this configuration. If undefined returns 'None'. |
150 * @return {string} The configuration source: 'None', 'User', 'Device', | 150 * @return {string} The configuration source: 'None', 'User', 'Device', |
151 * 'UserPolicy', or 'DevicePolicy'. | 151 * 'UserPolicy', or 'DevicePolicy'. |
152 */ | 152 */ |
153 getSource: function() { | 153 getSource: function() { |
154 var source = this.getActiveValue('Source'); | 154 var source = this.getActiveValue('Source'); |
155 if (source == undefined) | 155 if (source == undefined) |
156 return 'None'; | 156 return 'None'; |
| 157 assert(typeof source == 'string'); |
157 return source; | 158 return source; |
158 }, | 159 }, |
159 | 160 |
160 /** | 161 /** |
161 * Returns the WiFi security type (defaults to 'None'). | 162 * Returns the WiFi security type (defaults to 'None'). |
162 * @return {string} The security type. | 163 * @return {string} The security type. |
163 */ | 164 */ |
164 getWiFiSecurity: function() { | 165 getWiFiSecurity: function() { |
165 var security = this.getActiveValue('WiFi.Security'); | 166 var security = this.getActiveValue('WiFi.Security'); |
166 if (security == undefined) | 167 if (security == undefined) |
167 return 'None'; | 168 return 'None'; |
| 169 assert(typeof security == 'string'); |
168 return security; | 170 return security; |
169 }, | 171 }, |
170 | 172 |
171 /** | 173 /** |
172 * Get the effective value from a Managed property ONC dictionary. | 174 * Get the effective value from a Managed property ONC dictionary. |
173 * @param {Object} property The managed property ONC dictionary. | 175 * @param {Object} property The managed property ONC dictionary. |
174 * @return {cr.onc.OncValue} The effective value or undefined. | 176 * @return {cr.onc.OncValue} The effective value or undefined. |
175 * @private | 177 * @private |
176 */ | 178 */ |
177 getEffectiveValueFromProperty_: function(property) { | 179 getEffectiveValueFromProperty_: function(property) { |
178 if ('Effective' in property) { | 180 if ('Effective' in property) { |
179 var effective = property.Effective; | 181 var effective = property.Effective; |
180 if (effective in property) | 182 if (effective in property) |
181 return property[effective]; | 183 return property[effective]; |
182 } | 184 } |
183 return undefined; | 185 return undefined; |
184 } | 186 } |
185 }; | 187 }; |
186 | 188 |
187 return { | 189 return { |
188 OncData: OncData | 190 OncData: OncData |
189 }; | 191 }; |
190 }); | 192 }); |
OLD | NEW |