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. 4 5/** 6 * @fileoverview Password confirmation screen implementation. 7 */ 8 9login.createScreen('ConfirmPasswordScreen', 'confirm-password', function() { 10 return { 11 EXTERNAL_API: [ 12 'show' 13 ], 14 15 /** 16 * Callback to run when the screen is dismissed. 17 * @type {function(string)} 18 */ 19 callback_: null, 20 21 /** @override */ 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)); 27 }, 28 29 get defaultControl() { 30 return $('confirm-password-input'); 31 }, 32 33 /** @override */ 34 onBeforeShow: function(data) { 35 $('login-header-bar').signinUIState = 36 SIGNIN_UI_STATE.SAML_PASSWORD_CONFIRM; 37 }, 38 39 /** 40 * Handle 'keydown' event on password input field. 41 */ 42 onPasswordFieldKeyDown_: function(e) { 43 if (e.keyIdentifier == 'Enter') 44 this.onConfirmPassword_(); 45 }, 46 47 /** 48 * Invoked when user clicks on the 'confirm' button. 49 */ 50 onConfirmPassword_: function() { 51 this.callback_($('confirm-password-input').value); 52 }, 53 54 /** 55 * Shows the confirm password screen. 56 * @param {number} attemptCount Number of attempts tried, starting at 0. 57 * @param {function(string)} callback The callback to be invoked when the 58 * screen is dismissed. 59 */ 60 show: function(attemptCount, callback) { 61 this.callback_ = callback; 62 this.classList.toggle('error', attemptCount > 0); 63 64 $('confirm-password-input').value = ''; 65 Oobe.showScreen({id: SCREEN_CONFIRM_PASSWORD}); 66 $('progress-dots').hidden = true; 67 } 68 }; 69}); 70