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 this.querySelector("." + stats_id_map[key]).textContent | |
1445 = profileStats[key]; | |
1446 num_stats_loaded++; | |
1447 total_count += profileStats[key]; | |
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1939 | 1969 |
1940 /** @override */ | 1970 /** @override */ |
1941 update: function() { | 1971 update: function() { |
1942 this.imageElement.src = this.user.userImage; | 1972 this.imageElement.src = this.user.userImage; |
1943 this.nameElement.textContent = this.user.displayName; | 1973 this.nameElement.textContent = this.user.displayName; |
1944 this.reauthNameHintElement.textContent = this.user.displayName; | 1974 this.reauthNameHintElement.textContent = this.user.displayName; |
1945 | 1975 |
1946 var isLockedUser = this.user.needsSignin; | 1976 var isLockedUser = this.user.needsSignin; |
1947 var isLegacySupervisedUser = this.user.legacySupervisedUser; | 1977 var isLegacySupervisedUser = this.user.legacySupervisedUser; |
1948 var isChildUser = this.user.childUser; | 1978 var isChildUser = this.user.childUser; |
1979 var isSyncedUser = this.user.emailAddress !== ""; | |
1980 var isProfileLoaded = this.user.isProfileLoaded; | |
1949 this.classList.toggle('locked', isLockedUser); | 1981 this.classList.toggle('locked', isLockedUser); |
1950 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); | 1982 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); |
1951 this.classList.toggle('child', isChildUser); | 1983 this.classList.toggle('child', isChildUser); |
1984 this.classList.toggle('synced', isSyncedUser); | |
1985 this.classList.toggle('has-no-stats', !isProfileLoaded); | |
1952 | 1986 |
1953 if (this.isAuthTypeUserClick) | 1987 if (this.isAuthTypeUserClick) |
1954 this.passwordLabelElement.textContent = this.authValue; | 1988 this.passwordLabelElement.textContent = this.authValue; |
1955 | 1989 |
1956 this.actionBoxRemoveUserWarningTextElement.hidden = | 1990 // Convert HTML textContent into HTML. Done only once. |
1957 isLegacySupervisedUser; | 1991 var tag = |
1958 this.actionBoxRemoveLegacySupervisedUserWarningTextElement.hidden = | 1992 this.querySelector('.action-box-remove-user-warning-text-nonsync'); |
1959 !isLegacySupervisedUser; | 1993 if (!tag.childElementCount) { |
1994 this.querySelector('.action-box-remove-user-warning-text-nonsync') | |
1995 .innerHTML = loadTimeData.getString( | |
Dmitry Polukhin
2015/08/13 15:34:17
For security reasons I prefer use textContent here
lwchkg
2015/08/17 17:36:32
I see. So I'll try other methods.
| |
1996 'removeUserWarningTextNonSync'); | |
1997 this.querySelector('.action-box-remove-user-warning-text-sync') | |
1998 .innerHTML = loadTimeData.getString( | |
1999 'removeUserWarningTextSync'); | |
2000 } | |
1960 | 2001 |
1961 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( | 2002 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
1962 'passwordFieldAccessibleName', this.user_.emailAddress)); | 2003 'passwordFieldAccessibleName', this.user_.emailAddress)); |
1963 | 2004 |
1964 UserPod.prototype.updateActionBoxArea.call(this); | 2005 UserPod.prototype.updateActionBoxArea.call(this); |
1965 }, | 2006 }, |
1966 | 2007 |
1967 /** @override */ | 2008 /** @override */ |
1968 focusInput: function() { | 2009 focusInput: function() { |
1969 // Move tabIndex from the whole pod to the main input. | 2010 // 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) { | 3215 if (pod && pod.multiProfilesPolicyApplied) { |
3175 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3216 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3176 } | 3217 } |
3177 } | 3218 } |
3178 }; | 3219 }; |
3179 | 3220 |
3180 return { | 3221 return { |
3181 PodRow: PodRow | 3222 PodRow: PodRow |
3182 }; | 3223 }; |
3183 }); | 3224 }); |
OLD | NEW |