Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 type: Object, | 30 type: Object, |
| 31 observer: 'networkPropertiesChanged_', | 31 observer: 'networkPropertiesChanged_', |
| 32 }, | 32 }, |
| 33 | 33 |
| 34 /** Preferences state. */ | 34 /** Preferences state. */ |
| 35 prefs: { | 35 prefs: { |
| 36 type: Object, | 36 type: Object, |
| 37 notify: true, | 37 notify: true, |
| 38 }, | 38 }, |
| 39 | 39 |
| 40 /** Whether the user is a secondary user. */ | |
|
michaelpg
2016/12/13 23:49:54
nit: @private
stevenjb
2016/12/14 00:11:20
Done.
| |
| 41 isSecondaryUser_: { | |
| 42 type: Boolean, | |
| 43 value: function() { | |
| 44 return loadTimeData.getBoolean('isSecondaryUser'); | |
| 45 }, | |
| 46 readOnly: true, | |
| 47 }, | |
| 48 | |
| 49 /** Email address for the primary user when user is a secondary user. */ | |
| 50 primaryUserEmail_: { | |
| 51 type: String, | |
| 52 value: function() { | |
| 53 return loadTimeData.getBoolean('isSecondaryUser') ? | |
| 54 loadTimeData.getString('primaryUserEmail') : ''; | |
| 55 }, | |
| 56 readOnly: true, | |
| 57 }, | |
| 58 | |
| 40 /** | 59 /** |
| 41 * Highest priority connected network or null. | 60 * Highest priority connected network or null. |
| 42 * @type {?CrOnc.NetworkStateProperties} | 61 * @type {?CrOnc.NetworkStateProperties} |
| 43 */ | 62 */ |
| 44 defaultNetwork: { | 63 defaultNetwork: { |
| 45 type: Object, | 64 type: Object, |
| 46 value: null, | 65 value: null, |
| 47 }, | 66 }, |
| 48 | 67 |
| 49 /** | 68 /** |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 if (networkIds.indexOf(this.guid) != -1) | 219 if (networkIds.indexOf(this.guid) != -1) |
| 201 this.getNetworkDetails_(); | 220 this.getNetworkDetails_(); |
| 202 }, | 221 }, |
| 203 | 222 |
| 204 /** | 223 /** |
| 205 * Calls networkingPrivate.getProperties for this.guid. | 224 * Calls networkingPrivate.getProperties for this.guid. |
| 206 * @private | 225 * @private |
| 207 */ | 226 */ |
| 208 getNetworkDetails_: function() { | 227 getNetworkDetails_: function() { |
| 209 assert(!!this.guid); | 228 assert(!!this.guid); |
| 210 this.networkingPrivate.getManagedProperties( | 229 if (this.isSecondaryUser_) { |
| 211 this.guid, this.getPropertiesCallback_.bind(this)); | 230 this.networkingPrivate.getState( |
| 231 this.guid, this.getStateCallback_.bind(this)); | |
| 232 } else { | |
| 233 this.networkingPrivate.getManagedProperties( | |
| 234 this.guid, this.getPropertiesCallback_.bind(this)); | |
| 235 } | |
| 212 }, | 236 }, |
| 213 | 237 |
| 214 /** | 238 /** |
| 215 * networkingPrivate.getProperties callback. | 239 * networkingPrivate.getProperties callback. |
| 216 * @param {CrOnc.NetworkProperties} properties The network properties. | 240 * @param {CrOnc.NetworkProperties} properties The network properties. |
| 217 * @private | 241 * @private |
| 218 */ | 242 */ |
| 219 getPropertiesCallback_: function(properties) { | 243 getPropertiesCallback_: function(properties) { |
| 220 this.networkProperties = properties; | 244 this.networkProperties = properties; |
| 221 if (!properties) { | 245 if (!properties) { |
| 222 // If |properties| becomes null (i.e. the network is no longer visible), | 246 // If |properties| is null, the network is no longer visible, close this. |
| 223 // close the page. | |
| 224 console.error('Network no longer exists: ' + this.guid); | 247 console.error('Network no longer exists: ' + this.guid); |
| 225 this.close_(); | 248 this.close_(); |
| 226 } | 249 } |
| 227 }, | 250 }, |
| 228 | 251 |
| 229 /** | 252 /** |
| 253 * networkingPrivate.getState callback. | |
| 254 * @param {CrOnc.NetworkStateProperties} state The network state properties. | |
| 255 * @private | |
| 256 */ | |
| 257 getStateCallback_: function(state) { | |
| 258 if (!state) { | |
| 259 // If |state| is null, the network is no longer visible, close this. | |
| 260 console.error('Network no longer exists: ' + this.guid); | |
| 261 this.networkProperties = undefined; | |
| 262 this.close_(); | |
| 263 } | |
| 264 this.networkProperties = { | |
| 265 GUID: state.GUID, | |
| 266 Type: state.Type, | |
| 267 Connectable: state.Connectable, | |
| 268 ConnectionState: state.ConnectionState, | |
| 269 }; | |
| 270 }, | |
| 271 | |
| 272 /** | |
| 230 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC | 273 * @param {!chrome.networkingPrivate.NetworkConfigProperties} onc The ONC |
| 231 * network properties. | 274 * network properties. |
| 232 * @private | 275 * @private |
| 233 */ | 276 */ |
| 234 setNetworkProperties_: function(onc) { | 277 setNetworkProperties_: function(onc) { |
| 235 assert(!!this.guid); | 278 assert(!!this.guid); |
| 236 this.networkingPrivate.setProperties(this.guid, onc, function() { | 279 this.networkingPrivate.setProperties(this.guid, onc, function() { |
| 237 if (chrome.runtime.lastError) { | 280 if (chrome.runtime.lastError) { |
| 238 // An error typically indicates invalid input; request the properties | 281 // An error typically indicates invalid input; request the properties |
| 239 // to update any invalid fields. | 282 // to update any invalid fields. |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 */ | 806 */ |
| 764 allPropertiesMatch_: function(curValue, newValue) { | 807 allPropertiesMatch_: function(curValue, newValue) { |
| 765 for (let key in newValue) { | 808 for (let key in newValue) { |
| 766 if (newValue[key] != curValue[key]) | 809 if (newValue[key] != curValue[key]) |
| 767 return false; | 810 return false; |
| 768 } | 811 } |
| 769 return true; | 812 return true; |
| 770 } | 813 } |
| 771 }); | 814 }); |
| 772 })(); | 815 })(); |
| OLD | NEW |