Commit 708a3b80 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS: Never show the navigation widget on lock/login screens

We were showing the nav widget in the right conditions, but we were
not hiding it aggressively enough.

Add tests to prevent future regressions.

BUG=992336

Change-Id: I4d19473f514b8979c940daa008e16a43e3de9773
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761492Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688608}
parent fe1f1c8f
......@@ -34,6 +34,9 @@
#include "ash/public/mojom/tray_action.mojom.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_navigation_widget.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/system/power/backlights_forced_off_setter.h"
#include "ash/system/power/power_button_controller.h"
......@@ -2665,4 +2668,19 @@ TEST_F(LockContentsViewUnitTest, MediaControlsHiddenOnLoginScreen) {
EXPECT_EQ(nullptr, lock_contents.media_controls_view());
}
TEST_F(LockContentsViewUnitTest, NoNavigationWidgetOnLockScreen) {
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOCKED);
LockContentsView* contents = new LockContentsView(
mojom::TrayActionState::kNotAvailable, LockScreen::ScreenType::kLock,
DataDispatcher(),
std::make_unique<FakeLoginDetachableBaseModel>(DataDispatcher()));
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(contents);
ShelfWidget* shelf_widget =
Shelf::ForWindow(widget->GetNativeWindow())->shelf_widget();
EXPECT_FALSE(shelf_widget->navigation_widget()->IsVisible())
<< "The navigation widget should not appear on the lock screen.";
}
} // namespace ash
......@@ -19,6 +19,7 @@
#include "ash/session/session_controller_impl.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_navigation_widget.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shutdown_controller_impl.h"
......@@ -522,6 +523,13 @@ TEST_F(LoginShelfViewTest, ShouldUpdateUiAfterShutdownButtonStatusChange) {
EXPECT_TRUE(IsButtonEnabled(LoginShelfView::kShutdown));
}
TEST_F(LoginShelfViewTest, ShouldNotShowNavigationWidget) {
gfx::NativeWindow window = login_shelf_view_->GetWidget()->GetNativeWindow();
ShelfWidget* shelf_widget = Shelf::ForWindow(window)->shelf_widget();
EXPECT_FALSE(shelf_widget->navigation_widget()->IsVisible())
<< "The navigation widget should not appear in the login shelf.";
}
TEST_F(LoginShelfViewTest, ParentAccessButtonVisibility) {
// Parent access button should only be visible on lock screen.
Shell::Get()->login_screen_controller()->ShowParentAccessButton(true);
......
......@@ -1050,6 +1050,10 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(
shelf_bounds.InsetsFrom(target_bounds.shelf_bounds_in_shelf)));
shelf_widget_->GetContentsView()->Layout();
// Never show the navigation widget outside of an active session.
if (!state_.IsActiveSessionState())
nav_widget->Hide();
// Setting visibility during an animation causes the visibility property to
// animate. Set the visibility property without an animation.
if (target_bounds.opacity) {
......
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