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

Side by Side Diff: chrome/browser/resources/settings/internet_page/internet_detail_page.js

Issue 2863713004: MD Settings: Network: Do not call setProperties when setting defaults (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | 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 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 * Listener function for chrome.networkingPrivate.onNetworksChanged event. 142 * Listener function for chrome.networkingPrivate.onNetworksChanged event.
143 * @type {?function(!Array<string>)} 143 * @type {?function(!Array<string>)}
144 * @private 144 * @private
145 */ 145 */
146 networksChangedListener_: null, 146 networksChangedListener_: null,
147 147
148 /** @private {boolean} */ 148 /** @private {boolean} */
149 didSetFocus_: false, 149 didSetFocus_: false,
150 150
151 /** 151 /**
152 * Set to true to once the initial properties have been received. This
153 * prevents setProperties from being called when setting default properties.
154 * @private {boolean}
155 */
156 networkPropertiesReceived_: false,
157
158 /**
152 * Set in currentRouteChanged() if the showConfigure URL query 159 * Set in currentRouteChanged() if the showConfigure URL query
153 * parameter is set to true. The dialog cannot be shown until the 160 * parameter is set to true. The dialog cannot be shown until the
154 * network properties have been fetched in 161 * network properties have been fetched in networkPropertiesChanged_().
155 * networkPropertiesChanged_(). 162 * @private {boolean}
156 * @type {boolean}
157 * @private
158 */ 163 */
159 shoudlShowConfigureWhenNetworkLoaded_: false, 164 shoudlShowConfigureWhenNetworkLoaded_: false,
160 165
161 /** 166 /**
162 * Whether the previous route was also the network detail page. 167 * Whether the previous route was also the network detail page.
163 * @type {boolean} 168 * @private {boolean}
164 * @private
165 */ 169 */
166 wasPreviousRouteNetworkDetailPage_: false, 170 wasPreviousRouteNetworkDetailPage_: false,
167 171
168 /** 172 /**
169 * settings.RouteObserverBehavior 173 * settings.RouteObserverBehavior
170 * @param {!settings.Route} route 174 * @param {!settings.Route} route
171 * @param {!settings.Route} oldRoute 175 * @param {!settings.Route} oldRoute
172 * @protected 176 * @protected
173 */ 177 */
174 currentRouteChanged: function(route, oldRoute) { 178 currentRouteChanged: function(route, oldRoute) {
(...skipping 10 matching lines...) Expand all
185 this.networkingPrivate.onNetworksChanged.addListener( 189 this.networkingPrivate.onNetworksChanged.addListener(
186 this.networksChangedListener_); 190 this.networksChangedListener_);
187 } 191 }
188 var queryParams = settings.getQueryParameters(); 192 var queryParams = settings.getQueryParameters();
189 this.guid = queryParams.get('guid') || ''; 193 this.guid = queryParams.get('guid') || '';
190 if (!this.guid) { 194 if (!this.guid) {
191 console.error('No guid specified for page:' + route); 195 console.error('No guid specified for page:' + route);
192 this.close_(); 196 this.close_();
193 } 197 }
194 // Set basic networkProperties until they are loaded. 198 // Set basic networkProperties until they are loaded.
199 this.networkPropertiesReceived_ = false;
195 var type = /** @type {!chrome.networkingPrivate.NetworkType} */ ( 200 var type = /** @type {!chrome.networkingPrivate.NetworkType} */ (
196 queryParams.get('type')) || 201 queryParams.get('type')) ||
197 CrOnc.Type.WI_FI; 202 CrOnc.Type.WI_FI;
198 this.shoudlShowConfigureWhenNetworkLoaded_ = 203 this.shoudlShowConfigureWhenNetworkLoaded_ =
199 queryParams.get('showConfigure') == 'true'; 204 queryParams.get('showConfigure') == 'true';
200 this.wasPreviousRouteNetworkDetailPage_ = 205 this.wasPreviousRouteNetworkDetailPage_ =
201 oldRoute == settings.Route.NETWORK_DETAIL; 206 oldRoute == settings.Route.NETWORK_DETAIL;
202 var name = queryParams.get('name') || type; 207 var name = queryParams.get('name') || type;
203 this.networkProperties = { 208 this.networkProperties = {
204 GUID: this.guid, 209 GUID: this.guid,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 327 }
323 this.close_(); 328 this.close_();
324 return; 329 return;
325 } 330 }
326 if (!properties) { 331 if (!properties) {
327 console.error('No properties for: ' + this.guid); 332 console.error('No properties for: ' + this.guid);
328 this.close_(); 333 this.close_();
329 return; 334 return;
330 } 335 }
331 this.networkProperties = properties; 336 this.networkProperties = properties;
337 this.networkPropertiesReceived_ = true;
332 }, 338 },
333 339
334 /** 340 /**
335 * networkingPrivate.getState callback. 341 * networkingPrivate.getState callback.
336 * @param {CrOnc.NetworkStateProperties} state The network state properties. 342 * @param {CrOnc.NetworkStateProperties} state The network state properties.
337 * @private 343 * @private
338 */ 344 */
339 getStateCallback_: function(state) { 345 getStateCallback_: function(state) {
340 if (!state) { 346 if (!state) {
341 // If |state| is null, the network is no longer visible, close this. 347 // If |state| is null, the network is no longer visible, close this.
342 console.error('Network no longer exists: ' + this.guid); 348 console.error('Network no longer exists: ' + this.guid);
343 this.networkProperties = undefined; 349 this.networkProperties = undefined;
344 this.close_(); 350 this.close_();
345 } 351 }
346 this.networkProperties = { 352 this.networkProperties = {
347 GUID: state.GUID, 353 GUID: state.GUID,
348 Type: state.Type, 354 Type: state.Type,
349 Connectable: state.Connectable, 355 Connectable: state.Connectable,
350 ConnectionState: state.ConnectionState, 356 ConnectionState: state.ConnectionState,
351 }; 357 };
358 this.networkPropertiesReceived_ = true;
352 }, 359 },
353 360
354 /** 361 /**
355 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC 362 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC
356 * network properties. 363 * network properties.
357 * @private 364 * @private
358 */ 365 */
359 setNetworkProperties_: function(onc) { 366 setNetworkProperties_: function(onc) {
367 if (!this.networkPropertiesReceived_)
368 return;
369
360 assert(!!this.guid); 370 assert(!!this.guid);
361 this.networkingPrivate.setProperties(this.guid, onc, function() { 371 this.networkingPrivate.setProperties(this.guid, onc, function() {
362 if (chrome.runtime.lastError) { 372 if (chrome.runtime.lastError) {
363 // An error typically indicates invalid input; request the properties 373 // An error typically indicates invalid input; request the properties
364 // to update any invalid fields. 374 // to update any invalid fields.
365 this.getNetworkDetails_(); 375 this.getNetworkDetails_();
366 } 376 }
367 }.bind(this)); 377 }.bind(this));
368 }, 378 },
369 379
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 */ 1018 */
1009 allPropertiesMatch_: function(curValue, newValue) { 1019 allPropertiesMatch_: function(curValue, newValue) {
1010 for (var key in newValue) { 1020 for (var key in newValue) {
1011 if (newValue[key] != curValue[key]) 1021 if (newValue[key] != curValue[key])
1012 return false; 1022 return false;
1013 } 1023 }
1014 return true; 1024 return true;
1015 } 1025 }
1016 }); 1026 });
1017 })(); 1027 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698