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

Side by Side Diff: ui/login/account_picker/user_pod_row.js

Issue 2265133003: Fix warning message of the user profile is not seen on second instance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | 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 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 }, 1526 },
1527 1527
1528 /** 1528 /**
1529 * Shows remove user warning. Used for legacy supervised users 1529 * Shows remove user warning. Used for legacy supervised users
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
1537 var message;
1538 if (!this.user.isDesktopUser) { 1536 if (!this.user.isDesktopUser) {
1539 this.moveActionMenuUpIfNeeded_(); 1537 this.moveActionMenuUpIfNeeded_();
1540 if (!this.user.legacySupervisedUser) { 1538 if (!this.user.legacySupervisedUser) {
1541 this.querySelector( 1539 this.querySelector(
1542 '.action-box-remove-user-warning-text').style.display = 'none'; 1540 '.action-box-remove-user-warning-text').style.display = 'none';
1543 this.querySelector( 1541 this.querySelector(
1544 '.action-box-remove-user-warning-table-nonsync').style.display 1542 '.action-box-remove-user-warning-table-nonsync').style.display
1545 = 'none'; 1543 = 'none';
1546 var message = loadTimeData.getString('removeNonOwnerUserWarningText'); 1544 var message = loadTimeData.getString('removeNonOwnerUserWarningText');
1547 var element_id = '.action-box-remove-non-owner-user-warning-text'; 1545 this.updateRemoveNonOwnerUserWarningMessage_(this.user.profilePath,
1548 this.updateRemoveWarningDialogSetMessage_(element_id, 1546 message);
1549 this.user.profilePath,
1550 message);
1551 } 1547 }
1552 } else { 1548 } else {
1549 // Show extra statistics information for desktop users
1553 this.querySelector( 1550 this.querySelector(
1554 '.action-box-remove-non-owner-user-warning-text').hidden = true; 1551 '.action-box-remove-non-owner-user-warning-text').hidden = true;
1555 this.RemoveWarningDialogSetMessage_(true, false); 1552 this.RemoveWarningDialogSetMessage_(true, false);
1556 // set a global handler for the callback 1553 // set a global handler for the callback
1557 window.updateRemoveWarningDialog = 1554 window.updateRemoveWarningDialog =
1558 this.updateRemoveWarningDialog_.bind(this); 1555 this.updateRemoveWarningDialog_.bind(this);
1559 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); 1556 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]);
1560 } 1557 }
1561 chrome.send('logRemoveUserWarningShown'); 1558 chrome.send('logRemoveUserWarningShown');
1562 }, 1559 },
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 stats_elements[key].textContent = count; 1602 stats_elements[key].textContent = count;
1606 total_count += count; 1603 total_count += count;
1607 num_stats_loaded++; 1604 num_stats_loaded++;
1608 } 1605 }
1609 } 1606 }
1610 1607
1611 // this.classList is used for selecting the appropriate dialog. 1608 // this.classList is used for selecting the appropriate dialog.
1612 if (total_count) 1609 if (total_count)
1613 this.classList.remove('has-no-stats'); 1610 this.classList.remove('has-no-stats');
1614 1611
1615 var elementSelector = '.action-box-remove-user-warning-text';
1616 var is_synced_user = this.user.emailAddress !== ""; 1612 var is_synced_user = this.user.emailAddress !== "";
1617 // Write total number if all statistics are loaded. 1613 // Write total number if all statistics are loaded.
1618 if (num_stats_loaded === Object.keys(stats_elements).length) { 1614 if (num_stats_loaded === Object.keys(stats_elements).length) {
1619 if (!total_count) { 1615 if (!total_count) {
1620 this.classList.add('has-no-stats'); 1616 this.classList.add('has-no-stats');
1621 var message = loadTimeData.getString( 1617 var message = loadTimeData.getString(
1622 is_synced_user ? 'removeUserWarningTextSyncNoStats' : 1618 is_synced_user ? 'removeUserWarningTextSyncNoStats' :
1623 'removeUserWarningTextNonSyncNoStats'); 1619 'removeUserWarningTextNonSyncNoStats');
1624 this.updateRemoveWarningDialogSetMessage_(elementSelector, 1620 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath,
1625 this.user.profilePath,
1626 message); 1621 message);
1627 } else { 1622 } else {
1628 window.updateRemoveWarningDialogSetMessage = 1623 window.updateRemoveWarningDialogSetMessage =
1629 this.updateRemoveWarningDialogSetMessage_.bind(this); 1624 this.updateRemoveWarningDialogSetMessage_.bind(this);
1630 chrome.send('getRemoveWarningDialogMessage',[{ 1625 chrome.send('getRemoveWarningDialogMessage',[{
1631 profilePath: this.user.profilePath, 1626 profilePath: this.user.profilePath,
1632 isSyncedUser: is_synced_user, 1627 isSyncedUser: is_synced_user,
1633 hasErrors: hasErrors, 1628 hasErrors: hasErrors,
1634 totalCount: total_count 1629 totalCount: total_count
1635 }]); 1630 }]);
1636 } 1631 }
1637 } else if (isInitial) { 1632 } else if (isInitial) {
1638 if (!this.user.isProfileLoaded) { 1633 if (!this.user.isProfileLoaded) {
1639 message = loadTimeData.getString( 1634 message = loadTimeData.getString(
1640 is_synced_user ? 'removeUserWarningTextSyncNoStats' : 1635 is_synced_user ? 'removeUserWarningTextSyncNoStats' :
1641 'removeUserWarningTextNonSyncNoStats'); 1636 'removeUserWarningTextNonSyncNoStats');
1642 this.updateRemoveWarningDialogSetMessage_(elementSelector, 1637 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath,
1643 this.user.profilePath,
1644 message); 1638 message);
1645 } else { 1639 } else {
1646 message = loadTimeData.getString( 1640 message = loadTimeData.getString(
1647 is_synced_user ? 'removeUserWarningTextSyncCalculating' : 1641 is_synced_user ? 'removeUserWarningTextSyncCalculating' :
1648 'removeUserWarningTextNonSyncCalculating'); 1642 'removeUserWarningTextNonSyncCalculating');
1649 substitute = loadTimeData.getString( 1643 substitute = loadTimeData.getString(
1650 'removeUserWarningTextCalculating'); 1644 'removeUserWarningTextCalculating');
1651 this.updateRemoveWarningDialogSetMessage_(elementSelector, 1645 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath,
1652 this.user.profilePath,
1653 message, substitute); 1646 message, substitute);
1654 } 1647 }
1655 } 1648 }
1656 }, 1649 },
1657 1650
1658 /** 1651 /**
1659 * Refresh the message in the remove user warning dialog. 1652 * Refresh the message in the remove user warning dialog.
1660 * @param {string} elementSelector The elementSelector of warning dialog.
1661 * @param {string} profilePath The filepath of the URL (must be verified). 1653 * @param {string} profilePath The filepath of the URL (must be verified).
1662 * @param {string} message The message to be written. 1654 * @param {string} message The message to be written.
1663 * @param {number|string=} count The number or string to replace $1 in 1655 * @param {number|string=} count The number or string to replace $1 in
1664 * |message|. Can be omitted if $1 is not present in |message|. 1656 * |message|. Can be omitted if $1 is not present in |message|.
1665 */ 1657 */
1666 updateRemoveWarningDialogSetMessage_: function(elementSelector, 1658 updateRemoveWarningDialogSetMessage_: function(profilePath, message,
1667 profilePath,
1668 message,
1669 count) { 1659 count) {
1670 if (profilePath !== this.user.profilePath) 1660 if (profilePath !== this.user.profilePath)
1671 return; 1661 return;
1672 // Add localized messages where $1 will be replaced with 1662 // Add localized messages where $1 will be replaced with
1673 // <span class="total-count"></span> and $2 will be replaced with 1663 // <span class="total-count"></span> and $2 will be replaced with
1674 // <span class="email"></span>. 1664 // <span class="email"></span>.
1675 var element = this.querySelector(elementSelector); 1665 var element = this.querySelector('.action-box-remove-user-warning-text');
1676 element.textContent = ''; 1666 element.textContent = '';
1677 1667
1678 messageParts = message.split(/(\$[12])/); 1668 messageParts = message.split(/(\$[12])/);
1679 var numParts = messageParts.length; 1669 var numParts = messageParts.length;
1680 for (var j = 0; j < numParts; j++) { 1670 for (var j = 0; j < numParts; j++) {
1681 if (messageParts[j] === '$1') { 1671 if (messageParts[j] === '$1') {
1682 var elementToAdd = document.createElement('span'); 1672 var elementToAdd = document.createElement('span');
1683 elementToAdd.classList.add('total-count'); 1673 elementToAdd.classList.add('total-count');
1684 elementToAdd.textContent = count; 1674 elementToAdd.textContent = count;
1685 element.appendChild(elementToAdd); 1675 element.appendChild(elementToAdd);
1686 } else if (messageParts[j] === '$2') { 1676 } else if (messageParts[j] === '$2') {
1687 var elementToAdd = document.createElement('span'); 1677 var elementToAdd = document.createElement('span');
1688 elementToAdd.classList.add('email'); 1678 elementToAdd.classList.add('email');
1689 elementToAdd.textContent = this.user.emailAddress; 1679 elementToAdd.textContent = this.user.emailAddress;
1690 element.appendChild(elementToAdd); 1680 element.appendChild(elementToAdd);
1691 } else { 1681 } else {
1692 element.appendChild(document.createTextNode(messageParts[j])); 1682 element.appendChild(document.createTextNode(messageParts[j]));
1693 } 1683 }
1694 } 1684 }
1695 this.moveActionMenuUpIfNeeded_(); 1685 this.moveActionMenuUpIfNeeded_();
1696 }, 1686 },
1697 1687
1698 /** 1688 /**
1689 * Update the message in the remove non-owner user warning dialog on CrOS.
Alexander Alekseev 2016/08/24 01:02:56 nit: Update message in the "remove non-owner user
1690 * @param {string} profilePath The filepath of the URL (must be verified).
1691 * @param (string) message The message to be written.
1692 */
1693 updateRemoveNonOwnerUserWarningMessage_: function(profilePath, message) {
1694 if (profilePath !== this.user.profilePath)
1695 return;
1696 // Add localized messages where $1 will be replaced with
1697 // <span class="email"></span>.
1698 var element = this.querySelector(
1699 '.action-box-remove-non-owner-user-warning-text');
1700 element.textContent = '';
1701
1702 messageParts = message.split(/(\$[1])/);
1703 var numParts = messageParts.length;
1704 for (var j = 0; j < numParts; j++) {
1705 if (messageParts[j] == '$1') {
1706 var elementToAdd = document.createElement('span');
1707 elementToAdd.classList.add('email');
1708 elementToAdd.textContent = this.user.emailAddress;
1709 element.appendChild(elementToAdd);
1710 } else {
1711 element.appendChild(document.createTextNode(messageParts[j]));
1712 }
1713 }
1714 this.moveActionMenuUpIfNeeded_();
1715 },
1716
1717 /**
1699 * Handles a click event on remove user confirmation button. 1718 * Handles a click event on remove user confirmation button.
1700 * @param {Event} e Click event. 1719 * @param {Event} e Click event.
1701 */ 1720 */
1702 handleRemoveUserConfirmationClick_: function(e) { 1721 handleRemoveUserConfirmationClick_: function(e) {
1703 if (this.isActionBoxMenuActive) { 1722 if (this.isActionBoxMenuActive) {
1704 this.isActionBoxMenuActive = false; 1723 this.isActionBoxMenuActive = false;
1705 this.removeUser(this.user); 1724 this.removeUser(this.user);
1706 e.stopPropagation(); 1725 e.stopPropagation();
1707 } 1726 }
1708 }, 1727 },
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 if (pod && pod.multiProfilesPolicyApplied) { 3562 if (pod && pod.multiProfilesPolicyApplied) {
3544 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3563 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3545 } 3564 }
3546 } 3565 }
3547 }; 3566 };
3548 3567
3549 return { 3568 return {
3550 PodRow: PodRow 3569 PodRow: PodRow
3551 }; 3570 };
3552 }); 3571 });
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698