delayed_animation_observer_impl.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2018 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_OVERVIEW_DELAYED_ANIMATION_OBSERVER_IMPL_H_
  5. #define ASH_WM_OVERVIEW_DELAYED_ANIMATION_OBSERVER_IMPL_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/wm/overview/delayed_animation_observer.h"
  8. #include "ui/compositor/layer_animation_observer.h"
  9. namespace ash {
  10. class OverviewDelegate;
  11. // An observer that does not watch any animation, but instead has a timeout
  12. // before telling its owner to destroy it. It is used when entering overview
  13. // without any animations but we still want to delay some tasks.
  14. class ASH_EXPORT ForceDelayObserver : public DelayedAnimationObserver {
  15. public:
  16. explicit ForceDelayObserver(base::TimeDelta delay);
  17. ForceDelayObserver(const ForceDelayObserver&) = delete;
  18. ForceDelayObserver& operator=(const ForceDelayObserver&) = delete;
  19. ~ForceDelayObserver() override;
  20. // DelayedAnimationObserver:
  21. void SetOwner(OverviewDelegate* owner) override;
  22. void Shutdown() override;
  23. private:
  24. void Finish();
  25. OverviewDelegate* owner_ = nullptr;
  26. base::WeakPtrFactory<ForceDelayObserver> weak_ptr_factory_{this};
  27. };
  28. // An observer which watches a overview enter animation and signals its owner
  29. // when the animation it is watching finishes.
  30. class ASH_EXPORT EnterAnimationObserver : public ui::ImplicitAnimationObserver,
  31. public DelayedAnimationObserver {
  32. public:
  33. EnterAnimationObserver();
  34. EnterAnimationObserver(const EnterAnimationObserver&) = delete;
  35. EnterAnimationObserver& operator=(const EnterAnimationObserver&) = delete;
  36. ~EnterAnimationObserver() override;
  37. // ui::ImplicitAnimationObserver:
  38. void OnImplicitAnimationsCompleted() override;
  39. // DelayedAnimationObserver:
  40. void SetOwner(OverviewDelegate* owner) override;
  41. void Shutdown() override;
  42. private:
  43. OverviewDelegate* owner_ = nullptr;
  44. };
  45. // An observer which watches a overview exit animation and signals its owner
  46. // when the animation it is watching finishes.
  47. class ASH_EXPORT ExitAnimationObserver : public ui::ImplicitAnimationObserver,
  48. public DelayedAnimationObserver {
  49. public:
  50. ExitAnimationObserver();
  51. ExitAnimationObserver(const ExitAnimationObserver&) = delete;
  52. ExitAnimationObserver& operator=(const ExitAnimationObserver&) = delete;
  53. ~ExitAnimationObserver() override;
  54. // ui::ImplicitAnimationObserver:
  55. void OnImplicitAnimationsCompleted() override;
  56. // DelayedAnimationObserver:
  57. void SetOwner(OverviewDelegate* owner) override;
  58. void Shutdown() override;
  59. private:
  60. OverviewDelegate* owner_ = nullptr;
  61. };
  62. } // namespace ash
  63. #endif // ASH_WM_OVERVIEW_DELAYED_ANIMATION_OBSERVER_IMPL_H_