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

Unified Diff: ui/login/account_picker/user_pod_row.js

Issue 1248613003: Issue 501916 : Add data type counts to profile deletion flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update: HTML message in generated_resouces.grd changed to plain text. HTML tags are generated by JS now. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
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 6115625876b80feb04eddd91c5c6add47165e425..9ef1dcb62bc28fd93f9fdeead202f32b25b07cc6 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)) {
+ var count = profileStats[key].success ? profileStats[key].count : 0;
Mike Lerman 2015/08/24 14:45:40 I'm not sure if an error in counting means we want
lwchkg 2015/08/26 14:43:12 By rolfe: (actually referring to #39 in the bug)
Mike Lerman 2015/08/27 18:13:48 Having asked the question, I prefer to implement t
+ this.querySelector("." + stats_id_map[key]).textContent = count;
+ num_stats_loaded++;
+ total_count += count;
+ }
+ }
+ // 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;
+ }
+ }
+ }
},
/**
@@ -1950,17 +1980,49 @@ 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;
+ // Add localized messages where $1 will be replaced with
+ // <span class="total-count"></span>. Done only once.
+ messagesToAdd = [
+ {
+ selector: '.action-box-remove-user-warning-text-nonsync',
+ messageID: 'removeUserWarningTextNonSync'
+ },
+ {
+ selector: '.action-box-remove-user-warning-text-sync',
+ messageID: 'removeUserWarningTextSync'
+ }
+ ];
+ var waitingMessage =
+ loadTimeData.getString('removeUserWarningTextCalculating');
+ for (var i = 0; i < messagesToAdd.length; i++) {
+ var element = this.querySelector(messagesToAdd[i].selector);
+ if (element.childElementCount)
+ continue;
+
+ var message = loadTimeData.getString(messagesToAdd[i].messageID);
+ messageParts = message.split('$1');
+ numParts = messageParts.length;
+ for (var j = 0; j < numParts; j++) {
+ element.appendChild(document.createTextNode(messageParts[j]));
+ if (j < numParts - 1) {
+ var elementToAdd = document.createElement('span');
+ elementToAdd.classList.add('total-count');
+ elementToAdd.textContent = waitingMessage;
+ element.appendChild(elementToAdd);
+ }
+ }
+ }
this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF(
'passwordFieldAccessibleName', this.user_.emailAddress));

Powered by Google App Engine
This is Rietveld 408576698