Commit 645b928b authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

kiosk: No shelf/launcher in tablet mode

- Shelf stays with SHELF_AUTO_HIDE_ALWAYS_HIDDEN in tablet mode when
  running in a kiosk session;
- App window keeps the immersive mode disabled when entering tablet
  mode in a kiosk session;

Bug: 834058
Test: ash_unittests ShelfControllerAppModeTest.AutoHideBehavior and browser_tests ChromeNativeAppWindowViewsAuraAshBrowserTest.NoImmersiveModeWhenForcedFullscreen
Change-Id: I57cf9ac08fdc48c433dcb0d5c3f7c561041431c3
Reviewed-on: https://chromium-review.googlesource.com/1035522Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555222}
parent 5007ca43
......@@ -325,6 +325,10 @@ void ShelfController::OnActiveUserPrefServiceChanged(
}
void ShelfController::OnTabletModeStarted() {
// Do nothing when running in app mode.
if (Shell::Get()->session_controller()->IsRunningInAppMode())
return;
// Force the shelf to be visible and to be bottom aligned in tablet mode; the
// prefs are restored on exit.
for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) {
......@@ -340,6 +344,10 @@ void ShelfController::OnTabletModeStarted() {
}
void ShelfController::OnTabletModeEnded() {
// Do nothing when running in app mode.
if (Shell::Get()->session_controller()->IsRunningInAppMode())
return;
SetShelfBehaviorsFromPrefs();
// Only animate out of tablet mode if the shelf alignment will not change.
for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) {
......
......@@ -452,5 +452,26 @@ TEST_F(ShelfControllerPrefsTest, ShelfSettingsInTabletMode) {
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
}
using ShelfControllerAppModeTest = NoSessionAshTestBase;
// Tests that shelf auto hide behavior is always hidden in app mode.
TEST_F(ShelfControllerAppModeTest, AutoHideBehavior) {
SimulateKioskMode(user_manager::USER_TYPE_KIOSK_APP);
Shelf* shelf = GetPrimaryShelf();
EXPECT_EQ(SHELF_AUTO_HIDE_ALWAYS_HIDDEN, shelf->auto_hide_behavior());
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
EXPECT_EQ(SHELF_AUTO_HIDE_ALWAYS_HIDDEN, shelf->auto_hide_behavior());
display_manager()->SetDisplayRotation(
display::Screen::GetScreen()->GetPrimaryDisplay().id(),
display::Display::ROTATE_90, display::Display::RotationSource::ACTIVE);
EXPECT_EQ(SHELF_AUTO_HIDE_ALWAYS_HIDDEN, shelf->auto_hide_behavior());
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
EXPECT_EQ(SHELF_AUTO_HIDE_ALWAYS_HIDDEN, shelf->auto_hide_behavior());
}
} // namespace
} // namespace ash
......@@ -566,27 +566,41 @@ void ChromeNativeAppWindowViewsAuraAsh::OnMenuClosed() {
menu_model_.reset();
}
bool ChromeNativeAppWindowViewsAuraAsh::ShouldEnableImmersiveMode() const {
// No immersive mode for forced fullscreen.
if (app_window()->IsForcedFullscreen())
return false;
// Always use immersive mode in a public session.
if (profiles::IsPublicSession())
return true;
// Always use immersive mode when fullscreen is set by the OS.
if (app_window()->IsOsFullscreen())
return true;
TabletModeClient* client = TabletModeClient::Get();
// Windows in tablet mode which are resizable have their title bars
// hidden in ash for more size, so enable immersive mode so users
// have access to window controls. Non resizable windows do not gain
// size by hidding the title bar, so it is not hidden and thus there
// is no need for immersive mode.
// TODO(sammiequon): Investigate whether we should check
// resizability using WindowState instead of CanResize.
// TODO(crbug.com/801619): This adds a little extra animation
// when minimizing or unminimizing window.
return client && client->tablet_mode_enabled() && CanResize() &&
!IsMinimized();
}
void ChromeNativeAppWindowViewsAuraAsh::UpdateImmersiveMode() {
// |immersive_fullscreen_controller_| should only be set if immersive
// fullscreen is the fullscreen type used by the OS, or if we're in a
// public session where we always use immersive.
if (!immersive_fullscreen_controller_)
return;
TabletModeClient* client = TabletModeClient::Get();
const bool immersive_enabled =
profiles::IsPublicSession() || app_window()->IsOsFullscreen() ||
// Windows in tablet mode which are resizable have their title bars
// hidden in ash for more size, so enable immersive mode so users
// have access to window controls. Non resizable windows do not gain
// size by hidding the title bar, so it is not hidden and thus there
// is no need for immersive mode.
// TODO(sammiequon): Investigate whether we should check
// resizability using WindowState instead of CanResize.
// TODO(crbug.com/801619): This adds a little extra animation
// when minimizing or unminimizing window.
(client && client->tablet_mode_enabled() && CanResize() &&
!IsMinimized());
immersive_fullscreen_controller_->SetEnabled(
ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP,
immersive_enabled);
ShouldEnableImmersiveMode());
}
......@@ -123,6 +123,8 @@ class ChromeNativeAppWindowViewsAuraAsh
ImmersiveWorkFlow);
FRIEND_TEST_ALL_PREFIXES(ChromeNativeAppWindowViewsAuraAshBrowserTest,
ImmersiveModeFullscreenRestoreType);
FRIEND_TEST_ALL_PREFIXES(ChromeNativeAppWindowViewsAuraAshBrowserTest,
NoImmersiveModeWhenForcedFullscreen);
FRIEND_TEST_ALL_PREFIXES(ChromeNativeAppWindowViewsAuraAshInteractiveTest,
NoImmersiveOrBubbleOutsidePublicSessionWindow);
FRIEND_TEST_ALL_PREFIXES(ChromeNativeAppWindowViewsAuraAshInteractiveTest,
......@@ -137,6 +139,9 @@ class ChromeNativeAppWindowViewsAuraAsh
// Callback for MenuRunner
void OnMenuClosed();
// Whether immersive mode should be enabled.
bool ShouldEnableImmersiveMode() const;
// Helper function to update the immersive mode based on the current
// app's and window manager's state.
void UpdateImmersiveMode();
......
......@@ -112,3 +112,25 @@ IN_PROC_BROWSER_TEST_F(ChromeNativeAppWindowViewsAuraAshBrowserTest,
CloseAppWindow(app_window);
}
// Verify that immersive mode stays disabled when entering tablet mode in
// forced fullscreen mode (e.g. when running in a kiosk session).
IN_PROC_BROWSER_TEST_F(ChromeNativeAppWindowViewsAuraAshBrowserTest,
NoImmersiveModeWhenForcedFullscreen) {
extensions::AppWindow* app_window = CreateTestAppWindow("{}");
auto* window = static_cast<ChromeNativeAppWindowViewsAuraAsh*>(
GetNativeAppWindowForAppWindow(app_window));
ASSERT_TRUE(window != nullptr);
ASSERT_TRUE(window->immersive_fullscreen_controller_.get() != nullptr);
app_window->ForcedFullscreen();
ash::TabletModeController* tablet_mode_controller =
ash::Shell::Get()->tablet_mode_controller();
tablet_mode_controller->EnableTabletModeWindowManager(true);
tablet_mode_controller->FlushForTesting();
EXPECT_FALSE(window->immersive_fullscreen_controller_->IsEnabled());
tablet_mode_controller->EnableTabletModeWindowManager(false);
tablet_mode_controller->FlushForTesting();
EXPECT_FALSE(window->immersive_fullscreen_controller_->IsEnabled());
}
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