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

Side by Side Diff: chrome/browser/resources/settings/internet_page/internet_subpage.js

Issue 2914053002: Settings: Network: Closure cleanup (Closed)
Patch Set: . Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 displaying information about WiFi, 6 * @fileoverview Polymer element for displaying information about WiFi,
7 * WiMAX, or virtual networks. 7 * WiMAX, or virtual networks.
8 */ 8 */
9 9
10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */
11 var DeviceStateProperties;
12
13 Polymer({ 10 Polymer({
14 is: 'settings-internet-subpage', 11 is: 'settings-internet-subpage',
15 12
16 behaviors: [ 13 behaviors: [
17 CrPolicyNetworkBehavior, 14 CrPolicyNetworkBehavior,
18 settings.RouteObserverBehavior, 15 settings.RouteObserverBehavior,
19 I18nBehavior, 16 I18nBehavior,
20 ], 17 ],
21 18
22 properties: { 19 properties: {
23 /** 20 /**
24 * Highest priority connected network or null. Provided by 21 * Highest priority connected network or null. Provided by
25 * settings-internet-page (but set in network-summary). 22 * settings-internet-page (but set in network-summary).
26 * @type {?CrOnc.NetworkStateProperties|undefined} 23 * @type {?CrOnc.NetworkStateProperties|undefined}
27 */ 24 */
28 defaultNetwork: Object, 25 defaultNetwork: Object,
29 26
30 /** 27 /**
31 * Device state for the network type. 28 * Device state for the network type.
32 * @type {?DeviceStateProperties} 29 * @type {!CrOnc.DeviceStateProperties|undefined}
33 */ 30 */
34 deviceState: { 31 deviceState: Object,
35 type: Object,
36 value: null,
37 },
38 32
39 /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */ 33 /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */
40 globalPolicy: Object, 34 globalPolicy: Object,
41 35
42 /** 36 /**
43 * List of third party VPN providers. 37 * List of third party VPN providers.
44 * @type 38 * @type
45 * {!Array<!chrome.networkingPrivate.ThirdPartyVPNProperties>|undefined} 39 * {!Array<!chrome.networkingPrivate.ThirdPartyVPNProperties>|undefined}
46 */ 40 */
47 thirdPartyVpnProviders: Array, 41 thirdPartyVpnProviders: Array,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } else { 191 } else {
198 networkStateList.push(state); 192 networkStateList.push(state);
199 } 193 }
200 } 194 }
201 this.networkStateList_ = networkStateList; 195 this.networkStateList_ = networkStateList;
202 this.thirdPartyVpns_ = thirdPartyVpns; 196 this.thirdPartyVpns_ = thirdPartyVpns;
203 }.bind(this)); 197 }.bind(this));
204 }, 198 },
205 199
206 /** 200 /**
207 * @param {!DeviceStateProperties|undefined} deviceState 201 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
208 * @return {boolean} Whether or not the device state is enabled. 202 * @return {boolean} Whether or not the device state is enabled.
209 * @private 203 * @private
210 */ 204 */
211 deviceIsEnabled_: function(deviceState) { 205 deviceIsEnabled_: function(deviceState) {
212 return !!deviceState && 206 return !!deviceState && deviceState.State == CrOnc.DeviceState.ENABLED;
213 deviceState.State == chrome.networkingPrivate.DeviceStateType.ENABLED;
214 }, 207 },
215 208
216 /** 209 /**
217 * @param {!DeviceStateProperties|undefined} deviceState 210 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
218 * @param {string} onstr 211 * @param {string} onstr
219 * @param {string} offstr 212 * @param {string} offstr
220 * @return {string} 213 * @return {string}
221 * @private 214 * @private
222 */ 215 */
223 getOffOnString_: function(deviceState, onstr, offstr) { 216 getOffOnString_: function(deviceState, onstr, offstr) {
224 return this.deviceIsEnabled_(deviceState) ? onstr : offstr; 217 return this.deviceIsEnabled_(deviceState) ? onstr : offstr;
225 }, 218 },
226 219
227 /** 220 /**
228 * @param {?DeviceStateProperties} deviceState 221 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
229 * @return {boolean} 222 * @return {boolean}
230 * @private 223 * @private
231 */ 224 */
232 enableToggleIsVisible_: function(deviceState) { 225 enableToggleIsVisible_: function(deviceState) {
233 return !!deviceState && deviceState.Type != CrOnc.Type.ETHERNET && 226 return !!deviceState && deviceState.Type != CrOnc.Type.ETHERNET &&
234 deviceState.Type != CrOnc.Type.VPN; 227 deviceState.Type != CrOnc.Type.VPN;
235 }, 228 },
236 229
237 /** 230 /**
238 * @param {?DeviceStateProperties} deviceState 231 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
239 * @return {boolean} 232 * @return {boolean}
240 * @private 233 * @private
241 */ 234 */
242 enableToggleIsEnabled_: function(deviceState) { 235 enableToggleIsEnabled_: function(deviceState) {
243 return !!deviceState && 236 return !!deviceState && deviceState.State != CrOnc.DeviceState.PROHIBITED;
244 deviceState.State !=
245 chrome.networkingPrivate.DeviceStateType.PROHIBITED;
246 }, 237 },
247 238
248 /** 239 /**
249 * @param {!DeviceStateProperties} deviceState 240 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
250 * @return {string} 241 * @return {string}
251 * @private 242 * @private
252 */ 243 */
253 getToggleA11yString_: function(deviceState) { 244 getToggleA11yString_: function(deviceState) {
254 if (!this.enableToggleIsVisible_(deviceState)) 245 if (!this.enableToggleIsVisible_(deviceState))
255 return ''; 246 return '';
256 switch (deviceState.Type) { 247 switch (deviceState.Type) {
257 case CrOnc.Type.TETHER: 248 case CrOnc.Type.TETHER:
258 return this.i18n('internetToggleTetherA11yLabel'); 249 return this.i18n('internetToggleTetherA11yLabel');
259 case CrOnc.Type.CELLULAR: 250 case CrOnc.Type.CELLULAR:
(...skipping 19 matching lines...) Expand all
279 /** 270 /**
280 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy 271 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy
281 * @return {boolean} 272 * @return {boolean}
282 * @private 273 * @private
283 */ 274 */
284 allowAddConnection_: function(globalPolicy) { 275 allowAddConnection_: function(globalPolicy) {
285 return globalPolicy && !globalPolicy.AllowOnlyPolicyNetworksToConnect; 276 return globalPolicy && !globalPolicy.AllowOnlyPolicyNetworksToConnect;
286 }, 277 },
287 278
288 /** 279 /**
289 * @param {!DeviceStateProperties} deviceState 280 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
290 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy 281 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy
291 * @return {boolean} 282 * @return {boolean}
292 * @private 283 * @private
293 */ 284 */
294 showAddButton_: function(deviceState, globalPolicy) { 285 showAddButton_: function(deviceState, globalPolicy) {
295 if (!deviceState || deviceState.Type != CrOnc.Type.WI_FI) 286 if (!deviceState || deviceState.Type != CrOnc.Type.WI_FI)
296 return false; 287 return false;
297 if (!this.deviceIsEnabled_(deviceState)) 288 if (!this.deviceIsEnabled_(deviceState))
298 return false; 289 return false;
299 return this.allowAddConnection_(globalPolicy); 290 return this.allowAddConnection_(globalPolicy);
(...skipping 13 matching lines...) Expand all
313 * !{item: !chrome.networkingPrivate.ThirdPartyVPNProperties}, 304 * !{item: !chrome.networkingPrivate.ThirdPartyVPNProperties},
314 * }} event 305 * }} event
315 * @private 306 * @private
316 */ 307 */
317 onAddThirdPartyVpnTap_: function(event) { 308 onAddThirdPartyVpnTap_: function(event) {
318 var provider = event.model.item; 309 var provider = event.model.item;
319 chrome.send('addNetwork', [CrOnc.Type.VPN, provider.ExtensionID]); 310 chrome.send('addNetwork', [CrOnc.Type.VPN, provider.ExtensionID]);
320 }, 311 },
321 312
322 /** 313 /**
323 * @param {!DeviceStateProperties} deviceState 314 * @param {!CrOnc.DeviceStateProperties|undefined} deviceState
324 * @return {boolean} 315 * @return {boolean}
325 * @private 316 * @private
326 */ 317 */
327 knownNetworksIsVisible_: function(deviceState) { 318 knownNetworksIsVisible_: function(deviceState) {
328 return deviceState && deviceState.Type == CrOnc.Type.WI_FI; 319 return !!deviceState && deviceState.Type == CrOnc.Type.WI_FI;
329 }, 320 },
330 321
331 /** 322 /**
332 * Event triggered when the known networks button is tapped. 323 * Event triggered when the known networks button is tapped.
333 * @private 324 * @private
334 */ 325 */
335 onKnownNetworksTap_: function() { 326 onKnownNetworksTap_: function() {
336 assert(this.deviceState.Type == CrOnc.Type.WI_FI); 327 assert(this.deviceState.Type == CrOnc.Type.WI_FI);
337 this.fire('show-known-networks', {Type: this.deviceState.Type}); 328 this.fire('show-known-networks', {Type: this.deviceState.Type});
338 }, 329 },
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 406
416 /** 407 /**
417 * @param {*} lhs 408 * @param {*} lhs
418 * @param {*} rhs 409 * @param {*} rhs
419 * @return {boolean} 410 * @return {boolean}
420 */ 411 */
421 isEqual_: function(lhs, rhs) { 412 isEqual_: function(lhs, rhs) {
422 return lhs === rhs; 413 return lhs === rhs;
423 }, 414 },
424 }); 415 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698