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

Side by Side 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: Ninth draft - singular/plural strings handled correctly Created 5 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
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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 947
948 /** 948 /**
949 * Gets action box menu, remove user command item div. 949 * Gets action box menu, remove user command item div.
950 * @type {!HTMLInputElement} 950 * @type {!HTMLInputElement}
951 */ 951 */
952 get actionBoxMenuRemoveElement() { 952 get actionBoxMenuRemoveElement() {
953 return this.querySelector('.action-box-menu-remove'); 953 return this.querySelector('.action-box-menu-remove');
954 }, 954 },
955 955
956 /** 956 /**
957 * Gets action box menu, remove user warning text div.
958 * @type {!HTMLInputElement}
959 */
960 get actionBoxRemoveUserWarningTextElement() {
961 return this.querySelector('.action-box-remove-user-warning-text');
962 },
963
964 /**
965 * Gets action box menu, remove legacy supervised user warning text div.
966 * @type {!HTMLInputElement}
967 */
968 get actionBoxRemoveLegacySupervisedUserWarningTextElement() {
969 return this.querySelector(
970 '.action-box-remove-legacy-supervised-user-warning-text');
971 },
972
973 /**
974 * Gets action box menu, remove user command item div. 957 * Gets action box menu, remove user command item div.
975 * @type {!HTMLInputElement} 958 * @type {!HTMLInputElement}
976 */ 959 */
977 get actionBoxRemoveUserWarningElement() { 960 get actionBoxRemoveUserWarningElement() {
978 return this.querySelector('.action-box-remove-user-warning'); 961 return this.querySelector('.action-box-remove-user-warning');
979 }, 962 },
980 963
981 /** 964 /**
982 * Gets action box menu, remove user command item div. 965 * Gets action box menu, remove user command item div.
983 * @type {!HTMLInputElement} 966 * @type {!HTMLInputElement}
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 // Move up the menu if it overlaps shelf. 1401 // Move up the menu if it overlaps shelf.
1419 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( 1402 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping(
1420 this.actionBoxMenu); 1403 this.actionBoxMenu);
1421 var actualHeight = parseInt( 1404 var actualHeight = parseInt(
1422 window.getComputedStyle(this.actionBoxMenu).height); 1405 window.getComputedStyle(this.actionBoxMenu).height);
1423 if (maxHeight < actualHeight) { 1406 if (maxHeight < actualHeight) {
1424 this.actionBoxMenu.classList.add('menu-moved-up'); 1407 this.actionBoxMenu.classList.add('menu-moved-up');
1425 this.actionBoxAreaElement.classList.add('menu-moved-up'); 1408 this.actionBoxAreaElement.classList.add('menu-moved-up');
1426 } 1409 }
1427 chrome.send('logRemoveUserWarningShown'); 1410 chrome.send('logRemoveUserWarningShown');
1411
1412 // Show extra statistics information for desktop users
1413 if (this.user.isDesktopUser) {
1414 this.classList.remove('has-errors');
1415 var isSyncedUser = this.user.emailAddress !== "";
1416 if (!this.user.isProfileLoaded) {
1417 var message = loadTimeData.getString(
1418 isSyncedUser ? 'removeUserWarningTextSyncNoStats' :
1419 'removeUserWarningTextNonSyncNoStats');
1420 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath,
1421 message);
1422 } else {
1423 window.updateRemoveWarningDialogSetMessage =
1424 this.updateRemoveWarningDialogSetMessage_.bind(this);
1425 chrome.send('getRemoveWarningDialogMessage',[{
1426 profilePath: this.user.profilePath,
1427 isSyncedUser: isSyncedUser,
1428 hasErrors: false,
1429 hasCount: false
1430 }]);
1431 }
1432
1433 // set a global handler for the callback
1434 window.updateRemoveWarningDialog =
1435 this.updateRemoveWarningDialog_.bind(this);
1436 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]);
1437 }
1428 }, 1438 },
1429 1439
1430 /** 1440 /**
1441 * Refresh the statistics in the remove user warning dialog.
1442 * @param {string} profilePath The filepath of the URL (must be verified).
1443 * @param {Object} profileStats Statistics associated with profileURL.
1444 */
1445 updateRemoveWarningDialog_: function(profilePath, profileStats) {
1446 if (profilePath !== this.user.profilePath)
1447 return;
1448 // Converting profileStats into id attribute by an object.
1449 var stats_id_map = {
1450 'BrowsingHistory': 'action-box-remove-user-warning-history',
1451 'Passwords': 'action-box-remove-user-warning-passwords',
1452 'Bookmarks': 'action-box-remove-user-warning-bookmarks',
1453 'Settings': 'action-box-remove-user-warning-settings',
1454 }
1455 // Load individual statistics
1456 var num_stats_loaded = 0;
1457 var total_count = 0;
1458 var failed = false;
1459 for (var key in profileStats) {
1460 if (stats_id_map.hasOwnProperty(key)) {
1461 if (profileStats[key].success) {
1462 var count = profileStats[key].count;
1463 this.querySelector("." + stats_id_map[key]).textContent = count;
1464 total_count += count;
1465 } else {
1466 failed = true;
1467 this.querySelector("." + stats_id_map[key]).textContent = '';
1468 }
1469 num_stats_loaded++;
1470 }
1471 }
1472
1473 // this.classList is used for selecting the appropriate dialog.
1474 this.classList.toggle('has-errors', failed);
1475 if (total_count > 0) {
1476 this.classList.remove('has-no-stats');
1477 }
1478
1479 // Write total number if all statistics are loaded.
1480 if (num_stats_loaded === Object.keys(stats_id_map).length) {
1481 if (total_count === 0) {
1482 this.classList.add('has-no-stats');
1483 var isSyncedUser = this.user.emailAddress !== "";
1484 var message = loadTimeData.getString(
1485 isSyncedUser ? 'removeUserWarningTextSyncNoStats' :
1486 'removeUserWarningTextNonSyncNoStats');
1487 this.updateRemoveWarningDialogSetMessage_(this.user.profilePath,
1488 message);
1489 } else {
1490 window.updateRemoveWarningDialogSetMessage =
1491 this.updateRemoveWarningDialogSetMessage_.bind(this);
1492 chrome.send('getRemoveWarningDialogMessage',[{
1493 profilePath: this.user.profilePath,
1494 isSyncedUser: this.user.emailAddress !== "",
1495 hasErrors: failed,
1496 hasCount: true,
1497 totalCount: total_count
1498 }]);
1499 }
1500 }
1501 },
1502
1503 /**
1504 * Refresh the message in the remove user warning dialog.
1505 * @param {string} profilePath The filepath of the URL (must be verified).
1506 * @param {string} message The message to be written.
1507 * @param {number|string=} count The number or string to replace $1 in
1508 * |message|. Can be omitted if $1 is not present in |message|.
1509 */
1510 updateRemoveWarningDialogSetMessage_: function(profilePath, message,
1511 count) {
1512 if (profilePath !== this.user.profilePath)
1513 return;
1514 // Add localized messages where $1 will be replaced with
1515 // <span class="total-count"></span>.
1516 var element = this.querySelector('.action-box-remove-user-warning-text');
1517 while (element.firstChild)
1518 element.removeChild(element.firstChild);
1519
1520 messageParts = message.split('$1');
1521 var numParts = messageParts.length;
1522 for (var j = 0; j < numParts; j++) {
1523 element.appendChild(document.createTextNode(messageParts[j]));
1524 if (j < numParts - 1) {
1525 var elementToAdd = document.createElement('span');
1526 elementToAdd.classList.add('total-count');
1527 elementToAdd.textContent = count;
1528 element.appendChild(elementToAdd);
1529 }
1530 }
1531 },
1532
1533 /**
1431 * Handles a click event on remove user confirmation button. 1534 * Handles a click event on remove user confirmation button.
1432 * @param {Event} e Click event. 1535 * @param {Event} e Click event.
1433 */ 1536 */
1434 handleRemoveUserConfirmationClick_: function(e) { 1537 handleRemoveUserConfirmationClick_: function(e) {
1435 if (this.isActionBoxMenuActive) { 1538 if (this.isActionBoxMenuActive) {
1436 this.isActionBoxMenuActive = false; 1539 this.isActionBoxMenuActive = false;
1437 this.removeUser(this.user); 1540 this.removeUser(this.user);
1438 e.stopPropagation(); 1541 e.stopPropagation();
1439 } 1542 }
1440 }, 1543 },
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 2046
1944 /** @override */ 2047 /** @override */
1945 update: function() { 2048 update: function() {
1946 this.imageElement.src = this.user.userImage; 2049 this.imageElement.src = this.user.userImage;
1947 this.nameElement.textContent = this.user.displayName; 2050 this.nameElement.textContent = this.user.displayName;
1948 this.reauthNameHintElement.textContent = this.user.displayName; 2051 this.reauthNameHintElement.textContent = this.user.displayName;
1949 2052
1950 var isLockedUser = this.user.needsSignin; 2053 var isLockedUser = this.user.needsSignin;
1951 var isLegacySupervisedUser = this.user.legacySupervisedUser; 2054 var isLegacySupervisedUser = this.user.legacySupervisedUser;
1952 var isChildUser = this.user.childUser; 2055 var isChildUser = this.user.childUser;
2056 var isSyncedUser = this.user.emailAddress !== "";
2057 var isProfileLoaded = this.user.isProfileLoaded;
1953 this.classList.toggle('locked', isLockedUser); 2058 this.classList.toggle('locked', isLockedUser);
1954 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); 2059 this.classList.toggle('legacy-supervised', isLegacySupervisedUser);
1955 this.classList.toggle('child', isChildUser); 2060 this.classList.toggle('child', isChildUser);
2061 this.classList.toggle('synced', isSyncedUser);
2062 this.classList.toggle('has-no-stats', !isProfileLoaded);
1956 2063
1957 if (this.isAuthTypeUserClick) 2064 if (this.isAuthTypeUserClick)
1958 this.passwordLabelElement.textContent = this.authValue; 2065 this.passwordLabelElement.textContent = this.authValue;
1959 2066
1960 this.actionBoxRemoveUserWarningTextElement.hidden =
1961 isLegacySupervisedUser;
1962 this.actionBoxRemoveLegacySupervisedUserWarningTextElement.hidden =
1963 !isLegacySupervisedUser;
1964
1965 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( 2067 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF(
1966 'passwordFieldAccessibleName', this.user_.emailAddress)); 2068 'passwordFieldAccessibleName', this.user_.emailAddress));
1967 2069
1968 UserPod.prototype.updateActionBoxArea.call(this); 2070 UserPod.prototype.updateActionBoxArea.call(this);
1969 }, 2071 },
1970 2072
1971 /** @override */ 2073 /** @override */
1972 activate: function(e) { 2074 activate: function(e) {
1973 if (!this.user.needsSignin) { 2075 if (!this.user.needsSignin) {
1974 Oobe.launchUser(this.user.profilePath); 2076 Oobe.launchUser(this.user.profilePath);
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3173 if (pod && pod.multiProfilesPolicyApplied) { 3275 if (pod && pod.multiProfilesPolicyApplied) {
3174 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3276 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3175 } 3277 }
3176 } 3278 }
3177 }; 3279 };
3178 3280
3179 return { 3281 return {
3180 PodRow: PodRow 3282 PodRow: PodRow
3181 }; 3283 };
3182 }); 3284 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698