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

Side by Side Diff: ui/webui/resources/cr_elements/network/cr_network_icon.js

Issue 2290853002: MD Settings: Use network name for detail page title (Closed)
Patch Set: Rebase + use ordered array of types instead of sort Created 4 years, 3 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 Polymer element for rendering network icons based on ONC 6 * @fileoverview Polymer element for rendering network icons based on ONC
7 * state properties. 7 * state properties.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 properties: { 53 properties: {
54 /** 54 /**
55 * If set, the ONC properties will be used to display the icon. This may 55 * If set, the ONC properties will be used to display the icon. This may
56 * either be the complete set of NetworkProperties or the subset of 56 * either be the complete set of NetworkProperties or the subset of
57 * NetworkStateProperties. 57 * NetworkStateProperties.
58 * @type {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} 58 * @type {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined}
59 */ 59 */
60 networkState: { 60 networkState: {
61 type: Object, 61 type: Object,
62 observer: 'networkStateChanged_' 62 observer: 'networkStateChanged_',
63 }, 63 },
64 64
65 /** 65 /**
66 * If set, the ONC network type will be used to display the icon. 66 * If set, the ONC network type will be used to display the icon.
67 * @type {?chrome.networkingPrivate.NetworkType} 67 * @type {?chrome.networkingPrivate.NetworkType}
68 */ 68 */
69 networkType: { 69 networkType: {
70 type: String, 70 type: String,
71 value: null, 71 value: null,
72 observer: 'networkTypeChanged_' 72 observer: 'networkTypeChanged_',
73 }, 73 },
74 74
75 /** 75 /**
76 * If true, the icon is part of a list of networks and may be displayed 76 * If true, the icon is part of a list of networks and may be displayed
77 * differently, e.g. the disconnected image will never be shown for 77 * differently, e.g. the disconnected image will never be shown for
78 * list items. 78 * list items.
79 */ 79 */
80 isListItem: { 80 isListItem: {
81 type: Boolean, 81 type: Boolean,
82 value: false, 82 value: false,
83 observer: 'isListItemChanged_' 83 observer: 'isListItemChanged_',
84 }, 84 },
85 85
86 /** The icon type to use for the base image of the icon. */ 86 /** The icon type to use for the base image of the icon. */
87 iconType_: { 87 iconType_: {
88 type: String, 88 type: String,
89 value: 'ethernet' 89 value: 'ethernet',
90 }, 90 },
91 91
92 /** Set to true to show a badge for roaming networks. */ 92 /** Set to true to show a badge for roaming networks. */
93 roaming_: { 93 roaming_: {
94 type: Boolean, 94 type: Boolean,
95 value: false 95 value: false,
96 }, 96 },
97 97
98 /** Set to true to show a badge for secure networks. */ 98 /** Set to true to show a badge for secure networks. */
99 secure_: { 99 secure_: {
100 type: Boolean, 100 type: Boolean,
101 value: false 101 value: false,
102 }, 102 },
103 103
104 /** Set to the name of a technology to show show a badge. */ 104 /** Set to the name of a technology to show show a badge. */
105 technology_: { 105 technology_: {
106 type: String, 106 type: String,
107 value: '' 107 value: '',
108 }, 108 },
109 }, 109 },
110 110
111 /** 111 /**
112 * Polymer networkState changed method. Updates the icon based on the 112 * Polymer networkState changed method. Updates the icon based on the
113 * network state. 113 * network state.
114 * @private 114 * @private
115 */ 115 */
116 networkStateChanged_: function() { 116 networkStateChanged_: function() {
117 if (!this.networkState) 117 if (!this.networkState)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 setIcon_: function(params) { 186 setIcon_: function(params) {
187 var icon = this.$.icon; 187 var icon = this.$.icon;
188 188
189 var multiLevel = (this.iconType_ == 'wifi' || this.iconType_ == 'mobile'); 189 var multiLevel = (this.iconType_ == 'wifi' || this.iconType_ == 'mobile');
190 190
191 if (this.networkState && multiLevel) { 191 if (this.networkState && multiLevel) {
192 this.setMultiLevelIcon_(params); 192 this.setMultiLevelIcon_(params);
193 } else { 193 } else {
194 icon.classList.toggle('multi-level', multiLevel); 194 icon.classList.toggle('multi-level', multiLevel);
195 icon.classList.toggle('level0', multiLevel); 195 icon.classList.toggle('level0', multiLevel);
196 icon.classList.toggle('level1', false);
197 icon.classList.toggle('level2', false);
198 icon.classList.toggle('level3', false);
199 icon.classList.toggle('level4', false);
196 } 200 }
197 201
198 this.setIconBadges_(params); 202 this.setIconBadges_(params);
199 }, 203 },
200 204
201 /** 205 /**
202 * Toggles icon classes based on strength and connecting properties. 206 * Toggles icon classes based on strength and connecting properties.
203 * |this.networkState| is expected to be specified. 207 * |this.networkState| is expected to be specified.
204 * @param {!NetworkIconParamType} params Set of params describing the icon. 208 * @param {!NetworkIconParamType} params Set of params describing the icon.
205 * @private 209 * @private
206 */ 210 */
207 setMultiLevelIcon_: function(params) { 211 setMultiLevelIcon_: function(params) {
208 // Set the strength or connecting properties. 212 // Set the strength or connecting properties.
209 var networkState = this.networkState; 213 var networkState = this.networkState;
210 214
211 var connectionState = networkState.ConnectionState; 215 var connectionState = networkState.ConnectionState;
212 var connecting = false; 216 var connecting = false;
213 var strength = -1; 217 var strength = -1;
214 if (connectionState == CrOnc.ConnectionState.CONNECTING) { 218 if (connectionState == CrOnc.ConnectionState.CONNECTING) {
215 strength = 0; 219 strength = 0;
216 connecting = true; 220 connecting = true;
217 } else if (connectionState == CrOnc.ConnectionState.CONNECTED || 221 } else if (
218 !params.showDisconnected) { 222 connectionState == CrOnc.ConnectionState.CONNECTED ||
223 !params.showDisconnected) {
219 strength = params.strength || 0; 224 strength = params.strength || 0;
220 } 225 }
221 226
222 var icon = this.$.icon; 227 var icon = this.$.icon;
223 icon.classList.toggle('multi-level', true); 228 icon.classList.toggle('multi-level', true);
224 icon.classList.toggle('connecting', connecting); 229 icon.classList.toggle('connecting', connecting);
225 icon.classList.toggle('level0', strength < 0); 230 icon.classList.toggle('level0', strength < 0);
226 icon.classList.toggle('level1', strength >= 0 && strength <= 25); 231 icon.classList.toggle('level1', strength >= 0 && strength <= 25);
227 icon.classList.toggle('level2', strength > 25 && strength <= 50); 232 icon.classList.toggle('level2', strength > 25 && strength <= 50);
228 icon.classList.toggle('level3', strength > 50 && strength <= 75); 233 icon.classList.toggle('level3', strength > 50 && strength <= 75);
229 icon.classList.toggle('level4', strength > 75); 234 icon.classList.toggle('level4', strength > 75);
230 }, 235 },
231 236
232 /** 237 /**
233 * Sets the icon badge visibility properties: roaming, secure, technology. 238 * Sets the icon badge visibility properties: roaming, secure, technology.
234 * @param {!NetworkIconParamType} params Set of params describing the icon. 239 * @param {!NetworkIconParamType} params Set of params describing the icon.
235 * @private 240 * @private
236 */ 241 */
237 setIconBadges_: function(params) { 242 setIconBadges_: function(params) {
238 var networkState = this.networkState; 243 var networkState = this.networkState;
239 244
240 var type = 245 var type = (params.showBadges && networkState) ? networkState.Type : '';
241 (params.showBadges && networkState) ? networkState.Type : '';
242 if (type == CrOnc.Type.WI_FI) { 246 if (type == CrOnc.Type.WI_FI) {
243 this.roaming_ = false; 247 this.roaming_ = false;
244 var security = networkState.WiFi ? networkState.WiFi.Security : ''; 248 var security = networkState.WiFi ? networkState.WiFi.Security : '';
245 this.secure_ = !!security && security != 'None'; 249 this.secure_ = !!security && security != 'None';
246 this.technology_ = ''; 250 this.technology_ = '';
247 } else if (type == CrOnc.Type.WI_MAX) { 251 } else if (type == CrOnc.Type.WI_MAX) {
248 this.roaming_ = false; 252 this.roaming_ = false;
249 this.secure_ = false; 253 this.secure_ = false;
250 this.technology_ = '4g'; 254 this.technology_ = '4g';
251 } else if (type == CrOnc.Type.CELLULAR && networkState.Cellular) { 255 } else if (type == CrOnc.Type.CELLULAR && networkState.Cellular) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 break; 288 break;
285 } 289 }
286 } else { 290 } else {
287 this.roaming_ = false; 291 this.roaming_ = false;
288 this.secure_ = false; 292 this.secure_ = false;
289 this.technology_ = ''; 293 this.technology_ = '';
290 } 294 }
291 }, 295 },
292 }); 296 });
293 })(); 297 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698