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

Unified Diff: chrome/browser/resources/settings/internet_page/network_ip_config.js

Issue 2817613002: MD Settings: Internet: IP Settings: Only set to static on change (Closed)
Patch Set: Feedback / elim dead code Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/settings/internet_page/internet_detail_page.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2d056e69fa83b15876e72686ae3b35dbb5688948 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,49 +84,39 @@ 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_)
+ if (!this.automatic_ || !this.ipConfig_) {
+ // When switching from automatic, don't send any changes, ip-change will
+ // be fired in onIPChange when a field is changed.
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 = {
- Gateway: this.savedStaticIp_.Gateway,
- IPAddress: this.savedStaticIp_.IPAddress,
- RoutingPrefix: this.savedStaticIp_.RoutingPrefix,
- Type: this.savedStaticIp_.Type,
- };
- this.fire('ip-change', {
- field: 'StaticIPConfig',
- value: this.getIPConfigProperties_(ipconfig),
- });
}
+ // Save the static IP configuration when switching to automatic.
+ this.savedStaticIp_ = this.ipConfig_.ipv4;
+ // Send the change.
+ this.fire('ip-change', {
+ field: 'IPAddressConfigType',
+ value: CrOnc.IPConfigType.DHCP,
+ });
},
/**
@@ -203,6 +193,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)
« no previous file with comments | « chrome/browser/resources/settings/internet_page/internet_detail_page.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698