shelf_locking_manager.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_SHELF_SHELF_LOCKING_MANAGER_H_
  5. #define ASH_SHELF_SHELF_LOCKING_MANAGER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/session/session_observer.h"
  8. #include "ash/public/cpp/shelf_types.h"
  9. #include "ash/wm/lock_state_observer.h"
  10. namespace ash {
  11. class Shelf;
  12. // ShelfLockingManager observes screen and session events to align the shelf at
  13. // the bottom of the screen when the screen is locked.
  14. class ASH_EXPORT ShelfLockingManager : public SessionObserver,
  15. public LockStateObserver {
  16. public:
  17. explicit ShelfLockingManager(Shelf* shelf);
  18. ShelfLockingManager(const ShelfLockingManager&) = delete;
  19. ShelfLockingManager& operator=(const ShelfLockingManager&) = delete;
  20. ~ShelfLockingManager() override;
  21. bool is_locked() const { return session_locked_ || screen_locked_; }
  22. void set_stored_alignment(ShelfAlignment value) { stored_alignment_ = value; }
  23. ShelfAlignment stored_alignment() const { return stored_alignment_; }
  24. // SessionObserver:
  25. void OnLockStateChanged(bool locked) override;
  26. void OnSessionStateChanged(session_manager::SessionState state) override;
  27. // LockStateObserver:
  28. void OnLockStateEvent(EventType event) override;
  29. private:
  30. // Update the shelf state for session and screen lock changes.
  31. void UpdateLockedState();
  32. Shelf* const shelf_;
  33. bool session_locked_ = false;
  34. bool screen_locked_ = false;
  35. ShelfAlignment stored_alignment_ = ShelfAlignment::kBottomLocked;
  36. ScopedSessionObserver scoped_session_observer_;
  37. };
  38. } // namespace ash
  39. #endif // ASH_SHELF_SHELF_LOCKING_MANAGER_H_