lock_action_handler_layout_manager.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2017 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_WM_LOCK_ACTION_HANDLER_LAYOUT_MANAGER_H_
  5. #define ASH_WM_LOCK_ACTION_HANDLER_LAYOUT_MANAGER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/lock_screen_action/lock_screen_action_background_controller.h"
  8. #include "ash/lock_screen_action/lock_screen_action_background_observer.h"
  9. #include "ash/lock_screen_action/lock_screen_action_background_state.h"
  10. #include "ash/public/cpp/shelf_types.h"
  11. #include "ash/tray_action/tray_action.h"
  12. #include "ash/tray_action/tray_action_observer.h"
  13. #include "ash/wm/lock_layout_manager.h"
  14. #include "base/scoped_observation.h"
  15. namespace ash {
  16. class Shelf;
  17. // Window layout manager for windows intended to handle lock tray actions.
  18. // Since "new note" is currently the only supported action, the layout
  19. // manager uses new note tray action state to determine it state.
  20. // The layout is intended to be used for LockActionHandlerContainer. The
  21. // container state depends on the lock screen "new_note" action state:
  22. // * for active action state - the windows should be visible above the lock
  23. // screen
  24. // * for rest of the states - the windows should not be visible.
  25. // The layout manager will observe new note action state changes and update
  26. // the container's children state as needed.
  27. // The windows in this container will have be maximized, if possible. If they
  28. // are not resizable, they will be centered on the screen - similar to windows
  29. // in lock screen container.
  30. // Unlike lock layout manager, when maximizing windows, this layout manager will
  31. // ensure that the windows do not obscure the system shelf.
  32. class ASH_EXPORT LockActionHandlerLayoutManager
  33. : public LockLayoutManager,
  34. public TrayActionObserver,
  35. public LockScreenActionBackgroundObserver {
  36. public:
  37. LockActionHandlerLayoutManager(
  38. aura::Window* window,
  39. Shelf* shelf,
  40. LockScreenActionBackgroundController* action_background_controller);
  41. LockActionHandlerLayoutManager(const LockActionHandlerLayoutManager&) =
  42. delete;
  43. LockActionHandlerLayoutManager& operator=(
  44. const LockActionHandlerLayoutManager&) = delete;
  45. ~LockActionHandlerLayoutManager() override;
  46. // WmDefaultLayoutManager:
  47. void OnWindowAddedToLayout(aura::Window* child) override;
  48. void OnChildWindowVisibilityChanged(aura::Window* child,
  49. bool visibile) override;
  50. // TrayActionObserver:
  51. void OnLockScreenNoteStateChanged(mojom::TrayActionState state) override;
  52. // LockScreenActionBackgroundObserver:
  53. void OnLockScreenActionBackgroundStateChanged(
  54. LockScreenActionBackgroundState state) override;
  55. private:
  56. // Updates the child window visibility depending on lock screen note action
  57. // state and the lock screen action background state.
  58. void UpdateChildren(mojom::TrayActionState action_state,
  59. LockScreenActionBackgroundState background_state);
  60. LockScreenActionBackgroundController* action_background_controller_;
  61. base::ScopedObservation<TrayAction, TrayActionObserver>
  62. tray_action_observation_{this};
  63. base::ScopedObservation<LockScreenActionBackgroundController,
  64. LockScreenActionBackgroundObserver>
  65. action_background_observation_{this};
  66. };
  67. } // namespace ash
  68. #endif // ASH_WM_LOCK_ACTION_HANDLER_LAYOUT_MANAGER_H_