| 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 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 if (this.disabled) | 1520 if (this.disabled) |
| 1521 return; | 1521 return; |
| 1522 this.actionBoxMenuTitleElement.tabIndex = -1; | 1522 this.actionBoxMenuTitleElement.tabIndex = -1; |
| 1523 }, | 1523 }, |
| 1524 | 1524 |
| 1525 /** | 1525 /** |
| 1526 * Handles a click event on remove user command. | 1526 * Handles a click event on remove user command. |
| 1527 * @param {Event} e Click event. | 1527 * @param {Event} e Click event. |
| 1528 */ | 1528 */ |
| 1529 handleRemoveCommandClick_: function(e) { | 1529 handleRemoveCommandClick_: function(e) { |
| 1530 if (this.user.legacySupervisedUser || this.user.isDesktopUser) { | 1530 this.showRemoveWarning_(); |
| 1531 this.showRemoveWarning_(); | |
| 1532 return; | |
| 1533 } | |
| 1534 if (this.isActionBoxMenuActive) | |
| 1535 chrome.send('removeUser', [this.user.username]); | |
| 1536 }, | 1531 }, |
| 1537 | 1532 |
| 1538 /** | 1533 /** |
| 1539 * Move the action box menu up if needed. | 1534 * Move the action box menu up if needed. |
| 1540 */ | 1535 */ |
| 1541 moveActionMenuUpIfNeeded_: function() { | 1536 moveActionMenuUpIfNeeded_: function() { |
| 1542 // Skip checking (computationally expensive) if already moved up. | 1537 // Skip checking (computationally expensive) if already moved up. |
| 1543 if (this.actionBoxMenu.classList.contains('menu-moved-up')) | 1538 if (this.actionBoxMenu.classList.contains('menu-moved-up')) |
| 1544 return; | 1539 return; |
| 1545 | 1540 |
| 1546 // Move up the menu if it overlaps shelf. | 1541 // Move up the menu if it overlaps shelf. |
| 1547 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( | 1542 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( |
| 1548 this.actionBoxMenu, true); | 1543 this.actionBoxMenu, true); |
| 1549 var actualHeight = parseInt( | 1544 var actualHeight = parseInt( |
| 1550 window.getComputedStyle(this.actionBoxMenu).height); | 1545 window.getComputedStyle(this.actionBoxMenu).height); |
| 1551 if (maxHeight < actualHeight) { | 1546 if (maxHeight < actualHeight) { |
| 1552 this.actionBoxMenu.classList.add('menu-moved-up'); | 1547 this.actionBoxMenu.classList.add('menu-moved-up'); |
| 1553 this.actionBoxAreaElement.classList.add('menu-moved-up'); | 1548 this.actionBoxAreaElement.classList.add('menu-moved-up'); |
| 1554 } | 1549 } |
| 1555 }, | 1550 }, |
| 1556 | 1551 |
| 1557 /** | 1552 /** |
| 1558 * Shows remove user warning. Used for legacy supervised users on CrOS, and | 1553 * Shows remove user warning. Used for legacy supervised users |
| 1559 * for all users on desktop. | 1554 * and non-device-owner on CrOS, and for all users on desktop. |
| 1560 */ | 1555 */ |
| 1561 showRemoveWarning_: function() { | 1556 showRemoveWarning_: function() { |
| 1562 this.actionBoxMenuRemoveElement.hidden = true; | 1557 this.actionBoxMenuRemoveElement.hidden = true; |
| 1563 this.actionBoxRemoveUserWarningElement.hidden = false; | 1558 this.actionBoxRemoveUserWarningElement.hidden = false; |
| 1564 | 1559 |
| 1565 // Show extra statistics information for desktop users | 1560 // Show extra statistics information for desktop users |
| 1566 var message; | 1561 var message; |
| 1567 if (this.user.isLegacySupervisedUser) { | 1562 if (!this.user.isDesktopUser) { |
| 1568 this.moveActionMenuUpIfNeeded_(); | 1563 this.moveActionMenuUpIfNeeded_(); |
| 1569 } else { | 1564 } else { |
| 1565 this.querySelector( |
| 1566 '.action-box-remove-non-owner-user-warning-text').hidden = true; |
| 1570 this.RemoveWarningDialogSetMessage_(true, false); | 1567 this.RemoveWarningDialogSetMessage_(true, false); |
| 1571 // set a global handler for the callback | 1568 // set a global handler for the callback |
| 1572 window.updateRemoveWarningDialog = | 1569 window.updateRemoveWarningDialog = |
| 1573 this.updateRemoveWarningDialog_.bind(this); | 1570 this.updateRemoveWarningDialog_.bind(this); |
| 1574 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); | 1571 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); |
| 1575 } | 1572 } |
| 1576 chrome.send('logRemoveUserWarningShown'); | 1573 chrome.send('logRemoveUserWarningShown'); |
| 1577 }, | 1574 }, |
| 1578 | 1575 |
| 1579 /** | 1576 /** |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1736 | 1733 |
| 1737 /** | 1734 /** |
| 1738 * Handles a keydown event on remove command. | 1735 * Handles a keydown event on remove command. |
| 1739 * @param {Event} e KeyDown event. | 1736 * @param {Event} e KeyDown event. |
| 1740 */ | 1737 */ |
| 1741 handleRemoveCommandKeyDown_: function(e) { | 1738 handleRemoveCommandKeyDown_: function(e) { |
| 1742 if (this.disabled) | 1739 if (this.disabled) |
| 1743 return; | 1740 return; |
| 1744 switch (e.key) { | 1741 switch (e.key) { |
| 1745 case 'Enter': | 1742 case 'Enter': |
| 1746 if (this.user.legacySupervisedUser || this.user.isDesktopUser) { | 1743 e.preventDefault(); |
| 1747 // Prevent default so that we don't trigger a 'click' event on the | 1744 this.showRemoveWarning_(); |
| 1748 // remove button that will be focused. | |
| 1749 e.preventDefault(); | |
| 1750 this.showRemoveWarning_(); | |
| 1751 } else { | |
| 1752 this.removeUser(this.user); | |
| 1753 } | |
| 1754 e.stopPropagation(); | 1745 e.stopPropagation(); |
| 1755 break; | 1746 break; |
| 1756 case 'ArrowUp': | 1747 case 'ArrowUp': |
| 1757 case 'ArrowDown': | 1748 case 'ArrowDown': |
| 1758 e.stopPropagation(); | 1749 e.stopPropagation(); |
| 1759 break; | 1750 break; |
| 1760 // Ignore these two, so ChromeVox hotkeys don't close the menu before | 1751 // Ignore these two, so ChromeVox hotkeys don't close the menu before |
| 1761 // they can navigate through it. | 1752 // they can navigate through it. |
| 1762 case 'Shift': | 1753 case 'Shift': |
| 1763 case 'Meta': | 1754 case 'Meta': |
| (...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3513 if (pod && pod.multiProfilesPolicyApplied) { | 3504 if (pod && pod.multiProfilesPolicyApplied) { |
| 3514 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3505 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3515 } | 3506 } |
| 3516 } | 3507 } |
| 3517 }; | 3508 }; |
| 3518 | 3509 |
| 3519 return { | 3510 return { |
| 3520 PodRow: PodRow | 3511 PodRow: PodRow |
| 3521 }; | 3512 }; |
| 3522 }); | 3513 }); |
| OLD | NEW |