Chromium Code Reviews| Index: chrome/browser/resources/settings/internet_page/network_ip_config.js |
| diff --git a/chrome/browser/resources/settings/internet_page/network_ip_config.js b/chrome/browser/resources/settings/internet_page/network_ip_config.js |
| index 43f34e18b65d0a36da6cf3e5a46f05ee55d6820f..6da711f7f45440e7493cb34f67dce02492368756 100644 |
| --- a/chrome/browser/resources/settings/internet_page/network_ip_config.js |
| +++ b/chrome/browser/resources/settings/internet_page/network_ip_config.js |
| @@ -35,7 +35,7 @@ Polymer({ |
| */ |
| automatic_: { |
| type: Boolean, |
| - value: false, |
| + value: true, |
| observer: 'automaticChanged_', |
| }, |
| @@ -84,36 +84,32 @@ Polymer({ |
| this.savedStaticIp_ = undefined; |
| // Update the 'automatic' property. |
| - var ipConfigType = |
| - CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType); |
| - this.automatic_ = (ipConfigType != CrOnc.IPConfigType.STATIC); |
| - |
| - // Update the 'ipConfig' property. |
| - var ipv4 = |
| - CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); |
| - var ipv6 = |
| - CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV6); |
| - this.ipConfig_ = { |
| - ipv4: this.getIPConfigUIProperties_(ipv4), |
| - ipv6: this.getIPConfigUIProperties_(ipv6) |
| - }; |
| + if (this.networkProperties.IPAddressConfigType ) { |
| + var ipConfigType = |
| + CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType); |
| + this.automatic_ = (ipConfigType != CrOnc.IPConfigType.STATIC); |
| + } |
| + |
| + if (this.networkProperties.IPConfigs) { |
| + // Update the 'ipConfig' property. |
| + var ipv4 = |
| + CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); |
| + var ipv6 = |
| + CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV6); |
| + this.ipConfig_ = { |
| + ipv4: this.getIPConfigUIProperties_(ipv4), |
| + ipv6: this.getIPConfigUIProperties_(ipv6) |
| + }; |
| + } |
| }, |
| - /** |
| - * Polymer automatic changed method. |
| - */ |
| + /** @private */ |
| automaticChanged_: function() { |
| if (!this.automatic_ || !this.ipConfig_) |
| return; |
| if (this.automatic_ || !this.savedStaticIp_) { |
| // Save the static IP configuration when switching to automatic. |
| this.savedStaticIp_ = this.ipConfig_.ipv4; |
| - var configType = |
| - this.automatic_ ? CrOnc.IPConfigType.DHCP : CrOnc.IPConfigType.STATIC; |
| - this.fire('ip-change', { |
| - field: 'IPAddressConfigType', |
| - value: configType, |
| - }); |
| } else { |
| // Restore the saved static IP configuration. |
| var ipconfig = { |
| @@ -122,9 +118,13 @@ Polymer({ |
| RoutingPrefix: this.savedStaticIp_.RoutingPrefix, |
| Type: this.savedStaticIp_.Type, |
| }; |
| + } |
| + // Only fire ip-change wehn switching to automatic. Changing to static IP |
|
michaelpg
2017/04/12 23:35:18
"when"
stevenjb
2017/04/13 00:04:47
Done.
|
| + // will occur when a field is changed. |
| + if (this.automatic_) { |
|
michaelpg
2017/04/12 23:35:18
the early return on 108 suggests this is never fal
stevenjb
2017/04/13 00:04:47
You're right. There's a bunch of dead / unnecessar
|
| this.fire('ip-change', { |
| - field: 'StaticIPConfig', |
| - value: this.getIPConfigProperties_(ipconfig), |
| + field: 'IPAddressConfigType', |
| + value: CrOnc.IPConfigType.DHCP, |
| }); |
| } |
| }, |
| @@ -203,6 +203,7 @@ Polymer({ |
| var value = event.detail.value; |
| // Note: |field| includes the 'ipv4.' prefix. |
| this.set('ipConfig_.' + field, value); |
| + // This will also set IPAddressConfigType to STATIC. |
| this.fire('ip-change', { |
| field: 'StaticIPConfig', |
| value: this.getIPConfigProperties_(this.ipConfig_.ipv4) |