OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 /** | |
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. | |
11 */ | |
12 | |
13 Polymer('cr-onc-data', { | |
14 publish: { | |
15 /** | |
16 * ONC configuration property dictionary, e.g. the result of a | |
17 * chrome.networkingPrivate.getProperties() call. | |
18 * | |
19 * @attribute data | |
20 * @type CrOnc.NetworkConfigType | |
21 * @default {} | |
22 */ | |
23 data: {} | |
michaelpg
2015/02/10 08:11:25
Again, it's safer to set an object value in the cr
stevenjb
2015/02/11 00:16:12
Done.
| |
24 }, | |
25 | |
26 /** | |
27 * @return {number} The signal strength of the network. | |
28 */ | |
29 getStrength: function() { | |
30 var type = this.data.Type; | |
31 var strength = 0; | |
32 if (type == 'WiFi') { | |
33 strength = this.data.WiFi ? this.data.WiFi.SignalStrength : 0; | |
34 } else if (type == 'Cellular') { | |
35 strength = this.data.Cellular ? this.data.Cellular.SignalStrength : 0; | |
36 } else if (type == 'WiMAX') { | |
37 strength = this.data.WiMAX ? this.data.WiMAX.SignalStrength : 0; | |
38 } | |
39 return strength; | |
40 }, | |
41 | |
42 /** | |
43 * Returns the WiFi security type. Undefined or empty defaults to 'None'. | |
44 * @return {string} The WiFi security type. | |
45 */ | |
46 getWiFiSecurity: function() { | |
47 var security = this.data.WiFi ? this.data.WiFi.Security : undefined; | |
48 if (security) | |
49 return security; | |
50 return 'None'; | |
51 } | |
52 }); | |
OLD | NEW |