OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 This file has two parts: | 6 * @fileoverview This file has two parts: |
7 * | 7 * |
8 * 1. Typedefs for network properties. Note: These 'types' define a subset of | 8 * 1. Typedefs for network properties. Note: These 'types' define a subset of |
9 * ONC properties in the ONC data dictionary. The first letter is capitalized to | 9 * ONC properties in the ONC data dictionary. The first letter is capitalized to |
10 * match the ONC spec and avoid an extra layer of translation. | 10 * match the ONC spec and avoid an extra layer of translation. |
(...skipping 24 matching lines...) Expand all Loading... |
35 * UserPolicy: (!CrOnc.NetworkPropertyType|undefined), | 35 * UserPolicy: (!CrOnc.NetworkPropertyType|undefined), |
36 * DevicePolicy: (!CrOnc.NetworkPropertyType|undefined), | 36 * DevicePolicy: (!CrOnc.NetworkPropertyType|undefined), |
37 * UserSetting: (!CrOnc.NetworkPropertyType|undefined), | 37 * UserSetting: (!CrOnc.NetworkPropertyType|undefined), |
38 * SharedSetting: (!CrOnc.NetworkPropertyType|undefined), | 38 * SharedSetting: (!CrOnc.NetworkPropertyType|undefined), |
39 * UserEditable: (boolean|undefined), | 39 * UserEditable: (boolean|undefined), |
40 * DeviceEditable: (boolean|undefined) | 40 * DeviceEditable: (boolean|undefined) |
41 * }} | 41 * }} |
42 */ | 42 */ |
43 CrOnc.ManagedProperty; | 43 CrOnc.ManagedProperty; |
44 | 44 |
| 45 /** @typedef {!CrOnc.NetworkPropertyType|!CrOnc.ManagedProperty} */ |
| 46 CrOnc.NetworkProperty; |
| 47 |
45 /** @typedef {chrome.networkingPrivate.SIMLockStatus} */ | 48 /** @typedef {chrome.networkingPrivate.SIMLockStatus} */ |
46 CrOnc.SIMLockStatus; | 49 CrOnc.SIMLockStatus; |
47 | 50 |
48 /** @typedef {chrome.networkingPrivate.APNProperties} */ | 51 /** @typedef {chrome.networkingPrivate.APNProperties} */ |
49 CrOnc.APNProperties; | 52 CrOnc.APNProperties; |
50 | 53 |
51 /** @typedef {chrome.networkingPrivate.CellularSimState} */ | 54 /** @typedef {chrome.networkingPrivate.CellularSimState} */ |
52 CrOnc.CellularSimState; | 55 CrOnc.CellularSimState; |
53 | 56 |
54 /** @typedef {chrome.networkingPrivate.IPConfigProperties} */ | 57 /** @typedef {chrome.networkingPrivate.IPConfigProperties} */ |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if (type == CrOnc.Type.CELLULAR && properties.Cellular) | 261 if (type == CrOnc.Type.CELLULAR && properties.Cellular) |
259 return properties.Cellular.SignalStrength || 0; | 262 return properties.Cellular.SignalStrength || 0; |
260 else if (type == CrOnc.Type.WI_FI && properties.WiFi) | 263 else if (type == CrOnc.Type.WI_FI && properties.WiFi) |
261 return properties.WiFi.SignalStrength || 0; | 264 return properties.WiFi.SignalStrength || 0; |
262 else if (type == CrOnc.Type.WI_MAX && properties.WiMAX) | 265 else if (type == CrOnc.Type.WI_MAX && properties.WiMAX) |
263 return properties.WiMAX.SignalStrength || 0; | 266 return properties.WiMAX.SignalStrength || 0; |
264 return 0; | 267 return 0; |
265 } | 268 } |
266 | 269 |
267 /** | 270 /** |
| 271 * Gets the Managed AutoConnect dictionary from |properties| based on |
| 272 * properties.Type. |
| 273 * @param {!CrOnc.NetworkProperties|undefined} |
| 274 * properties The ONC network properties or state properties. |
| 275 * @return {!chrome.networkingPrivate.ManagedBoolean|undefined} The AutoConnect |
| 276 * managed dictionary or undefined. |
| 277 */ |
| 278 CrOnc.getManagedAutoConnect = function(properties) { |
| 279 var type = properties.Type; |
| 280 if (type == CrOnc.Type.CELLULAR && properties.Cellular) |
| 281 return properties.Cellular.AutoConnect; |
| 282 else if (type == CrOnc.Type.VPN && properties.VPN) |
| 283 return properties.VPN.AutoConnect; |
| 284 else if (type == CrOnc.Type.WI_FI && properties.WiFi) |
| 285 return properties.WiFi.AutoConnect; |
| 286 else if (type == CrOnc.Type.WI_MAX && properties.WiMAX) |
| 287 return properties.WiMAX.AutoConnect; |
| 288 return undefined; |
| 289 } |
| 290 |
| 291 /** |
268 * Gets the AutoConnect value from |properties| based on properties.Type. | 292 * Gets the AutoConnect value from |properties| based on properties.Type. |
269 * @param {!CrOnc.NetworkProperties|undefined} | 293 * @param {!CrOnc.NetworkProperties|undefined} |
270 * properties The ONC network properties or state properties. | 294 * properties The ONC network properties or state properties. |
271 * @return {boolean} The AutoConnect value if it exists or false. | 295 * @return {boolean} The AutoConnect value if it exists or false. |
272 */ | 296 */ |
273 CrOnc.getAutoConnect = function(properties) { | 297 CrOnc.getAutoConnect = function(properties) { |
274 var type = properties.Type; | 298 var autoconnect = CrOnc.getManagedAutoConnect(properties); |
275 /** @type {!chrome.networkingPrivate.ManagedBoolean|undefined} */ | |
276 var autoconnect; | |
277 if (type == CrOnc.Type.CELLULAR && properties.Cellular) | |
278 autoconnect = properties.Cellular.AutoConnect; | |
279 else if (type == CrOnc.Type.VPN && properties.VPN) | |
280 autoconnect = properties.VPN.AutoConnect; | |
281 else if (type == CrOnc.Type.WI_FI && properties.WiFi) | |
282 autoconnect = properties.WiFi.AutoConnect; | |
283 else if (type == CrOnc.Type.WI_MAX && properties.WiMAX) | |
284 autoconnect = properties.WiMAX.AutoConnect; | |
285 return !!CrOnc.getActiveValue(autoconnect); | 299 return !!CrOnc.getActiveValue(autoconnect); |
286 } | 300 } |
287 | 301 |
288 /** | 302 /** |
289 * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} | 303 * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} |
290 * properties The ONC network properties or state properties. | 304 * properties The ONC network properties or state properties. |
291 * @return {boolean} True if |properties| is a Cellular network with a | 305 * @return {boolean} True if |properties| is a Cellular network with a |
292 * locked SIM. | 306 * locked SIM. |
293 */ | 307 */ |
294 CrOnc.isSimLocked = function(properties) { | 308 CrOnc.isSimLocked = function(properties) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 prefixLength += 1; | 463 prefixLength += 1; |
450 } else if (token == '0') { | 464 } else if (token == '0') { |
451 prefixLength += 0; | 465 prefixLength += 0; |
452 } else { | 466 } else { |
453 // mask is not a valid number. | 467 // mask is not a valid number. |
454 return -1; | 468 return -1; |
455 } | 469 } |
456 } | 470 } |
457 return prefixLength; | 471 return prefixLength; |
458 }; | 472 }; |
OLD | NEW |