| 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 /** | 5 /** |
| 6 * @fileoverview Account picker screen implementation. | 6 * @fileoverview Account picker screen implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('login', function() { | 9 cr.define('login', function() { |
| 10 /** | 10 /** |
| 11 * Maximum number of offline login failures before online login. | 11 * Maximum number of offline login failures before online login. |
| 12 @type {number} | 12 * @type {number} |
| 13 @const | 13 * @const |
| 14 */ | 14 */ |
| 15 var MAX_LOGIN_ATTEMPTS_IN_POD = 3; | 15 var MAX_LOGIN_ATTEMPTS_IN_POD = 3; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Whether to preselect the first pod automatically on login screen. |
| 19 * @type {boolean} |
| 20 * @const |
| 21 */ |
| 22 var PRESELECT_FIRST_POD = true; |
| 23 |
| 24 /** |
| 18 * Creates a new account picker screen div. | 25 * Creates a new account picker screen div. |
| 19 * @constructor | 26 * @constructor |
| 20 * @extends {HTMLDivElement} | 27 * @extends {HTMLDivElement} |
| 21 */ | 28 */ |
| 22 var AccountPickerScreen = cr.ui.define('div'); | 29 var AccountPickerScreen = cr.ui.define('div'); |
| 23 | 30 |
| 24 /** | 31 /** |
| 25 * Registers with Oobe. | 32 * Registers with Oobe. |
| 26 */ | 33 */ |
| 27 AccountPickerScreen.register = function() { | 34 AccountPickerScreen.register = function() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 onBeforeShow: function(data) { | 69 onBeforeShow: function(data) { |
| 63 chrome.send('hideCaptivePortal'); | 70 chrome.send('hideCaptivePortal'); |
| 64 var podRow = $('pod-row'); | 71 var podRow = $('pod-row'); |
| 65 podRow.handleShow(); | 72 podRow.handleShow(); |
| 66 | 73 |
| 67 // If this is showing for the lock screen display the sign out button, | 74 // If this is showing for the lock screen display the sign out button, |
| 68 // hide the add user button and activate the locked user's pod. | 75 // hide the add user button and activate the locked user's pod. |
| 69 var lockedPod = podRow.lockedPod; | 76 var lockedPod = podRow.lockedPod; |
| 70 $('add-user-header-bar-item').hidden = !!lockedPod; | 77 $('add-user-header-bar-item').hidden = !!lockedPod; |
| 71 $('sign-out-user-item').hidden = !lockedPod; | 78 $('sign-out-user-item').hidden = !lockedPod; |
| 72 if (lockedPod) { | 79 var preselectedPod = PRESELECT_FIRST_POD ? |
| 80 lockedPod || podRow.pods[0] : lockedPod; |
| 81 if (preselectedPod) { |
| 73 // TODO(altimofeev): empirically I investigated that focus isn't | 82 // TODO(altimofeev): empirically I investigated that focus isn't |
| 74 // set correctly if following CSS rules are present: | 83 // set correctly if following CSS rules are present: |
| 75 // | 84 // |
| 76 // podrow { | 85 // podrow { |
| 77 // -webkit-transition: all 200ms ease-in-out; | 86 // -webkit-transition: all 200ms ease-in-out; |
| 78 // } | 87 // } |
| 79 // .pod { | 88 // .pod { |
| 80 // -webkit-transition: all 230ms ease; | 89 // -webkit-transition: all 230ms ease; |
| 81 // } | 90 // } |
| 82 // | 91 // |
| 83 // Workaround is either delete these rules or delay the focus setting. | 92 // Workaround is either delete these rules or delay the focus setting. |
| 84 var self = this; | 93 var self = this; |
| 85 lockedPod.addEventListener('webkitTransitionEnd', function f(e) { | 94 preselectedPod.addEventListener('webkitTransitionEnd', function f(e) { |
| 86 if (e.target == lockedPod) { | 95 if (e.target == preselectedPod) { |
| 87 podRow.focusPod(lockedPod); | 96 podRow.focusPod(preselectedPod); |
| 88 lockedPod.removeEventListener(f); | 97 preselectedPod.removeEventListener(f); |
| 89 // Delay the accountPickerReady signal so that if there are any | 98 // Delay the accountPickerReady signal so that if there are any |
| 90 // timeouts waiting to fire we can process these first. This was | 99 // timeouts waiting to fire we can process these first. This was |
| 91 // causing crbug.com/112218 as the account pod was sometimes focuse | 100 // causing crbug.com/112218 as the account pod was sometimes focuse |
| 92 // using focusPod (which resets the password) after the test code | 101 // using focusPod (which resets the password) after the test code |
| 93 // set the password. | 102 // set the password. |
| 94 self.onShow(); | 103 self.onShow(); |
| 95 } | 104 } |
| 96 }); | 105 }); |
| 97 } else { | 106 } else { |
| 98 this.onShow(); | 107 this.onShow(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 * @param {boolean} enabled Whether Caps Lock is on. | 182 * @param {boolean} enabled Whether Caps Lock is on. |
| 174 */ | 183 */ |
| 175 AccountPickerScreen.setCapsLockState = function(enabled) { | 184 AccountPickerScreen.setCapsLockState = function(enabled) { |
| 176 $('pod-row').classList[enabled ? 'add' : 'remove']('capslock-on'); | 185 $('pod-row').classList[enabled ? 'add' : 'remove']('capslock-on'); |
| 177 }; | 186 }; |
| 178 | 187 |
| 179 return { | 188 return { |
| 180 AccountPickerScreen: AccountPickerScreen | 189 AccountPickerScreen: AccountPickerScreen |
| 181 }; | 190 }; |
| 182 }); | 191 }); |
| OLD | NEW |