| 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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 '.action-box-remove-user-warning-table-nonsync').style.display | 1708 '.action-box-remove-user-warning-table-nonsync').style.display |
| 1709 = 'none'; | 1709 = 'none'; |
| 1710 var message = loadTimeData.getString('removeNonOwnerUserWarningText'); | 1710 var message = loadTimeData.getString('removeNonOwnerUserWarningText'); |
| 1711 this.updateRemoveNonOwnerUserWarningMessage_(this.user.profilePath, | 1711 this.updateRemoveNonOwnerUserWarningMessage_(this.user.profilePath, |
| 1712 message); | 1712 message); |
| 1713 } | 1713 } |
| 1714 } else { | 1714 } else { |
| 1715 // Show extra statistics information for desktop users | 1715 // Show extra statistics information for desktop users |
| 1716 this.querySelector( | 1716 this.querySelector( |
| 1717 '.action-box-remove-non-owner-user-warning-text').hidden = true; | 1717 '.action-box-remove-non-owner-user-warning-text').hidden = true; |
| 1718 this.RemoveWarningDialogSetMessage_(true, false); | 1718 this.RemoveWarningDialogSetMessage_(); |
| 1719 // set a global handler for the callback | 1719 // set a global handler for the callback |
| 1720 window.updateRemoveWarningDialog = | 1720 window.updateRemoveWarningDialog = |
| 1721 this.updateRemoveWarningDialog_.bind(this); | 1721 this.updateRemoveWarningDialog_.bind(this); |
| 1722 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); | 1722 var is_synced_user = this.user.emailAddress !== ""; |
| 1723 if (!is_synced_user) { |
| 1724 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); |
| 1725 } |
| 1723 } | 1726 } |
| 1724 chrome.send('logRemoveUserWarningShown'); | 1727 chrome.send('logRemoveUserWarningShown'); |
| 1725 }, | 1728 }, |
| 1726 | 1729 |
| 1727 /** | 1730 /** |
| 1728 * Refresh the statistics in the remove user warning dialog. | 1731 * Refresh the statistics in the remove user warning dialog. |
| 1729 * @param {string} profilePath The filepath of the URL (must be verified). | 1732 * @param {string} profilePath The filepath of the URL (must be verified). |
| 1730 * @param {Object} profileStats Statistics associated with profileURL. | 1733 * @param {Object} profileStats Statistics associated with profileURL. |
| 1731 */ | 1734 */ |
| 1732 updateRemoveWarningDialog_: function(profilePath, profileStats) { | 1735 updateRemoveWarningDialog_: function(profilePath, profileStats) { |
| 1733 if (profilePath !== this.user.profilePath) | 1736 if (profilePath !== this.user.profilePath) |
| 1734 return; | 1737 return; |
| 1735 | 1738 |
| 1736 var stats_elements = this.statsMapElements; | 1739 var stats_elements = this.statsMapElements; |
| 1737 // Update individual statistics | 1740 // Update individual statistics |
| 1738 var hasErrors = false; | |
| 1739 for (var key in profileStats) { | 1741 for (var key in profileStats) { |
| 1740 if (stats_elements.hasOwnProperty(key)) { | 1742 if (stats_elements.hasOwnProperty(key)) { |
| 1741 if (profileStats[key].success) { | 1743 stats_elements[key].textContent = profileStats[key].count; |
| 1742 this.user.statistics[key] = profileStats[key]; | |
| 1743 } else if (!this.user.statistics[key].success) { | |
| 1744 hasErrors = true; | |
| 1745 stats_elements[key].textContent = ''; | |
| 1746 } | |
| 1747 } | |
| 1748 } | |
| 1749 | |
| 1750 this.RemoveWarningDialogSetMessage_(false, hasErrors); | |
| 1751 }, | |
| 1752 | |
| 1753 /** | |
| 1754 * Set the new message in the dialog. | |
| 1755 * @param {boolean} Whether this is the first output, that requires setting | |
| 1756 * a in-progress message. | |
| 1757 * @param {boolean} Whether any actual query to the statistics have failed. | |
| 1758 * Should be true only if there is an error and the corresponding statistic | |
| 1759 * is also unavailable in ProfileAttributesStorage. | |
| 1760 */ | |
| 1761 RemoveWarningDialogSetMessage_: function(isInitial, hasErrors) { | |
| 1762 var stats_elements = this.statsMapElements; | |
| 1763 var total_count = 0; | |
| 1764 var num_stats_loaded = 0; | |
| 1765 for (var key in stats_elements) { | |
| 1766 if (this.user.statistics[key].success) { | |
| 1767 var count = this.user.statistics[key].count; | |
| 1768 stats_elements[key].textContent = count; | |
| 1769 total_count += count; | |
| 1770 num_stats_loaded++; | |
| 1771 } | |
| 1772 } | |
| 1773 | |
| 1774 var is_synced_user = this.user.emailAddress !== ""; | |
| 1775 // Write total number if all statistics are loaded. | |
| 1776 if (num_stats_loaded === Object.keys(stats_elements).length) { | |
| 1777 if (!total_count) { | |
| 1778 var message = loadTimeData.getString( | |
| 1779 is_synced_user ? 'removeUserWarningTextSyncNoStats' : | |
| 1780 'removeUserWarningTextNonSyncNoStats'); | |
| 1781 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, | |
| 1782 message); | |
| 1783 } else { | |
| 1784 window.updateRemoveWarningDialogSetMessage = | |
| 1785 this.updateRemoveWarningDialogSetMessage_.bind(this); | |
| 1786 chrome.send('getRemoveWarningDialogMessage',[{ | |
| 1787 profilePath: this.user.profilePath, | |
| 1788 isSyncedUser: is_synced_user, | |
| 1789 hasErrors: hasErrors, | |
| 1790 totalCount: total_count | |
| 1791 }]); | |
| 1792 } | |
| 1793 } else if (isInitial) { | |
| 1794 if (!this.user.isProfileLoaded) { | |
| 1795 message = loadTimeData.getString( | |
| 1796 is_synced_user ? 'removeUserWarningTextSyncNoStats' : | |
| 1797 'removeUserWarningTextNonSyncNoStats'); | |
| 1798 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, | |
| 1799 message); | |
| 1800 } else { | |
| 1801 message = loadTimeData.getString( | |
| 1802 is_synced_user ? 'removeUserWarningTextSyncCalculating' : | |
| 1803 'removeUserWarningTextNonSyncCalculating'); | |
| 1804 substitute = loadTimeData.getString( | |
| 1805 'removeUserWarningTextCalculating'); | |
| 1806 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, | |
| 1807 message, substitute); | |
| 1808 } | 1744 } |
| 1809 } | 1745 } |
| 1810 }, | 1746 }, |
| 1811 | 1747 |
| 1812 /** | 1748 /** |
| 1749 * Set the new message in the dialog. |
| 1750 */ |
| 1751 RemoveWarningDialogSetMessage_: function() { |
| 1752 var is_synced_user = this.user.emailAddress !== ""; |
| 1753 message = loadTimeData.getString( |
| 1754 is_synced_user ? 'removeUserWarningTextSync' : |
| 1755 'removeUserWarningTextNonSync'); |
| 1756 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath, |
| 1757 message); |
| 1758 }, |
| 1759 |
| 1760 /** |
| 1813 * Refresh the message in the remove user warning dialog. | 1761 * Refresh the message in the remove user warning dialog. |
| 1814 * @param {string} profilePath The filepath of the URL (must be verified). | 1762 * @param {string} profilePath The filepath of the URL (must be verified). |
| 1815 * @param {string} message The message to be written. | 1763 * @param {string} message The message to be written. |
| 1816 * @param {number|string=} count The number or string to replace $1 in | 1764 * @param {number|string=} count The number or string to replace $1 in |
| 1817 * |message|. Can be omitted if $1 is not present in |message|. | 1765 * |message|. Can be omitted if $1 is not present in |message|. |
| 1818 */ | 1766 */ |
| 1819 updateRemoveWarningDialogSetMessage_: function(profilePath, message, | 1767 updateRemoveWarningDialogSetMessage_: function(profilePath, message, |
| 1820 count) { | 1768 count) { |
| 1821 if (profilePath !== this.user.profilePath) | 1769 if (profilePath !== this.user.profilePath) |
| 1822 return; | 1770 return; |
| (...skipping 2140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3963 if (pod && pod.multiProfilesPolicyApplied) { | 3911 if (pod && pod.multiProfilesPolicyApplied) { |
| 3964 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3912 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3965 } | 3913 } |
| 3966 } | 3914 } |
| 3967 }; | 3915 }; |
| 3968 | 3916 |
| 3969 return { | 3917 return { |
| 3970 PodRow: PodRow | 3918 PodRow: PodRow |
| 3971 }; | 3919 }; |
| 3972 }); | 3920 }); |
| OLD | NEW |