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 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 * and non-device-owner on CrOS, and for all users on desktop. | 1530 * and non-device-owner on CrOS, and for all users on desktop. |
1531 */ | 1531 */ |
1532 showRemoveWarning_: function() { | 1532 showRemoveWarning_: function() { |
1533 this.actionBoxMenuRemoveElement.hidden = true; | 1533 this.actionBoxMenuRemoveElement.hidden = true; |
1534 this.actionBoxRemoveUserWarningElement.hidden = false; | 1534 this.actionBoxRemoveUserWarningElement.hidden = false; |
1535 | 1535 |
1536 // Show extra statistics information for desktop users | 1536 // Show extra statistics information for desktop users |
1537 var message; | 1537 var message; |
1538 if (!this.user.isDesktopUser) { | 1538 if (!this.user.isDesktopUser) { |
1539 this.moveActionMenuUpIfNeeded_(); | 1539 this.moveActionMenuUpIfNeeded_(); |
| 1540 if (!this.user.legacySupervisedUser) { |
| 1541 this.querySelector( |
| 1542 '.action-box-remove-user-warning-text').style.display = 'none'; |
| 1543 this.querySelector( |
| 1544 '.action-box-remove-user-warning-table-nonsync').style.display |
| 1545 = 'none'; |
| 1546 var message = loadTimeData.getString('removeNonOwnerUserWarningText'); |
| 1547 var element_id = '.action-box-remove-non-owner-user-warning-text'; |
| 1548 this.updateRemoveWarningDialogSetMessage_(element_id, |
| 1549 this.user.profilePath, |
| 1550 message); |
| 1551 } |
1540 } else { | 1552 } else { |
1541 this.querySelector( | 1553 this.querySelector( |
1542 '.action-box-remove-non-owner-user-warning-text').hidden = true; | 1554 '.action-box-remove-non-owner-user-warning-text').hidden = true; |
1543 this.RemoveWarningDialogSetMessage_(true, false); | 1555 this.RemoveWarningDialogSetMessage_(true, false); |
1544 // set a global handler for the callback | 1556 // set a global handler for the callback |
1545 window.updateRemoveWarningDialog = | 1557 window.updateRemoveWarningDialog = |
1546 this.updateRemoveWarningDialog_.bind(this); | 1558 this.updateRemoveWarningDialog_.bind(this); |
1547 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); | 1559 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); |
1548 } | 1560 } |
1549 chrome.send('logRemoveUserWarningShown'); | 1561 chrome.send('logRemoveUserWarningShown'); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 stats_elements[key].textContent = count; | 1605 stats_elements[key].textContent = count; |
1594 total_count += count; | 1606 total_count += count; |
1595 num_stats_loaded++; | 1607 num_stats_loaded++; |
1596 } | 1608 } |
1597 } | 1609 } |
1598 | 1610 |
1599 // this.classList is used for selecting the appropriate dialog. | 1611 // this.classList is used for selecting the appropriate dialog. |
1600 if (total_count) | 1612 if (total_count) |
1601 this.classList.remove('has-no-stats'); | 1613 this.classList.remove('has-no-stats'); |
1602 | 1614 |
| 1615 var elementSelector = '.action-box-remove-user-warning-text'; |
1603 var is_synced_user = this.user.emailAddress !== ""; | 1616 var is_synced_user = this.user.emailAddress !== ""; |
1604 // Write total number if all statistics are loaded. | 1617 // Write total number if all statistics are loaded. |
1605 if (num_stats_loaded === Object.keys(stats_elements).length) { | 1618 if (num_stats_loaded === Object.keys(stats_elements).length) { |
1606 if (!total_count) { | 1619 if (!total_count) { |
1607 this.classList.add('has-no-stats'); | 1620 this.classList.add('has-no-stats'); |
1608 var message = loadTimeData.getString( | 1621 var message = loadTimeData.getString( |
1609 is_synced_user ? 'removeUserWarningTextSyncNoStats' : | 1622 is_synced_user ? 'removeUserWarningTextSyncNoStats' : |
1610 'removeUserWarningTextNonSyncNoStats'); | 1623 'removeUserWarningTextNonSyncNoStats'); |
1611 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, | 1624 this.updateRemoveWarningDialogSetMessage_(elementSelector, |
| 1625 this.user.profilePath, |
1612 message); | 1626 message); |
1613 } else { | 1627 } else { |
1614 window.updateRemoveWarningDialogSetMessage = | 1628 window.updateRemoveWarningDialogSetMessage = |
1615 this.updateRemoveWarningDialogSetMessage_.bind(this); | 1629 this.updateRemoveWarningDialogSetMessage_.bind(this); |
1616 chrome.send('getRemoveWarningDialogMessage',[{ | 1630 chrome.send('getRemoveWarningDialogMessage',[{ |
1617 profilePath: this.user.profilePath, | 1631 profilePath: this.user.profilePath, |
1618 isSyncedUser: is_synced_user, | 1632 isSyncedUser: is_synced_user, |
1619 hasErrors: hasErrors, | 1633 hasErrors: hasErrors, |
1620 totalCount: total_count | 1634 totalCount: total_count |
1621 }]); | 1635 }]); |
1622 } | 1636 } |
1623 } else if (isInitial) { | 1637 } else if (isInitial) { |
1624 if (!this.user.isProfileLoaded) { | 1638 if (!this.user.isProfileLoaded) { |
1625 message = loadTimeData.getString( | 1639 message = loadTimeData.getString( |
1626 is_synced_user ? 'removeUserWarningTextSyncNoStats' : | 1640 is_synced_user ? 'removeUserWarningTextSyncNoStats' : |
1627 'removeUserWarningTextNonSyncNoStats'); | 1641 'removeUserWarningTextNonSyncNoStats'); |
1628 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, | 1642 this.updateRemoveWarningDialogSetMessage_(elementSelector, |
| 1643 this.user.profilePath, |
1629 message); | 1644 message); |
1630 } else { | 1645 } else { |
1631 message = loadTimeData.getString( | 1646 message = loadTimeData.getString( |
1632 is_synced_user ? 'removeUserWarningTextSyncCalculating' : | 1647 is_synced_user ? 'removeUserWarningTextSyncCalculating' : |
1633 'removeUserWarningTextNonSyncCalculating'); | 1648 'removeUserWarningTextNonSyncCalculating'); |
1634 substitute = loadTimeData.getString( | 1649 substitute = loadTimeData.getString( |
1635 'removeUserWarningTextCalculating'); | 1650 'removeUserWarningTextCalculating'); |
1636 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, | 1651 this.updateRemoveWarningDialogSetMessage_(elementSelector, |
| 1652 this.user.profilePath, |
1637 message, substitute); | 1653 message, substitute); |
1638 } | 1654 } |
1639 } | 1655 } |
1640 }, | 1656 }, |
1641 | 1657 |
1642 /** | 1658 /** |
1643 * Refresh the message in the remove user warning dialog. | 1659 * Refresh the message in the remove user warning dialog. |
| 1660 * @param {string} elementSelector The elementSelector of warning dialog. |
1644 * @param {string} profilePath The filepath of the URL (must be verified). | 1661 * @param {string} profilePath The filepath of the URL (must be verified). |
1645 * @param {string} message The message to be written. | 1662 * @param {string} message The message to be written. |
1646 * @param {number|string=} count The number or string to replace $1 in | 1663 * @param {number|string=} count The number or string to replace $1 in |
1647 * |message|. Can be omitted if $1 is not present in |message|. | 1664 * |message|. Can be omitted if $1 is not present in |message|. |
1648 */ | 1665 */ |
1649 updateRemoveWarningDialogSetMessage_: function(profilePath, message, | 1666 updateRemoveWarningDialogSetMessage_: function(elementSelector, |
| 1667 profilePath, |
| 1668 message, |
1650 count) { | 1669 count) { |
1651 if (profilePath !== this.user.profilePath) | 1670 if (profilePath !== this.user.profilePath) |
1652 return; | 1671 return; |
1653 // Add localized messages where $1 will be replaced with | 1672 // Add localized messages where $1 will be replaced with |
1654 // <span class="total-count"></span> and $2 will be replaced with | 1673 // <span class="total-count"></span> and $2 will be replaced with |
1655 // <span class="email"></span>. | 1674 // <span class="email"></span>. |
1656 var element = this.querySelector('.action-box-remove-user-warning-text'); | 1675 var element = this.querySelector(elementSelector); |
1657 element.textContent = ''; | 1676 element.textContent = ''; |
1658 | 1677 |
1659 messageParts = message.split(/(\$[12])/); | 1678 messageParts = message.split(/(\$[12])/); |
1660 var numParts = messageParts.length; | 1679 var numParts = messageParts.length; |
1661 for (var j = 0; j < numParts; j++) { | 1680 for (var j = 0; j < numParts; j++) { |
1662 if (messageParts[j] === '$1') { | 1681 if (messageParts[j] === '$1') { |
1663 var elementToAdd = document.createElement('span'); | 1682 var elementToAdd = document.createElement('span'); |
1664 elementToAdd.classList.add('total-count'); | 1683 elementToAdd.classList.add('total-count'); |
1665 elementToAdd.textContent = count; | 1684 elementToAdd.textContent = count; |
1666 element.appendChild(elementToAdd); | 1685 element.appendChild(elementToAdd); |
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3523 if (pod && pod.multiProfilesPolicyApplied) { | 3542 if (pod && pod.multiProfilesPolicyApplied) { |
3524 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3543 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3525 } | 3544 } |
3526 } | 3545 } |
3527 }; | 3546 }; |
3528 | 3547 |
3529 return { | 3548 return { |
3530 PodRow: PodRow | 3549 PodRow: PodRow |
3531 }; | 3550 }; |
3532 }); | 3551 }); |
OLD | NEW |