Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 6 * @fileoverview |
| 7 * 'settings-internet-detail' is the settings subpage containing details | 7 * 'settings-internet-detail' is the settings subpage containing details |
| 8 * for a network. | 8 * for a network. |
| 9 */ | 9 */ |
| 10 (function() { | 10 (function() { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); | 156 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); |
| 157 this.networkingPrivate.onNetworksChanged.addListener( | 157 this.networkingPrivate.onNetworksChanged.addListener( |
| 158 this.networksChangedListener_); | 158 this.networksChangedListener_); |
| 159 } | 159 } |
| 160 var queryParams = settings.getQueryParameters(); | 160 var queryParams = settings.getQueryParameters(); |
| 161 this.guid = queryParams.get('guid') || ''; | 161 this.guid = queryParams.get('guid') || ''; |
| 162 if (!this.guid) { | 162 if (!this.guid) { |
| 163 console.error('No guid specified for page:' + route); | 163 console.error('No guid specified for page:' + route); |
| 164 this.close_(); | 164 this.close_(); |
| 165 } | 165 } |
| 166 // Set basic networkProperties until the are loaded. | |
|
michaelpg
2017/01/31 21:47:46
the => they
stevenjb
2017/01/31 22:23:55
Done.
| |
| 167 var type = /** @type {!chrome.networkingPrivate.NetworkType} */ ( | |
| 168 queryParams.get('type')) || | |
| 169 CrOnc.Type.WI_FI; | |
| 170 this.networkProperties = { | |
| 171 GUID: this.guid, | |
| 172 Type: type, | |
| 173 ConnectionState: CrOnc.ConnectionState.NOT_CONNECTED, | |
| 174 Name: {Active: queryParams.get('name') || type}, | |
|
michaelpg
2017/01/31 21:47:46
nit: var name = ... (as above)
the... dependency
stevenjb
2017/01/31 22:23:55
Done.
| |
| 175 }; | |
| 166 this.getNetworkDetails_(); | 176 this.getNetworkDetails_(); |
| 167 }, | 177 }, |
| 168 | 178 |
| 169 /** @private */ | 179 /** @private */ |
| 170 close_: function() { | 180 close_: function() { |
| 171 // Delay navigating until the next render frame to allow other subpages to | 181 // Delay navigating until the next render frame to allow other subpages to |
| 172 // load first. | 182 // load first. |
| 173 setTimeout(function() { | 183 setTimeout(function() { |
| 174 settings.navigateTo(settings.Route.INTERNET); | 184 settings.navigateTo(settings.Route.INTERNET); |
| 175 }); | 185 }); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 * @return {boolean} | 347 * @return {boolean} |
| 338 * @private | 348 * @private |
| 339 */ | 349 */ |
| 340 isRememberedOrConnected_: function(networkProperties) { | 350 isRememberedOrConnected_: function(networkProperties) { |
| 341 return this.isRemembered_(networkProperties) || | 351 return this.isRemembered_(networkProperties) || |
| 342 this.isConnectedState_(networkProperties); | 352 this.isConnectedState_(networkProperties); |
| 343 }, | 353 }, |
| 344 | 354 |
| 345 /** | 355 /** |
| 346 * @param {!CrOnc.NetworkProperties} networkProperties | 356 * @param {!CrOnc.NetworkProperties} networkProperties |
| 357 * @return {boolean} | |
| 358 * @private | |
| 359 */ | |
| 360 isCellular_: function(networkProperties) { | |
| 361 return networkProperties.Type == CrOnc.Type.CELLULAR && | |
| 362 !!networkProperties.Cellular; | |
| 363 }, | |
| 364 | |
| 365 /** | |
| 366 * @param {!CrOnc.NetworkProperties} networkProperties | |
| 347 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy | 367 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy |
| 348 * @return {boolean} | 368 * @return {boolean} |
| 349 * @private | 369 * @private |
| 350 */ | 370 */ |
| 351 connectNotAllowed_: function(networkProperties, globalPolicy) { | 371 connectNotAllowed_: function(networkProperties, globalPolicy) { |
| 352 return networkProperties.Type == CrOnc.Type.WI_FI && | 372 return networkProperties.Type == CrOnc.Type.WI_FI && |
| 353 !!globalPolicy.AllowOnlyPolicyNetworksToConnect && | 373 !!globalPolicy.AllowOnlyPolicyNetworksToConnect && |
| 354 !this.isPolicySource(networkProperties.Source); | 374 !this.isPolicySource(networkProperties.Source); |
| 355 }, | 375 }, |
| 356 | 376 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 return false; | 410 return false; |
| 391 return this.isRemembered_(networkProperties); | 411 return this.isRemembered_(networkProperties); |
| 392 }, | 412 }, |
| 393 | 413 |
| 394 /** | 414 /** |
| 395 * @param {!CrOnc.NetworkProperties} networkProperties | 415 * @param {!CrOnc.NetworkProperties} networkProperties |
| 396 * @return {boolean} | 416 * @return {boolean} |
| 397 * @private | 417 * @private |
| 398 */ | 418 */ |
| 399 showActivate_: function(networkProperties) { | 419 showActivate_: function(networkProperties) { |
| 400 if (networkProperties.Type != CrOnc.Type.CELLULAR) | 420 if (!this.isCellular_(networkProperties)) |
| 401 return false; | 421 return false; |
| 402 var activation = networkProperties.Cellular.ActivationState; | 422 var activation = networkProperties.Cellular.ActivationState; |
| 403 return activation == CrOnc.ActivationState.NOT_ACTIVATED || | 423 return activation == CrOnc.ActivationState.NOT_ACTIVATED || |
| 404 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED; | 424 activation == CrOnc.ActivationState.PARTIALLY_ACTIVATED; |
| 405 }, | 425 }, |
| 406 | 426 |
| 407 /** | 427 /** |
| 408 * @param {!CrOnc.NetworkProperties} networkProperties | 428 * @param {!CrOnc.NetworkProperties} networkProperties |
| 409 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy | 429 * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy |
| 410 * @return {boolean} | 430 * @return {boolean} |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 423 } | 443 } |
| 424 return this.isRemembered_(networkProperties); | 444 return this.isRemembered_(networkProperties); |
| 425 }, | 445 }, |
| 426 | 446 |
| 427 /** | 447 /** |
| 428 * @param {!CrOnc.NetworkProperties} networkProperties | 448 * @param {!CrOnc.NetworkProperties} networkProperties |
| 429 * @return {boolean} | 449 * @return {boolean} |
| 430 * @private | 450 * @private |
| 431 */ | 451 */ |
| 432 showViewAccount_: function(networkProperties) { | 452 showViewAccount_: function(networkProperties) { |
| 433 // Show either the 'Activate' or the 'View Account' button. | 453 // Show either the 'Activate' or the 'View Account' button (Cellular only). |
| 434 if (this.showActivate_(networkProperties)) | 454 if (!this.isCellular_(networkProperties) || |
| 435 return false; | 455 this.showActivate_(networkProperties)) { |
| 436 | |
| 437 if (networkProperties.Type != CrOnc.Type.CELLULAR || | |
| 438 !networkProperties.Cellular) { | |
| 439 return false; | 456 return false; |
| 440 } | 457 } |
| 441 | 458 |
| 442 // Only show if online payment URL is provided or the carrier is Verizon. | 459 // Only show if online payment URL is provided or the carrier is Verizon. |
| 443 var carrier = CrOnc.getActiveValue(networkProperties.Cellular.Carrier); | 460 var carrier = CrOnc.getActiveValue(networkProperties.Cellular.Carrier); |
| 444 if (carrier != CARRIER_VERIZON) { | 461 if (carrier != CARRIER_VERIZON) { |
| 445 var paymentPortal = networkProperties.Cellular.PaymentPortal; | 462 var paymentPortal = networkProperties.Cellular.PaymentPortal; |
| 446 if (!paymentPortal || !paymentPortal.Url) | 463 if (!paymentPortal || !paymentPortal.Url) |
| 447 return false; | 464 return false; |
| 448 } | 465 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 hasInfoFields_: function() { | 732 hasInfoFields_: function() { |
| 716 return this.hasVisibleFields_(this.getInfoFields_()); | 733 return this.hasVisibleFields_(this.getInfoFields_()); |
| 717 }, | 734 }, |
| 718 | 735 |
| 719 /** | 736 /** |
| 720 * @return {!Array<string>} The fields to display in the info section. | 737 * @return {!Array<string>} The fields to display in the info section. |
| 721 * @private | 738 * @private |
| 722 */ | 739 */ |
| 723 getInfoFields_: function() { | 740 getInfoFields_: function() { |
| 724 /** @type {!Array<string>} */ var fields = []; | 741 /** @type {!Array<string>} */ var fields = []; |
| 725 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) { | 742 var type = this.networkProperties.Type; |
| 743 if (type == CrOnc.Type.CELLULAR && !!this.networkProperties.Cellular) { | |
|
michaelpg
2017/01/31 21:47:46
maybe put this logic in a helper function, e.g. is
stevenjb
2017/01/31 22:23:55
Well, I have a helper, but we've already extracted
| |
| 726 fields.push( | 744 fields.push( |
| 727 'Cellular.ActivationState', 'Cellular.RoamingState', | 745 'Cellular.ActivationState', 'Cellular.RoamingState', |
| 728 'RestrictedConnectivity', 'Cellular.ServingOperator.Name'); | 746 'RestrictedConnectivity', 'Cellular.ServingOperator.Name'); |
| 729 } | 747 } else if (type == CrOnc.Type.VPN && !!this.networkProperties.VPN) { |
| 730 if (this.networkProperties.Type == CrOnc.Type.VPN) { | |
| 731 var vpnType = CrOnc.getActiveValue(this.networkProperties.VPN.Type); | 748 var vpnType = CrOnc.getActiveValue(this.networkProperties.VPN.Type); |
| 732 if (vpnType == 'ThirdPartyVPN') { | 749 if (vpnType == 'ThirdPartyVPN') { |
| 733 fields.push('VPN.ThirdPartyVPN.ProviderName'); | 750 fields.push('VPN.ThirdPartyVPN.ProviderName'); |
| 734 } else { | 751 } else { |
| 735 fields.push('VPN.Host', 'VPN.Type'); | 752 fields.push('VPN.Host', 'VPN.Type'); |
| 736 if (vpnType == 'OpenVPN') | 753 if (vpnType == 'OpenVPN') |
| 737 fields.push('VPN.OpenVPN.Username'); | 754 fields.push('VPN.OpenVPN.Username'); |
| 738 else if (vpnType == 'L2TP-IPsec') | 755 else if (vpnType == 'L2TP-IPsec') |
| 739 fields.push('VPN.L2TP.Username'); | 756 fields.push('VPN.L2TP.Username'); |
| 740 } | 757 } |
| 741 } | 758 } else if (type == CrOnc.Type.WI_FI) { |
| 742 if (this.networkProperties.Type == CrOnc.Type.WI_FI) | |
| 743 fields.push('RestrictedConnectivity'); | 759 fields.push('RestrictedConnectivity'); |
| 744 if (this.networkProperties.Type == CrOnc.Type.WI_MAX) { | 760 } else if (type == CrOnc.Type.WI_MAX) { |
| 745 fields.push('RestrictedConnectivity', 'WiMAX.EAP.Identity'); | 761 fields.push('RestrictedConnectivity', 'WiMAX.EAP.Identity'); |
| 746 } | 762 } |
| 747 return fields; | 763 return fields; |
| 748 }, | 764 }, |
| 749 | 765 |
| 750 /** | 766 /** |
| 751 * @return {!Array<string>} The fields to display in the Advanced section. | 767 * @return {!Array<string>} The fields to display in the Advanced section. |
| 752 * @private | 768 * @private |
| 753 */ | 769 */ |
| 754 getAdvancedFields_: function() { | 770 getAdvancedFields_: function() { |
| 755 /** @type {!Array<string>} */ var fields = []; | 771 /** @type {!Array<string>} */ var fields = []; |
| 756 fields.push('MacAddress'); | 772 fields.push('MacAddress'); |
| 757 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) { | 773 var type = this.networkProperties.Type; |
| 774 if (type == CrOnc.Type.CELLULAR && !!this.networkProperties.Cellular) { | |
| 758 fields.push( | 775 fields.push( |
| 759 'Cellular.Carrier', 'Cellular.Family', 'Cellular.NetworkTechnology', | 776 'Cellular.Carrier', 'Cellular.Family', 'Cellular.NetworkTechnology', |
| 760 'Cellular.ServingOperator.Code'); | 777 'Cellular.ServingOperator.Code'); |
| 761 } | 778 } else if (type == CrOnc.Type.WI_FI) { |
| 762 if (this.networkProperties.Type == CrOnc.Type.WI_FI) { | |
| 763 fields.push( | 779 fields.push( |
| 764 'WiFi.SSID', 'WiFi.BSSID', 'WiFi.Security', 'WiFi.SignalStrength', | 780 'WiFi.SSID', 'WiFi.BSSID', 'WiFi.Security', 'WiFi.SignalStrength', |
| 765 'WiFi.Frequency'); | 781 'WiFi.Frequency'); |
| 782 } else if (type == CrOnc.Type.WI_MAX) { | |
| 783 fields.push('WiFi.SignalStrength'); | |
| 766 } | 784 } |
| 767 if (this.networkProperties.Type == CrOnc.Type.WI_MAX) | |
| 768 fields.push('WiFi.SignalStrength'); | |
| 769 return fields; | 785 return fields; |
| 770 }, | 786 }, |
| 771 | 787 |
| 772 /** | 788 /** |
| 773 * @return {!Array<string>} The fields to display in the device section. | 789 * @return {!Array<string>} The fields to display in the device section. |
| 774 * @private | 790 * @private |
| 775 */ | 791 */ |
| 776 getDeviceFields_: function() { | 792 getDeviceFields_: function() { |
| 777 /** @type {!Array<string>} */ var fields = []; | 793 /** @type {!Array<string>} */ var fields = []; |
| 778 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) { | 794 if (this.networkProperties.Type == CrOnc.Type.CELLULAR) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 866 */ | 882 */ |
| 867 allPropertiesMatch_: function(curValue, newValue) { | 883 allPropertiesMatch_: function(curValue, newValue) { |
| 868 for (var key in newValue) { | 884 for (var key in newValue) { |
| 869 if (newValue[key] != curValue[key]) | 885 if (newValue[key] != curValue[key]) |
| 870 return false; | 886 return false; |
| 871 } | 887 } |
| 872 return true; | 888 return true; |
| 873 } | 889 } |
| 874 }); | 890 }); |
| 875 })(); | 891 })(); |
| OLD | NEW |