| 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 Polymer element for displaying and modifying a list of cellular | 6 * @fileoverview Polymer element for displaying and modifying a list of cellular |
| 7 * access points. | 7 * access points. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'network-apnlist', | 10 is: 'network-apnlist', |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 otherApn.AccessPointName = | 132 otherApn.AccessPointName = |
| 133 otherApn.AccessPointName || this.DefaultAccessPointName; | 133 otherApn.AccessPointName || this.DefaultAccessPointName; |
| 134 | 134 |
| 135 // Save the 'other' properties. | 135 // Save the 'other' properties. |
| 136 this.otherApn_ = otherApn; | 136 this.otherApn_ = otherApn; |
| 137 | 137 |
| 138 // Append 'other' to the end of the list of APNs. | 138 // Append 'other' to the end of the list of APNs. |
| 139 result.push(otherApn); | 139 result.push(otherApn); |
| 140 | 140 |
| 141 this.apnSelectList_ = result; | 141 this.apnSelectList_ = result; |
| 142 this.selectedApn_ = | 142 // Set selectedApn_ after dom-repeat has been stamped. |
| 143 (activeApn && activeApn.AccessPointName) || otherApn.AccessPointName; | 143 this.async(function() { |
| 144 // We need to flush the DOM here, otherwise the paper-dropdown-menu-light | 144 this.selectedApn_ = |
| 145 // will not update to correctly display the selected AccessPointName. | 145 (activeApn && activeApn.AccessPointName) || otherApn.AccessPointName; |
| 146 Polymer.dom.flush(); | 146 }.bind(this)); |
| 147 }, | 147 }, |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * @param {!CrOnc.APNProperties|undefined=} apnProperties | 150 * @param {!CrOnc.APNProperties|undefined=} apnProperties |
| 151 * @return {!CrOnc.APNProperties} A new APN object with properties from | 151 * @return {!CrOnc.APNProperties} A new APN object with properties from |
| 152 * |apnProperties| if provided. | 152 * |apnProperties| if provided. |
| 153 * @private | 153 * @private |
| 154 */ | 154 */ |
| 155 createApnObject_: function(apnProperties) { | 155 createApnObject_: function(apnProperties) { |
| 156 var newApn = {AccessPointName: ''}; | 156 var newApn = {AccessPointName: ''}; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 170 /** @type {!chrome.networkingPrivate.ManagedAPNList|undefined} */ var | 170 /** @type {!chrome.networkingPrivate.ManagedAPNList|undefined} */ var |
| 171 apnlist = this.networkProperties.Cellular.APNList; | 171 apnlist = this.networkProperties.Cellular.APNList; |
| 172 if (!apnlist) | 172 if (!apnlist) |
| 173 return []; | 173 return []; |
| 174 return /** @type {!Array<!CrOnc.APNProperties>} */ ( | 174 return /** @type {!Array<!CrOnc.APNProperties>} */ ( |
| 175 CrOnc.getActiveValue(apnlist)); | 175 CrOnc.getActiveValue(apnlist)); |
| 176 }, | 176 }, |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * Event triggered when the selectApn selection changes. | 179 * Event triggered when the selectApn selection changes. |
| 180 * @param {!{detail: !{selected: string}}} event | 180 * @param {!Event} event |
| 181 * @private | 181 * @private |
| 182 */ | 182 */ |
| 183 onSelectApnChange_: function(event) { | 183 onSelectApnChange_: function(event) { |
| 184 /** @type {string} */ var accessPointName = event.detail.selected; | 184 let target = /** @type {!HTMLSelectElement} */(event.target); |
| 185 var accessPointName = target.value; |
| 185 // When selecting 'Other', don't set a change event unless a valid | 186 // When selecting 'Other', don't set a change event unless a valid |
| 186 // non-default value has been set for Other. | 187 // non-default value has been set for Other. |
| 187 if (this.isOtherSelected_(accessPointName) && | 188 if (this.isOtherSelected_(accessPointName) && |
| 188 (!this.otherApn_ || !this.otherApn_.AccessPointName || | 189 (!this.otherApn_ || !this.otherApn_.AccessPointName || |
| 189 this.otherApn_.AccessPointName == this.DefaultAccessPointName)) { | 190 this.otherApn_.AccessPointName == this.DefaultAccessPointName)) { |
| 191 this.selectedApn_ = accessPointName; |
| 190 return; | 192 return; |
| 191 } | 193 } |
| 192 this.sendApnChange_(accessPointName); | 194 this.sendApnChange_(accessPointName); |
| 193 }, | 195 }, |
| 194 | 196 |
| 195 /** | 197 /** |
| 196 * Event triggered when any 'Other' APN network property changes. | 198 * Event triggered when any 'Other' APN network property changes. |
| 197 * @param {!{detail: {field: string, value: string}}} event | 199 * @param {!{detail: {field: string, value: string}}} event |
| 198 * @private | 200 * @private |
| 199 */ | 201 */ |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 * @private | 262 * @private |
| 261 */ | 263 */ |
| 262 findApnInList: function(apnList, accessPointName) { | 264 findApnInList: function(apnList, accessPointName) { |
| 263 for (let a of apnList) { | 265 for (let a of apnList) { |
| 264 if (a.AccessPointName == accessPointName) | 266 if (a.AccessPointName == accessPointName) |
| 265 return a; | 267 return a; |
| 266 } | 268 } |
| 267 return undefined; | 269 return undefined; |
| 268 } | 270 } |
| 269 }); | 271 }); |
| OLD | NEW |