Skip to content

Commit

Permalink
[cros login] Always show public sessions even when user pods are not …
Browse files Browse the repository at this point in the history
…shown per policy.

BUG=363983
TEST=Manually: enrolled to domain with public session configured, disabled user pods on login screen per policy.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267347 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
nkostylev@chromium.org committed Apr 30, 2014
1 parent 54b25a8 commit 7ed04df
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
34 changes: 19 additions & 15 deletions chrome/browser/chromeos/login/existing_user_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,31 +188,35 @@ void ExistingUserController::UpdateLoginDisplay(const UserList& users) {

cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
&show_users_on_signin);
if (show_users_on_signin) {
for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
// TODO(xiyuan): Clean user profile whose email is not in whitelist.
bool meets_locally_managed_requirements =
(*it)->GetType() != User::USER_TYPE_LOCALLY_MANAGED ||
UserManager::Get()->AreLocallyManagedUsersAllowed();
bool meets_whitelist_requirements =
LoginUtils::IsWhitelisted((*it)->email(), NULL) ||
(*it)->GetType() != User::USER_TYPE_REGULAR;
if (meets_locally_managed_requirements && meets_whitelist_requirements) {
filtered_users.push_back(*it);
}
for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
// TODO(xiyuan): Clean user profile whose email is not in whitelist.
bool meets_locally_managed_requirements =
(*it)->GetType() != User::USER_TYPE_LOCALLY_MANAGED ||
UserManager::Get()->AreLocallyManagedUsersAllowed();
bool meets_whitelist_requirements =
LoginUtils::IsWhitelisted((*it)->email(), NULL) ||
(*it)->GetType() != User::USER_TYPE_REGULAR;

// Public session accounts are always shown on login screen.
bool meets_show_users_requirements = show_users_on_signin ||
(*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT;
if (meets_locally_managed_requirements &&
meets_whitelist_requirements &&
meets_show_users_requirements) {
filtered_users.push_back(*it);
}
}

// If no user pods are visible, fallback to single new user pod which will
// have guest session link.
bool show_guest;
cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &show_guest);
bool show_users;
cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_users);
show_users_on_signin |= !filtered_users.empty();
show_guest &= !filtered_users.empty();
bool show_new_user = true;
login_display_->set_parent_window(GetNativeWindow());
login_display_->Init(filtered_users, show_guest, show_users, show_new_user);
login_display_->Init(
filtered_users, show_guest, show_users_on_signin, show_new_user);
host_->OnPreferencesChanged();
}

Expand Down
22 changes: 20 additions & 2 deletions chrome/browser/chromeos/login/wallpaper_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ bool SaveWallpaperInternal(const base::FilePath& path,
return written_bytes == size;
}

// Returns index of the first public session user found in |users|
// or -1 otherwise.
int FindPublicSession(const chromeos::UserList& users) {
int index = -1;
int i = 0;
for (UserList::const_iterator it = users.begin();
it != users.end(); ++it, ++i) {
if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) {
index = i;
break;
}
}

return index;
}

} // namespace

const char kWallpaperSequenceTokenName[] = "wallpaper-sequence";
Expand Down Expand Up @@ -1295,17 +1311,19 @@ void WallpaperManager::InitializeRegisteredDeviceWallpaper() {
DCHECK(result) << "Unable to fetch setting "
<< kAccountsPrefShowUserNamesOnSignIn;
const chromeos::UserList& users = UserManager::Get()->GetUsers();
if (!show_users || users.empty()) {
int public_session_user_index = FindPublicSession(users);
if ((!show_users && public_session_user_index == -1) || users.empty()) {
// Boot into sign in form, preload default wallpaper.
SetDefaultWallpaperDelayed(UserManager::kSignInUser);
return;
}

if (!disable_boot_animation) {
int index = public_session_user_index != -1 ? public_session_user_index : 0;
// Normal boot, load user wallpaper.
// If normal boot animation is disabled wallpaper would be set
// asynchronously once user pods are loaded.
SetUserWallpaperDelayed(users[0]->email());
SetUserWallpaperDelayed(users[index]->email());
}
}

Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/chromeos/login/webui_login_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class WebUILoginDisplay : public LoginDisplay,
// Whether to show guest login.
bool show_guest_;

// Weather to show the user pads or a plain credentials dialogue.
// Weather to show the user pods or a GAIA sign in.
// Public sessions are always shown.
bool show_users_;

// Whether to show add new user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ class SigninScreenHandlerDelegate {
// Whether login as guest is available.
virtual bool IsShowGuest() const = 0;

// Whether login as guest is available.
// Weather to show the user pods or only GAIA sign in.
// Public sessions are always shown.
virtual bool IsShowUsers() const = 0;

// Whether new user pod is available.
Expand Down

0 comments on commit 7ed04df

Please sign in to comment.