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..df1ad9118ae5eb1d7240315bccb5136e07697ccc 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} |
*/ |
@@ -1425,6 +1408,53 @@ 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); |
+ 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) { |
+ // Remove class has-no-stats. The class may be set before, but that is |
+ // no longer true when this function is called. |
+ this.classList.remove('has-no-stats'); |
+ |
+ // 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; |
+ } |
+ } |
+ } |
}, |
/** |
@@ -1946,17 +1976,31 @@ cr.define('login', function() { |
var isLockedUser = this.user.needsSignin; |
var isLegacySupervisedUser = this.user.legacySupervisedUser; |
var isChildUser = this.user.childUser; |
+ var isSyncedUser = this.user.emailAddress !== ""; |
+ var isProfileLoaded = this.user.isProfileLoaded; |
this.classList.toggle('locked', isLockedUser); |
this.classList.toggle('legacy-supervised', isLegacySupervisedUser); |
this.classList.toggle('child', isChildUser); |
+ this.classList.toggle('synced', isSyncedUser); |
+ this.classList.toggle('has-no-stats', !isProfileLoaded); |
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)); |