OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 Password confirmation screen implementation. | 6 * @fileoverview Password confirmation screen implementation. |
7 */ | 7 */ |
8 | 8 |
9 login.createScreen('ConfirmPasswordScreen', 'confirm-password', function() { | 9 login.createScreen('ConfirmPasswordScreen', 'confirm-password', function() { |
10 return { | 10 return { |
11 EXTERNAL_API: [ | 11 EXTERNAL_API: [ |
12 'show' | 12 'show' |
13 ], | 13 ], |
14 | 14 |
15 /** | 15 /** |
16 * Callback to run when the screen is dismissed. | 16 * Callback to run when the screen is dismissed. |
17 * @type {function(string)} | 17 * @type {function(string)} |
18 */ | 18 */ |
19 callback_: null, | 19 callback_: null, |
20 | 20 |
21 /** @override */ | 21 /** @override */ |
22 decorate: function() { | 22 decorate: function() { |
23 $('confirm-password-input').addEventListener( | 23 $('confirm-password-input').addEventListener( |
24 'keydown', this.onPasswordFieldKeyDown_.bind(this)); | 24 'keydown', this.onPasswordFieldKeyDown_.bind(this)); |
25 $('confirm-password-confirm-button').addEventListener( | 25 $('confirm-password-confirm-button').addEventListener( |
26 'click', this.onConfirmPassword_.bind(this)); | 26 'click', this.onConfirmPassword_.bind(this)); |
| 27 |
| 28 $('saml-confirm-password').addEventListener('cancel', function(e) { |
| 29 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER}); |
| 30 Oobe.resetSigninUI(true); |
| 31 }); |
| 32 $('saml-confirm-password').addEventListener('passwordEnter', function(e) { |
| 33 this.callback_(e.detail.password); |
| 34 }.bind(this)); |
27 }, | 35 }, |
28 | 36 |
29 get defaultControl() { | 37 get defaultControl() { |
30 return $('confirm-password-input'); | 38 return $('confirm-password-input'); |
31 }, | 39 }, |
32 | 40 |
33 /** @override */ | 41 /** @override */ |
34 onBeforeShow: function(data) { | 42 onBeforeShow: function(data) { |
35 $('login-header-bar').signinUIState = | 43 $('login-header-bar').signinUIState = |
36 SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM; | 44 SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM; |
37 }, | 45 }, |
38 | 46 |
| 47 /** @override */ |
| 48 onAfterShow: function(data) { |
| 49 if (Oobe.isNewGaiaFlow()) |
| 50 $('saml-confirm-password').focus(); |
| 51 }, |
| 52 |
| 53 /** @override */ |
| 54 onBeforeHide: function() { |
| 55 if (Oobe.isNewGaiaFlow()) |
| 56 $('saml-confirm-password').reset(); |
| 57 }, |
| 58 |
39 /** | 59 /** |
40 * Handle 'keydown' event on password input field. | 60 * Handle 'keydown' event on password input field. |
41 */ | 61 */ |
42 onPasswordFieldKeyDown_: function(e) { | 62 onPasswordFieldKeyDown_: function(e) { |
43 if (e.keyIdentifier == 'Enter') | 63 if (e.keyIdentifier == 'Enter') |
44 this.onConfirmPassword_(); | 64 this.onConfirmPassword_(); |
45 }, | 65 }, |
46 | 66 |
47 /** | 67 /** |
48 * Invoked when user clicks on the 'confirm' button. | 68 * Invoked when user clicks on the 'confirm' button. |
49 */ | 69 */ |
50 onConfirmPassword_: function() { | 70 onConfirmPassword_: function() { |
51 this.callback_($('confirm-password-input').value); | 71 this.callback_($('confirm-password-input').value); |
52 }, | 72 }, |
53 | 73 |
54 /** | 74 /** |
55 * Shows the confirm password screen. | 75 * Shows the confirm password screen. |
| 76 * @param {string} email The authenticated user's e-mail. |
56 * @param {number} attemptCount Number of attempts tried, starting at 0. | 77 * @param {number} attemptCount Number of attempts tried, starting at 0. |
57 * @param {function(string)} callback The callback to be invoked when the | 78 * @param {function(string)} callback The callback to be invoked when the |
58 * screen is dismissed. | 79 * screen is dismissed. |
59 */ | 80 */ |
60 show: function(attemptCount, callback) { | 81 show: function(email, attemptCount, callback) { |
61 this.callback_ = callback; | 82 this.callback_ = callback; |
62 this.classList.toggle('error', attemptCount > 0); | 83 this.classList.toggle('error', attemptCount > 0); |
63 | 84 if (Oobe.isNewGaiaFlow()) { |
64 $('confirm-password-input').value = ''; | 85 $('saml-confirm-password-contents').hidden = true; |
| 86 var samlConfirmPassword = $('saml-confirm-password'); |
| 87 samlConfirmPassword.reset(); |
| 88 samlConfirmPassword.hidden = false; |
| 89 samlConfirmPassword.email = email; |
| 90 if (attemptCount > 0) |
| 91 samlConfirmPassword.invalidate(); |
| 92 } else { |
| 93 $('confirm-password-input').value = ''; |
| 94 } |
65 Oobe.showScreen({id: SCREEN_CONFIRM_PASSWORD}); | 95 Oobe.showScreen({id: SCREEN_CONFIRM_PASSWORD}); |
66 $('progress-dots').hidden = true; | 96 $('progress-dots').hidden = true; |
67 } | 97 } |
68 }; | 98 }; |
69 }); | 99 }); |
OLD | NEW |