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/network_ip_config.js

Issue 2817613002: MD Settings: Internet: IP Settings: Only set to static on change (Closed)
Patch Set: . 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Polymer element for displaying the IP Config properties for 6 * @fileoverview Polymer element for displaying the IP Config properties for
7 * a network state. TODO(stevenjb): Allow editing of static IP configurations 7 * a network state. TODO(stevenjb): Allow editing of static IP configurations
8 * when 'editable' is true. 8 * when 'editable' is true.
9 */ 9 */
10 Polymer({ 10 Polymer({
(...skipping 17 matching lines...) Expand all
28 type: Boolean, 28 type: Boolean,
29 value: false, 29 value: false,
30 }, 30 },
31 31
32 /** 32 /**
33 * State of 'Configure IP Addresses Automatically'. 33 * State of 'Configure IP Addresses Automatically'.
34 * @private 34 * @private
35 */ 35 */
36 automatic_: { 36 automatic_: {
37 type: Boolean, 37 type: Boolean,
38 value: false, 38 value: true,
39 observer: 'automaticChanged_', 39 observer: 'automaticChanged_',
40 }, 40 },
41 41
42 /** 42 /**
43 * The currently visible IP Config property dictionary. The 'RoutingPrefix' 43 * The currently visible IP Config property dictionary. The 'RoutingPrefix'
44 * property is a human-readable mask instead of a prefix length. 44 * property is a human-readable mask instead of a prefix length.
45 * @private {!{ 45 * @private {!{
46 * ipv4: !CrOnc.IPConfigUIProperties, 46 * ipv4: !CrOnc.IPConfigUIProperties,
47 * ipv6: !CrOnc.IPConfigUIProperties 47 * ipv6: !CrOnc.IPConfigUIProperties
48 * }|undefined} 48 * }|undefined}
(...skipping 28 matching lines...) Expand all
77 * Polymer networkProperties changed method. 77 * Polymer networkProperties changed method.
78 */ 78 */
79 networkPropertiesChanged_: function(newValue, oldValue) { 79 networkPropertiesChanged_: function(newValue, oldValue) {
80 if (!this.networkProperties) 80 if (!this.networkProperties)
81 return; 81 return;
82 82
83 if (newValue.GUID != (oldValue && oldValue.GUID)) 83 if (newValue.GUID != (oldValue && oldValue.GUID))
84 this.savedStaticIp_ = undefined; 84 this.savedStaticIp_ = undefined;
85 85
86 // Update the 'automatic' property. 86 // Update the 'automatic' property.
87 var ipConfigType = 87 if (this.networkProperties.IPAddressConfigType ) {
88 CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType); 88 var ipConfigType =
89 this.automatic_ = (ipConfigType != CrOnc.IPConfigType.STATIC); 89 CrOnc.getActiveValue(this.networkProperties.IPAddressConfigType);
90 this.automatic_ = (ipConfigType != CrOnc.IPConfigType.STATIC);
91 }
90 92
91 // Update the 'ipConfig' property. 93 if (this.networkProperties.IPConfigs) {
92 var ipv4 = 94 // Update the 'ipConfig' property.
93 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4); 95 var ipv4 =
94 var ipv6 = 96 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV4);
95 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV6); 97 var ipv6 =
96 this.ipConfig_ = { 98 CrOnc.getIPConfigForType(this.networkProperties, CrOnc.IPType.IPV6);
97 ipv4: this.getIPConfigUIProperties_(ipv4), 99 this.ipConfig_ = {
98 ipv6: this.getIPConfigUIProperties_(ipv6) 100 ipv4: this.getIPConfigUIProperties_(ipv4),
99 }; 101 ipv6: this.getIPConfigUIProperties_(ipv6)
102 };
103 }
100 }, 104 },
101 105
102 /** 106 /** @private */
103 * Polymer automatic changed method.
104 */
105 automaticChanged_: function() { 107 automaticChanged_: function() {
106 if (!this.automatic_ || !this.ipConfig_) 108 if (!this.automatic_ || !this.ipConfig_)
107 return; 109 return;
108 if (this.automatic_ || !this.savedStaticIp_) { 110 if (this.automatic_ || !this.savedStaticIp_) {
109 // Save the static IP configuration when switching to automatic. 111 // Save the static IP configuration when switching to automatic.
110 this.savedStaticIp_ = this.ipConfig_.ipv4; 112 this.savedStaticIp_ = this.ipConfig_.ipv4;
111 var configType =
112 this.automatic_ ? CrOnc.IPConfigType.DHCP : CrOnc.IPConfigType.STATIC;
113 this.fire('ip-change', {
114 field: 'IPAddressConfigType',
115 value: configType,
116 });
117 } else { 113 } else {
118 // Restore the saved static IP configuration. 114 // Restore the saved static IP configuration.
119 var ipconfig = { 115 var ipconfig = {
120 Gateway: this.savedStaticIp_.Gateway, 116 Gateway: this.savedStaticIp_.Gateway,
121 IPAddress: this.savedStaticIp_.IPAddress, 117 IPAddress: this.savedStaticIp_.IPAddress,
122 RoutingPrefix: this.savedStaticIp_.RoutingPrefix, 118 RoutingPrefix: this.savedStaticIp_.RoutingPrefix,
123 Type: this.savedStaticIp_.Type, 119 Type: this.savedStaticIp_.Type,
124 }; 120 };
121 }
122 // 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.
123 // will occur when a field is changed.
124 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
125 this.fire('ip-change', { 125 this.fire('ip-change', {
126 field: 'StaticIPConfig', 126 field: 'IPAddressConfigType',
127 value: this.getIPConfigProperties_(ipconfig), 127 value: CrOnc.IPConfigType.DHCP,
128 }); 128 });
129 } 129 }
130 }, 130 },
131 131
132 /** 132 /**
133 * @param {!CrOnc.IPConfigProperties|undefined} ipconfig 133 * @param {!CrOnc.IPConfigProperties|undefined} ipconfig
134 * @return {!CrOnc.IPConfigUIProperties} A new IPConfigUIProperties object 134 * @return {!CrOnc.IPConfigUIProperties} A new IPConfigUIProperties object
135 * with RoutingPrefix expressed as a string mask instead of a prefix 135 * with RoutingPrefix expressed as a string mask instead of a prefix
136 * length. Returns an empty object if |ipconfig| is undefined. 136 * length. Returns an empty object if |ipconfig| is undefined.
137 * @private 137 * @private
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 * network-property-list change event. 196 * network-property-list change event.
197 * @private 197 * @private
198 */ 198 */
199 onIPChange_: function(event) { 199 onIPChange_: function(event) {
200 if (!this.ipConfig_) 200 if (!this.ipConfig_)
201 return; 201 return;
202 var field = event.detail.field; 202 var field = event.detail.field;
203 var value = event.detail.value; 203 var value = event.detail.value;
204 // Note: |field| includes the 'ipv4.' prefix. 204 // Note: |field| includes the 'ipv4.' prefix.
205 this.set('ipConfig_.' + field, value); 205 this.set('ipConfig_.' + field, value);
206 // This will also set IPAddressConfigType to STATIC.
206 this.fire('ip-change', { 207 this.fire('ip-change', {
207 field: 'StaticIPConfig', 208 field: 'StaticIPConfig',
208 value: this.getIPConfigProperties_(this.ipConfig_.ipv4) 209 value: this.getIPConfigProperties_(this.ipConfig_.ipv4)
209 }); 210 });
210 }, 211 },
211 }); 212 });
OLDNEW
« 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