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

Unified Diff: chrome/browser/resources/chromeos/login/user_pod_row.js

Issue 16104008: First try at a user management screen for the desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix linux CrOS browser test Created 7 years, 5 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: chrome/browser/resources/chromeos/login/user_pod_row.js
diff --git a/chrome/browser/resources/chromeos/login/user_pod_row.js b/chrome/browser/resources/chromeos/login/user_pod_row.js
index 5d62216eae2f08709a247d3eaf7bcba1c2a66b2c..5482a9c6a69e80f4fe1a6107c54ced1c68bf4704 100644
--- a/chrome/browser/resources/chromeos/login/user_pod_row.js
+++ b/chrome/browser/resources/chromeos/login/user_pod_row.js
@@ -154,10 +154,12 @@ cr.define('login', function() {
this.handleRemoveCommandKeyDown_.bind(this));
this.actionBoxMenuRemoveElement.addEventListener('blur',
this.handleRemoveCommandBlur_.bind(this));
- this.actionBoxRemoveManagedUserWarningButtonElement.addEventListener(
- 'click',
- this.handleRemoveUserConfirmationClick_.bind(this));
+ if (this.actionBoxRemoveManagedUserWarningButtonElement) {
+ this.actionBoxRemoveManagedUserWarningButtonElement.addEventListener(
+ 'click',
+ this.handleRemoveUserConfirmationClick_.bind(this));
+ }
},
/**
@@ -332,12 +334,19 @@ cr.define('login', function() {
'?id=' + UserPod.userImageSalt_[this.user.username];
this.nameElement.textContent = this.user_.displayName;
- this.actionBoxAreaElement.hidden = this.user_.publicAccount;
- this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove;
this.signedInIndicatorElement.hidden = !this.user_.signedIn;
var needSignin = this.needGaiaSignin;
this.passwordElement.hidden = needSignin;
+ this.signinButtonElement.hidden = !needSignin;
+
+ this.updateActionBoxArea();
+ },
+
+ updateActionBoxArea: function() {
+ this.actionBoxAreaElement.hidden = this.user_.publicAccount;
+ this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove;
+
this.actionBoxAreaElement.setAttribute(
'aria-label', loadTimeData.getStringF(
'podMenuButtonAccessibleName', this.user_.emailAddress));
@@ -355,7 +364,6 @@ cr.define('login', function() {
loadTimeData.getString('removeUser');
this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF(
'passwordFieldAccessibleName', this.user_.emailAddress));
- this.signinButtonElement.hidden = !needSignin;
this.userTypeIconAreaElement.hidden = !this.user_.locallyManagedUser;
},
@@ -408,7 +416,8 @@ cr.define('login', function() {
if (active) {
this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove;
- this.actionBoxRemoveManagedUserWarningElement.hidden = true;
+ if (this.actionBoxRemoveManagedUserWarningElement)
+ this.actionBoxRemoveManagedUserWarningElement.hidden = true;
// Clear focus first if another pod is focused.
if (!this.parentNode.isFocused(this)) {
@@ -619,6 +628,7 @@ cr.define('login', function() {
handleMouseDown_: function(e) {
if (this.parentNode.disabled)
return;
+
if (!this.signinButtonElement.hidden && !this.isActionBoxMenuActive) {
this.showSigninUI();
// Prevent default so that we don't trigger 'focus' event.
@@ -809,6 +819,79 @@ cr.define('login', function() {
};
/**
+ * Creates a user pod to be used only in desktop chrome.
+ * @constructor
+ * @extends {UserPod}
+ */
+ var DesktopUserPod = cr.ui.define(function() {
+ // Don't just instantiate a UserPod(), as this will call decorate() on the
+ // parent object, and add duplicate event listeners.
+ var node = $('user-pod-template').cloneNode(true);
+ node.removeAttribute('id');
+ return node;
+ });
+
+ DesktopUserPod.prototype = {
+ __proto__: UserPod.prototype,
+
+ /** @override */
+ decorate: function() {
+ UserPod.prototype.decorate.call(this);
+ },
+
+ /** @override */
+ focusInput: function() {
+ var isLockedUser = this.user.needsSignin;
+ this.signinButtonElement.hidden = isLockedUser;
+ this.passwordElement.hidden = !isLockedUser;
+
+ // Move tabIndex from the whole pod to the main input.
+ this.tabIndex = -1;
+ this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT;
+ this.mainInput.focus();
+ },
+
+ /** @override */
+ update: function() {
+ // TODO(noms): Use the actual profile avatar for local profiles once the
+ // new, non-pixellated avatars are available.
+ this.imageElement.src = this.user.emailAddress == '' ?
+ 'chrome://theme/IDR_USER_MANAGER_DEFAULT_AVATAR' :
+ this.user.userImage;
+ this.nameElement.textContent = this.user_.displayName;
+ var isLockedUser = this.user.needsSignin;
+ this.passwordElement.hidden = !isLockedUser;
+ this.signinButtonElement.hidden = isLockedUser;
+
+ UserPod.prototype.updateActionBoxArea.call(this);
+ },
+
+ /** @override */
+ activate: function() {
+ Oobe.launchUser(this.user.emailAddress, this.user.displayName);
+ return true;
+ },
+
+ /** @override */
+ handleMouseDown_: function(e) {
+ if (this.parentNode.disabled)
+ return;
+
+ // Don't sign in until the user presses the button. Just activate the pod.
+ Oobe.clearErrors();
+ this.parentNode.lastFocusedPod_ =
+ this.parentNode.getPodWithUsername_(this.user.emailAddress);
+ },
+
+ /** @override */
+ handleRemoveCommandClick_: function(e) {
+ //TODO(noms): Add deletion confirmation overlay before attempting
+ // to delete the user.
+ UserPod.prototype.handleRemoveCommandClick_.call(this, e);
+ },
+ };
+
+ /**
* Creates a new pod row element.
* @constructor
* @extends {HTMLDivElement}
@@ -914,7 +997,9 @@ cr.define('login', function() {
*/
createUserPod: function(user) {
var userPod;
- if (user.publicAccount)
+ if (user.isDesktopUser)
+ userPod = new DesktopUserPod({user: user});
+ else if (user.publicAccount)
userPod = new PublicAccountUserPod({user: user});
else
userPod = new UserPod({user: user});

Powered by Google App Engine
This is Rietveld 408576698