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 * Updates the properties of |data_| from the properties in |update|. | 174 * Updates the properties of |data_| from the properties in |update|. |
173 * Note: this only looks at top level entries, so if a dictionary is | 175 * Note: this only looks at top level entries, so if a dictionary is |
174 * updated the entire dictionary is written over. TODO(stevenjb): | 176 * updated the entire dictionary is written over. TODO(stevenjb): |
175 * eliminate this function when |data_| contains only ONC entries and | 177 * eliminate this function when |data_| contains only ONC entries and |
176 * any updates consist of complete ONC dictionaries. | 178 * any updates consist of complete ONC dictionaries. |
177 * @param {Object} update Dictionary containing the updated properties. | 179 * @param {Object} update Dictionary containing the updated properties. |
(...skipping 18 matching lines...) Expand all Loading... |
196 return property[effective]; | 198 return property[effective]; |
197 } | 199 } |
198 return undefined; | 200 return undefined; |
199 } | 201 } |
200 }; | 202 }; |
201 | 203 |
202 return { | 204 return { |
203 OncData: OncData | 205 OncData: OncData |
204 }; | 206 }; |
205 }); | 207 }); |
OLD | NEW |