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