Chromium Code Reviews| Index: ui/login/account_picker/user_pod_row.js |
| diff --git a/ui/login/account_picker/user_pod_row.js b/ui/login/account_picker/user_pod_row.js |
| index a8ab31671f9b8187395807bf7674e0572c29d9e4..8096b75373b714d09d6cac2c5c56a794712d66fc 100644 |
| --- a/ui/login/account_picker/user_pod_row.js |
| +++ b/ui/login/account_picker/user_pod_row.js |
| @@ -954,23 +954,6 @@ cr.define('login', function() { |
| }, |
| /** |
| - * Gets action box menu, remove user warning text div. |
| - * @type {!HTMLInputElement} |
| - */ |
| - get actionBoxRemoveUserWarningTextElement() { |
| - return this.querySelector('.action-box-remove-user-warning-text'); |
| - }, |
| - |
| - /** |
| - * Gets action box menu, remove legacy supervised user warning text div. |
| - * @type {!HTMLInputElement} |
| - */ |
| - get actionBoxRemoveLegacySupervisedUserWarningTextElement() { |
| - return this.querySelector( |
| - '.action-box-remove-legacy-supervised-user-warning-text'); |
| - }, |
| - |
| - /** |
| * Gets action box menu, remove user command item div. |
| * @type {!HTMLInputElement} |
| */ |
| @@ -1411,6 +1394,12 @@ cr.define('login', function() { |
| * for all users on desktop. |
| */ |
| showRemoveWarning_: function() { |
|
lwchkg
2015/08/06 04:58:23
I need some help to test for the "legacy supervise
Mike Lerman
2015/08/06 17:38:27
Be signed in to your profile. Then: Chrome Setting
|
| + // Temporary add/remove this class to choose the shorter dialog. The |
| + // problems of switching from a shorter dialog to a longer dialog is |
| + // visually less problematic than otherwise. |
| + // TODO(lwchkg): Show the correct dialog in one pass. |
| + this.classList.toggle('has-no-stats', this.classList.contains('synced')); |
|
lwchkg
2015/08/06 04:58:23
I've verified that this hack does not work, so we
Mike Lerman
2015/08/06 17:38:27
Add something to UserManagerScreenHandler::SendUse
|
| + |
| this.actionBoxMenuRemoveElement.hidden = true; |
| this.actionBoxRemoveUserWarningElement.hidden = false; |
| this.actionBoxRemoveUserWarningButtonElement.focus(); |
| @@ -1425,6 +1414,63 @@ cr.define('login', function() { |
| this.actionBoxAreaElement.classList.add('menu-moved-up'); |
| } |
| chrome.send('logRemoveUserWarningShown'); |
| + |
| + // Show extra statistics information for desktop users |
| + if (this.user.isDesktopUser) { |
| + // set a global handler for the callback |
| + window.updateRemoveWarningDialog = |
| + this.updateRemoveWarningDialog_.bind(this); |
| + window.updateRemoveWarningDialogHasNoStats = |
| + this.updateRemoveWarningDialogHasNoStats_.bind(this); |
| + chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); |
| + } |
| + }, |
| + |
| + /** |
| + * Refresh the statistics in the remove user warning dialog. |
| + * @param {string} profilePath The filepath of the URL (must be verified) |
| + * @param {Object} profileStats Statistics associated with profileURL. |
| + */ |
| + updateRemoveWarningDialog_: function(profilePath, profileStats) { |
| + if (profilePath === this.user.profilePath) { |
| + // Converting profileStats into id attribute by an object. |
| + var stats_id_map = { |
| + 'BrowsingHistory': 'action-box-remove-user-warning-history', |
| + 'Passwords': 'action-box-remove-user-warning-passwords', |
| + 'Bookmarks': 'action-box-remove-user-warning-bookmarks', |
| + 'Settings': 'action-box-remove-user-warning-settings', |
| + } |
| + // Load individual statistics |
| + var num_stats_loaded = 0; |
| + var total_count = 0; |
| + for (var key in profileStats) { |
| + if (stats_id_map.hasOwnProperty(key)) { |
| + this.querySelector("." + stats_id_map[key]).textContent |
| + = profileStats[key]; |
| + num_stats_loaded++; |
| + total_count += profileStats[key]; |
| + } |
| + } |
| + // Write total number if all statistics are loaded. |
| + if (num_stats_loaded === Object.keys(stats_id_map).length) { |
| + elements = this.getElementsByClassName('total-count'); |
| + for (var i = 0; i < elements.length; i++) { |
| + elements[i].textContent = total_count; |
| + } |
| + } |
| + } |
| + }, |
| + |
| + /** |
| + * Select the dialog the statistics in the remove user warning dialog. |
| + * @param {string} profilePath The filepath of the URL (must be verified) |
| + * @param {boolean} hasNoStats Whether the profile has no statistics |
| + * available. |
| + */ |
| + updateRemoveWarningDialogHasNoStats_: function(profilePath, hasNoStats) { |
| + if (profilePath === this.user.profilePath) { |
| + this.classList.toggle('has-no-stats', hasNoStats); |
| + } |
| }, |
| /** |
| @@ -1946,17 +1992,29 @@ cr.define('login', function() { |
| var isLockedUser = this.user.needsSignin; |
| var isLegacySupervisedUser = this.user.legacySupervisedUser; |
| var isChildUser = this.user.childUser; |
| + var isSyncedUser = this.user.emailAddress !== ""; |
| this.classList.toggle('locked', isLockedUser); |
| this.classList.toggle('legacy-supervised', isLegacySupervisedUser); |
| this.classList.toggle('child', isChildUser); |
| + this.classList.toggle('synced', isSyncedUser); |
| if (this.isAuthTypeUserClick) |
| this.passwordLabelElement.textContent = this.authValue; |
| - this.actionBoxRemoveUserWarningTextElement.hidden = |
| - isLegacySupervisedUser; |
| - this.actionBoxRemoveLegacySupervisedUserWarningTextElement.hidden = |
| - !isLegacySupervisedUser; |
| + // Convert HTML textContent into HTML. Done only once. |
| + var tag = |
| + this.querySelector('.action-box-remove-user-warning-text-nonsync'); |
| + if (!tag.childElementCount) { |
| + this.querySelector('.action-box-remove-user-warning-text-nonsync') |
| + .innerHTML = loadTimeData.getString( |
| + 'removeUserWarningTextNonSync'); |
| + this.querySelector('.action-box-remove-user-warning-text-sync') |
| + .innerHTML = loadTimeData.getString( |
| + 'removeUserWarningTextSync'); |
| + this.querySelector('.action-box-remove-user-warning-manage-link-sync') |
| + .innerHTML = loadTimeData.getString( |
| + 'removeUserWarningManageLinkSync'); |
| + } |
| this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
| 'passwordFieldAccessibleName', this.user_.emailAddress)); |