Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Side by Side Diff: ui/webui/resources/cr_elements/cr_onc/cr_onc_data.js

Issue 954293003: Support badges and connecting animation in cr-network-icon element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Feedback Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ONC network configuration support class. Wraps a dictionary 6 * @fileoverview ONC network configuration support class. Wraps a dictionary
7 * object containing ONC managed or unmanaged dictionaries. Also provides 7 * object containing ONC managed or unmanaged dictionaries. Also provides
8 * special accessors for ONC properties. See cr-onc-types for ONC types, 8 * special accessors for ONC properties. See cr-onc-types for ONC types,
9 * e.g. CrOnc.NetworkConfigType. Used by consumers of the 9 * e.g. CrOnc.NetworkConfigType. Used by consumers of the
10 * chrome.networkingPrivate API. See components/onc/docs/onc_spec.html. 10 * chrome.networkingPrivate API. See components/onc/docs/onc_spec.html.
11 */ 11 */
12 Polymer('cr-onc-data', { 12 Polymer('cr-onc-data', {
13 publish: { 13 publish: {
14 /** 14 /**
15 * ONC configuration property dictionary, e.g. the result of a 15 * ONC configuration property dictionary, e.g. the result of a
16 * chrome.networkingPrivate.getProperties() call. 16 * chrome.networkingPrivate.getProperties() call.
17 * 17 *
18 * @attribute data 18 * @attribute data
19 * @type CrOnc.NetworkConfigType 19 * @type CrOnc.NetworkConfigType
20 * @default null 20 * @default null
21 */ 21 */
22 data: null, 22 data: null,
23 }, 23 },
24 24
25 /** @override */
25 created: function() { 26 created: function() {
26 this.data = /** @type {CrOnc.NetworkConfigType} */({}); 27 this.data = /** @type {CrOnc.NetworkConfigType} */({});
27 }, 28 },
28 29
29 /** 30 /** @return {boolean} True if the network is connected. */
30 * @return {number} The signal strength of the network. 31 connected: function() {
31 */ 32 return this.data.ConnectionState == CrOnc.ConnectionState.CONNECTED;
33 },
34
35 /** @return {boolean} True if the network is connecting. */
36 connecting: function() {
37 return this.data.ConnectionState == CrOnc.ConnectionState.CONNECTING;
38 },
39
40 /** @return {number} The signal strength of the network. */
32 getStrength: function() { 41 getStrength: function() {
33 var type = this.data.Type; 42 var type = this.data.Type;
34 var strength = 0; 43 var strength = 0;
35 if (type == 'WiFi') 44 if (type == 'WiFi')
36 strength = this.data.WiFi ? this.data.WiFi.SignalStrength : 0; 45 strength = this.data.WiFi ? this.data.WiFi.SignalStrength : 0;
37 else if (type == 'Cellular') 46 else if (type == 'Cellular')
38 strength = this.data.Cellular ? this.data.Cellular.SignalStrength : 0; 47 strength = this.data.Cellular ? this.data.Cellular.SignalStrength : 0;
39 else if (type == 'WiMAX') 48 else if (type == 'WiMAX')
40 strength = this.data.WiMAX ? this.data.WiMAX.SignalStrength : 0; 49 strength = this.data.WiMAX ? this.data.WiMAX.SignalStrength : 0;
41 return strength; 50 return strength;
42 }, 51 },
43 52
44 /** 53 /** @return {CrOnc.Security} The ONC security type. */
45 * Returns the WiFi security type. Undefined or empty defaults to 'None'.
46 * @return {string} The WiFi security type.
47 */
48 getWiFiSecurity: function() { 54 getWiFiSecurity: function() {
49 return (this.data.WiFi && this.data.WiFi.Security) ? 55 return (this.data.WiFi && this.data.WiFi.Security) ?
50 this.data.WiFi.Security : 'None'; 56 this.data.WiFi.Security : CrOnc.Security.NONE;
57 },
58
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;
63 },
64
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;
51 } 69 }
52 }); 70 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/cr_network_icon/secure.png ('k') | ui/webui/resources/cr_elements/cr_onc/cr_onc_types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698