Commit f1b13367 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

palette: Do not show welcome bubble if guest mode or not in active state.

Originally tries to show bubble when the pref service (user) changes.
Added checks in PaletteWelcomeBubble::ShowIfNeeded to check for the
two cases where the bubble is not wanted. PaletteTray tries to show the
bubble again when the session state changes.

Test: ash_unittests PaletteWelcomeBubbleTest.*
Bug: 786418, 786590
Change-Id: I0695a83383ce6c9d79f8d8f6dfda2eab0fb37071
Reviewed-on: https://chromium-review.googlesource.com/780841Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520575}
parent ecba1947
...@@ -218,13 +218,14 @@ void PaletteTray::OnActiveUserPrefServiceChanged(PrefService* pref_service) { ...@@ -218,13 +218,14 @@ void PaletteTray::OnActiveUserPrefServiceChanged(PrefService* pref_service) {
// external stylus, but only if the device has seen a stylus before (avoid // external stylus, but only if the device has seen a stylus before (avoid
// showing the bubble if the device has never and may never be used with // showing the bubble if the device has never and may never be used with
// stylus). // stylus).
if (HasSeenStylus() && !stylus_utils::HasInternalStylus()) { if (HasSeenStylus() && !stylus_utils::HasInternalStylus())
welcome_bubble_->ShowIfNeeded(false /* shown_by_stylus */); welcome_bubble_->ShowIfNeeded(false /* shown_by_stylus */);
}
} }
void PaletteTray::OnSessionStateChanged(session_manager::SessionState state) { void PaletteTray::OnSessionStateChanged(session_manager::SessionState state) {
UpdateIconVisibility(); UpdateIconVisibility();
if (HasSeenStylus() && !stylus_utils::HasInternalStylus())
welcome_bubble_->ShowIfNeeded(false /* shown_by_stylus */);
} }
void PaletteTray::OnLockStateChanged(bool locked) { void PaletteTray::OnLockStateChanged(bool locked) {
......
...@@ -133,7 +133,19 @@ void PaletteWelcomeBubble::OnActiveUserPrefServiceChanged( ...@@ -133,7 +133,19 @@ void PaletteWelcomeBubble::OnActiveUserPrefServiceChanged(
} }
void PaletteWelcomeBubble::ShowIfNeeded(bool shown_by_stylus) { void PaletteWelcomeBubble::ShowIfNeeded(bool shown_by_stylus) {
DCHECK(active_user_pref_service_); if (!active_user_pref_service_)
return;
if (Shell::Get()->session_controller()->GetSessionState() !=
session_manager::SessionState::ACTIVE) {
return;
}
base::Optional<user_manager::UserType> user_type =
Shell::Get()->session_controller()->GetUserType();
if (user_type && *user_type == user_manager::USER_TYPE_GUEST)
return;
if (!active_user_pref_service_->GetBoolean( if (!active_user_pref_service_->GetBoolean(
prefs::kShownPaletteWelcomeBubble) && prefs::kShownPaletteWelcomeBubble) &&
!bubble_shown()) { !bubble_shown()) {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/session_manager/session_manager_types.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
...@@ -23,6 +24,7 @@ namespace { ...@@ -23,6 +24,7 @@ namespace {
constexpr char kUser1Email[] = "user1@palettewelcome.com"; constexpr char kUser1Email[] = "user1@palettewelcome.com";
constexpr char kUser2Email[] = "user2@palettewelcome.com"; constexpr char kUser2Email[] = "user2@palettewelcome.com";
constexpr char kGuestEmail[] = "guest@palettewelcome.com";
} // namespace } // namespace
...@@ -149,4 +151,34 @@ TEST_F(PaletteWelcomeBubbleTest, BubbleShownForSecondUser) { ...@@ -149,4 +151,34 @@ TEST_F(PaletteWelcomeBubbleTest, BubbleShownForSecondUser) {
EXPECT_TRUE(welcome_bubble_->bubble_shown()); EXPECT_TRUE(welcome_bubble_->bubble_shown());
} }
TEST_F(PaletteWelcomeBubbleTest, BubbleNotShownInactiveSession) {
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOGGED_IN_NOT_ACTIVE);
welcome_bubble_->ShowIfNeeded(false /* shown_by_stylus */);
EXPECT_FALSE(welcome_bubble_->bubble_shown());
}
class PaletteWelcomeBubbleGuestModeTest : public AshTestBase {
public:
PaletteWelcomeBubbleGuestModeTest() = default;
~PaletteWelcomeBubbleGuestModeTest() override = default;
// AshTestBase:
void SetUp() override {
AshTestBase::SetUp();
GetSessionControllerClient()->AddUserSession(kGuestEmail,
user_manager::USER_TYPE_GUEST);
}
private:
DISALLOW_COPY_AND_ASSIGN(PaletteWelcomeBubbleGuestModeTest);
};
TEST_F(PaletteWelcomeBubbleGuestModeTest, BubbleNotShownForGuest) {
auto welcome_bubble = std::make_unique<PaletteWelcomeBubble>(
StatusAreaWidgetTestHelper::GetStatusAreaWidget()->palette_tray());
welcome_bubble->ShowIfNeeded(false /* shown_by_stylus */);
EXPECT_FALSE(welcome_bubble->bubble_shown());
}
} // namespace ash } // namespace ash
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