Commit aea6a8e3 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Disable user chooser btn with single user

In the old SystemTray, user button was not focusable when there was only
one user account on the device.

TEST=manual
BUG=863337

Change-Id: I8373b144371fce060c454ae07e7456f1fe914a4f
Reviewed-on: https://chromium-review.googlesource.com/1164869Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581429}
parent 6ea40306
...@@ -146,6 +146,7 @@ TopShortcutsView::TopShortcutsView(UnifiedSystemTrayController* controller) ...@@ -146,6 +146,7 @@ TopShortcutsView::TopShortcutsView(UnifiedSystemTrayController* controller)
if (Shell::Get()->session_controller()->login_status() != if (Shell::Get()->session_controller()->login_status() !=
LoginStatus::NOT_LOGGED_IN) { LoginStatus::NOT_LOGGED_IN) {
user_avatar_button_ = new UserAvatarButton(this); user_avatar_button_ = new UserAvatarButton(this);
user_avatar_button_->SetEnabled(controller->IsUserChooserEnabled());
container_->AddChildView(user_avatar_button_); container_->AddChildView(user_avatar_button_);
} }
...@@ -198,7 +199,7 @@ void TopShortcutsView::SetExpandedAmount(double expanded_amount) { ...@@ -198,7 +199,7 @@ void TopShortcutsView::SetExpandedAmount(double expanded_amount) {
void TopShortcutsView::ButtonPressed(views::Button* sender, void TopShortcutsView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (sender == user_avatar_button_) if (sender == user_avatar_button_)
controller_->ShowUserChooserWidget(); controller_->ShowUserChooserView();
else if (sender == sign_out_button_) else if (sender == sign_out_button_)
controller_->HandleSignOutAction(); controller_->HandleSignOutAction();
else if (sender == lock_button_) else if (sender == lock_button_)
......
...@@ -213,22 +213,9 @@ void UnifiedSystemTrayController::Fling(int velocity) { ...@@ -213,22 +213,9 @@ void UnifiedSystemTrayController::Fling(int velocity) {
StartAnimation(velocity < 0); StartAnimation(velocity < 0);
} }
void UnifiedSystemTrayController::ShowUserChooserWidget() { void UnifiedSystemTrayController::ShowUserChooserView() {
// Don't allow user add or switch when CancelCastingDialog is open. if (!IsUserChooserEnabled())
// See http://crrev.com/291276 and http://crbug.com/353170.
if (Shell::IsSystemModalWindowOpen())
return;
// Don't allow at login, lock or when adding a multi-profile user.
SessionController* session = Shell::Get()->session_controller();
if (session->IsUserSessionBlocked())
return; return;
// Don't show if we cannot add or switch users.
if (session->GetAddUserPolicy() != AddUserSessionPolicy::ALLOWED &&
session->NumberOfLoggedInUsers() <= 1)
return;
unified_view_->SetDetailedView(new UserChooserView(this)); unified_view_->SetDetailedView(new UserChooserView(this));
} }
...@@ -305,6 +292,24 @@ void UnifiedSystemTrayController::EnsureExpanded() { ...@@ -305,6 +292,24 @@ void UnifiedSystemTrayController::EnsureExpanded() {
animation_->Show(); animation_->Show();
} }
bool UnifiedSystemTrayController::IsUserChooserEnabled() const {
// Don't allow user add or switch when CancelCastingDialog is open.
// See http://crrev.com/291276 and http://crbug.com/353170.
if (Shell::IsSystemModalWindowOpen())
return false;
// Don't allow at login, lock or when adding a multi-profile user.
SessionController* session = Shell::Get()->session_controller();
if (session->IsUserSessionBlocked())
return false;
// Don't show if we cannot add or switch users.
if (session->GetAddUserPolicy() != AddUserSessionPolicy::ALLOWED &&
session->NumberOfLoggedInUsers() <= 1)
return false;
return true;
}
void UnifiedSystemTrayController::AnimationEnded( void UnifiedSystemTrayController::AnimationEnded(
const gfx::Animation* animation) { const gfx::Animation* animation) {
UpdateExpandedAmount(); UpdateExpandedAmount();
......
...@@ -69,8 +69,8 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate { ...@@ -69,8 +69,8 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
void EndDrag(const gfx::Point& location); void EndDrag(const gfx::Point& location);
void Fling(int velocity); void Fling(int velocity);
// Show user selector popup widget. Called from the view. // Show user selector view. Called from the view.
void ShowUserChooserWidget(); void ShowUserChooserView();
// Show the detailed view of network. If |force| is true, it shows the // Show the detailed view of network. If |force| is true, it shows the
// detailed view even if it's collapsed. Called from the view. // detailed view even if it's collapsed. Called from the view.
void ShowNetworkDetailedView(bool force); void ShowNetworkDetailedView(bool force);
...@@ -103,6 +103,9 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate { ...@@ -103,6 +103,9 @@ class ASH_EXPORT UnifiedSystemTrayController : public gfx::AnimationDelegate {
// Ensure the main view is expanded. Called from the slider bubble controller. // Ensure the main view is expanded. Called from the slider bubble controller.
void EnsureExpanded(); void EnsureExpanded();
// Return true if user chooser is enabled. Called from the view.
bool IsUserChooserEnabled() const;
// gfx::AnimationDelegate: // gfx::AnimationDelegate:
void AnimationEnded(const gfx::Animation* animation) override; void AnimationEnded(const gfx::Animation* animation) override;
void AnimationProgressed(const gfx::Animation* animation) override; void AnimationProgressed(const gfx::Animation* animation) override;
......
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