ambient_animation_shield_controller.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2022 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_AMBIENT_UI_AMBIENT_ANIMATION_SHIELD_CONTROLLER_H_
  5. #define ASH_AMBIENT_UI_AMBIENT_ANIMATION_SHIELD_CONTROLLER_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ash/public/cpp/style/color_mode_observer.h"
  9. #include "ash/style/dark_light_mode_controller_impl.h"
  10. #include "base/memory/raw_ptr.h"
  11. #include "base/scoped_observation.h"
  12. namespace views {
  13. class View;
  14. } // namespace views
  15. namespace ash {
  16. // Adds a view containing a dark-mode "shield" to the UI hierarchy whenever dark
  17. // mode is active, and removes it whenever light mode is active. The "shield"
  18. // view's details are up to the caller but is intended to paint some form of
  19. // a "dark" layer on top of the actual contents only when dark mode is active.
  20. //
  21. // The shield UX requirements for animated mode do not overlap enough with the
  22. // gradient-based AmbientShieldView to be re-used.
  23. class ASH_EXPORT AmbientAnimationShieldController : public ColorModeObserver {
  24. public:
  25. AmbientAnimationShieldController(std::unique_ptr<views::View> shield_view,
  26. views::View* parent_view);
  27. AmbientAnimationShieldController(const AmbientAnimationShieldController&) =
  28. delete;
  29. AmbientAnimationShieldController& operator=(
  30. const AmbientAnimationShieldController&) = delete;
  31. ~AmbientAnimationShieldController() override;
  32. private:
  33. void OnColorModeChanged(bool dark_mode_enabled) override;
  34. const std::unique_ptr<views::View> shield_view_;
  35. const base::raw_ptr<views::View> parent_view_;
  36. base::ScopedObservation<DarkLightModeControllerImpl, ColorModeObserver>
  37. color_provider_observer_{this};
  38. };
  39. } // namespace ash
  40. #endif // ASH_AMBIENT_UI_AMBIENT_ANIMATION_SHIELD_CONTROLLER_H_