| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('mobile', function() { | 5 cr.define('mobile', function() { |
| 6 | 6 |
| 7 function SimUnlock() { | 7 function SimUnlock() { |
| 8 } | 8 } |
| 9 | 9 |
| 10 cr.addSingletonGetter(SimUnlock); | 10 cr.addSingletonGetter(SimUnlock); |
| 11 | 11 |
| 12 // State of the dialog. | 12 // State of the dialog. |
| 13 SimUnlock.SIM_UNLOCK_LOADING = -1; | 13 SimUnlock.SIM_UNLOCK_LOADING = -1; |
| 14 SimUnlock.SIM_ABSENT_NOT_LOCKED = 0, | 14 SimUnlock.SIM_ABSENT_NOT_LOCKED = 0, |
| 15 SimUnlock.SIM_NOT_LOCKED_ASK_PIN = 1; | 15 SimUnlock.SIM_NOT_LOCKED_ASK_PIN = 1; |
| 16 SimUnlock.SIM_NOT_LOCKED_CHANGE_PIN = 2; | 16 SimUnlock.SIM_NOT_LOCKED_CHANGE_PIN = 2; |
| 17 SimUnlock.SIM_LOCKED_PIN = 3; | 17 SimUnlock.SIM_LOCKED_PIN = 3; |
| 18 SimUnlock.SIM_LOCKED_NO_PIN_TRIES_LEFT = 4; | 18 SimUnlock.SIM_LOCKED_NO_PIN_TRIES_LEFT = 4; |
| 19 SimUnlock.SIM_LOCKED_PUK = 5; | 19 SimUnlock.SIM_LOCKED_PUK = 5; |
| 20 SimUnlock.SIM_LOCKED_NO_PUK_TRIES_LEFT = 6; | 20 SimUnlock.SIM_LOCKED_NO_PUK_TRIES_LEFT = 6; |
| 21 SimUnlock.SIM_DISABLED = 7; | 21 SimUnlock.SIM_DISABLED = 7; |
| 22 | 22 |
| 23 // Mode of the dialog. | 23 // Mode of the dialog. |
| 24 SimUnlock.SIM_DIALOG_UNLOCK = 0; | 24 SimUnlock.SIM_DIALOG_UNLOCK = 0; |
| 25 SimUnlock.SIM_DIALOG_CHANGE_PIN = 1; | 25 SimUnlock.SIM_DIALOG_CHANGE_PIN = 1; |
| 26 SimUnlock.SIM_DIALOG_SET_LOCK_ON = 2; | 26 SimUnlock.SIM_DIALOG_SET_LOCK_ON = 2; |
| 27 SimUnlock.SIM_DIALOG_SET_LOCK_OFF = 3; | 27 SimUnlock.SIM_DIALOG_SET_LOCK_OFF = 3; |
| 28 | 28 |
| 29 // Error codes. | 29 // Error codes. |
| 30 SimUnlock.ERROR_PIN = 'incorrectPin'; | 30 SimUnlock.ERROR_PIN = 'incorrectPin'; |
| 31 SimUnlock.ERROR_PUK = 'incorrectPuk'; | 31 SimUnlock.ERROR_PUK = 'incorrectPuk'; |
| 32 SimUnlock.ERROR_OK = 'ok'; | 32 SimUnlock.ERROR_OK = 'ok'; |
| 33 | 33 |
| 34 // Misc constants. | 34 // Misc constants. |
| 35 SimUnlock.PIN_MIN_LENGTH = 4; | 35 SimUnlock.PIN_MIN_LENGTH = 4; |
| 36 SimUnlock.PUK_LENGTH = 8; | 36 SimUnlock.PUK_LENGTH = 8; |
| 37 | 37 |
| 38 SimUnlock.localStrings_ = new LocalStrings(); | 38 SimUnlock.localStrings_ = new LocalStrings(); |
| 39 | 39 |
| 40 SimUnlock.prototype = { | 40 SimUnlock.prototype = { |
| 41 initialized_: false, | 41 initialized_: false, |
| 42 mode_: SimUnlock.SIM_DIALOG_UNLOCK, | 42 mode_: SimUnlock.SIM_DIALOG_UNLOCK, |
| 43 pukValue_: '', | 43 pukValue_: '', |
| 44 state_: SimUnlock.SIM_UNLOCK_LOADING, | 44 state_: SimUnlock.SIM_UNLOCK_LOADING, |
| 45 | 45 |
| 46 changeState_: function(simInfo) { | 46 changeState_: function(simInfo) { |
| 47 var newState = simInfo.state; | 47 var newState = simInfo.state; |
| 48 var error = simInfo.error; | 48 var error = simInfo.error; |
| 49 var tries = simInfo.tries; | 49 var tries = simInfo.tries; |
| 50 var pinMessage; | 50 var pinMessage; |
| 51 this.hideAll_(); | 51 this.hideAll_(); |
| 52 switch(newState) { | 52 switch (newState) { |
| 53 case SimUnlock.SIM_UNLOCK_LOADING: | 53 case SimUnlock.SIM_UNLOCK_LOADING: |
| 54 break; | 54 break; |
| 55 case SimUnlock.SIM_ABSENT_NOT_LOCKED: | 55 case SimUnlock.SIM_ABSENT_NOT_LOCKED: |
| 56 SimUnlock.close(); | 56 SimUnlock.close(); |
| 57 break; | 57 break; |
| 58 case SimUnlock.SIM_LOCKED_PIN: | 58 case SimUnlock.SIM_LOCKED_PIN: |
| 59 if (error == SimUnlock.ERROR_OK) { | 59 if (error == SimUnlock.ERROR_OK) { |
| 60 pinMessage = SimUnlock.localStrings_.getStringF( | 60 pinMessage = SimUnlock.localStrings_.getStringF( |
| 61 'enterPinTriesMessage', tries); | 61 'enterPinTriesMessage', tries); |
| 62 $('pin-error-msg').classList.remove('error'); | 62 $('pin-error-msg').classList.remove('error'); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 227 } |
| 228 }); | 228 }); |
| 229 $('pin-input').addEventListener('keyup', function(event) { | 229 $('pin-input').addEventListener('keyup', function(event) { |
| 230 $('enter-pin-confirm').disabled = | 230 $('enter-pin-confirm').disabled = |
| 231 $('enter-pin-dismiss').disabled || | 231 $('enter-pin-dismiss').disabled || |
| 232 this.value.length < SimUnlock.PIN_MIN_LENGTH; | 232 this.value.length < SimUnlock.PIN_MIN_LENGTH; |
| 233 }); | 233 }); |
| 234 $('pin-input').addEventListener('textInput', | 234 $('pin-input').addEventListener('textInput', |
| 235 SimUnlock.processInput.bind(this)); | 235 SimUnlock.processInput.bind(this)); |
| 236 $('enter-pin-confirm').addEventListener('click', function(event) { | 236 $('enter-pin-confirm').addEventListener('click', function(event) { |
| 237 SimUnlock.submitPin() | 237 SimUnlock.submitPin(); |
| 238 }); | 238 }); |
| 239 $('enter-pin-dismiss').addEventListener('click', function(event) { | 239 $('enter-pin-dismiss').addEventListener('click', function(event) { |
| 240 SimUnlock.cancel(); | 240 SimUnlock.cancel(); |
| 241 }); | 241 }); |
| 242 | 242 |
| 243 // No PIN retries left screen. | 243 // No PIN retries left screen. |
| 244 $('pin-no-tries-proceed').addEventListener('click', function(event) { | 244 $('pin-no-tries-proceed').addEventListener('click', function(event) { |
| 245 chrome.send('proceedToPukInput'); | 245 chrome.send('proceedToPukInput'); |
| 246 }); | 246 }); |
| 247 $('pin-no-tries-dismiss').addEventListener('click', function(event) { | 247 $('pin-no-tries-dismiss').addEventListener('click', function(event) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 }; | 412 }; |
| 413 | 413 |
| 414 // Export | 414 // Export |
| 415 return { | 415 return { |
| 416 SimUnlock: SimUnlock | 416 SimUnlock: SimUnlock |
| 417 }; | 417 }; |
| 418 | 418 |
| 419 }); | 419 }); |
| 420 | 420 |
| 421 disableTextSelectAndDrag(); | 421 disableTextSelectAndDrag(); |
| OLD | NEW |