Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2346833003: cros: Hide stylus tools on various sign-in screens, disable active mode when inserting stylus. (Closed)
Patch Set: Initial upload Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tool_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/chromeos/palette/palette_tray.cc
diff --git a/ash/common/system/chromeos/palette/palette_tray.cc b/ash/common/system/chromeos/palette/palette_tray.cc
index 36f6cd9cfd2f9917f0a57df2a70fd9328b7ebe77..9830289733b4800fa32d0f337fed5e501e42775a 100644
--- a/ash/common/system/chromeos/palette/palette_tray.cc
+++ b/ash/common/system/chromeos/palette/palette_tray.cc
@@ -69,6 +69,17 @@ views::Separator* CreateSeparator(views::Separator::Orientation orientation) {
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 {
public:
explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) {
@@ -247,6 +258,11 @@ void PaletteTray::SessionStateChanged(
void PaletteTray::OnLockStateChanged(bool locked) {
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() {
@@ -391,33 +407,39 @@ void PaletteTray::UpdateTrayIcon() {
}
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;
- if (stylus_state == ui::StylusState::REMOVED && !bubble_) {
- is_bubble_auto_opened_ = true;
- ShowPalette();
- } else if (stylus_state == ui::StylusState::INSERTED && bubble_) {
- HidePalette();
+ // Auto show/hide the palette if allowed by the user.
+ if (palette_delegate->ShouldAutoOpenPalette()) {
+ if (stylus_state == ui::StylusState::REMOVED && !bubble_) {
+ is_bubble_auto_opened_ = true;
+ 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) {
- if (!enabled)
+ if (!enabled) {
SetVisible(false);
- else
+ palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE);
+ } else {
UpdateIconVisibility();
+ }
}
void PaletteTray::UpdateIconVisibility() {
- SessionStateDelegate* session_state_delegate =
- 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);
+ SetVisible(IsInUserSession());
}
} // namespace ash
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tool_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698