Commit 7f831f83 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Fix user chooser minor issues.

This CL fixes two issues related to UserChooserView in
UnifiedSystemTray.
* Ensure the UnifiedSystemTray bubble is expanded before showing
  UserChooserView.
* Show error messages when number of added users reaches the limit.

BUG=890720,890722
TEST=manual

Change-Id: I2ea7c807da18e165f66345e50b9c6cf39e954840
Reviewed-on: https://chromium-review.googlesource.com/1255745Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595760}
parent 2c1abe82
...@@ -229,6 +229,8 @@ void UnifiedSystemTrayController::Fling(int velocity) { ...@@ -229,6 +229,8 @@ void UnifiedSystemTrayController::Fling(int velocity) {
void UnifiedSystemTrayController::ShowUserChooserView() { void UnifiedSystemTrayController::ShowUserChooserView() {
if (!IsUserChooserEnabled()) if (!IsUserChooserEnabled())
return; return;
animation_->Reset(1.0);
UpdateExpandedAmount();
unified_view_->SetDetailedView(new UserChooserView(this)); unified_view_->SetDetailedView(new UserChooserView(this));
} }
......
...@@ -120,6 +120,18 @@ class Separator : public views::View { ...@@ -120,6 +120,18 @@ class Separator : public views::View {
DISALLOW_COPY_AND_ASSIGN(Separator); DISALLOW_COPY_AND_ASSIGN(Separator);
}; };
views::View* CreateAddUserErrorView(const base::string16& message) {
auto* label = new views::Label(message);
label->SetEnabledColor(kUnifiedMenuTextColor);
label->SetAutoColorReadabilityEnabled(false);
label->SetSubpixelRenderingEnabled(false);
label->SetBorder(
views::CreateEmptyBorder(gfx::Insets(kUnifiedTopShortcutSpacing)));
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
return label;
}
} // namespace } // namespace
views::View* CreateUserAvatarView(int user_index) { views::View* CreateUserAvatarView(int user_index) {
...@@ -257,9 +269,24 @@ UserChooserView::UserChooserView(UnifiedSystemTrayController* controller) { ...@@ -257,9 +269,24 @@ UserChooserView::UserChooserView(UnifiedSystemTrayController* controller) {
AddChildView(button); AddChildView(button);
AddChildView(new Separator(i < num_users - 1)); AddChildView(new Separator(i < num_users - 1));
} }
if (Shell::Get()->session_controller()->GetAddUserPolicy() ==
AddUserSessionPolicy::ALLOWED) { switch (Shell::Get()->session_controller()->GetAddUserPolicy()) {
AddChildView(new AddUserButton(controller)); case AddUserSessionPolicy::ALLOWED:
AddChildView(new AddUserButton(controller));
break;
case AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER:
AddChildView(CreateAddUserErrorView(l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER)));
break;
case AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED:
AddChildView(CreateAddUserErrorView(l10n_util::GetStringFUTF16Int(
IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER,
session_manager::kMaximumNumberOfUserSessions)));
break;
case AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS:
AddChildView(CreateAddUserErrorView(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS)));
break;
} }
Shell::Get()->media_controller()->AddObserver(this); Shell::Get()->media_controller()->AddObserver(this);
......
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