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 |
41 get isNewGaiaFlow() { | |
dzhioev (left Google)
2015/05/05 18:55:19
I believe I already saw exactly same function some
dzhioev (left Google)
2015/05/05 21:43:37
Here it https://code.google.com/p/chromium/codesea
Roman Sorokin (ftl)
2015/05/08 09:22:45
Done.
Roman Sorokin (ftl)
2015/05/08 09:22:45
Done.
| |
42 return document.querySelector('.new-gaia-flow') != undefined; | |
43 }, | |
44 | |
33 /** @override */ | 45 /** @override */ |
34 onBeforeShow: function(data) { | 46 onBeforeShow: function(data) { |
35 $('login-header-bar').signinUIState = | 47 $('login-header-bar').signinUIState = |
36 SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM; | 48 SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM; |
37 }, | 49 }, |
38 | 50 |
51 /** @override */ | |
52 onAfterShow: function(data) { | |
53 if (this.isNewGaiaFlow) | |
54 $('saml-confirm-password').focus(); | |
55 }, | |
56 | |
57 /** @override */ | |
58 onBeforeHide: function() { | |
59 if (this.isNewGaiaFlow) | |
60 $('saml-confirm-password').reset(); | |
61 }, | |
62 | |
39 /** | 63 /** |
40 * Handle 'keydown' event on password input field. | 64 * Handle 'keydown' event on password input field. |
41 */ | 65 */ |
42 onPasswordFieldKeyDown_: function(e) { | 66 onPasswordFieldKeyDown_: function(e) { |
43 if (e.keyIdentifier == 'Enter') | 67 if (e.keyIdentifier == 'Enter') |
44 this.onConfirmPassword_(); | 68 this.onConfirmPassword_(); |
45 }, | 69 }, |
46 | 70 |
47 /** | 71 /** |
48 * Invoked when user clicks on the 'confirm' button. | 72 * Invoked when user clicks on the 'confirm' button. |
49 */ | 73 */ |
50 onConfirmPassword_: function() { | 74 onConfirmPassword_: function() { |
51 this.callback_($('confirm-password-input').value); | 75 this.callback_($('confirm-password-input').value); |
52 }, | 76 }, |
53 | 77 |
54 /** | 78 /** |
55 * Shows the confirm password screen. | 79 * Shows the confirm password screen. |
80 * @param {string} email The authenticated user's e-mail. | |
56 * @param {number} attemptCount Number of attempts tried, starting at 0. | 81 * @param {number} attemptCount Number of attempts tried, starting at 0. |
57 * @param {function(string)} callback The callback to be invoked when the | 82 * @param {function(string)} callback The callback to be invoked when the |
58 * screen is dismissed. | 83 * screen is dismissed. |
59 */ | 84 */ |
60 show: function(attemptCount, callback) { | 85 show: function(email, attemptCount, callback) { |
61 this.callback_ = callback; | 86 this.callback_ = callback; |
62 this.classList.toggle('error', attemptCount > 0); | 87 this.classList.toggle('error', attemptCount > 0); |
63 | 88 if (this.isNewGaiaFlow) { |
64 $('confirm-password-input').value = ''; | 89 $('saml-confirm-password-contents').hidden = true; |
90 var samlConfirmPassword = $('saml-confirm-password'); | |
91 samlConfirmPassword.reset(); | |
92 samlConfirmPassword.hidden = false; | |
93 samlConfirmPassword.email = email; | |
94 if (attemptCount > 0) | |
95 samlConfirmPassword.invalidate(); | |
96 } else { | |
97 $('confirm-password-input').value = ''; | |
98 } | |
65 Oobe.showScreen({id: SCREEN_CONFIRM_PASSWORD}); | 99 Oobe.showScreen({id: SCREEN_CONFIRM_PASSWORD}); |
66 $('progress-dots').hidden = true; | 100 $('progress-dots').hidden = true; |
67 } | 101 } |
68 }; | 102 }; |
69 }); | 103 }); |
OLD | NEW |