Commit 5b1e551c authored by yilkal's avatar yilkal Committed by Commit Bot

Hide system tray items in chromeos when Kiosk Next is enabled.

Hidden items:
 1. Ime menu tray
 2. Overview button tray
 3. Palette tray
 4. Logout buton tray
 5. Virtual keyboard tray

Bug: 948955
Change-Id: I8ade734877dfeb6ef45e6516c86384328a1d052f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1622366
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664803}
parent 85bf8ed5
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/keyboard/ash_keyboard_controller.h" #include "ash/keyboard/ash_keyboard_controller.h"
#include "ash/keyboard/ui/keyboard_controller.h" #include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/keyboard/virtual_keyboard_controller.h" #include "ash/keyboard/virtual_keyboard_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/public/cpp/ash_constants.h" #include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/system_tray_client.h" #include "ash/public/cpp/system_tray_client.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
...@@ -337,6 +338,7 @@ ImeMenuTray::ImeMenuTray(Shelf* shelf) ...@@ -337,6 +338,7 @@ ImeMenuTray::ImeMenuTray(Shelf* shelf)
is_emoji_enabled_(false), is_emoji_enabled_(false),
is_handwriting_enabled_(false), is_handwriting_enabled_(false),
is_voice_enabled_(false), is_voice_enabled_(false),
is_enabled_(false),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(ime_controller_); DCHECK(ime_controller_);
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
...@@ -433,6 +435,12 @@ bool ImeMenuTray::ShouldShowKeyboardToggle() const { ...@@ -433,6 +435,12 @@ bool ImeMenuTray::ShouldShowKeyboardToggle() const {
!Shell::Get()->accessibility_controller()->virtual_keyboard_enabled(); !Shell::Get()->accessibility_controller()->virtual_keyboard_enabled();
} }
void ImeMenuTray::UpdateIconVisibility() {
bool visible =
is_enabled_ && !Shell::Get()->kiosk_next_shell_controller()->IsEnabled();
SetVisible(visible);
}
base::string16 ImeMenuTray::GetAccessibleNameForTray() { base::string16 ImeMenuTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
} }
...@@ -494,7 +502,8 @@ void ImeMenuTray::OnIMERefresh() { ...@@ -494,7 +502,8 @@ void ImeMenuTray::OnIMERefresh() {
} }
void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) { void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) {
SetVisible(is_activated); is_enabled_ = is_activated;
UpdateIconVisibility();
if (is_activated) if (is_activated)
UpdateTrayLabel(); UpdateTrayLabel();
else else
......
...@@ -51,6 +51,8 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView, ...@@ -51,6 +51,8 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
// opt-in IME menu. // opt-in IME menu.
bool ShouldShowKeyboardToggle() const; bool ShouldShowKeyboardToggle() const;
void UpdateIconVisibility();
// TrayBackgroundView: // TrayBackgroundView:
base::string16 GetAccessibleNameForTray() override; base::string16 GetAccessibleNameForTray() override;
void HideBubbleWithView(const TrayBubbleView* bubble_view) override; void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
...@@ -104,6 +106,9 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView, ...@@ -104,6 +106,9 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
bool is_handwriting_enabled_; bool is_handwriting_enabled_;
bool is_voice_enabled_; bool is_voice_enabled_;
// Whether the IME menu has been enabled.
bool is_enabled_;
base::WeakPtrFactory<ImeMenuTray> weak_ptr_factory_; base::WeakPtrFactory<ImeMenuTray> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ImeMenuTray); DISALLOW_COPY_AND_ASSIGN(ImeMenuTray);
......
...@@ -4,10 +4,15 @@ ...@@ -4,10 +4,15 @@
#include "ash/system/ime_menu/ime_menu_tray.h" #include "ash/system/ime_menu/ime_menu_tray.h"
#include <memory>
#include "ash/accelerators/accelerator_controller_impl.h" #include "ash/accelerators/accelerator_controller_impl.h"
#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/accessibility_controller.h"
#include "ash/ime/ime_controller.h" #include "ash/ime/ime_controller.h"
#include "ash/ime/test_ime_controller_client.h" #include "ash/ime/test_ime_controller_client.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/public/interfaces/ime_info.mojom.h" #include "ash/public/interfaces/ime_info.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/ime_menu/ime_list_view.h" #include "ash/system/ime_menu/ime_list_view.h"
...@@ -16,6 +21,7 @@ ...@@ -16,6 +21,7 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/base/ime/ime_bridge.h" #include "ui/base/ime/ime_bridge.h"
#include "ui/base/ime/text_input_flags.h" #include "ui/base/ime/text_input_flags.h"
...@@ -353,4 +359,32 @@ TEST_F(ImeMenuTrayTest, ShouldShowBottomButtonsSeperate) { ...@@ -353,4 +359,32 @@ TEST_F(ImeMenuTrayTest, ShouldShowBottomButtonsSeperate) {
EXPECT_FALSE(IsVoiceEnabled()); EXPECT_FALSE(IsVoiceEnabled());
} }
class KioskNextImeMenuTest : public ImeMenuTrayTest {
public:
KioskNextImeMenuTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
ImeMenuTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextImeMenuTest);
};
TEST_F(KioskNextImeMenuTest, ImeMenuNotVisible) {
ASSERT_FALSE(IsVisible());
Shell::Get()->ime_controller()->ShowImeMenuOnShelf(true);
EXPECT_TRUE(IsVisible());
LogInKioskNextUser(GetSessionControllerClient());
EXPECT_FALSE(IsVisible());
}
} // namespace ash } // namespace ash
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/system/overview/overview_button_tray.h" #include "ash/system/overview/overview_button_tray.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/metrics/user_metrics_recorder.h" #include "ash/metrics/user_metrics_recorder.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"
...@@ -69,6 +70,25 @@ void OverviewButtonTray::SnapRippleToActivated() { ...@@ -69,6 +70,25 @@ void OverviewButtonTray::SnapRippleToActivated() {
GetInkDrop()->SnapToActivated(); GetInkDrop()->SnapToActivated();
} }
void OverviewButtonTray::UpdateIconVisibility() {
// The visibility of the OverviewButtonTray has diverged from
// OverviewController::CanSelect. The visibility of the button should
// not change during transient times in which CanSelect is false. Such as when
// a modal dialog is present.
SessionControllerImpl* session_controller =
Shell::Get()->session_controller();
bool kiosk_next = Shell::Get()->kiosk_next_shell_controller()->IsEnabled();
bool events_blocked = Shell::Get()
->tablet_mode_controller()
->AreInternalInputDeviceEventsBlocked();
bool active_session = session_controller->GetSessionState() ==
session_manager::SessionState::ACTIVE;
bool app_mode = session_controller->IsRunningInAppMode();
SetVisible(!kiosk_next && events_blocked && active_session && !app_mode);
}
void OverviewButtonTray::OnGestureEvent(ui::GestureEvent* event) { void OverviewButtonTray::OnGestureEvent(ui::GestureEvent* event) {
Button::OnGestureEvent(event); Button::OnGestureEvent(event);
if (event->type() == ui::ET_GESTURE_LONG_PRESS) { if (event->type() == ui::ET_GESTURE_LONG_PRESS) {
...@@ -172,19 +192,4 @@ const char* OverviewButtonTray::GetClassName() const { ...@@ -172,19 +192,4 @@ const char* OverviewButtonTray::GetClassName() const {
return "OverviewButtonTray"; return "OverviewButtonTray";
} }
void OverviewButtonTray::UpdateIconVisibility() {
// The visibility of the OverviewButtonTray has diverged from
// OverviewController::CanSelect. The visibility of the button should
// not change during transient times in which CanSelect is false. Such as when
// a modal dialog is present.
SessionControllerImpl* session_controller =
Shell::Get()->session_controller();
SetVisible(Shell::Get()
->tablet_mode_controller()
->AreInternalInputDeviceEventsBlocked() &&
session_controller->GetSessionState() ==
session_manager::SessionState::ACTIVE &&
!session_controller->IsRunningInAppMode());
}
} // namespace ash } // namespace ash
...@@ -48,6 +48,8 @@ class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView, ...@@ -48,6 +48,8 @@ class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView,
// Sets the ink drop ripple to ACTIVATED immediately with no animations. // Sets the ink drop ripple to ACTIVATED immediately with no animations.
void SnapRippleToActivated(); void SnapRippleToActivated();
void UpdateIconVisibility();
// views::Button: // views::Button:
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
...@@ -75,10 +77,6 @@ class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView, ...@@ -75,10 +77,6 @@ class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView,
private: private:
friend class OverviewButtonTrayTest; friend class OverviewButtonTrayTest;
// Sets the icon to visible if tablet mode is enabled and
// OverviewController::CanSelect.
void UpdateIconVisibility();
// Weak pointer, will be parented by TrayContainer for its lifetime. // Weak pointer, will be parented by TrayContainer for its lifetime.
views::ImageView* icon_; views::ImageView* icon_;
......
...@@ -4,8 +4,13 @@ ...@@ -4,8 +4,13 @@
#include "ash/system/overview/overview_button_tray.h" #include "ash/system/overview/overview_button_tray.h"
#include <memory>
#include "ash/display/window_tree_host_manager.h" #include "ash/display/window_tree_host_manager.h"
#include "ash/kiosk_next/kiosk_next_shell_test_util.h"
#include "ash/kiosk_next/mock_kiosk_next_shell_client.h"
#include "ash/login_status.h" #include "ash/login_status.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/rotator/screen_rotation_animator.h" #include "ash/rotator/screen_rotation_animator.h"
...@@ -24,6 +29,7 @@ ...@@ -24,6 +29,7 @@
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/test/metrics/user_action_tester.h" #include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "services/ws/public/cpp/input_devices/input_device_client_test_api.h" #include "services/ws/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
...@@ -385,4 +391,33 @@ TEST_F(OverviewButtonTrayTest, LeaveTabletModeBecauseExternalMouse) { ...@@ -385,4 +391,33 @@ TEST_F(OverviewButtonTrayTest, LeaveTabletModeBecauseExternalMouse) {
EXPECT_TRUE(GetTray()->GetVisible()); EXPECT_TRUE(GetTray()->GetVisible());
} }
class KioskNextOverviewTest : public OverviewButtonTrayTest {
public:
KioskNextOverviewTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
OverviewButtonTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextOverviewTest);
};
TEST_F(KioskNextOverviewTest, OverViewButtonHidden) {
TabletModeControllerTestApi().EnterTabletMode();
CreateUserSessions(1);
EXPECT_TRUE(GetTray()->GetVisible());
ClearLogin();
LogInKioskNextUser(GetSessionControllerClient());
EXPECT_FALSE(GetTray()->GetVisible());
}
} // namespace ash } // namespace ash
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#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_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/stylus_utils.h" #include "ash/public/cpp/stylus_utils.h"
#include "ash/public/cpp/system_tray_client.h" #include "ash/public/cpp/system_tray_client.h"
...@@ -560,13 +561,10 @@ void PaletteTray::UpdateTrayIcon() { ...@@ -560,13 +561,10 @@ void PaletteTray::UpdateTrayIcon() {
void PaletteTray::OnPaletteEnabledPrefChanged() { void PaletteTray::OnPaletteEnabledPrefChanged() {
is_palette_enabled_ = pref_change_registrar_user_->prefs()->GetBoolean( is_palette_enabled_ = pref_change_registrar_user_->prefs()->GetBoolean(
prefs::kEnableStylusTools); prefs::kEnableStylusTools);
if (!is_palette_enabled_)
if (!is_palette_enabled_) {
SetVisible(false);
palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE); palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE);
} else {
UpdateIconVisibility(); UpdateIconVisibility();
}
} }
void PaletteTray::OnHasSeenStylusPrefChanged() { void PaletteTray::OnHasSeenStylusPrefChanged() {
...@@ -597,7 +595,8 @@ bool PaletteTray::HasSeenStylus() { ...@@ -597,7 +595,8 @@ bool PaletteTray::HasSeenStylus() {
void PaletteTray::UpdateIconVisibility() { void PaletteTray::UpdateIconVisibility() {
SetVisible(HasSeenStylus() && is_palette_enabled_ && SetVisible(HasSeenStylus() && is_palette_enabled_ &&
stylus_utils::HasStylusInput() && ShouldShowOnDisplay(this) && stylus_utils::HasStylusInput() && ShouldShowOnDisplay(this) &&
palette_utils::IsInUserSession()); palette_utils::IsInUserSession() &&
!Shell::Get()->kiosk_next_shell_controller()->IsEnabled());
} }
} // namespace ash } // namespace ash
...@@ -89,6 +89,9 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView, ...@@ -89,6 +89,9 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView,
PaletteInvocationMethod method) override; PaletteInvocationMethod method) override;
void RecordPaletteModeCancellation(PaletteModeCancelType type) override; void RecordPaletteModeCancellation(PaletteModeCancelType type) override;
// Sets the icon to visible if the palette can be used.
void UpdateIconVisibility();
private: private:
friend class PaletteTrayTestApi; friend class PaletteTrayTestApi;
...@@ -112,9 +115,6 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView, ...@@ -112,9 +115,6 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView,
// Updates the tray icon from the palette tool manager. // Updates the tray icon from the palette tool manager.
void UpdateTrayIcon(); void UpdateTrayIcon();
// Sets the icon to visible if the palette can be used.
void UpdateIconVisibility();
// Called when the palette enabled pref has changed. // Called when the palette enabled pref has changed.
void OnPaletteEnabledPrefChanged(); void OnPaletteEnabledPrefChanged();
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "ash/assistant/test/test_assistant_service.h" #include "ash/assistant/test/test_assistant_service.h"
#include "ash/highlighter/highlighter_controller.h" #include "ash/highlighter/highlighter_controller.h"
#include "ash/highlighter/highlighter_controller_test_api.h" #include "ash/highlighter/highlighter_controller_test_api.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/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/stylus_utils.h" #include "ash/public/cpp/stylus_utils.h"
...@@ -81,6 +84,8 @@ class PaletteTrayTest : public AshTestBase { ...@@ -81,6 +84,8 @@ class PaletteTrayTest : public AshTestBase {
test_api_ = std::make_unique<PaletteTrayTestApi>(palette_tray_); test_api_ = std::make_unique<PaletteTrayTestApi>(palette_tray_);
} }
PaletteTray* palette_tray() { return palette_tray_; }
protected: protected:
PrefService* active_user_pref_service() { PrefService* active_user_pref_service() {
return Shell::Get()->session_controller()->GetActivePrefService(); return Shell::Get()->session_controller()->GetActivePrefService();
...@@ -761,4 +766,29 @@ TEST_F(PaletteTrayNoSessionTestWithInternalStylus, ...@@ -761,4 +766,29 @@ TEST_F(PaletteTrayNoSessionTestWithInternalStylus,
EXPECT_FALSE(external_tray->GetBubbleView()); EXPECT_FALSE(external_tray->GetBubbleView());
} }
class KioskNextPaletteTrayTest : public PaletteTrayTest {
public:
KioskNextPaletteTrayTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
PaletteTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextPaletteTrayTest);
};
TEST_F(KioskNextPaletteTrayTest, PaletteTrayHidden) {
LogInKioskNextUser(GetSessionControllerClient());
local_state_pref_service()->SetBoolean(prefs::kHasSeenStylus, true);
EXPECT_FALSE(palette_tray()->GetVisible());
}
} // namespace ash } // namespace ash
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_typography.h" #include "ash/public/cpp/ash_typography.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
...@@ -65,6 +66,14 @@ void LogoutButtonTray::UpdateAfterShelfAlignmentChange() { ...@@ -65,6 +66,14 @@ void LogoutButtonTray::UpdateAfterShelfAlignmentChange() {
container_->UpdateAfterShelfAlignmentChange(); container_->UpdateAfterShelfAlignmentChange();
} }
void LogoutButtonTray::UpdateVisibility() {
LoginStatus login_status = shelf_->GetStatusAreaWidget()->login_status();
SetVisible(show_logout_button_in_tray_ &&
login_status != LoginStatus::NOT_LOGGED_IN &&
login_status != LoginStatus::LOCKED &&
!Shell::Get()->kiosk_next_shell_controller()->IsEnabled());
}
void LogoutButtonTray::ButtonPressed(views::Button* sender, void LogoutButtonTray::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
DCHECK_EQ(button_, sender); DCHECK_EQ(button_, sender);
...@@ -124,13 +133,6 @@ void LogoutButtonTray::UpdateAfterLoginStatusChange() { ...@@ -124,13 +133,6 @@ void LogoutButtonTray::UpdateAfterLoginStatusChange() {
UpdateButtonTextAndImage(); UpdateButtonTextAndImage();
} }
void LogoutButtonTray::UpdateVisibility() {
LoginStatus login_status = shelf_->GetStatusAreaWidget()->login_status();
SetVisible(show_logout_button_in_tray_ &&
login_status != LoginStatus::NOT_LOGGED_IN &&
login_status != LoginStatus::LOCKED);
}
void LogoutButtonTray::UpdateButtonTextAndImage() { void LogoutButtonTray::UpdateButtonTextAndImage() {
LoginStatus login_status = shelf_->GetStatusAreaWidget()->login_status(); LoginStatus login_status = shelf_->GetStatusAreaWidget()->login_status();
const base::string16 title = const base::string16 title =
......
...@@ -39,6 +39,8 @@ class ASH_EXPORT LogoutButtonTray : public views::View, ...@@ -39,6 +39,8 @@ class ASH_EXPORT LogoutButtonTray : public views::View,
void UpdateAfterLoginStatusChange(); void UpdateAfterLoginStatusChange();
void UpdateAfterShelfAlignmentChange(); void UpdateAfterShelfAlignmentChange();
void UpdateVisibility();
// views::View: // views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
const char* GetClassName() const override; const char* GetClassName() const override;
...@@ -54,7 +56,6 @@ class ASH_EXPORT LogoutButtonTray : public views::View, ...@@ -54,7 +56,6 @@ class ASH_EXPORT LogoutButtonTray : public views::View,
private: private:
void UpdateShowLogoutButtonInTray(); void UpdateShowLogoutButtonInTray();
void UpdateLogoutDialogDuration(); void UpdateLogoutDialogDuration();
void UpdateVisibility();
void UpdateButtonTextAndImage(); void UpdateButtonTextAndImage();
Shelf* const shelf_; Shelf* const shelf_;
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
#include "ash/system/session/logout_button_tray.h" #include "ash/system/session/logout_button_tray.h"
#include <memory>
#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/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
...@@ -16,6 +21,7 @@ ...@@ -16,6 +21,7 @@
#include "ash/test_shell_delegate.h" #include "ash/test_shell_delegate.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/metrics/user_action_tester.h" #include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
#include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/button/md_text_button.h"
...@@ -36,6 +42,12 @@ class LogoutButtonTrayTest : public NoSessionAshTestBase { ...@@ -36,6 +42,12 @@ class LogoutButtonTrayTest : public NoSessionAshTestBase {
SimulateUserLogin(kUserEmail); SimulateUserLogin(kUserEmail);
} }
LogoutButtonTray* logout_button_tray() {
return Shell::GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->logout_button_tray_for_testing();
}
PrefService* pref_service() { PrefService* pref_service() {
return Shell::Get()->session_controller()->GetUserPrefServiceForUser( return Shell::Get()->session_controller()->GetUserPrefServiceForUser(
AccountId::FromUserEmail(kUserEmail)); AccountId::FromUserEmail(kUserEmail));
...@@ -47,9 +59,8 @@ class LogoutButtonTrayTest : public NoSessionAshTestBase { ...@@ -47,9 +59,8 @@ class LogoutButtonTrayTest : public NoSessionAshTestBase {
TEST_F(LogoutButtonTrayTest, Visibility) { TEST_F(LogoutButtonTrayTest, Visibility) {
// Button is not visible before login. // Button is not visible before login.
LogoutButtonTray* button = Shell::GetPrimaryRootWindowController() LogoutButtonTray* button = logout_button_tray();
->GetStatusAreaWidget()
->logout_button_tray_for_testing();
ASSERT_TRUE(button); ASSERT_TRUE(button);
EXPECT_FALSE(button->GetVisible()); EXPECT_FALSE(button->GetVisible());
...@@ -77,9 +88,8 @@ TEST_F(LogoutButtonTrayTest, ButtonPressed) { ...@@ -77,9 +88,8 @@ TEST_F(LogoutButtonTrayTest, ButtonPressed) {
constexpr char kUserEmail[] = "user1@test.com"; constexpr char kUserEmail[] = "user1@test.com";
constexpr char kUserAction[] = "DemoMode.ExitFromShelf"; constexpr char kUserAction[] = "DemoMode.ExitFromShelf";
LogoutButtonTray* const tray = Shell::GetPrimaryRootWindowController() LogoutButtonTray* const tray = logout_button_tray();
->GetStatusAreaWidget()
->logout_button_tray_for_testing();
ASSERT_TRUE(tray); ASSERT_TRUE(tray);
views::MdTextButton* const button = tray->button_for_test(); views::MdTextButton* const button = tray->button_for_test();
TestSessionControllerClient* const session_client = TestSessionControllerClient* const session_client =
...@@ -132,5 +142,30 @@ TEST_F(LogoutButtonTrayTest, ButtonPressed) { ...@@ -132,5 +142,30 @@ TEST_F(LogoutButtonTrayTest, ButtonPressed) {
->confirm_logout_count_for_test()); ->confirm_logout_count_for_test());
} }
class KioskNextLogoutButtonTrayTest : public LogoutButtonTrayTest {
public:
KioskNextLogoutButtonTrayTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
LogoutButtonTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextLogoutButtonTrayTest);
};
TEST_F(KioskNextLogoutButtonTrayTest, LogoutButtonHidden) {
ClearLogin();
LogInKioskNextUser(GetSessionControllerClient());
pref_service()->SetBoolean(prefs::kShowLogoutButtonInTray, true);
EXPECT_FALSE(logout_button_tray()->GetVisible());
}
} // namespace } // namespace
} // namespace ash } // namespace ash
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -37,6 +38,7 @@ StatusAreaWidget::StatusAreaWidget(aura::Window* status_container, Shelf* shelf) ...@@ -37,6 +38,7 @@ StatusAreaWidget::StatusAreaWidget(aura::Window* status_container, Shelf* shelf)
Init(params); Init(params);
set_focus_on_creation(false); set_focus_on_creation(false);
SetContentsView(status_area_widget_delegate_); SetContentsView(status_area_widget_delegate_);
Shell::Get()->kiosk_next_shell_controller()->AddObserver(this);
} }
void StatusAreaWidget::Initialize() { void StatusAreaWidget::Initialize() {
...@@ -97,6 +99,8 @@ StatusAreaWidget::~StatusAreaWidget() { ...@@ -97,6 +99,8 @@ StatusAreaWidget::~StatusAreaWidget() {
logout_button_tray_.reset(); logout_button_tray_.reset();
overview_button_tray_.reset(); overview_button_tray_.reset();
Shell::Get()->kiosk_next_shell_controller()->RemoveObserver(this);
// All child tray views have been removed. // All child tray views have been removed.
DCHECK(GetContentsView()->children().empty()); DCHECK(GetContentsView()->children().empty());
} }
...@@ -190,6 +194,14 @@ bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { ...@@ -190,6 +194,14 @@ bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
return true; return true;
} }
void StatusAreaWidget::OnKioskNextEnabled() {
ime_menu_tray_->UpdateIconVisibility();
overview_button_tray_->UpdateIconVisibility();
palette_tray_->UpdateIconVisibility();
virtual_keyboard_tray_->UpdateIconVisibility();
logout_button_tray_->UpdateVisibility();
}
void StatusAreaWidget::OnMouseEvent(ui::MouseEvent* event) { void StatusAreaWidget::OnMouseEvent(ui::MouseEvent* event) {
// Clicking anywhere except the virtual keyboard tray icon should hide the // Clicking anywhere except the virtual keyboard tray icon should hide the
// virtual keyboard. // virtual keyboard.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ASH_SYSTEM_STATUS_AREA_WIDGET_H_ #define ASH_SYSTEM_STATUS_AREA_WIDGET_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/kiosk_next/kiosk_next_shell_observer.h"
#include "ash/login_status.h" #include "ash/login_status.h"
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf_background_animator_observer.h" #include "ash/shelf/shelf_background_animator_observer.h"
...@@ -34,7 +35,8 @@ class VirtualKeyboardTray; ...@@ -34,7 +35,8 @@ class VirtualKeyboardTray;
// so that it can be shown in cases where the rest of the shelf is hidden (e.g. // so that it can be shown in cases where the rest of the shelf is hidden (e.g.
// on secondary monitors at the login screen). // on secondary monitors at the login screen).
class ASH_EXPORT StatusAreaWidget : public views::Widget, class ASH_EXPORT StatusAreaWidget : public views::Widget,
public ShelfBackgroundAnimatorObserver { public ShelfBackgroundAnimatorObserver,
public KioskNextShellObserver {
public: public:
StatusAreaWidget(aura::Window* status_container, Shelf* shelf); StatusAreaWidget(aura::Window* status_container, Shelf* shelf);
~StatusAreaWidget() override; ~StatusAreaWidget() override;
...@@ -99,6 +101,9 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget, ...@@ -99,6 +101,9 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget,
const ui::NativeTheme* GetNativeTheme() const override; const ui::NativeTheme* GetNativeTheme() const override;
bool OnNativeWidgetActivationChanged(bool active) override; bool OnNativeWidgetActivationChanged(bool active) override;
// KioskNextShellObserver:
void OnKioskNextEnabled() override;
// TODO(jamescook): Introduce a test API instead of these methods. // TODO(jamescook): Introduce a test API instead of these methods.
LogoutButtonTray* logout_button_tray_for_testing() { LogoutButtonTray* logout_button_tray_for_testing() {
return logout_button_tray_.get(); return logout_button_tray_.get();
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/accessibility_controller.h"
#include "ash/keyboard/ui/keyboard_controller.h" #include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.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"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
...@@ -91,9 +92,7 @@ bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { ...@@ -91,9 +92,7 @@ bool VirtualKeyboardTray::PerformAction(const ui::Event& event) {
} }
void VirtualKeyboardTray::OnAccessibilityStatusChanged() { void VirtualKeyboardTray::OnAccessibilityStatusChanged() {
bool new_enabled = UpdateIconVisibility();
Shell::Get()->accessibility_controller()->virtual_keyboard_enabled();
SetVisible(new_enabled);
} }
void VirtualKeyboardTray::OnKeyboardVisibilityStateChanged( void VirtualKeyboardTray::OnKeyboardVisibilityStateChanged(
...@@ -124,4 +123,11 @@ void VirtualKeyboardTray::UpdateIcon() { ...@@ -124,4 +123,11 @@ void VirtualKeyboardTray::UpdateIcon() {
gfx::Insets(vertical_padding, horizontal_padding))); gfx::Insets(vertical_padding, horizontal_padding)));
} }
void VirtualKeyboardTray::UpdateIconVisibility() {
bool visible =
Shell::Get()->accessibility_controller()->virtual_keyboard_enabled() &&
!Shell::Get()->kiosk_next_shell_controller()->IsEnabled();
SetVisible(visible);
}
} // namespace ash } // namespace ash
...@@ -46,6 +46,8 @@ class VirtualKeyboardTray : public TrayBackgroundView, ...@@ -46,6 +46,8 @@ class VirtualKeyboardTray : public TrayBackgroundView,
// views::View: // views::View:
const char* GetClassName() const override; const char* GetClassName() const override;
void UpdateIconVisibility();
private: private:
// Updates the icon UI. // Updates the icon UI.
void UpdateIcon(); void UpdateIcon();
......
...@@ -4,15 +4,25 @@ ...@@ -4,15 +4,25 @@
#include "ash/system/virtual_keyboard/virtual_keyboard_tray.h" #include "ash/system/virtual_keyboard/virtual_keyboard_tray.h"
#include <memory>
#include "ash/keyboard/ui/keyboard_controller.h" #include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/keyboard/ui/keyboard_util.h" #include "ash/keyboard/ui/keyboard_util.h"
#include "ash/keyboard/ui/test/keyboard_test_util.h" #include "ash/keyboard/ui/test/keyboard_test_util.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/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/keyboard/keyboard_switches.h" #include "ash/public/cpp/keyboard/keyboard_switches.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/status_area_widget_test_helper.h" #include "ash/system/status_area_widget_test_helper.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/test/scoped_feature_list.h"
#include "components/prefs/pref_service.h"
namespace ash { namespace ash {
...@@ -57,4 +67,42 @@ TEST_F(VirtualKeyboardTrayTest, PerformActionTogglesVirtualKeyboard) { ...@@ -57,4 +67,42 @@ TEST_F(VirtualKeyboardTrayTest, PerformActionTogglesVirtualKeyboard) {
ASSERT_TRUE(keyboard::WaitUntilHidden()); ASSERT_TRUE(keyboard::WaitUntilHidden());
} }
class KioskNextVirtualKeyboardTest : public AshTestBase {
public:
KioskNextVirtualKeyboardTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
AshTestBase::SetUp();
client_ = BindMockKioskNextShellClient();
}
void EnableVirtualKeyboardForActiveUser() {
PrefService* pref_service =
Shell::Get()->session_controller()->GetActivePrefService();
pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, true);
}
VirtualKeyboardTray* tray() {
StatusAreaWidget* status =
StatusAreaWidgetTestHelper::GetStatusAreaWidget();
return status->virtual_keyboard_tray_for_testing();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextVirtualKeyboardTest);
};
TEST_F(KioskNextVirtualKeyboardTest, VirtualKeyboardTrayHidden) {
LogInKioskNextUser(GetSessionControllerClient());
EnableVirtualKeyboardForActiveUser();
EXPECT_FALSE(tray()->GetVisible());
}
} // 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