Commit 9e935549 authored by David Black's avatar David Black Committed by Chromium LUCI CQ

Hide holding space tray on user adding screen.

Previously the holding space tray did not update visibility when the
user adding screen was shown and interacting with holding space items
appeared to no-op to the user since actions were being performed behind
the login screen.

Bug: 1168059
Change-Id: I8a55e811b2eb74edeecdcae11dc811173420aff8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643412Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#846211}
parent be9b75cb
...@@ -69,6 +69,7 @@ std::unique_ptr<views::ImageView> CreateDefaultTrayIcon() { ...@@ -69,6 +69,7 @@ std::unique_ptr<views::ImageView> CreateDefaultTrayIcon() {
HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) { HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
controller_observer_.Observe(HoldingSpaceController::Get()); controller_observer_.Observe(HoldingSpaceController::Get());
session_observer_.Observe(Shell::Get()->session_controller());
SetVisible(false); SetVisible(false);
// Icon. // Icon.
...@@ -82,7 +83,6 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) { ...@@ -82,7 +83,6 @@ HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
// If previews feature is enabled, the preview icon is displayed // If previews feature is enabled, the preview icon is displayed
// conditionally, depending on user prefs state. // conditionally, depending on user prefs state.
session_observer_.Observe(Shell::Get()->session_controller());
auto* prefs = Shell::Get()->session_controller()->GetActivePrefService(); auto* prefs = Shell::Get()->session_controller()->GetActivePrefService();
if (prefs) if (prefs)
ObservePrefService(prefs); ObservePrefService(prefs);
...@@ -212,11 +212,8 @@ void HoldingSpaceTray::FirePreviewsUpdateTimerIfRunningForTesting() { ...@@ -212,11 +212,8 @@ void HoldingSpaceTray::FirePreviewsUpdateTimerIfRunningForTesting() {
} }
void HoldingSpaceTray::UpdateVisibility() { void HoldingSpaceTray::UpdateVisibility() {
HoldingSpaceModel* model = HoldingSpaceController::Get()->model(); HoldingSpaceModel* const model = HoldingSpaceController::Get()->model();
LoginStatus login_status = shelf()->GetStatusAreaWidget()->login_status(); if (!model || Shell::Get()->session_controller()->IsUserSessionBlocked()) {
const bool in_active_session = login_status != LoginStatus::NOT_LOGGED_IN &&
login_status != LoginStatus::LOCKED;
if (!model || !in_active_session) {
SetVisiblePreferred(false); SetVisiblePreferred(false);
return; return;
} }
...@@ -363,10 +360,18 @@ void HoldingSpaceTray::OnWidgetDestroying(views::Widget* widget) { ...@@ -363,10 +360,18 @@ void HoldingSpaceTray::OnWidgetDestroying(views::Widget* widget) {
} }
void HoldingSpaceTray::OnActiveUserPrefServiceChanged(PrefService* prefs) { void HoldingSpaceTray::OnActiveUserPrefServiceChanged(PrefService* prefs) {
if (!features::IsTemporaryHoldingSpacePreviewsEnabled())
return;
UpdatePreviewsState(); UpdatePreviewsState();
ObservePrefService(prefs); ObservePrefService(prefs);
} }
void HoldingSpaceTray::OnSessionStateChanged(
session_manager::SessionState state) {
UpdateVisibility();
}
void HoldingSpaceTray::ObservePrefService(PrefService* prefs) { void HoldingSpaceTray::ObservePrefService(PrefService* prefs) {
pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>(); pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
pref_change_registrar_->Init(prefs); pref_change_registrar_->Init(prefs);
......
...@@ -97,6 +97,7 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView, ...@@ -97,6 +97,7 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView,
// SessionObserver: // SessionObserver:
void OnActiveUserPrefServiceChanged(PrefService* prefs) override; void OnActiveUserPrefServiceChanged(PrefService* prefs) override;
void OnSessionStateChanged(session_manager::SessionState state) override;
// ui::SimpleMenuModel::Delegate: // ui::SimpleMenuModel::Delegate:
void ExecuteCommand(int command_id, int event_flags) override; void ExecuteCommand(int command_id, int event_flags) override;
......
...@@ -396,6 +396,27 @@ TEST_P(HoldingSpaceTrayTest, HideButtonOnChangeToNonEmptyModel) { ...@@ -396,6 +396,27 @@ TEST_P(HoldingSpaceTrayTest, HideButtonOnChangeToNonEmptyModel) {
UnregisterModelForUser("user@secondary"); UnregisterModelForUser("user@secondary");
} }
TEST_P(HoldingSpaceTrayTest, HideButtonOnUserAddingScreen) {
MarkTimeOfFirstPin();
StartSession();
// The tray button should be hidden if the user has previously pinned an item
// and the holding space is empty.
EXPECT_FALSE(test_api()->IsShowingInShelf());
// The tray button should be showing if the user has an item in holding space.
AddItem(HoldingSpaceItem::Type::kDownload, base::FilePath("/tmp/fake_1"));
EXPECT_TRUE(test_api()->IsShowingInShelf());
// The tray button should be hidden if the user adding screen is running.
SetUserAddingScreenRunning(true);
EXPECT_FALSE(test_api()->IsShowingInShelf());
// The tray button should be showing if the user adding screen is finished.
SetUserAddingScreenRunning(false);
EXPECT_TRUE(test_api()->IsShowingInShelf());
}
TEST_P(HoldingSpaceTrayTest, AddingItemShowsTrayBubble) { TEST_P(HoldingSpaceTrayTest, AddingItemShowsTrayBubble) {
MarkTimeOfFirstPin(); MarkTimeOfFirstPin();
StartSession(); StartSession();
......
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