OLD | NEW |
---|---|
1 // Copyright (c) 2012 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); |
(...skipping 17 matching lines...) Expand all Loading... | |
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(); | |
39 | |
40 SimUnlock.prototype = { | 38 SimUnlock.prototype = { |
41 initialized_: false, | 39 initialized_: false, |
42 mode_: SimUnlock.SIM_DIALOG_UNLOCK, | 40 mode_: SimUnlock.SIM_DIALOG_UNLOCK, |
43 pukValue_: '', | 41 pukValue_: '', |
44 defaultDialogSize_: { | 42 defaultDialogSize_: { |
45 'width': window.innerWidth, | 43 'width': window.innerWidth, |
46 'height': window.innerHeight | 44 'height': window.innerHeight |
47 }, | 45 }, |
48 state_: SimUnlock.SIM_UNLOCK_LOADING, | 46 state_: SimUnlock.SIM_UNLOCK_LOADING, |
49 | 47 |
50 changeState_: function(simInfo) { | 48 changeState_: function(simInfo) { |
51 var newState = simInfo.state; | 49 var newState = simInfo.state; |
52 var error = simInfo.error; | 50 var error = simInfo.error; |
53 var tries = simInfo.tries; | 51 var tries = simInfo.tries; |
54 var pinMessage; | 52 var pinMessage; |
55 this.hideAll_(); | 53 this.hideAll_(); |
56 switch (newState) { | 54 switch (newState) { |
57 case SimUnlock.SIM_UNLOCK_LOADING: | 55 case SimUnlock.SIM_UNLOCK_LOADING: |
58 break; | 56 break; |
59 case SimUnlock.SIM_ABSENT_NOT_LOCKED: | 57 case SimUnlock.SIM_ABSENT_NOT_LOCKED: |
60 SimUnlock.close(); | 58 SimUnlock.close(); |
61 break; | 59 break; |
62 case SimUnlock.SIM_LOCKED_PIN: | 60 case SimUnlock.SIM_LOCKED_PIN: |
63 if (error == SimUnlock.ERROR_OK) { | 61 if (error == SimUnlock.ERROR_OK) { |
64 pinMessage = SimUnlock.localStrings_.getStringF( | 62 pinMessage = loadTimeData.getStringF( |
65 'enterPinTriesMessage', tries); | 63 'enterPinTriesMessage', tries); |
Dan Beam
2014/09/23 00:20:47
unwrap
Evan Stade
2014/09/23 01:05:36
Done.
| |
66 $('pin-error-msg').classList.remove('error'); | 64 $('pin-error-msg').classList.remove('error'); |
67 } else if (error == SimUnlock.ERROR_PIN) { | 65 } else if (error == SimUnlock.ERROR_PIN) { |
68 pinMessage = SimUnlock.localStrings_.getStringF( | 66 pinMessage = loadTimeData.getStringF( |
69 'incorrectPinTriesMessage', tries); | 67 'incorrectPinTriesMessage', tries); |
70 $('pin-error-msg').classList.add('error'); | 68 $('pin-error-msg').classList.add('error'); |
71 } | 69 } |
72 $('pin-error-msg').textContent = pinMessage; | 70 $('pin-error-msg').textContent = pinMessage; |
73 $('pin-input').value = ''; | 71 $('pin-input').value = ''; |
74 SimUnlock.enablePinDialog(true); | 72 SimUnlock.enablePinDialog(true); |
75 $('locked-pin-overlay').hidden = false; | 73 $('locked-pin-overlay').hidden = false; |
76 $('pin-input').focus(); | 74 $('pin-input').focus(); |
77 break; | 75 break; |
78 case SimUnlock.SIM_NOT_LOCKED_ASK_PIN: | 76 case SimUnlock.SIM_NOT_LOCKED_ASK_PIN: |
79 if (error == SimUnlock.ERROR_OK) { | 77 if (error == SimUnlock.ERROR_OK) { |
80 pinMessage = SimUnlock.localStrings_.getString('enterPinMessage'); | 78 pinMessage = loadTimeData.getString('enterPinMessage'); |
81 $('pin-error-msg').classList.remove('error'); | 79 $('pin-error-msg').classList.remove('error'); |
82 } else if (error == SimUnlock.ERROR_PIN) { | 80 } else if (error == SimUnlock.ERROR_PIN) { |
83 pinMessage = SimUnlock.localStrings_.getStringF( | 81 pinMessage = loadTimeData.getStringF( |
84 'incorrectPinTriesMessage', tries); | 82 'incorrectPinTriesMessage', tries); |
85 $('pin-error-msg').classList.add('error'); | 83 $('pin-error-msg').classList.add('error'); |
86 } | 84 } |
87 $('pin-error-msg').textContent = pinMessage; | 85 $('pin-error-msg').textContent = pinMessage; |
88 $('pin-input').value = ''; | 86 $('pin-input').value = ''; |
89 SimUnlock.enablePinDialog(true); | 87 SimUnlock.enablePinDialog(true); |
90 $('locked-pin-overlay').hidden = false; | 88 $('locked-pin-overlay').hidden = false; |
91 $('pin-input').focus(); | 89 $('pin-input').focus(); |
92 break; | 90 break; |
93 case SimUnlock.SIM_NOT_LOCKED_CHANGE_PIN: | 91 case SimUnlock.SIM_NOT_LOCKED_CHANGE_PIN: |
94 SimUnlock.prepareChoosePinDialog(true); | 92 SimUnlock.prepareChoosePinDialog(true); |
95 if (error == SimUnlock.ERROR_OK) { | 93 if (error == SimUnlock.ERROR_OK) { |
96 pinMessage = SimUnlock.localStrings_.getString('changePinMessage'); | 94 pinMessage = loadTimeData.getString('changePinMessage'); |
97 $('choose-pin-msg').classList.remove('error'); | 95 $('choose-pin-msg').classList.remove('error'); |
98 } else if (error == SimUnlock.ERROR_PIN) { | 96 } else if (error == SimUnlock.ERROR_PIN) { |
99 pinMessage = SimUnlock.localStrings_.getStringF( | 97 pinMessage = loadTimeData.getStringF( |
100 'incorrectPinTriesMessage', tries); | 98 'incorrectPinTriesMessage', tries); |
101 $('choose-pin-msg').classList.add('error'); | 99 $('choose-pin-msg').classList.add('error'); |
102 } | 100 } |
103 $('choose-pin-msg').textContent = pinMessage; | 101 $('choose-pin-msg').textContent = pinMessage; |
104 $('old-pin-input').value = ''; | 102 $('old-pin-input').value = ''; |
105 $('new-pin-input').value = ''; | 103 $('new-pin-input').value = ''; |
106 $('retype-new-pin-input').value = ''; | 104 $('retype-new-pin-input').value = ''; |
107 $('choose-pin-overlay').hidden = false; | 105 $('choose-pin-overlay').hidden = false; |
108 SimUnlock.enableChoosePinDialog(true); | 106 SimUnlock.enableChoosePinDialog(true); |
109 $('old-pin-input').focus(); | 107 $('old-pin-input').focus(); |
110 break; | 108 break; |
111 case SimUnlock.SIM_LOCKED_NO_PIN_TRIES_LEFT: | 109 case SimUnlock.SIM_LOCKED_NO_PIN_TRIES_LEFT: |
112 $('locked-pin-no-tries-overlay').hidden = false; | 110 $('locked-pin-no-tries-overlay').hidden = false; |
113 break; | 111 break; |
114 case SimUnlock.SIM_LOCKED_PUK: | 112 case SimUnlock.SIM_LOCKED_PUK: |
115 $('puk-input').value = ''; | 113 $('puk-input').value = ''; |
116 if (tries && tries >= 0) { | 114 if (tries && tries >= 0) { |
117 var pukMessage = SimUnlock.localStrings_.getStringF( | 115 var pukMessage = loadTimeData.getStringF( |
118 'enterPukWarning', tries); | 116 'enterPukWarning', tries); |
Dan Beam
2014/09/23 00:20:47
unwrap
Evan Stade
2014/09/23 01:05:36
Done.
| |
119 $('puk-warning-msg').textContent = pukMessage; | 117 $('puk-warning-msg').textContent = pukMessage; |
120 } | 118 } |
121 $('enter-puk-confirm').disabled = true; | 119 $('enter-puk-confirm').disabled = true; |
122 $('locked-puk-overlay').hidden = false; | 120 $('locked-puk-overlay').hidden = false; |
123 $('puk-input').focus(); | 121 $('puk-input').focus(); |
124 | 122 |
125 // Resize the dialog to accomodate the PUK contents. | 123 // Resize the dialog to accomodate the PUK contents. |
126 this.updateDialogSize_(0, 45); | 124 this.updateDialogSize_(0, 45); |
127 break; | 125 break; |
128 case SimUnlock.SIM_LOCKED_NO_PUK_TRIES_LEFT: | 126 case SimUnlock.SIM_LOCKED_NO_PUK_TRIES_LEFT: |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 SimUnlock.enablePinDialog(false); | 379 SimUnlock.enablePinDialog(false); |
382 chrome.send('enterPinCode', [pin]); | 380 chrome.send('enterPinCode', [pin]); |
383 }; | 381 }; |
384 | 382 |
385 SimUnlock.prepareChoosePinDialog = function(changePin) { | 383 SimUnlock.prepareChoosePinDialog = function(changePin) { |
386 // Our dialog has different height than choose-pin step of the | 384 // Our dialog has different height than choose-pin step of the |
387 // unlock process which we're reusing. | 385 // unlock process which we're reusing. |
388 if (changePin) { | 386 if (changePin) { |
389 $('choose-pin-content-area').classList.remove('choose-pin-content-area'); | 387 $('choose-pin-content-area').classList.remove('choose-pin-content-area'); |
390 $('choose-pin-content-area').classList.add('change-pin-content-area'); | 388 $('choose-pin-content-area').classList.add('change-pin-content-area'); |
391 var title = SimUnlock.localStrings_.getString('changePinTitle'); | 389 var title = loadTimeData.getString('changePinTitle'); |
392 $('choose-pin-title').textContent = title; | 390 $('choose-pin-title').textContent = title; |
393 } else { | 391 } else { |
394 $('choose-pin-content-area').classList.remove('change-pin-content-area'); | 392 $('choose-pin-content-area').classList.remove('change-pin-content-area'); |
395 $('choose-pin-content-area').classList.add('choose-pin-content-area'); | 393 $('choose-pin-content-area').classList.add('choose-pin-content-area'); |
396 var pinMessage = SimUnlock.localStrings_.getString('choosePinMessage'); | 394 var pinMessage = loadTimeData.getString('choosePinMessage'); |
397 $('choose-pin-msg').classList.remove('error'); | 395 $('choose-pin-msg').classList.remove('error'); |
398 $('choose-pin-msg').textContent = pinMessage; | 396 $('choose-pin-msg').textContent = pinMessage; |
399 var title = SimUnlock.localStrings_.getString('choosePinTitle'); | 397 var title = loadTimeData.getString('choosePinTitle'); |
400 $('choose-pin-title').textContent = title; | 398 $('choose-pin-title').textContent = title; |
401 } | 399 } |
402 $('old-pin-label').hidden = !changePin; | 400 $('old-pin-label').hidden = !changePin; |
403 $('old-pin-input-area').hidden = !changePin; | 401 $('old-pin-input-area').hidden = !changePin; |
404 }; | 402 }; |
405 | 403 |
406 SimUnlock.newPinEntered = function(newPin, newPin2) { | 404 SimUnlock.newPinEntered = function(newPin, newPin2) { |
407 SimUnlock.getInstance().newPinEntered_(newPin, newPin2); | 405 SimUnlock.getInstance().newPinEntered_(newPin, newPin2); |
408 }; | 406 }; |
409 | 407 |
(...skipping 14 matching lines...) Expand all Loading... | |
424 }; | 422 }; |
425 | 423 |
426 // Export | 424 // Export |
427 return { | 425 return { |
428 SimUnlock: SimUnlock | 426 SimUnlock: SimUnlock |
429 }; | 427 }; |
430 | 428 |
431 }); | 429 }); |
432 | 430 |
433 disableTextSelectAndDrag(); | 431 disableTextSelectAndDrag(); |
OLD | NEW |