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
3 // found in the LICENSE file.
6 * @fileoverview Password confirmation screen implementation.
9 login.createScreen('ConfirmPasswordScreen', 'confirm-password', function() {
16 * Callback to run when the screen is dismissed.
17 * @type {function(string)}
22 decorate: function() {
23 $('confirm-password-input').addEventListener(
24 'keydown', this.onPasswordFieldKeyDown_.bind(this));
25 $('confirm-password-confirm-button').addEventListener(
26 'click', this.onConfirmPassword_.bind(this));
28 $('saml-confirm-password').addEventListener('cancel', function(e) {
29 Oobe.showScreen({id: SCREEN_ACCOUNT_PICKER});
30 Oobe.resetSigninUI(true);
32 $('saml-confirm-password').addEventListener('passwordEnter', function(e) {
33 this.callback_(e.detail.password);
37 get defaultControl() {
38 return $('confirm-password-input');
42 onBeforeShow: function(data) {
43 $('login-header-bar').signinUIState =
44 SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM;
48 onAfterShow: function(data) {
49 if (Oobe.isNewGaiaFlow())
50 $('saml-confirm-password').focus();
54 onBeforeHide: function() {
55 if (Oobe.isNewGaiaFlow())
56 $('saml-confirm-password').reset();
60 * Handle 'keydown' event on password input field.
62 onPasswordFieldKeyDown_: function(e) {
63 if (e.keyIdentifier == 'Enter')
64 this.onConfirmPassword_();
68 * Invoked when user clicks on the 'confirm' button.
70 onConfirmPassword_: function() {
71 this.callback_($('confirm-password-input').value);
75 * Shows the confirm password screen.
76 * @param {string} email The authenticated user's e-mail.
77 * @param {number} attemptCount Number of attempts tried, starting at 0.
78 * @param {function(string)} callback The callback to be invoked when the
79 * screen is dismissed.
81 show: function(email, attemptCount, callback) {
82 this.callback_ = callback;
83 this.classList.toggle('error', attemptCount > 0);
84 if (Oobe.isNewGaiaFlow()) {
85 $('saml-confirm-password-contents').hidden = true;
86 var samlConfirmPassword = $('saml-confirm-password');
87 samlConfirmPassword.reset();
88 samlConfirmPassword.hidden = false;
89 samlConfirmPassword.email = email;
91 samlConfirmPassword.invalidate();
93 $('confirm-password-input').value = '';
95 Oobe.showScreen({id: SCREEN_CONFIRM_PASSWORD});
96 $('progress-dots').hidden = true;