Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/resources/login/user_pod_row.js

Issue 373813002: User manager: fix deleting desktop/managed users with the keyboard (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: refactor removeUser Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 this.passwordElement.value = ''; 794 this.passwordElement.value = '';
792 if (takeFocus) { 795 if (takeFocus) {
793 if (!this.multiProfilesPolicyApplied) 796 if (!this.multiProfilesPolicyApplied)
794 this.focusInput(); // This will set a custom tab order. 797 this.focusInput(); // This will set a custom tab order.
795 } 798 }
796 else 799 else
797 this.resetTabOrder(); 800 this.resetTabOrder();
798 }, 801 },
799 802
800 /** 803 /**
804 * Removes a user using the correct identifier based on user type.
805 * @param {Object} user User to be removed.
806 */
807 removeUser: function(user) {
808 chrome.send('removeUser',
809 [user.isDesktopUser ? user.profilePath : user.username]);
810 },
811
812 /**
801 * Handles a click event on action area button. 813 * Handles a click event on action area button.
802 * @param {Event} e Click event. 814 * @param {Event} e Click event.
803 */ 815 */
804 handleActionAreaButtonClick_: function(e) { 816 handleActionAreaButtonClick_: function(e) {
805 if (this.parentNode.disabled) 817 if (this.parentNode.disabled)
806 return; 818 return;
807 this.isActionBoxMenuActive = !this.isActionBoxMenuActive; 819 this.isActionBoxMenuActive = !this.isActionBoxMenuActive;
808 e.stopPropagation(); 820 e.stopPropagation();
809 }, 821 },
810 822
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 chrome.send('removeUser', [this.user.username]); 869 chrome.send('removeUser', [this.user.username]);
858 }, 870 },
859 871
860 /** 872 /**
861 * Shows remove user warning. Used for supervised users on CrOS, and for all 873 * Shows remove user warning. Used for supervised users on CrOS, and for all
862 * users on desktop. 874 * users on desktop.
863 */ 875 */
864 showRemoveWarning_: function() { 876 showRemoveWarning_: function() {
865 this.actionBoxMenuRemoveElement.hidden = true; 877 this.actionBoxMenuRemoveElement.hidden = true;
866 this.actionBoxRemoveUserWarningElement.hidden = false; 878 this.actionBoxRemoveUserWarningElement.hidden = false;
879 this.actionBoxRemoveUserWarningButtonElement.focus();
867 }, 880 },
868 881
869 /** 882 /**
870 * Handles a click event on remove user confirmation button. 883 * Handles a click event on remove user confirmation button.
871 * @param {Event} e Click event. 884 * @param {Event} e Click event.
872 */ 885 */
873 handleRemoveUserConfirmationClick_: function(e) { 886 handleRemoveUserConfirmationClick_: function(e) {
874 if (this.isActionBoxMenuActive) 887 if (this.isActionBoxMenuActive) {
875 chrome.send('removeUser', [this.user.username]); 888 this.isActionBoxMenuActive = false;
889 this.removeUser(this.user);
890 e.stopPropagation();
891 }
876 }, 892 },
877 893
878 /** 894 /**
895 * Handles a keydown event on remove user confirmation button.
896 * @param {Event} e KeyDown event.
897 */
898 handleRemoveUserConfirmationKeyDown_: function(e) {
899 if (!this.isActionBoxMenuActive)
900 return;
901
902 // Only handle pressing 'Enter' or 'Space', and let all other events
903 // bubble to the action box menu.
904 if (e.keyIdentifier == 'Enter' || e.keyIdentifier == 'U+0020') {
905 this.isActionBoxMenuActive = false;
906 this.removeUser(this.user);
907 e.stopPropagation();
908 // Prevent default so that we don't trigger a 'click' event.
909 e.preventDefault();
910 }
911 },
912
913 /**
879 * Handles a keydown event on remove command. 914 * Handles a keydown event on remove command.
880 * @param {Event} e KeyDown event. 915 * @param {Event} e KeyDown event.
881 */ 916 */
882 handleRemoveCommandKeyDown_: function(e) { 917 handleRemoveCommandKeyDown_: function(e) {
883 if (this.disabled) 918 if (this.disabled)
884 return; 919 return;
885 switch (e.keyIdentifier) { 920 switch (e.keyIdentifier) {
886 case 'Enter': 921 case 'Enter':
887 chrome.send('removeUser', [this.user.username]); 922 if (this.user.locallyManagedUser || this.user.isDesktopUser) {
923 // Prevent default so that we don't trigger a 'click' event on the
924 // remove button that will be focused.
925 e.preventDefault();
926 this.showRemoveWarning_();
927 } else {
928 this.removeUser(this.user);
929 }
888 e.stopPropagation(); 930 e.stopPropagation();
889 break; 931 break;
890 case 'Up': 932 case 'Up':
891 case 'Down': 933 case 'Down':
892 e.stopPropagation(); 934 e.stopPropagation();
893 break; 935 break;
894 case 'U+001B': // Esc 936 case 'U+001B': // Esc
895 this.actionBoxAreaElement.focus(); 937 this.actionBoxAreaElement.focus();
896 this.isActionBoxMenuActive = false; 938 this.isActionBoxMenuActive = false;
897 e.stopPropagation(); 939 e.stopPropagation();
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 this.parentNode.lastFocusedPod_ = this; 1314 this.parentNode.lastFocusedPod_ = this;
1273 1315
1274 // If this is an unlocked pod, then open a browser window. Otherwise 1316 // If this is an unlocked pod, then open a browser window. Otherwise
1275 // just activate the pod and show the password field. 1317 // just activate the pod and show the password field.
1276 if (!this.user.needsSignin && !this.isActionBoxMenuActive) 1318 if (!this.user.needsSignin && !this.isActionBoxMenuActive)
1277 this.activate(e); 1319 this.activate(e);
1278 1320
1279 if (this.isAuthTypeUserClick) 1321 if (this.isAuthTypeUserClick)
1280 chrome.send('attemptUnlock', [this.user.emailAddress]); 1322 chrome.send('attemptUnlock', [this.user.emailAddress]);
1281 }, 1323 },
1282
1283 /** @override */
1284 handleRemoveUserConfirmationClick_: function(e) {
1285 chrome.send('removeUser', [this.user.profilePath]);
1286 },
1287 }; 1324 };
1288 1325
1289 /** 1326 /**
1290 * Creates a user pod that represents kiosk app. 1327 * Creates a user pod that represents kiosk app.
1291 * @constructor 1328 * @constructor
1292 * @extends {UserPod} 1329 * @extends {UserPod}
1293 */ 1330 */
1294 var KioskAppPod = cr.ui.define(function() { 1331 var KioskAppPod = cr.ui.define(function() {
1295 var node = UserPod(); 1332 var node = UserPod();
1296 return node; 1333 return node;
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 if (this.podsWithPendingImages_.length == 0) { 2440 if (this.podsWithPendingImages_.length == 0) {
2404 this.classList.remove('images-loading'); 2441 this.classList.remove('images-loading');
2405 } 2442 }
2406 } 2443 }
2407 }; 2444 };
2408 2445
2409 return { 2446 return {
2410 PodRow: PodRow 2447 PodRow: PodRow
2411 }; 2448 };
2412 }); 2449 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698