Commit 5a91b484 authored by jdufault's avatar jdufault Committed by Commit bot

cros: Hide stylus tools on various sign-in screens, disable active mode when inserting stylus.

The stylus tools would be shown previous when adding a supervised user. They could also be shown by ejecting the stylus at any point.

This CL also causes the active mode to turn off when the user inserts the stylus.

BUG=647025

Review-Url: https://codereview.chromium.org/2346833003
Cr-Commit-Position: refs/heads/master@{#419278}
parent 6093ac4a
...@@ -106,6 +106,12 @@ void PaletteToolManager::NotifyViewsDestroyed() { ...@@ -106,6 +106,12 @@ void PaletteToolManager::NotifyViewsDestroyed() {
tool->OnViewDestroyed(); tool->OnViewDestroyed();
} }
void PaletteToolManager::DisableActiveTool(PaletteGroup group) {
PaletteToolId tool_id = GetActiveTool(group);
if (tool_id != PaletteToolId::NONE)
DeactivateTool(tool_id);
}
void PaletteToolManager::EnableTool(PaletteToolId tool_id) { void PaletteToolManager::EnableTool(PaletteToolId tool_id) {
ActivateTool(tool_id); ActivateTool(tool_id);
} }
......
...@@ -90,6 +90,9 @@ class ASH_EXPORT PaletteToolManager : public PaletteTool::Delegate { ...@@ -90,6 +90,9 @@ class ASH_EXPORT PaletteToolManager : public PaletteTool::Delegate {
// should clear any (now) stale references. // should clear any (now) stale references.
void NotifyViewsDestroyed(); void NotifyViewsDestroyed();
// Helper method to disable any active tool in the given |group|.
void DisableActiveTool(PaletteGroup group);
private: private:
// PaleteTool::Delegate overrides. // PaleteTool::Delegate overrides.
void EnableTool(PaletteToolId tool_id) override; void EnableTool(PaletteToolId tool_id) override;
......
...@@ -69,6 +69,17 @@ views::Separator* CreateSeparator(views::Separator::Orientation orientation) { ...@@ -69,6 +69,17 @@ views::Separator* CreateSeparator(views::Separator::Orientation orientation) {
return separator; return separator;
} }
// Returns true if we are in a user session that can show the stylus tools.
bool IsInUserSession() {
SessionStateDelegate* session_state_delegate =
WmShell::Get()->GetSessionStateDelegate();
return !session_state_delegate->IsUserSessionBlocked() &&
session_state_delegate->GetSessionState() ==
SessionStateDelegate::SESSION_STATE_ACTIVE &&
WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
LoginStatus::KIOSK_APP;
}
class TitleView : public views::View, public views::ButtonListener { class TitleView : public views::View, public views::ButtonListener {
public: public:
explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) {
...@@ -247,6 +258,11 @@ void PaletteTray::SessionStateChanged( ...@@ -247,6 +258,11 @@ void PaletteTray::SessionStateChanged(
void PaletteTray::OnLockStateChanged(bool locked) { void PaletteTray::OnLockStateChanged(bool locked) {
UpdateIconVisibility(); UpdateIconVisibility();
// The user can eject the stylus during the lock screen transition, which will
// open the palette. Make sure to close it if that happens.
if (locked)
HidePalette();
} }
void PaletteTray::ClickedOutsideBubble() { void PaletteTray::ClickedOutsideBubble() {
...@@ -391,33 +407,39 @@ void PaletteTray::UpdateTrayIcon() { ...@@ -391,33 +407,39 @@ void PaletteTray::UpdateTrayIcon() {
} }
void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) { void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) {
if (!WmShell::Get()->palette_delegate()->ShouldAutoOpenPalette()) PaletteDelegate* palette_delegate = WmShell::Get()->palette_delegate();
// Don't do anything if the palette should not be shown or if the user has
// disabled it all-together.
if (!IsInUserSession() || !palette_delegate->ShouldShowPalette())
return; return;
if (stylus_state == ui::StylusState::REMOVED && !bubble_) { // Auto show/hide the palette if allowed by the user.
is_bubble_auto_opened_ = true; if (palette_delegate->ShouldAutoOpenPalette()) {
ShowPalette(); if (stylus_state == ui::StylusState::REMOVED && !bubble_) {
} else if (stylus_state == ui::StylusState::INSERTED && bubble_) { is_bubble_auto_opened_ = true;
HidePalette(); ShowPalette();
} else if (stylus_state == ui::StylusState::INSERTED && bubble_) {
HidePalette();
}
} }
// Disable any active modes if the stylus has been inserted.
if (stylus_state == ui::StylusState::INSERTED)
palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE);
} }
void PaletteTray::OnPaletteEnabledPrefChanged(bool enabled) { void PaletteTray::OnPaletteEnabledPrefChanged(bool enabled) {
if (!enabled) if (!enabled) {
SetVisible(false); SetVisible(false);
else palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE);
} else {
UpdateIconVisibility(); UpdateIconVisibility();
}
} }
void PaletteTray::UpdateIconVisibility() { void PaletteTray::UpdateIconVisibility() {
SessionStateDelegate* session_state_delegate = SetVisible(IsInUserSession());
WmShell::Get()->GetSessionStateDelegate();
SetVisible(!session_state_delegate->IsScreenLocked() &&
session_state_delegate->GetSessionState() ==
SessionStateDelegate::SESSION_STATE_ACTIVE &&
WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
LoginStatus::KIOSK_APP);
} }
} // 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