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
3 // found in the LICENSE file.
6 * @fileoverview ONC network configuration support class. Wraps a dictionary
7 * object containing ONC managed or unmanaged dictionaries. Also provides
8 * special accessors for ONC properties. See cr-onc-types for ONC types,
9 * e.g. CrOnc.NetworkConfigType. Used by consumers of the
10 * chrome.networkingPrivate API. See components/onc/docs/onc_spec.html.
12 Polymer('cr-onc-data', {
15 * ONC configuration property dictionary, e.g. the result of a
16 * chrome.networkingPrivate.getProperties() call.
19 * @type CrOnc.NetworkConfigType
27 this.data = /** @type {CrOnc.NetworkConfigType} */({});
30 /** @return {boolean} True if the network is connected. */
31 connected: function() {
32 return this.data.ConnectionState == CrOnc.ConnectionState.CONNECTED;
35 /** @return {boolean} True if the network is connecting. */
36 connecting: function() {
37 return this.data.ConnectionState == CrOnc.ConnectionState.CONNECTING;
40 /** @return {number} The signal strength of the network. */
41 getStrength: function() {
42 var type = this.data.Type;
45 strength = this.data.WiFi ? this.data.WiFi.SignalStrength : 0;
46 else if (type == 'Cellular')
47 strength = this.data.Cellular ? this.data.Cellular.SignalStrength : 0;
48 else if (type == 'WiMAX')
49 strength = this.data.WiMAX ? this.data.WiMAX.SignalStrength : 0;
53 /** @return {CrOnc.Security} The ONC security type. */
54 getWiFiSecurity: function() {
55 return (this.data.WiFi && this.data.WiFi.Security) ?
56 this.data.WiFi.Security : CrOnc.Security.NONE;
59 /** @return {CrOnc.RoamingState} The ONC roaming state. */
60 getCellularRoamingState: function() {
61 return (this.data.Cellular && this.data.Cellular.RoamingState) ?
62 this.data.Cellular.RoamingState : CrOnc.RoamingState.UNKNOWN;
65 /** @return {CrOnc.NetworkTechnology} The ONC network technology. */
66 getCellularTechnology: function() {
67 return (this.data.Cellular && this.data.Cellular.NetworkTechnology) ?
68 this.data.Cellular.NetworkTechnology : CrOnc.NetworkTechnology.UNKNOWN;