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 Polymer element for displaying and modifying cellular sim info. | 6 * @fileoverview Polymer element for displaying and modifying cellular sim info. |
| 7 */ | 7 */ |
| 8 (function() { | 8 (function() { |
| 9 | 9 |
| 10 /** @enum {string} */ | 10 /** @enum {string} */ |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 observer: 'networkPropertiesChanged_', | 33 observer: 'networkPropertiesChanged_', |
| 34 }, | 34 }, |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Interface for networkingPrivate calls, passed from internet_page. | 37 * Interface for networkingPrivate calls, passed from internet_page. |
| 38 * @type {NetworkingPrivate} | 38 * @type {NetworkingPrivate} |
| 39 */ | 39 */ |
| 40 networkingPrivate: Object, | 40 networkingPrivate: Object, |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Reflects networkProperties.Cellular.SIMLockStatus.LockEnabled for the | |
| 44 * toggle button. | |
| 45 * @private | |
| 46 */ | |
| 47 lockEnabled_: { | |
| 48 type: Boolean, | |
| 49 value: false, | |
| 50 }, | |
| 51 | |
| 52 /** | |
| 43 * Set to true when a PUK is required to unlock the SIM. | 53 * Set to true when a PUK is required to unlock the SIM. |
| 44 * @private | 54 * @private |
| 45 */ | 55 */ |
| 46 pukRequired_: { | 56 pukRequired_: { |
| 47 type: Boolean, | 57 type: Boolean, |
| 48 value: false, | 58 value: false, |
| 49 observer: 'pukRequiredChanged_', | 59 observer: 'pukRequiredChanged_', |
| 50 }, | 60 }, |
| 51 | 61 |
| 52 /** | 62 /** |
| 53 * Set to an ErrorType value after an incorrect PIN or PUK entry. | 63 * Set to an ErrorType value after an incorrect PIN or PUK entry. |
| 54 * @private {ErrorType} | 64 * @private {ErrorType} |
| 55 */ | 65 */ |
| 56 error_: { | 66 error_: { |
| 57 type: Object, | 67 type: Object, |
| 58 value: ErrorType.NONE, | 68 value: ErrorType.NONE, |
| 59 }, | 69 }, |
| 60 }, | 70 }, |
| 61 | 71 |
| 62 sendSimLockEnabled_: false, | 72 sendSimLockEnabled_: false, |
| 63 | 73 |
| 64 networkPropertiesChanged_: function() { | 74 networkPropertiesChanged_: function() { |
|
dpapad
2017/04/17 17:57:17
@private missing here and at |pukRequiredChanged_|
stevenjb
2017/04/17 18:08:34
Done.
| |
| 65 if (!this.networkProperties || !this.networkProperties.Cellular) | 75 if (!this.networkProperties || !this.networkProperties.Cellular) |
| 66 return; | 76 return; |
| 67 var simLockStatus = this.networkProperties.Cellular.SIMLockStatus; | 77 var simLockStatus = this.networkProperties.Cellular.SIMLockStatus; |
| 68 this.pukRequired_ = | 78 this.pukRequired_ = |
| 69 !!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK; | 79 !!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK; |
| 80 this.lockEnabled_ = simLockStatus.LockEnabled; | |
| 70 }, | 81 }, |
| 71 | 82 |
| 72 pukRequiredChanged_: function() { | 83 pukRequiredChanged_: function() { |
| 73 if (this.$.unlockPukDialog.open) { | 84 if (this.$.unlockPukDialog.open) { |
| 74 if (this.pukRequired_) | 85 if (this.pukRequired_) |
| 75 this.$.unlockPuk.focus(); | 86 this.$.unlockPuk.focus(); |
| 76 else | 87 else |
| 77 this.$.unlockPukDialog.close(); | 88 this.$.unlockPukDialog.close(); |
| 78 return; | 89 return; |
| 79 } | 90 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 105 /** | 116 /** |
| 106 * Opens the pin dialog when the sim lock enabled state changes. | 117 * Opens the pin dialog when the sim lock enabled state changes. |
| 107 * @param {Event} event | 118 * @param {Event} event |
| 108 * @private | 119 * @private |
| 109 */ | 120 */ |
| 110 onSimLockEnabledChange_: function(event) { | 121 onSimLockEnabledChange_: function(event) { |
| 111 if (!this.networkProperties || !this.networkProperties.Cellular) | 122 if (!this.networkProperties || !this.networkProperties.Cellular) |
| 112 return; | 123 return; |
| 113 this.sendSimLockEnabled_ = event.target.checked; | 124 this.sendSimLockEnabled_ = event.target.checked; |
| 114 this.error_ = ErrorType.NONE; | 125 this.error_ = ErrorType.NONE; |
| 126 this.$.enterPin.value = ''; | |
| 115 this.$.enterPinDialog.showModal(); | 127 this.$.enterPinDialog.showModal(); |
| 116 this.$.enterPin.value = ''; | 128 this.$.enterPin.focus(); |
|
dpapad
2017/04/17 17:57:17
Can we use the |autofocus| attribute instead? See
stevenjb
2017/04/17 18:08:34
Ah, yes, indeed we can. Done.
| |
| 117 }, | 129 }, |
| 118 | 130 |
| 119 /** | 131 /** |
| 120 * Sends the PIN value from the Enter PIN dialog. | 132 * Sends the PIN value from the Enter PIN dialog. |
| 121 * @param {Event} event | 133 * @param {Event} event |
| 122 * @private | 134 * @private |
| 123 */ | 135 */ |
| 124 sendEnterPin_: function(event) { | 136 sendEnterPin_: function(event) { |
| 125 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; | 137 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; |
| 126 var pin = this.$.enterPin.value; | 138 var pin = this.$.enterPin.value; |
| 127 if (!this.validatePin_(pin)) | 139 if (!this.validatePin_(pin)) { |
| 140 this.onEnterPinDialogCancel_(); | |
| 128 return; | 141 return; |
| 129 | 142 } |
| 130 var simState = /** @type {!CrOnc.CellularSimState} */ ({ | 143 var simState = /** @type {!CrOnc.CellularSimState} */ ({ |
| 131 currentPin: pin, | 144 currentPin: pin, |
| 132 requirePin: this.sendSimLockEnabled_, | 145 requirePin: this.sendSimLockEnabled_, |
| 133 }); | 146 }); |
| 134 this.networkingPrivate.setCellularSimState(guid, simState, function() { | 147 this.networkingPrivate.setCellularSimState(guid, simState, function() { |
| 135 if (chrome.runtime.lastError) { | 148 if (chrome.runtime.lastError) { |
| 136 this.error_ = ErrorType.INCORRECT_PIN; | 149 this.error_ = ErrorType.INCORRECT_PIN; |
| 137 this.$.enterPin.inputElement.select(); | 150 this.$.enterPin.inputElement.select(); |
| 138 } else { | 151 } else { |
| 139 this.error_ = ErrorType.NONE; | 152 this.error_ = ErrorType.NONE; |
| 140 this.$.enterPinDialog.close(); | 153 this.$.enterPinDialog.close(); |
| 141 } | 154 } |
| 142 }.bind(this)); | 155 }.bind(this)); |
| 143 }, | 156 }, |
| 144 | 157 |
| 145 /** | 158 /** |
| 146 * Opens the Change PIN dialog. | 159 * Opens the Change PIN dialog. |
| 147 * @param {!Event} event | 160 * @param {!Event} event |
| 148 * @private | 161 * @private |
| 149 */ | 162 */ |
| 150 onChangePinTap_: function(event) { | 163 onChangePinTap_: function(event) { |
| 151 if (!this.networkProperties || !this.networkProperties.Cellular) | 164 if (!this.networkProperties || !this.networkProperties.Cellular) |
| 152 return; | 165 return; |
| 153 event.preventDefault(); | 166 event.preventDefault(); |
| 154 this.error_ = ErrorType.NONE; | 167 this.error_ = ErrorType.NONE; |
| 155 this.$.changePinDialog.showModal(); | |
| 156 this.$.changePinOld.value = ''; | 168 this.$.changePinOld.value = ''; |
| 157 this.$.changePinNew1.value = ''; | 169 this.$.changePinNew1.value = ''; |
| 158 this.$.changePinNew2.value = ''; | 170 this.$.changePinNew2.value = ''; |
| 171 this.$.changePinDialog.showModal(); | |
| 172 this.$.changePinOld.focus(); | |
| 159 }, | 173 }, |
| 160 | 174 |
| 161 /** | 175 /** |
| 162 * Sends the old and new PIN values from the Change PIN dialog. | 176 * Sends the old and new PIN values from the Change PIN dialog. |
| 163 * @param {Event} event | 177 * @param {Event} event |
| 164 * @private | 178 * @private |
| 165 */ | 179 */ |
| 166 sendChangePin_: function(event) { | 180 sendChangePin_: function(event) { |
| 167 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; | 181 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; |
| 168 var newPin = this.$.changePinNew1.value; | 182 var newPin = this.$.changePinNew1.value; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 186 }, | 200 }, |
| 187 | 201 |
| 188 /** | 202 /** |
| 189 * Opens the Unlock PIN dialog. | 203 * Opens the Unlock PIN dialog. |
| 190 * @param {!Event} event | 204 * @param {!Event} event |
| 191 * @private | 205 * @private |
| 192 */ | 206 */ |
| 193 onUnlockPinTap_: function(event) { | 207 onUnlockPinTap_: function(event) { |
| 194 event.preventDefault(); | 208 event.preventDefault(); |
| 195 this.error_ = ErrorType.NONE; | 209 this.error_ = ErrorType.NONE; |
| 210 this.$.unlockPin.value = ''; | |
| 196 this.$.unlockPinDialog.showModal(); | 211 this.$.unlockPinDialog.showModal(); |
| 197 this.$.unlockPin.value = ''; | 212 this.$.unlockPin.focus(); |
| 198 }, | 213 }, |
| 199 | 214 |
| 200 /** | 215 /** |
| 201 * Sends the PIN value from the Unlock PIN dialog. | 216 * Sends the PIN value from the Unlock PIN dialog. |
| 202 * @param {Event} event | 217 * @param {Event} event |
| 203 * @private | 218 * @private |
| 204 */ | 219 */ |
| 205 sendUnlockPin_: function(event) { | 220 sendUnlockPin_: function(event) { |
| 206 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; | 221 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; |
| 207 var pin = this.$.unlockPin.value; | 222 var pin = this.$.unlockPin.value; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 219 }.bind(this)); | 234 }.bind(this)); |
| 220 }, | 235 }, |
| 221 | 236 |
| 222 /** @private */ | 237 /** @private */ |
| 223 showUnlockPukDialog_: function() { | 238 showUnlockPukDialog_: function() { |
| 224 this.error_ = ErrorType.NONE; | 239 this.error_ = ErrorType.NONE; |
| 225 this.$.unlockPuk.value = ''; | 240 this.$.unlockPuk.value = ''; |
| 226 this.$.unlockPin1.value = ''; | 241 this.$.unlockPin1.value = ''; |
| 227 this.$.unlockPin2.value = ''; | 242 this.$.unlockPin2.value = ''; |
| 228 this.$.unlockPukDialog.showModal(); | 243 this.$.unlockPukDialog.showModal(); |
| 244 this.$.unlockPuk.focus(); | |
| 229 }, | 245 }, |
| 230 | 246 |
| 231 /** | 247 /** |
| 232 * Sends the PUK value and new PIN value from the Unblock PUK dialog. | 248 * Sends the PUK value and new PIN value from the Unblock PUK dialog. |
| 233 * @param {Event} event | 249 * @param {Event} event |
| 234 * @private | 250 * @private |
| 235 */ | 251 */ |
| 236 sendUnlockPuk_: function(event) { | 252 sendUnlockPuk_: function(event) { |
| 237 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; | 253 var guid = (this.networkProperties && this.networkProperties.GUID) || ''; |
| 238 var puk = this.$.unlockPuk.value; | 254 var puk = this.$.unlockPuk.value; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 */ | 349 */ |
| 334 validatePuk_: function(puk) { | 350 validatePuk_: function(puk) { |
| 335 if (puk.length < PUK_MIN_LENGTH) { | 351 if (puk.length < PUK_MIN_LENGTH) { |
| 336 this.error_ = ErrorType.INVALID_PUK; | 352 this.error_ = ErrorType.INVALID_PUK; |
| 337 return false; | 353 return false; |
| 338 } | 354 } |
| 339 return true; | 355 return true; |
| 340 }, | 356 }, |
| 341 | 357 |
| 342 /** @private */ | 358 /** @private */ |
| 343 onEnterPinDialogClosed_: function() { | 359 onEnterPinDialogCancel_: function() { |
| 360 this.lockEnabled_ = | |
| 361 this.networkProperties.Cellular.SIMLockStatus.LockEnabled; | |
| 362 }, | |
| 363 | |
| 364 /** @private */ | |
| 365 onEnterPinDialogClose_: function() { | |
| 344 this.$$('#simLockButton').focus(); | 366 this.$$('#simLockButton').focus(); |
| 345 }, | 367 }, |
| 346 | 368 |
| 347 /** @private */ | 369 /** @private */ |
| 348 onChangePinDialogClose_: function() { | 370 onChangePinDialogClose_: function() { |
| 349 this.$$('#changePinButton').focus(); | 371 this.$$('#changePinButton').focus(); |
| 350 }, | 372 }, |
| 351 | 373 |
| 352 /** @private */ | 374 /** @private */ |
| 353 onUnlockPinDialogClose_: function() { | 375 onUnlockPinDialogClose_: function() { |
| 354 this.$$('#unlockPinButton').focus(); | 376 this.$$('#unlockPinButton').focus(); |
| 355 }, | 377 }, |
| 356 }); | 378 }); |
| 357 })(); | 379 })(); |
| OLD | NEW |