summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonross <jonross@chromium.org>2015-06-04 12:20:31 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-04 19:21:03 +0000
commitcd872eea1f6a0571d94796046bf690274254db2d (patch)
treed3fa83ba2d67ce19b5db5776591f7c25a3910a65
parent8fd41d0b5c8d1d884a4c6dff370140eaf3a57eaa (diff)
downloadchromium_src-cd872eea1f6a0571d94796046bf690274254db2d.zip
chromium_src-cd872eea1f6a0571d94796046bf690274254db2d.tar.gz
chromium_src-cd872eea1f6a0571d94796046bf690274254db2d.tar.bz2
Stop the OverviewButton from appearing on the Add-User screen
OverviewButtonTray was showing up on the Add-User screen. It should only be available when a user is logged in and in the active state. Update OverviewButtonTray to observe SessionState changes to determine visibility. Update WindowSelectorController to not allow overview mode while on the add-user screen. TEST=OverviewButtonTrayTest.VisibilityChangesForLoginStatus BUG=488464, 482591 Review URL: https://codereview.chromium.org/1149833006 Cr-Commit-Position: refs/heads/master@{#332872}
-rw-r--r--ash/system/overview/overview_button_tray.cc28
-rw-r--r--ash/system/overview/overview_button_tray.h6
-rw-r--r--ash/system/overview/overview_button_tray_unittest.cc41
3 files changed, 71 insertions, 4 deletions
diff --git a/ash/system/overview/overview_button_tray.cc b/ash/system/overview/overview_button_tray.cc
index edd5d67..f5295b5 100644
--- a/ash/system/overview/overview_button_tray.cc
+++ b/ash/system/overview/overview_button_tray.cc
@@ -4,6 +4,7 @@
#include "ash/system/overview/overview_button_tray.h"
+#include "ash/session/session_state_delegate.h"
#include "ash/shelf/shelf_types.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
@@ -42,10 +43,13 @@ OverviewButtonTray::OverviewButtonTray(StatusAreaWidget* status_area_widget)
tray_container()->AddChildView(icon_);
Shell::GetInstance()->AddShellObserver(this);
+ Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(this);
}
OverviewButtonTray::~OverviewButtonTray() {
Shell::GetInstance()->RemoveShellObserver(this);
+ Shell::GetInstance()->session_state_delegate()->RemoveSessionStateObserver(
+ this);
}
void OverviewButtonTray::UpdateAfterLoginStatusChange(
@@ -62,6 +66,11 @@ bool OverviewButtonTray::PerformAction(const ui::Event& event) {
return true;
}
+void OverviewButtonTray::SessionStateChanged(
+ SessionStateDelegate::SessionState state) {
+ UpdateIconVisibility();
+}
+
void OverviewButtonTray::OnMaximizeModeStarted() {
UpdateIconVisibility();
}
@@ -115,9 +124,22 @@ void OverviewButtonTray::SetIconBorderForShelfAlignment() {
}
void OverviewButtonTray::UpdateIconVisibility() {
- SetVisible(Shell::GetInstance()->maximize_mode_controller()->
- IsMaximizeModeWindowManagerEnabled() &&
- Shell::GetInstance()->window_selector_controller()->CanSelect());
+ // The visibility of the OverviewButtonTray has diverge from
+ // WindowSelectorController::CanSelect. The visibility of the button should
+ // not change during transient times in which CanSelect is false. Such as when
+ // a modal dialog is present.
+ Shell* shell = Shell::GetInstance();
+ SessionStateDelegate* session_state_delegate =
+ shell->session_state_delegate();
+
+ SetVisible(
+ shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() &&
+ session_state_delegate->IsActiveUserSessionStarted() &&
+ !session_state_delegate->IsScreenLocked() &&
+ session_state_delegate->GetSessionState() ==
+ SessionStateDelegate::SESSION_STATE_ACTIVE &&
+ shell->system_tray_delegate()->GetUserLoginStatus() !=
+ user::LOGGED_IN_KIOSK_APP);
}
} // namespace ash
diff --git a/ash/system/overview/overview_button_tray.h b/ash/system/overview/overview_button_tray.h
index a58bae1..d3988be 100644
--- a/ash/system/overview/overview_button_tray.h
+++ b/ash/system/overview/overview_button_tray.h
@@ -6,9 +6,9 @@
#define ASH_SYSTEM_OVERVIEW_OVERVIEW_BUTTON_TRAY_H_
#include "ash/ash_export.h"
+#include "ash/session/session_state_observer.h"
#include "ash/shell_observer.h"
#include "ash/system/tray/tray_background_view.h"
-#include "ash/wm/overview/window_selector_controller.h"
namespace views {
class ImageView;
@@ -22,6 +22,7 @@ namespace ash {
// This tray will only be visible while in this state. This tray does not
// provide any bubble view windows.
class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView,
+ public SessionStateObserver,
public ShellObserver {
public:
explicit OverviewButtonTray(StatusAreaWidget* status_area_widget);
@@ -34,6 +35,9 @@ class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView,
// ActionableView:
bool PerformAction(const ui::Event& event) override;
+ // SessionStateObserver:
+ void SessionStateChanged(SessionStateDelegate::SessionState state) override;
+
// ShellObserver:
void OnMaximizeModeStarted() override;
void OnMaximizeModeEnded() override;
diff --git a/ash/system/overview/overview_button_tray_unittest.cc b/ash/system/overview/overview_button_tray_unittest.cc
index a7e6a3e..4468aae 100644
--- a/ash/system/overview/overview_button_tray_unittest.cc
+++ b/ash/system/overview/overview_button_tray_unittest.cc
@@ -14,12 +14,16 @@
#include "ash/system/status_area_widget.h"
#include "ash/system/user/login_status.h"
#include "ash/test/ash_test_base.h"
+#include "ash/test/ash_test_helper.h"
#include "ash/test/status_area_widget_test_helper.h"
+#include "ash/test/test_session_state_delegate.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "base/command_line.h"
#include "base/test/user_action_tester.h"
#include "base/time/time.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
@@ -51,6 +55,8 @@ class OverviewButtonTrayTest : public test::AshTestBase {
void SetUp() override;
+ void NotifySessionStateChanged();
+
protected:
views::ImageView* GetImageView(OverviewButtonTray* tray) {
return tray->icon_;
@@ -68,6 +74,11 @@ void OverviewButtonTrayTest::SetUp() {
AshTestBase::SetUp();
}
+void OverviewButtonTrayTest::NotifySessionStateChanged() {
+ GetTray()->SessionStateChanged(
+ ash_test_helper()->GetTestSessionStateDelegate()->GetSessionState());
+}
+
// Ensures that creation doesn't cause any crashes and adds the image icon.
TEST_F(OverviewButtonTrayTest, BasicConstruction) {
EXPECT_TRUE(GetImageView(GetTray()) != NULL);
@@ -178,6 +189,12 @@ TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) {
SetSessionStarted(true);
Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER);
EXPECT_TRUE(GetTray()->visible());
+ SetUserAddingScreenRunning(true);
+ NotifySessionStateChanged();
+ EXPECT_FALSE(GetTray()->visible());
+ SetUserAddingScreenRunning(false);
+ NotifySessionStateChanged();
+ EXPECT_TRUE(GetTray()->visible());
Shell::GetInstance()->maximize_mode_controller()->
EnableMaximizeModeWindowManager(false);
}
@@ -230,4 +247,28 @@ TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) {
EXPECT_FALSE(GetTray()->visible());
}
+// Tests that the overview button becomes visible when the user enters
+// maximize mode with a system modal window open, and that it hides once
+// the user exits maximize mode.
+TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) {
+ // TODO(jonross): When CreateTestWindow*() have been unified, use the
+ // appropriate method to replace this setup. (crbug.com/483503)
+ scoped_ptr<aura::Window> window(new aura::Window(nullptr));
+ window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
+ window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
+ window->Init(ui::LAYER_TEXTURED);
+ window->Show();
+ ParentWindowInPrimaryRootWindow(window.get());
+
+ ASSERT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen());
+ Shell::GetInstance()
+ ->maximize_mode_controller()
+ ->EnableMaximizeModeWindowManager(true);
+ EXPECT_TRUE(GetTray()->visible());
+ Shell::GetInstance()
+ ->maximize_mode_controller()
+ ->EnableMaximizeModeWindowManager(false);
+ EXPECT_FALSE(GetTray()->visible());
+}
+
} // namespace ash