| OLD | NEW |
| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 }, | 138 }, |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Listener function for chrome.networkingPrivate.onNetworksChanged event. | 141 * Listener function for chrome.networkingPrivate.onNetworksChanged event. |
| 142 * @type {?function(!Array<string>)} | 142 * @type {?function(!Array<string>)} |
| 143 * @private | 143 * @private |
| 144 */ | 144 */ |
| 145 networksChangedListener_: null, | 145 networksChangedListener_: null, |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Set to true to once the initial properties have been received. This |
| 149 * prevents setProperties from being called when setting default properties. |
| 150 * @private {boolean} |
| 151 */ |
| 152 networkPropertiesReceived_: false, |
| 153 |
| 154 /** |
| 148 * settings.RouteObserverBehavior | 155 * settings.RouteObserverBehavior |
| 149 * @param {!settings.Route} route | 156 * @param {!settings.Route} route |
| 150 * @protected | 157 * @protected |
| 151 */ | 158 */ |
| 152 currentRouteChanged: function(route) { | 159 currentRouteChanged: function(route) { |
| 153 if (route != settings.Route.NETWORK_DETAIL) { | 160 if (route != settings.Route.NETWORK_DETAIL) { |
| 154 if (this.networksChangedListener_) { | 161 if (this.networksChangedListener_) { |
| 155 this.networkingPrivate.onNetworksChanged.removeListener( | 162 this.networkingPrivate.onNetworksChanged.removeListener( |
| 156 this.networksChangedListener_); | 163 this.networksChangedListener_); |
| 157 this.networksChangedListener_ = null; | 164 this.networksChangedListener_ = null; |
| 158 } | 165 } |
| 159 return; | 166 return; |
| 160 } | 167 } |
| 161 if (!this.networksChangedListener_) { | 168 if (!this.networksChangedListener_) { |
| 162 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); | 169 this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); |
| 163 this.networkingPrivate.onNetworksChanged.addListener( | 170 this.networkingPrivate.onNetworksChanged.addListener( |
| 164 this.networksChangedListener_); | 171 this.networksChangedListener_); |
| 165 } | 172 } |
| 166 var queryParams = settings.getQueryParameters(); | 173 var queryParams = settings.getQueryParameters(); |
| 167 this.guid = queryParams.get('guid') || ''; | 174 this.guid = queryParams.get('guid') || ''; |
| 168 if (!this.guid) { | 175 if (!this.guid) { |
| 169 console.error('No guid specified for page:' + route); | 176 console.error('No guid specified for page:' + route); |
| 170 this.close_(); | 177 this.close_(); |
| 171 } | 178 } |
| 172 // Set basic networkProperties until they are loaded. | 179 // Set basic networkProperties until they are loaded. |
| 180 this.networkPropertiesReceived_ = false; |
| 173 var type = /** @type {!chrome.networkingPrivate.NetworkType} */ ( | 181 var type = /** @type {!chrome.networkingPrivate.NetworkType} */ ( |
| 174 queryParams.get('type')) || | 182 queryParams.get('type')) || |
| 175 CrOnc.Type.WI_FI; | 183 CrOnc.Type.WI_FI; |
| 176 var name = queryParams.get('name') || type; | 184 var name = queryParams.get('name') || type; |
| 177 this.networkProperties = { | 185 this.networkProperties = { |
| 178 GUID: this.guid, | 186 GUID: this.guid, |
| 179 Type: type, | 187 Type: type, |
| 180 ConnectionState: CrOnc.ConnectionState.NOT_CONNECTED, | 188 ConnectionState: CrOnc.ConnectionState.NOT_CONNECTED, |
| 181 Name: {Active: name}, | 189 Name: {Active: name}, |
| 182 }; | 190 }; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 286 } |
| 279 this.close_(); | 287 this.close_(); |
| 280 return; | 288 return; |
| 281 } | 289 } |
| 282 if (!properties) { | 290 if (!properties) { |
| 283 console.error('No properties for: ' + this.guid); | 291 console.error('No properties for: ' + this.guid); |
| 284 this.close_(); | 292 this.close_(); |
| 285 return; | 293 return; |
| 286 } | 294 } |
| 287 this.networkProperties = properties; | 295 this.networkProperties = properties; |
| 296 this.networkPropertiesReceived_ = true; |
| 288 }, | 297 }, |
| 289 | 298 |
| 290 /** | 299 /** |
| 291 * networkingPrivate.getState callback. | 300 * networkingPrivate.getState callback. |
| 292 * @param {CrOnc.NetworkStateProperties} state The network state properties. | 301 * @param {CrOnc.NetworkStateProperties} state The network state properties. |
| 293 * @private | 302 * @private |
| 294 */ | 303 */ |
| 295 getStateCallback_: function(state) { | 304 getStateCallback_: function(state) { |
| 296 if (!state) { | 305 if (!state) { |
| 297 // If |state| is null, the network is no longer visible, close this. | 306 // If |state| is null, the network is no longer visible, close this. |
| 298 console.error('Network no longer exists: ' + this.guid); | 307 console.error('Network no longer exists: ' + this.guid); |
| 299 this.networkProperties = undefined; | 308 this.networkProperties = undefined; |
| 300 this.close_(); | 309 this.close_(); |
| 301 } | 310 } |
| 302 this.networkProperties = { | 311 this.networkProperties = { |
| 303 GUID: state.GUID, | 312 GUID: state.GUID, |
| 304 Type: state.Type, | 313 Type: state.Type, |
| 305 Connectable: state.Connectable, | 314 Connectable: state.Connectable, |
| 306 ConnectionState: state.ConnectionState, | 315 ConnectionState: state.ConnectionState, |
| 307 }; | 316 }; |
| 317 this.networkPropertiesReceived_ = true; |
| 308 }, | 318 }, |
| 309 | 319 |
| 310 /** | 320 /** |
| 311 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC | 321 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC |
| 312 * network properties. | 322 * network properties. |
| 313 * @private | 323 * @private |
| 314 */ | 324 */ |
| 315 setNetworkProperties_: function(onc) { | 325 setNetworkProperties_: function(onc) { |
| 326 if (!this.networkPropertiesReceived_) |
| 327 return; |
| 328 |
| 316 assert(!!this.guid); | 329 assert(!!this.guid); |
| 317 this.networkingPrivate.setProperties(this.guid, onc, function() { | 330 this.networkingPrivate.setProperties(this.guid, onc, function() { |
| 318 if (chrome.runtime.lastError) { | 331 if (chrome.runtime.lastError) { |
| 319 // An error typically indicates invalid input; request the properties | 332 // An error typically indicates invalid input; request the properties |
| 320 // to update any invalid fields. | 333 // to update any invalid fields. |
| 321 this.getNetworkDetails_(); | 334 this.getNetworkDetails_(); |
| 322 } | 335 } |
| 323 }.bind(this)); | 336 }.bind(this)); |
| 324 }, | 337 }, |
| 325 | 338 |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 */ | 939 */ |
| 927 allPropertiesMatch_: function(curValue, newValue) { | 940 allPropertiesMatch_: function(curValue, newValue) { |
| 928 for (var key in newValue) { | 941 for (var key in newValue) { |
| 929 if (newValue[key] != curValue[key]) | 942 if (newValue[key] != curValue[key]) |
| 930 return false; | 943 return false; |
| 931 } | 944 } |
| 932 return true; | 945 return true; |
| 933 } | 946 } |
| 934 }); | 947 }); |
| 935 })(); | 948 })(); |
| OLD | NEW |