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