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. |
| 12 */ |
| 13 const MAX_LOGIN_ATTEMPTS_IN_POD = 3; |
| 14 |
| 15 /** |
11 * Creates a new account picker screen div. | 16 * Creates a new account picker screen div. |
12 * @constructor | 17 * @constructor |
13 * @extends {HTMLDivElement} | 18 * @extends {HTMLDivElement} |
14 */ | 19 */ |
15 var AccountPickerScreen = cr.ui.define('div'); | 20 var AccountPickerScreen = cr.ui.define('div'); |
16 | 21 |
17 /** | 22 /** |
18 * Registers with Oobe. | 23 * Registers with Oobe. |
19 */ | 24 */ |
20 AccountPickerScreen.register = function() { | 25 AccountPickerScreen.register = function() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 podRow.handleShow(); | 62 podRow.handleShow(); |
58 | 63 |
59 // If this is showing for the lock screen display the sign out button, | 64 // If this is showing for the lock screen display the sign out button, |
60 // hide the add user button and activate the locked user's pod. | 65 // hide the add user button and activate the locked user's pod. |
61 var lockedPod = podRow.lockedPod; | 66 var lockedPod = podRow.lockedPod; |
62 $('add-user-header-bar-item').hidden = !!lockedPod; | 67 $('add-user-header-bar-item').hidden = !!lockedPod; |
63 $('sign-out-user-item').hidden = !lockedPod; | 68 $('sign-out-user-item').hidden = !lockedPod; |
64 if (lockedPod) { | 69 if (lockedPod) { |
65 var focusPod = function() { | 70 var focusPod = function() { |
66 podRow.focusPod(lockedPod); | 71 podRow.focusPod(lockedPod); |
67 } | 72 }; |
68 // TODO(altimofeev): empirically I investigated that focus isn't | 73 // TODO(altimofeev): empirically I investigated that focus isn't |
69 // set correctly if following CSS rules are present: | 74 // set correctly if following CSS rules are present: |
70 // | 75 // |
71 // podrow { | 76 // podrow { |
72 // -webkit-transition: all 200ms ease-in-out; | 77 // -webkit-transition: all 200ms ease-in-out; |
73 // } | 78 // } |
74 // .pod { | 79 // .pod { |
75 // -webkit-transition: all 230ms ease; | 80 // -webkit-transition: all 230ms ease; |
76 // } | 81 // } |
77 // | 82 // |
(...skipping 12 matching lines...) Expand all Loading... |
90 chrome.send('accountPickerReady', []); | 95 chrome.send('accountPickerReady', []); |
91 } | 96 } |
92 }, | 97 }, |
93 | 98 |
94 /** | 99 /** |
95 * Event handler that is invoked just before the frame is hidden. | 100 * Event handler that is invoked just before the frame is hidden. |
96 * @param data {string} Screen init payload. | 101 * @param data {string} Screen init payload. |
97 */ | 102 */ |
98 onBeforeHide: function(data) { | 103 onBeforeHide: function(data) { |
99 $('pod-row').handleHide(); | 104 $('pod-row').handleHide(); |
| 105 }, |
| 106 |
| 107 /** |
| 108 * Shows sign-in error bubble. |
| 109 * @param {number} loginAttempts Number of login attemps tried. |
| 110 * @param {HTMLElement} content Content to show in bubble. |
| 111 */ |
| 112 showErrorBubble: function(loginAttempts, error) { |
| 113 var activatedPod = $('pod-row').activatedPod; |
| 114 if (!activatedPod) |
| 115 return; |
| 116 if (loginAttempts > MAX_LOGIN_ATTEMPTS_IN_POD) { |
| 117 activatedPod.showSigninUI(); |
| 118 } else { |
| 119 $('bubble').showContentForElement(activatedPod.mainInput, error, |
| 120 cr.ui.Bubble.Attachment.BOTTOM); |
| 121 } |
100 } | 122 } |
101 }; | 123 }; |
102 | 124 |
103 /** | 125 /** |
104 * Loads givens users in pod row. | 126 * Loads givens users in pod row. |
105 * @param {array} users Array of user. | 127 * @param {array} users Array of user. |
106 * @param {boolean} animated Whether to use init animation. | 128 * @param {boolean} animated Whether to use init animation. |
107 * @public | 129 * @public |
108 */ | 130 */ |
109 AccountPickerScreen.loadUsers = function(users, animated) { | 131 AccountPickerScreen.loadUsers = function(users, animated) { |
(...skipping 24 matching lines...) Expand all Loading... |
134 * @public | 156 * @public |
135 */ | 157 */ |
136 AccountPickerScreen.setCapsLockState = function(enabled) { | 158 AccountPickerScreen.setCapsLockState = function(enabled) { |
137 $('pod-row').classList[enabled ? 'add' : 'remove']('capslock-on'); | 159 $('pod-row').classList[enabled ? 'add' : 'remove']('capslock-on'); |
138 }; | 160 }; |
139 | 161 |
140 return { | 162 return { |
141 AccountPickerScreen: AccountPickerScreen | 163 AccountPickerScreen: AccountPickerScreen |
142 }; | 164 }; |
143 }); | 165 }); |
OLD | NEW |