OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 User pod row implementation. | 6 * @fileoverview User pod row implementation. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('login', function() { | 9 cr.define('login', function() { |
10 /** | 10 /** |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 this.handleRemoveCommandClick_.bind(this)); | 194 this.handleRemoveCommandClick_.bind(this)); |
195 this.actionBoxMenuRemoveElement.addEventListener('keydown', | 195 this.actionBoxMenuRemoveElement.addEventListener('keydown', |
196 this.handleRemoveCommandKeyDown_.bind(this)); | 196 this.handleRemoveCommandKeyDown_.bind(this)); |
197 this.actionBoxMenuRemoveElement.addEventListener('blur', | 197 this.actionBoxMenuRemoveElement.addEventListener('blur', |
198 this.handleRemoveCommandBlur_.bind(this)); | 198 this.handleRemoveCommandBlur_.bind(this)); |
199 | 199 |
200 if (this.actionBoxRemoveUserWarningButtonElement) { | 200 if (this.actionBoxRemoveUserWarningButtonElement) { |
201 this.actionBoxRemoveUserWarningButtonElement.addEventListener( | 201 this.actionBoxRemoveUserWarningButtonElement.addEventListener( |
202 'click', | 202 'click', |
203 this.handleRemoveUserConfirmationClick_.bind(this)); | 203 this.handleRemoveUserConfirmationClick_.bind(this)); |
204 this.actionBoxRemoveUserWarningButtonElement.addEventListener( | |
205 'keydown', | |
206 this.handleRemoveUserConfirmationKeyDown_.bind(this)); | |
204 } | 207 } |
205 }, | 208 }, |
206 | 209 |
207 /** | 210 /** |
208 * Initializes the pod after its properties set and added to a pod row. | 211 * Initializes the pod after its properties set and added to a pod row. |
209 */ | 212 */ |
210 initialize: function() { | 213 initialize: function() { |
211 this.passwordElement.addEventListener('keydown', | 214 this.passwordElement.addEventListener('keydown', |
212 this.parentNode.handleKeyDown.bind(this.parentNode)); | 215 this.parentNode.handleKeyDown.bind(this.parentNode)); |
213 this.passwordElement.addEventListener('keypress', | 216 this.passwordElement.addEventListener('keypress', |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 chrome.send('removeUser', [this.user.username]); | 860 chrome.send('removeUser', [this.user.username]); |
858 }, | 861 }, |
859 | 862 |
860 /** | 863 /** |
861 * Shows remove user warning. Used for supervised users on CrOS, and for all | 864 * Shows remove user warning. Used for supervised users on CrOS, and for all |
862 * users on desktop. | 865 * users on desktop. |
863 */ | 866 */ |
864 showRemoveWarning_: function() { | 867 showRemoveWarning_: function() { |
865 this.actionBoxMenuRemoveElement.hidden = true; | 868 this.actionBoxMenuRemoveElement.hidden = true; |
866 this.actionBoxRemoveUserWarningElement.hidden = false; | 869 this.actionBoxRemoveUserWarningElement.hidden = false; |
870 this.actionBoxRemoveUserWarningButtonElement.focus(); | |
867 }, | 871 }, |
868 | 872 |
869 /** | 873 /** |
870 * Handles a click event on remove user confirmation button. | 874 * Handles a click event on remove user confirmation button. |
871 * @param {Event} e Click event. | 875 * @param {Event} e Click event. |
872 */ | 876 */ |
873 handleRemoveUserConfirmationClick_: function(e) { | 877 handleRemoveUserConfirmationClick_: function(e) { |
874 if (this.isActionBoxMenuActive) | 878 if (this.isActionBoxMenuActive) { |
875 chrome.send('removeUser', [this.user.username]); | 879 this.isActionBoxMenuActive = false; |
880 chrome.send('removeUser', | |
Nikita (slow)
2014/07/08 11:58:53
nit: Make sense to extract
chrome.send('removeUse
noms (inactive)
2014/07/08 14:14:48
Done.
| |
881 [this.user.isDesktopUser ? this.user.profilePath : | |
882 this.user.username]); | |
883 e.stopPropagation(); | |
884 } | |
876 }, | 885 }, |
877 | 886 |
878 /** | 887 /** |
888 * Handles a keydown event on remove user confirmation button. | |
889 * @param {Event} e KeyDown event. | |
890 */ | |
891 handleRemoveUserConfirmationKeyDown_: function(e) { | |
892 if (!this.isActionBoxMenuActive) | |
893 return; | |
894 | |
895 // Only handle pressing 'Enter' or 'Space', and let all other events | |
896 // bubble to the action box menu. | |
897 if (e.keyIdentifier == 'Enter' || e.keyIdentifier == 'U+0020') { | |
898 this.isActionBoxMenuActive = false; | |
899 chrome.send('removeUser', | |
900 [this.user.isDesktopUser ? this.user.profilePath : | |
901 this.user.username]); | |
902 e.stopPropagation(); | |
903 // Prevent default so that we don't trigger a 'click' event. | |
904 e.preventDefault(); | |
905 } | |
906 }, | |
907 | |
908 /** | |
879 * Handles a keydown event on remove command. | 909 * Handles a keydown event on remove command. |
880 * @param {Event} e KeyDown event. | 910 * @param {Event} e KeyDown event. |
881 */ | 911 */ |
882 handleRemoveCommandKeyDown_: function(e) { | 912 handleRemoveCommandKeyDown_: function(e) { |
883 if (this.disabled) | 913 if (this.disabled) |
884 return; | 914 return; |
885 switch (e.keyIdentifier) { | 915 switch (e.keyIdentifier) { |
886 case 'Enter': | 916 case 'Enter': |
887 chrome.send('removeUser', [this.user.username]); | 917 if (this.user.locallyManagedUser || this.user.isDesktopUser) { |
918 // Prevent default so that we don't trigger a 'click' event on the | |
919 // remove button that will be focused. | |
920 e.preventDefault(); | |
921 this.showRemoveWarning_(); | |
922 } else { | |
923 chrome.send('removeUser', [this.user.username]); | |
924 } | |
888 e.stopPropagation(); | 925 e.stopPropagation(); |
889 break; | 926 break; |
890 case 'Up': | 927 case 'Up': |
891 case 'Down': | 928 case 'Down': |
892 e.stopPropagation(); | 929 e.stopPropagation(); |
893 break; | 930 break; |
894 case 'U+001B': // Esc | 931 case 'U+001B': // Esc |
895 this.actionBoxAreaElement.focus(); | 932 this.actionBoxAreaElement.focus(); |
896 this.isActionBoxMenuActive = false; | 933 this.isActionBoxMenuActive = false; |
897 e.stopPropagation(); | 934 e.stopPropagation(); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 this.parentNode.lastFocusedPod_ = this; | 1309 this.parentNode.lastFocusedPod_ = this; |
1273 | 1310 |
1274 // If this is an unlocked pod, then open a browser window. Otherwise | 1311 // If this is an unlocked pod, then open a browser window. Otherwise |
1275 // just activate the pod and show the password field. | 1312 // just activate the pod and show the password field. |
1276 if (!this.user.needsSignin && !this.isActionBoxMenuActive) | 1313 if (!this.user.needsSignin && !this.isActionBoxMenuActive) |
1277 this.activate(e); | 1314 this.activate(e); |
1278 | 1315 |
1279 if (this.isAuthTypeUserClick) | 1316 if (this.isAuthTypeUserClick) |
1280 chrome.send('attemptUnlock', [this.user.emailAddress]); | 1317 chrome.send('attemptUnlock', [this.user.emailAddress]); |
1281 }, | 1318 }, |
1282 | |
1283 /** @override */ | |
1284 handleRemoveUserConfirmationClick_: function(e) { | |
1285 chrome.send('removeUser', [this.user.profilePath]); | |
1286 }, | |
1287 }; | 1319 }; |
1288 | 1320 |
1289 /** | 1321 /** |
1290 * Creates a user pod that represents kiosk app. | 1322 * Creates a user pod that represents kiosk app. |
1291 * @constructor | 1323 * @constructor |
1292 * @extends {UserPod} | 1324 * @extends {UserPod} |
1293 */ | 1325 */ |
1294 var KioskAppPod = cr.ui.define(function() { | 1326 var KioskAppPod = cr.ui.define(function() { |
1295 var node = UserPod(); | 1327 var node = UserPod(); |
1296 return node; | 1328 return node; |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2403 if (this.podsWithPendingImages_.length == 0) { | 2435 if (this.podsWithPendingImages_.length == 0) { |
2404 this.classList.remove('images-loading'); | 2436 this.classList.remove('images-loading'); |
2405 } | 2437 } |
2406 } | 2438 } |
2407 }; | 2439 }; |
2408 | 2440 |
2409 return { | 2441 return { |
2410 PodRow: PodRow | 2442 PodRow: PodRow |
2411 }; | 2443 }; |
2412 }); | 2444 }); |
OLD | NEW |