Commit 1ddefa1b authored by Michael Giuffrida's avatar Michael Giuffrida Committed by Commit Bot

Update Quick Settings for Kiosk Next

Hide Quick Settings feature pods and some top-row shortcuts in Kiosk
Next sessions.

This also moves the SignOutButton's visibility logic to
TopShortcutsView, simplifying the button itself. This is in line with
how the other top-row shortcut buttons work.

Depending on user feedback, follow-up work might add some feature
pods back in, or remove the collapse/expand option. If we start
diverging more substantially from the normal Quick Settings, we can
create KioskNext versions of these classes instead.

Bug: 966890
Change-Id: I4c84e39021f213ca24fe8fcc39dd9b53a3119491
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1638880
Commit-Queue: Michael Giuffrida <michaelpg@chromium.org>
Auto-Submit: Michael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666121}
parent 43de5037
...@@ -14,10 +14,7 @@ SignOutButton::SignOutButton(views::ButtonListener* listener) ...@@ -14,10 +14,7 @@ SignOutButton::SignOutButton(views::ButtonListener* listener)
: RoundedLabelButton(listener, : RoundedLabelButton(listener,
user::GetLocalizedSignOutStringForStatus( user::GetLocalizedSignOutStringForStatus(
Shell::Get()->session_controller()->login_status(), Shell::Get()->session_controller()->login_status(),
false /* multiline */)) { false /* multiline */)) {}
SetVisible(Shell::Get()->session_controller()->login_status() !=
LoginStatus::NOT_LOGGED_IN);
}
SignOutButton::~SignOutButton() = default; SignOutButton::~SignOutButton() = default;
......
...@@ -14,9 +14,9 @@ class ButtonListener; ...@@ -14,9 +14,9 @@ class ButtonListener;
namespace ash { namespace ash {
// Sign out button shown in TopShortcutView with TopShortcutButtons. // Sign out button to be shown in TopShortcutView with TopShortcutButtons.
// Shows the label like "Sign out", "Exit guest", etc. depending on the session // Shows the label like "Sign out", "Exit guest", etc. depending on the session
// status. Not visible when not signed in. // status.
class SignOutButton : public RoundedLabelButton { class SignOutButton : public RoundedLabelButton {
public: public:
explicit SignOutButton(views::ButtonListener* listener); explicit SignOutButton(views::ButtonListener* listener);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <numeric> #include <numeric>
#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/accessibility_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/public/cpp/ash_view_ids.h" #include "ash/public/cpp/ash_view_ids.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
...@@ -166,39 +167,44 @@ TopShortcutsView::TopShortcutsView(UnifiedSystemTrayController* controller) ...@@ -166,39 +167,44 @@ TopShortcutsView::TopShortcutsView(UnifiedSystemTrayController* controller)
container_ = new TopShortcutButtonContainer(); container_ = new TopShortcutButtonContainer();
AddChildView(container_); AddChildView(container_);
if (Shell::Get()->session_controller()->login_status() != ash::Shell* shell = Shell::Get();
LoginStatus::NOT_LOGGED_IN) {
bool is_on_login_screen =
shell->session_controller()->login_status() == LoginStatus::NOT_LOGGED_IN;
bool is_kiosk_next = shell->kiosk_next_shell_controller()->IsEnabled();
bool can_show_settings = TrayPopupUtils::CanOpenWebUISettings();
bool can_lock_screen = shell->session_controller()->CanLockScreen();
if (!is_on_login_screen) {
user_avatar_button_ = new UserAvatarButton(this); user_avatar_button_ = new UserAvatarButton(this);
user_avatar_button_->SetEnabled( user_avatar_button_->SetEnabled(
UserChooserDetailedViewController::IsUserChooserEnabled()); UserChooserDetailedViewController::IsUserChooserEnabled());
container_->AddUserAvatarButton(user_avatar_button_); container_->AddUserAvatarButton(user_avatar_button_);
}
// Show the buttons in this row as disabled if the user is at the login
// screen, lock screen, or in a secondary account flow. The exception is
// |power_button_| which is always shown as enabled.
const bool can_show_web_ui = TrayPopupUtils::CanOpenWebUISettings();
sign_out_button_ = new SignOutButton(this); sign_out_button_ = new SignOutButton(this);
container_->AddSignOutButton(sign_out_button_); container_->AddSignOutButton(sign_out_button_);
}
bool reboot = Shell::Get()->shutdown_controller()->reboot_on_shutdown(); if (!is_kiosk_next) {
power_button_ = new TopShortcutButton( bool reboot = shell->shutdown_controller()->reboot_on_shutdown();
this, kUnifiedMenuPowerIcon, power_button_ = new TopShortcutButton(
reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN); this, kUnifiedMenuPowerIcon,
power_button_->SetID(VIEW_ID_POWER_BUTTON); reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN);
container_->AddChildView(power_button_); power_button_->SetID(VIEW_ID_POWER_BUTTON);
container_->AddChildView(power_button_);
}
lock_button_ = new TopShortcutButton(this, kUnifiedMenuLockIcon, if (can_show_settings && can_lock_screen && !is_kiosk_next) {
IDS_ASH_STATUS_TRAY_LOCK); lock_button_ = new TopShortcutButton(this, kUnifiedMenuLockIcon,
lock_button_->SetVisible(can_show_web_ui && IDS_ASH_STATUS_TRAY_LOCK);
Shell::Get()->session_controller()->CanLockScreen()); container_->AddChildView(lock_button_);
container_->AddChildView(lock_button_); }
settings_button_ = new TopShortcutButton(this, kUnifiedMenuSettingsIcon, if (can_show_settings) {
IDS_ASH_STATUS_TRAY_SETTINGS); settings_button_ = new TopShortcutButton(this, kUnifiedMenuSettingsIcon,
settings_button_->SetVisible(can_show_web_ui); IDS_ASH_STATUS_TRAY_SETTINGS);
container_->AddChildView(settings_button_); container_->AddChildView(settings_button_);
}
// |collapse_button_| should be right-aligned, so we make the buttons // |collapse_button_| should be right-aligned, so we make the buttons
// container flex occupying all remaining space. // container flex occupying all remaining space.
...@@ -209,7 +215,7 @@ TopShortcutsView::TopShortcutsView(UnifiedSystemTrayController* controller) ...@@ -209,7 +215,7 @@ TopShortcutsView::TopShortcutsView(UnifiedSystemTrayController* controller)
OnAccessibilityStatusChanged(); OnAccessibilityStatusChanged();
Shell::Get()->accessibility_controller()->AddObserver(this); shell->accessibility_controller()->AddObserver(this);
} }
TopShortcutsView::~TopShortcutsView() { TopShortcutsView::~TopShortcutsView() {
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "ash/system/unified/top_shortcuts_view.h" #include "ash/system/unified/top_shortcuts_view.h"
#include "ash/kiosk_next/kiosk_next_shell_test_util.h"
#include "ash/kiosk_next/mock_kiosk_next_shell_client.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/session/test_session_controller_client.h" #include "ash/session/test_session_controller_client.h"
#include "ash/system/unified/collapse_button.h" #include "ash/system/unified/collapse_button.h"
#include "ash/system/unified/sign_out_button.h" #include "ash/system/unified/sign_out_button.h"
...@@ -11,8 +14,8 @@ ...@@ -11,8 +14,8 @@
#include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_controller.h"
#include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_model.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/macros.h"
using views::Button; #include "base/test/scoped_feature_list.h"
namespace ash { namespace ash {
...@@ -23,6 +26,8 @@ class TopShortcutsViewTest : public NoSessionAshTestBase { ...@@ -23,6 +26,8 @@ class TopShortcutsViewTest : public NoSessionAshTestBase {
~TopShortcutsViewTest() override = default; ~TopShortcutsViewTest() override = default;
void SetUp() override { void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
NoSessionAshTestBase::SetUp(); NoSessionAshTestBase::SetUp();
model_ = std::make_unique<UnifiedSystemTrayModel>(); model_ = std::make_unique<UnifiedSystemTrayModel>();
...@@ -41,7 +46,12 @@ class TopShortcutsViewTest : public NoSessionAshTestBase { ...@@ -41,7 +46,12 @@ class TopShortcutsViewTest : public NoSessionAshTestBase {
top_shortcuts_view_ = std::make_unique<TopShortcutsView>(controller_.get()); top_shortcuts_view_ = std::make_unique<TopShortcutsView>(controller_.get());
} }
views::View* GetUserAvatar() { void CreateKioskNextSession() {
kiosk_next_shell_client_ = BindMockKioskNextShellClient();
LogInKioskNextUser(GetSessionControllerClient());
}
views::View* GetUserAvatar() {
return top_shortcuts_view_->user_avatar_button_; return top_shortcuts_view_->user_avatar_button_;
} }
...@@ -61,10 +71,12 @@ class TopShortcutsViewTest : public NoSessionAshTestBase { ...@@ -61,10 +71,12 @@ class TopShortcutsViewTest : public NoSessionAshTestBase {
return top_shortcuts_view_->collapse_button_; return top_shortcuts_view_->collapse_button_;
} }
void Layout() { void Layout() { top_shortcuts_view_->Layout(); }
top_shortcuts_view_->Layout();
}
private: private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> kiosk_next_shell_client_;
std::unique_ptr<UnifiedSystemTrayModel> model_; std::unique_ptr<UnifiedSystemTrayModel> model_;
std::unique_ptr<UnifiedSystemTrayController> controller_; std::unique_ptr<UnifiedSystemTrayController> controller_;
std::unique_ptr<TopShortcutsView> top_shortcuts_view_; std::unique_ptr<TopShortcutsView> top_shortcuts_view_;
...@@ -76,9 +88,9 @@ class TopShortcutsViewTest : public NoSessionAshTestBase { ...@@ -76,9 +88,9 @@ class TopShortcutsViewTest : public NoSessionAshTestBase {
TEST_F(TopShortcutsViewTest, ButtonStatesNotLoggedIn) { TEST_F(TopShortcutsViewTest, ButtonStatesNotLoggedIn) {
SetUpView(); SetUpView();
EXPECT_EQ(nullptr, GetUserAvatar()); EXPECT_EQ(nullptr, GetUserAvatar());
EXPECT_FALSE(GetSignOutButton()->GetVisible()); EXPECT_EQ(nullptr, GetSignOutButton());
EXPECT_FALSE(GetLockButton()->GetVisible()); EXPECT_EQ(nullptr, GetLockButton());
EXPECT_FALSE(GetSettingsButton()->GetVisible()); EXPECT_EQ(nullptr, GetSettingsButton());
EXPECT_TRUE(GetPowerButton()->GetVisible()); EXPECT_TRUE(GetPowerButton()->GetVisible());
EXPECT_TRUE(GetCollapseButton()->GetVisible()); EXPECT_TRUE(GetCollapseButton()->GetVisible());
} }
...@@ -87,7 +99,7 @@ TEST_F(TopShortcutsViewTest, ButtonStatesNotLoggedIn) { ...@@ -87,7 +99,7 @@ TEST_F(TopShortcutsViewTest, ButtonStatesNotLoggedIn) {
TEST_F(TopShortcutsViewTest, ButtonStatesLoggedIn) { TEST_F(TopShortcutsViewTest, ButtonStatesLoggedIn) {
CreateUserSessions(1); CreateUserSessions(1);
SetUpView(); SetUpView();
EXPECT_NE(nullptr, GetUserAvatar()); EXPECT_TRUE(GetUserAvatar()->GetVisible());
EXPECT_TRUE(GetSignOutButton()->GetVisible()); EXPECT_TRUE(GetSignOutButton()->GetVisible());
EXPECT_TRUE(GetLockButton()->GetVisible()); EXPECT_TRUE(GetLockButton()->GetVisible());
EXPECT_TRUE(GetSettingsButton()->GetVisible()); EXPECT_TRUE(GetSettingsButton()->GetVisible());
...@@ -99,10 +111,10 @@ TEST_F(TopShortcutsViewTest, ButtonStatesLoggedIn) { ...@@ -99,10 +111,10 @@ TEST_F(TopShortcutsViewTest, ButtonStatesLoggedIn) {
TEST_F(TopShortcutsViewTest, ButtonStatesLockScreen) { TEST_F(TopShortcutsViewTest, ButtonStatesLockScreen) {
BlockUserSession(BLOCKED_BY_LOCK_SCREEN); BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
SetUpView(); SetUpView();
EXPECT_NE(nullptr, GetUserAvatar()); EXPECT_TRUE(GetUserAvatar()->GetVisible());
EXPECT_TRUE(GetSignOutButton()->GetVisible()); EXPECT_TRUE(GetSignOutButton()->GetVisible());
EXPECT_FALSE(GetLockButton()->GetVisible()); EXPECT_EQ(nullptr, GetLockButton());
EXPECT_FALSE(GetSettingsButton()->GetVisible()); EXPECT_EQ(nullptr, GetSettingsButton());
EXPECT_TRUE(GetPowerButton()->GetVisible()); EXPECT_TRUE(GetPowerButton()->GetVisible());
EXPECT_TRUE(GetCollapseButton()->GetVisible()); EXPECT_TRUE(GetCollapseButton()->GetVisible());
} }
...@@ -113,10 +125,10 @@ TEST_F(TopShortcutsViewTest, ButtonStatesAddingUser) { ...@@ -113,10 +125,10 @@ TEST_F(TopShortcutsViewTest, ButtonStatesAddingUser) {
CreateUserSessions(1); CreateUserSessions(1);
SetUserAddingScreenRunning(true); SetUserAddingScreenRunning(true);
SetUpView(); SetUpView();
EXPECT_NE(nullptr, GetUserAvatar()); EXPECT_TRUE(GetUserAvatar()->GetVisible());
EXPECT_TRUE(GetSignOutButton()->GetVisible()); EXPECT_TRUE(GetSignOutButton()->GetVisible());
EXPECT_FALSE(GetLockButton()->GetVisible()); EXPECT_EQ(nullptr, GetLockButton());
EXPECT_FALSE(GetSettingsButton()->GetVisible()); EXPECT_EQ(nullptr, GetSettingsButton());
EXPECT_TRUE(GetPowerButton()->GetVisible()); EXPECT_TRUE(GetPowerButton()->GetVisible());
EXPECT_TRUE(GetCollapseButton()->GetVisible()); EXPECT_TRUE(GetCollapseButton()->GetVisible());
} }
...@@ -130,9 +142,9 @@ TEST_F(TopShortcutsViewTest, ButtonStatesSupervisedUserFlow) { ...@@ -130,9 +142,9 @@ TEST_F(TopShortcutsViewTest, ButtonStatesSupervisedUserFlow) {
"foo@example.com", user_manager::USER_TYPE_REGULAR, enable_settings); "foo@example.com", user_manager::USER_TYPE_REGULAR, enable_settings);
SetUpView(); SetUpView();
EXPECT_EQ(nullptr, GetUserAvatar()); EXPECT_EQ(nullptr, GetUserAvatar());
EXPECT_FALSE(GetSignOutButton()->GetVisible()); EXPECT_EQ(nullptr, GetSignOutButton());
EXPECT_FALSE(GetLockButton()->GetVisible()); EXPECT_EQ(nullptr, GetLockButton());
EXPECT_FALSE(GetSettingsButton()->GetVisible()); EXPECT_EQ(nullptr, GetSettingsButton());
EXPECT_TRUE(GetPowerButton()->GetVisible()); EXPECT_TRUE(GetPowerButton()->GetVisible());
EXPECT_TRUE(GetCollapseButton()->GetVisible()); EXPECT_TRUE(GetCollapseButton()->GetVisible());
} }
...@@ -173,4 +185,30 @@ TEST_F(TopShortcutsViewTest, ButtonLayoutSupervisedUserFlow) { ...@@ -173,4 +185,30 @@ TEST_F(TopShortcutsViewTest, ButtonLayoutSupervisedUserFlow) {
SetUpView(); SetUpView();
Layout(); Layout();
} }
// Some buttons are hidden in Kiosk Next sessions.
TEST_F(TopShortcutsViewTest, ButtonStatesKioskNextLoggedIn) {
CreateKioskNextSession();
SetUpView();
EXPECT_TRUE(GetUserAvatar()->GetVisible());
EXPECT_TRUE(GetSignOutButton()->GetVisible());
EXPECT_EQ(nullptr, GetLockButton());
EXPECT_TRUE(GetSettingsButton()->GetVisible());
EXPECT_EQ(nullptr, GetPowerButton());
EXPECT_TRUE(GetCollapseButton()->GetVisible());
}
// Settings button is also hidden at the lock screen in Kiosk Next sessions.
TEST_F(TopShortcutsViewTest, ButtonStatesKioskNextLockScreen) {
CreateKioskNextSession();
GetSessionControllerClient()->LockScreen();
SetUpView();
EXPECT_TRUE(GetUserAvatar()->GetVisible());
EXPECT_TRUE(GetSignOutButton()->GetVisible());
EXPECT_EQ(nullptr, GetLockButton());
EXPECT_EQ(nullptr, GetSettingsButton());
EXPECT_EQ(nullptr, GetPowerButton());
EXPECT_TRUE(GetCollapseButton()->GetVisible());
}
} // namespace ash } // namespace ash
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/metrics/user_metrics_action.h" #include "ash/metrics/user_metrics_action.h"
#include "ash/metrics/user_metrics_recorder.h" #include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/system_tray_client.h" #include "ash/public/cpp/system_tray_client.h"
...@@ -317,6 +318,10 @@ void UnifiedSystemTrayController::OnAudioSettingsButtonClicked() { ...@@ -317,6 +318,10 @@ void UnifiedSystemTrayController::OnAudioSettingsButtonClicked() {
} }
void UnifiedSystemTrayController::InitFeaturePods() { void UnifiedSystemTrayController::InitFeaturePods() {
// No feature pods in Kisok Next.
if (Shell::Get()->kiosk_next_shell_controller()->IsEnabled())
return;
AddFeaturePodItem(std::make_unique<NetworkFeaturePodController>(this)); AddFeaturePodItem(std::make_unique<NetworkFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this)); AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<QuietModeFeaturePodController>(this)); AddFeaturePodItem(std::make_unique<QuietModeFeaturePodController>(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