Commit b59f96b2 authored by stevenjb's avatar stevenjb Committed by Commit bot

MD Settings: Network: Do not call setProperties when setting defaults

In https://codereview.chromium.org/2665913002 we set some default
network properties in currentRouteChanged. This was triggering
networkPropertiesChanged_ which udates autoConnect_ and
preferNetwork_ which triggers calls to setNetworkProperties.

To prevent this sort of error, set networkPropertiesReceived_
once properties are received from Chrome and do not call
networkingPrivate.setProperties until that has been set.

BUG=718389

Review-Url: https://codereview.chromium.org/2863713004
Cr-Commit-Position: refs/heads/master@{#469523}
parent 06014b12
...@@ -148,20 +148,24 @@ Polymer({ ...@@ -148,20 +148,24 @@ Polymer({
/** @private {boolean} */ /** @private {boolean} */
didSetFocus_: false, didSetFocus_: false,
/**
* Set to true to once the initial properties have been received. This
* prevents setProperties from being called when setting default properties.
* @private {boolean}
*/
networkPropertiesReceived_: false,
/** /**
* Set in currentRouteChanged() if the showConfigure URL query * Set in currentRouteChanged() if the showConfigure URL query
* parameter is set to true. The dialog cannot be shown until the * parameter is set to true. The dialog cannot be shown until the
* network properties have been fetched in * network properties have been fetched in networkPropertiesChanged_().
* networkPropertiesChanged_(). * @private {boolean}
* @type {boolean}
* @private
*/ */
shoudlShowConfigureWhenNetworkLoaded_: false, shoudlShowConfigureWhenNetworkLoaded_: false,
/** /**
* Whether the previous route was also the network detail page. * Whether the previous route was also the network detail page.
* @type {boolean} * @private {boolean}
* @private
*/ */
wasPreviousRouteNetworkDetailPage_: false, wasPreviousRouteNetworkDetailPage_: false,
...@@ -192,6 +196,7 @@ Polymer({ ...@@ -192,6 +196,7 @@ Polymer({
this.close_(); this.close_();
} }
// Set basic networkProperties until they are loaded. // Set basic networkProperties until they are loaded.
this.networkPropertiesReceived_ = false;
var type = /** @type {!chrome.networkingPrivate.NetworkType} */ ( var type = /** @type {!chrome.networkingPrivate.NetworkType} */ (
queryParams.get('type')) || queryParams.get('type')) ||
CrOnc.Type.WI_FI; CrOnc.Type.WI_FI;
...@@ -329,6 +334,7 @@ Polymer({ ...@@ -329,6 +334,7 @@ Polymer({
return; return;
} }
this.networkProperties = properties; this.networkProperties = properties;
this.networkPropertiesReceived_ = true;
}, },
/** /**
...@@ -349,6 +355,7 @@ Polymer({ ...@@ -349,6 +355,7 @@ Polymer({
Connectable: state.Connectable, Connectable: state.Connectable,
ConnectionState: state.ConnectionState, ConnectionState: state.ConnectionState,
}; };
this.networkPropertiesReceived_ = true;
}, },
/** /**
...@@ -357,6 +364,9 @@ Polymer({ ...@@ -357,6 +364,9 @@ Polymer({
* @private * @private
*/ */
setNetworkProperties_: function(onc) { setNetworkProperties_: function(onc) {
if (!this.networkPropertiesReceived_)
return;
assert(!!this.guid); assert(!!this.guid);
this.networkingPrivate.setProperties(this.guid, onc, function() { this.networkingPrivate.setProperties(this.guid, onc, function() {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment