[multi-profiles] Allow bringing up sign in UI even if all users are restricted per their policies

* Don't allow launching GAIA sign in for user pod that is shown with multi-profile policy restriction
* Always show policy bubble when hovering over user pod / clicking/tapping on it.

BUG=385498

Review URL: https://codereview.chromium.org/341453002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278547 0039d316-1c4b-4281-b951-d872f2087c98
parent effc1026
...@@ -133,6 +133,11 @@ class UserManager { ...@@ -133,6 +133,11 @@ class UserManager {
virtual const UserList& GetUsers() const = 0; virtual const UserList& GetUsers() const = 0;
// Returns list of users admitted for logging in into multi-profile session. // Returns list of users admitted for logging in into multi-profile session.
// Users that have a policy that prevents them from being added to the
// multi-profile session will still be part of this list as long as they
// are regular users (i.e. not a public session/supervised etc.).
// Returns an empty list in case when primary user is not a regular one or
// has a policy that prohibids it to be part of multi-profile session.
virtual UserList GetUsersAdmittedForMultiProfile() const = 0; virtual UserList GetUsersAdmittedForMultiProfile() const = 0;
// Returns a list of users who are currently logged in. // Returns a list of users who are currently logged in.
......
...@@ -324,7 +324,6 @@ UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const { ...@@ -324,7 +324,6 @@ UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const {
} }
UserList result; UserList result;
int num_users_allowed = 0;
const UserList& users = GetUsers(); const UserList& users = GetUsers();
for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in()) { if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in()) {
...@@ -343,17 +342,10 @@ UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const { ...@@ -343,17 +342,10 @@ UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const {
check == MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS || check == MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS ||
check == MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY) { check == MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY) {
result.push_back(*it); result.push_back(*it);
if (check == MultiProfileUserController::ALLOWED)
num_users_allowed++;
} }
} }
} }
// We only show multi-profiles sign in UI if there's at least one user that
// is allowed to be added to the session.
if (!num_users_allowed)
result.clear();
return result; return result;
} }
......
...@@ -974,6 +974,10 @@ cr.define('cr.ui.login', function() { ...@@ -974,6 +974,10 @@ cr.define('cr.ui.login', function() {
DisplayManager.clearErrors = function() { DisplayManager.clearErrors = function() {
$('bubble').hide(); $('bubble').hide();
this.errorMessageWasShownForTesting_ = false; this.errorMessageWasShownForTesting_ = false;
var bubbles = document.querySelectorAll('.bubble-shown');
for (var i = 0; i < bubbles.length; ++i)
bubbles[i].classList.remove('bubble-shown');
}; };
/** /**
......
...@@ -300,6 +300,7 @@ html[dir=rtl] .user-type-icon-area { ...@@ -300,6 +300,7 @@ html[dir=rtl] .user-type-icon-area {
background-image: url('chrome://theme/IDR_KIOSK_APP_USER_POD_ICON'); background-image: url('chrome://theme/IDR_KIOSK_APP_USER_POD_ICON');
} }
.bubble-shown,
.user-type-icon-area.policy:hover ~ .user-type-bubble { .user-type-icon-area.policy:hover ~ .user-type-bubble {
opacity: 1; opacity: 1;
visibility: visible; visibility: visible;
......
...@@ -362,6 +362,14 @@ cr.define('login', function() { ...@@ -362,6 +362,14 @@ cr.define('login', function() {
return this.querySelector('.user-type-icon-area'); return this.querySelector('.user-type-icon-area');
}, },
/**
* Gets user type bubble like multi-profiles policy restriction message.
* @type {!HTMLDivElement}
*/
get userTypeBubbleElement() {
return this.querySelector('.user-type-bubble');
},
/** /**
* Gets user type icon. * Gets user type icon.
* @type {!HTMLDivElement} * @type {!HTMLDivElement}
...@@ -525,12 +533,9 @@ cr.define('login', function() { ...@@ -525,12 +533,9 @@ cr.define('login', function() {
}, },
customizeUserPodPerUserType: function() { customizeUserPodPerUserType: function() {
var isMultiProfilesUI =
(Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING);
if (this.user_.locallyManagedUser && !this.user_.isDesktopUser) { if (this.user_.locallyManagedUser && !this.user_.isDesktopUser) {
this.setUserPodIconType('supervised'); this.setUserPodIconType('supervised');
} else if (isMultiProfilesUI && !this.user_.isMultiProfilesAllowed) { } else if (this.multiProfilesPolicyApplied) {
// Mark user pod as not focusable which in addition to the grayed out // Mark user pod as not focusable which in addition to the grayed out
// filter makes it look in disabled state. // filter makes it look in disabled state.
this.classList.add('not-focusable'); this.classList.add('not-focusable');
...@@ -566,6 +571,17 @@ cr.define('login', function() { ...@@ -566,6 +571,17 @@ cr.define('login', function() {
this.update(); this.update();
}, },
/**
* Returns true if multi-profiles sign in is currently active and this
* user pod is restricted per policy.
* @type {boolean}
*/
get multiProfilesPolicyApplied() {
var isMultiProfilesUI =
(Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING);
return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed;
},
/** /**
* Gets main input element. * Gets main input element.
* @type {(HTMLButtonElement|HTMLInputElement)} * @type {(HTMLButtonElement|HTMLInputElement)}
...@@ -622,6 +638,8 @@ cr.define('login', function() { ...@@ -622,6 +638,8 @@ cr.define('login', function() {
this.actionBoxAreaElement.classList.add('hovered'); this.actionBoxAreaElement.classList.add('hovered');
this.classList.add('hovered'); this.classList.add('hovered');
} else { } else {
if (this.multiProfilesPolicyApplied)
this.userTypeBubbleElement.classList.remove('bubble-shown');
this.actionBoxAreaElement.classList.remove('hovered'); this.actionBoxAreaElement.classList.remove('hovered');
this.classList.remove('hovered'); this.classList.remove('hovered');
} }
...@@ -752,6 +770,11 @@ cr.define('login', function() { ...@@ -752,6 +770,11 @@ cr.define('login', function() {
if (this.user.locallyManagedUser && !this.user.isDesktopUser) { if (this.user.locallyManagedUser && !this.user.isDesktopUser) {
this.showSupervisedUserSigninWarning(); this.showSupervisedUserSigninWarning();
} else { } else {
// Special case for multi-profiles sign in. We show users even if they
// are not allowed per policy. Restrict those users from starting GAIA.
if (this.multiProfilesPolicyApplied)
return;
this.parentNode.showSigninUI(this.user.emailAddress); this.parentNode.showSigninUI(this.user.emailAddress);
} }
}, },
...@@ -898,6 +921,9 @@ cr.define('login', function() { ...@@ -898,6 +921,9 @@ cr.define('login', function() {
this.parentNode.setActivatedPod(this); this.parentNode.setActivatedPod(this);
} }
if (this.multiProfilesPolicyApplied)
this.userTypeBubbleElement.classList.add('bubble-shown');
// Prevent default so that we don't trigger 'focus' event. // Prevent default so that we don't trigger 'focus' event.
e.preventDefault(); e.preventDefault();
} }
...@@ -1963,6 +1989,9 @@ cr.define('login', function() { ...@@ -1963,6 +1989,9 @@ cr.define('login', function() {
*/ */
focusPod: function(podToFocus, opt_force) { focusPod: function(podToFocus, opt_force) {
if (this.isFocused(podToFocus) && !opt_force) { if (this.isFocused(podToFocus) && !opt_force) {
// Calling focusPod w/o podToFocus means reset.
if (!podToFocus)
Oobe.clearErrors();
this.keyboardActivated_ = false; this.keyboardActivated_ = false;
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment