Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1404 } | 1387 } |
| 1405 if (this.isActionBoxMenuActive) | 1388 if (this.isActionBoxMenuActive) |
| 1406 chrome.send('removeUser', [this.user.username]); | 1389 chrome.send('removeUser', [this.user.username]); |
| 1407 }, | 1390 }, |
| 1408 | 1391 |
| 1409 /** | 1392 /** |
| 1410 * Shows remove user warning. Used for legacy supervised users on CrOS, and | 1393 * Shows remove user warning. Used for legacy supervised users on CrOS, and |
| 1411 * for all users on desktop. | 1394 * for all users on desktop. |
| 1412 */ | 1395 */ |
| 1413 showRemoveWarning_: function() { | 1396 showRemoveWarning_: function() { |
| 1397 // Temporary add/remove this class to choose the shorter dialog. The | |
| 1398 // problems of switching from a shorter dialog to a longer dialog is | |
| 1399 // visually less problematic than otherwise. | |
| 1400 // TODO(lwchkg): Show the correct dialog in one pass. | |
| 1401 this.classList.toggle('has-no-stats', this.classList.contains('synced')); | |
| 1402 | |
| 1414 this.actionBoxMenuRemoveElement.hidden = true; | 1403 this.actionBoxMenuRemoveElement.hidden = true; |
| 1415 this.actionBoxRemoveUserWarningElement.hidden = false; | 1404 this.actionBoxRemoveUserWarningElement.hidden = false; |
| 1416 this.actionBoxRemoveUserWarningButtonElement.focus(); | 1405 this.actionBoxRemoveUserWarningButtonElement.focus(); |
| 1417 | 1406 |
| 1418 // Move up the menu if it overlaps shelf. | 1407 // Move up the menu if it overlaps shelf. |
| 1419 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( | 1408 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( |
| 1420 this.actionBoxMenu); | 1409 this.actionBoxMenu); |
| 1421 var actualHeight = parseInt( | 1410 var actualHeight = parseInt( |
| 1422 window.getComputedStyle(this.actionBoxMenu).height); | 1411 window.getComputedStyle(this.actionBoxMenu).height); |
| 1423 if (maxHeight < actualHeight) { | 1412 if (maxHeight < actualHeight) { |
| 1424 this.actionBoxMenu.classList.add('menu-moved-up'); | 1413 this.actionBoxMenu.classList.add('menu-moved-up'); |
| 1425 this.actionBoxAreaElement.classList.add('menu-moved-up'); | 1414 this.actionBoxAreaElement.classList.add('menu-moved-up'); |
| 1426 } | 1415 } |
| 1427 chrome.send('logRemoveUserWarningShown'); | 1416 chrome.send('logRemoveUserWarningShown'); |
| 1417 | |
| 1418 // Show extra statistics information for desktop users | |
| 1419 if (this.user.isDesktopUser) { | |
| 1420 // set a global handler for the callback | |
| 1421 window.updateRemoveWarningDialog = | |
| 1422 this.updateRemoveWarningDialog_.bind(this); | |
| 1423 window.updateRemoveWarningDialogHasNoStats = | |
| 1424 this.updateRemoveWarningDialogHasNoStats_.bind(this); | |
| 1425 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); | |
| 1426 } | |
| 1428 }, | 1427 }, |
| 1429 | 1428 |
| 1430 /** | 1429 /** |
| 1430 * Refresh the statistics in the remove user warning dialog. | |
| 1431 * @param {string} profilePath The filepath of the URL (must be verified) | |
| 1432 * @param {Object} profileStats Statistics associated with profileURL. | |
| 1433 */ | |
| 1434 updateRemoveWarningDialog_: function(profilePath, profileStats) { | |
| 1435 if (profilePath === this.user.profilePath) { | |
| 1436 // Converting profileStats into id attribute by an object. | |
| 1437 var stats_id_map = { | |
| 1438 'BrowsingHistory': 'action-box-remove-user-warning-history', | |
| 1439 'Passwords': 'action-box-remove-user-warning-passwords', | |
| 1440 'Bookmarks': 'action-box-remove-user-warning-bookmarks', | |
| 1441 'Settings': 'action-box-remove-user-warning-settings', | |
| 1442 } | |
| 1443 // Load individual statistics | |
| 1444 var num_stats_loaded = 0; | |
| 1445 var total_count = 0; | |
| 1446 for (var key in profileStats) { | |
| 1447 if (stats_id_map.hasOwnProperty(key)) { | |
| 1448 this.querySelector("." + stats_id_map[key]).textContent | |
| 1449 = profileStats[key]; | |
| 1450 num_stats_loaded++; | |
| 1451 total_count += profileStats[key]; | |
| 1452 } | |
| 1453 } | |
| 1454 // Write total number if all statistics are loaded. | |
| 1455 if (num_stats_loaded === Object.keys(stats_id_map).length) { | |
| 1456 elements = this.getElementsByClassName('total-count'); | |
| 1457 for (var i = 0; i < elements.length; i++) { | |
| 1458 elements[i].textContent = total_count; | |
| 1459 } | |
| 1460 } | |
| 1461 } | |
| 1462 }, | |
| 1463 | |
| 1464 /** | |
| 1465 * Select the dialog the statistics in the remove user warning dialog. | |
| 1466 * @param {string} profilePath The filepath of the URL (must be verified) | |
| 1467 * @param {boolean} hasNoStats Whether the profile has no statistics | |
| 1468 * available. | |
| 1469 */ | |
| 1470 updateRemoveWarningDialogHasNoStats_: function(profilePath, hasNoStats) { | |
| 1471 if (profilePath === this.user.profilePath) { | |
| 1472 this.classList.toggle('has-no-stats', hasNoStats); | |
| 1473 } | |
| 1474 }, | |
| 1475 | |
| 1476 /** | |
| 1431 * Handles a click event on remove user confirmation button. | 1477 * Handles a click event on remove user confirmation button. |
| 1432 * @param {Event} e Click event. | 1478 * @param {Event} e Click event. |
| 1433 */ | 1479 */ |
| 1434 handleRemoveUserConfirmationClick_: function(e) { | 1480 handleRemoveUserConfirmationClick_: function(e) { |
| 1435 if (this.isActionBoxMenuActive) { | 1481 if (this.isActionBoxMenuActive) { |
| 1436 this.isActionBoxMenuActive = false; | 1482 this.isActionBoxMenuActive = false; |
| 1437 this.removeUser(this.user); | 1483 this.removeUser(this.user); |
| 1438 e.stopPropagation(); | 1484 e.stopPropagation(); |
| 1439 } | 1485 } |
| 1440 }, | 1486 }, |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1939 | 1985 |
| 1940 /** @override */ | 1986 /** @override */ |
| 1941 update: function() { | 1987 update: function() { |
| 1942 this.imageElement.src = this.user.userImage; | 1988 this.imageElement.src = this.user.userImage; |
| 1943 this.nameElement.textContent = this.user.displayName; | 1989 this.nameElement.textContent = this.user.displayName; |
| 1944 this.reauthNameHintElement.textContent = this.user.displayName; | 1990 this.reauthNameHintElement.textContent = this.user.displayName; |
| 1945 | 1991 |
| 1946 var isLockedUser = this.user.needsSignin; | 1992 var isLockedUser = this.user.needsSignin; |
| 1947 var isLegacySupervisedUser = this.user.legacySupervisedUser; | 1993 var isLegacySupervisedUser = this.user.legacySupervisedUser; |
| 1948 var isChildUser = this.user.childUser; | 1994 var isChildUser = this.user.childUser; |
| 1995 var isSyncedUser = this.user.emailAddress !== ""; | |
| 1949 this.classList.toggle('locked', isLockedUser); | 1996 this.classList.toggle('locked', isLockedUser); |
| 1950 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); | 1997 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); |
| 1951 this.classList.toggle('child', isChildUser); | 1998 this.classList.toggle('child', isChildUser); |
| 1999 this.classList.toggle('synced', isSyncedUser); | |
| 1952 | 2000 |
| 1953 if (this.isAuthTypeUserClick) | 2001 if (this.isAuthTypeUserClick) |
| 1954 this.passwordLabelElement.textContent = this.authValue; | 2002 this.passwordLabelElement.textContent = this.authValue; |
| 1955 | 2003 |
| 1956 this.actionBoxRemoveUserWarningTextElement.hidden = | 2004 // Convert HTML textContent into HTML. Done only once. |
| 1957 isLegacySupervisedUser; | 2005 var tag = |
| 1958 this.actionBoxRemoveLegacySupervisedUserWarningTextElement.hidden = | 2006 this.querySelector('.action-box-remove-user-warning-text-nonsync'); |
| 1959 !isLegacySupervisedUser; | 2007 if (!tag.childElementCount) { |
| 2008 this.querySelector('.action-box-remove-user-warning-text-nonsync') | |
|
lwchkg
2015/07/30 17:07:19
nits: wrong indentation. Will update in the next p
| |
| 2009 .innerHTML = loadTimeData.getString( | |
| 2010 'removeUserWarningTextNonSync'); | |
| 2011 this.querySelector('.action-box-remove-user-warning-text-sync') | |
| 2012 .innerHTML = loadTimeData.getString( | |
| 2013 'removeUserWarningTextSync'); | |
| 2014 this.querySelector('.action-box-remove-user-warning-manage-link-sync') | |
| 2015 .innerHTML = loadTimeData.getString( | |
| 2016 'removeUserWarningManageLinkSync'); | |
| 2017 } | |
| 1960 | 2018 |
| 1961 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( | 2019 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
| 1962 'passwordFieldAccessibleName', this.user_.emailAddress)); | 2020 'passwordFieldAccessibleName', this.user_.emailAddress)); |
| 1963 | 2021 |
| 1964 UserPod.prototype.updateActionBoxArea.call(this); | 2022 UserPod.prototype.updateActionBoxArea.call(this); |
| 1965 }, | 2023 }, |
| 1966 | 2024 |
| 1967 /** @override */ | 2025 /** @override */ |
| 1968 focusInput: function() { | 2026 focusInput: function() { |
| 1969 // Move tabIndex from the whole pod to the main input. | 2027 // Move tabIndex from the whole pod to the main input. |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3174 if (pod && pod.multiProfilesPolicyApplied) { | 3232 if (pod && pod.multiProfilesPolicyApplied) { |
| 3175 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3233 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3176 } | 3234 } |
| 3177 } | 3235 } |
| 3178 }; | 3236 }; |
| 3179 | 3237 |
| 3180 return { | 3238 return { |
| 3181 PodRow: PodRow | 3239 PodRow: PodRow |
| 3182 }; | 3240 }; |
| 3183 }); | 3241 }); |
| OLD | NEW |