| 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // set a global handler for the callback |
| 1415 window.updateRemoveWarningDialog = |
| 1416 this.updateRemoveWarningDialog_.bind(this); |
| 1417 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); |
| 1418 } |
| 1428 }, | 1419 }, |
| 1429 | 1420 |
| 1430 /** | 1421 /** |
| 1422 * Refresh the statistics in the remove user warning dialog. |
| 1423 * @param {string} profilePath The filepath of the URL (must be verified) |
| 1424 * @param {Object} profileStats Statistics associated with profileURL. |
| 1425 */ |
| 1426 updateRemoveWarningDialog_: function(profilePath, profileStats) { |
| 1427 if (profilePath === this.user.profilePath) { |
| 1428 // Remove class has-no-stats. The class may be set before, but that is |
| 1429 // no longer true when this function is called. |
| 1430 this.classList.remove('has-no-stats'); |
| 1431 |
| 1432 // Converting profileStats into id attribute by an object. |
| 1433 var stats_id_map = { |
| 1434 'BrowsingHistory': 'action-box-remove-user-warning-history', |
| 1435 'Passwords': 'action-box-remove-user-warning-passwords', |
| 1436 'Bookmarks': 'action-box-remove-user-warning-bookmarks', |
| 1437 'Settings': 'action-box-remove-user-warning-settings', |
| 1438 } |
| 1439 // Load individual statistics |
| 1440 var num_stats_loaded = 0; |
| 1441 var total_count = 0; |
| 1442 for (var key in profileStats) { |
| 1443 if (stats_id_map.hasOwnProperty(key)) { |
| 1444 var count = profileStats[key].success ? profileStats[key].count : 0; |
| 1445 this.querySelector("." + stats_id_map[key]).textContent = count; |
| 1446 num_stats_loaded++; |
| 1447 total_count += count; |
| 1448 } |
| 1449 } |
| 1450 // Write total number if all statistics are loaded. |
| 1451 if (num_stats_loaded === Object.keys(stats_id_map).length) { |
| 1452 elements = this.getElementsByClassName('total-count'); |
| 1453 for (var i = 0; i < elements.length; i++) { |
| 1454 elements[i].textContent = total_count; |
| 1455 } |
| 1456 } |
| 1457 } |
| 1458 }, |
| 1459 |
| 1460 /** |
| 1431 * Handles a click event on remove user confirmation button. | 1461 * Handles a click event on remove user confirmation button. |
| 1432 * @param {Event} e Click event. | 1462 * @param {Event} e Click event. |
| 1433 */ | 1463 */ |
| 1434 handleRemoveUserConfirmationClick_: function(e) { | 1464 handleRemoveUserConfirmationClick_: function(e) { |
| 1435 if (this.isActionBoxMenuActive) { | 1465 if (this.isActionBoxMenuActive) { |
| 1436 this.isActionBoxMenuActive = false; | 1466 this.isActionBoxMenuActive = false; |
| 1437 this.removeUser(this.user); | 1467 this.removeUser(this.user); |
| 1438 e.stopPropagation(); | 1468 e.stopPropagation(); |
| 1439 } | 1469 } |
| 1440 }, | 1470 }, |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 | 1973 |
| 1944 /** @override */ | 1974 /** @override */ |
| 1945 update: function() { | 1975 update: function() { |
| 1946 this.imageElement.src = this.user.userImage; | 1976 this.imageElement.src = this.user.userImage; |
| 1947 this.nameElement.textContent = this.user.displayName; | 1977 this.nameElement.textContent = this.user.displayName; |
| 1948 this.reauthNameHintElement.textContent = this.user.displayName; | 1978 this.reauthNameHintElement.textContent = this.user.displayName; |
| 1949 | 1979 |
| 1950 var isLockedUser = this.user.needsSignin; | 1980 var isLockedUser = this.user.needsSignin; |
| 1951 var isLegacySupervisedUser = this.user.legacySupervisedUser; | 1981 var isLegacySupervisedUser = this.user.legacySupervisedUser; |
| 1952 var isChildUser = this.user.childUser; | 1982 var isChildUser = this.user.childUser; |
| 1983 var isSyncedUser = this.user.emailAddress !== ""; |
| 1984 var isProfileLoaded = this.user.isProfileLoaded; |
| 1953 this.classList.toggle('locked', isLockedUser); | 1985 this.classList.toggle('locked', isLockedUser); |
| 1954 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); | 1986 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); |
| 1955 this.classList.toggle('child', isChildUser); | 1987 this.classList.toggle('child', isChildUser); |
| 1988 this.classList.toggle('synced', isSyncedUser); |
| 1989 this.classList.toggle('has-no-stats', !isProfileLoaded); |
| 1956 | 1990 |
| 1957 if (this.isAuthTypeUserClick) | 1991 if (this.isAuthTypeUserClick) |
| 1958 this.passwordLabelElement.textContent = this.authValue; | 1992 this.passwordLabelElement.textContent = this.authValue; |
| 1959 | 1993 |
| 1960 this.actionBoxRemoveUserWarningTextElement.hidden = | 1994 // Convert HTML textContent into HTML. Done only once. |
| 1961 isLegacySupervisedUser; | 1995 var tag = |
| 1962 this.actionBoxRemoveLegacySupervisedUserWarningTextElement.hidden = | 1996 this.querySelector('.action-box-remove-user-warning-text-nonsync'); |
| 1963 !isLegacySupervisedUser; | 1997 if (!tag.childElementCount) { |
| 1998 this.querySelector('.action-box-remove-user-warning-text-nonsync') |
| 1999 .innerHTML = loadTimeData.getString( |
| 2000 'removeUserWarningTextNonSync'); |
| 2001 this.querySelector('.action-box-remove-user-warning-text-sync') |
| 2002 .innerHTML = loadTimeData.getString( |
| 2003 'removeUserWarningTextSync'); |
| 2004 } |
| 1964 | 2005 |
| 1965 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( | 2006 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
| 1966 'passwordFieldAccessibleName', this.user_.emailAddress)); | 2007 'passwordFieldAccessibleName', this.user_.emailAddress)); |
| 1967 | 2008 |
| 1968 UserPod.prototype.updateActionBoxArea.call(this); | 2009 UserPod.prototype.updateActionBoxArea.call(this); |
| 1969 }, | 2010 }, |
| 1970 | 2011 |
| 1971 /** @override */ | 2012 /** @override */ |
| 1972 activate: function(e) { | 2013 activate: function(e) { |
| 1973 if (!this.user.needsSignin) { | 2014 if (!this.user.needsSignin) { |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3173 if (pod && pod.multiProfilesPolicyApplied) { | 3214 if (pod && pod.multiProfilesPolicyApplied) { |
| 3174 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3215 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3175 } | 3216 } |
| 3176 } | 3217 } |
| 3177 }; | 3218 }; |
| 3178 | 3219 |
| 3179 return { | 3220 return { |
| 3180 PodRow: PodRow | 3221 PodRow: PodRow |
| 3181 }; | 3222 }; |
| 3182 }); | 3223 }); |
| OLD | NEW |