dark_light_mode_nudge_controller.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_STYLE_DARK_LIGHT_MODE_NUDGE_CONTROLLER_H_
  5. #define ASH_STYLE_DARK_LIGHT_MODE_NUDGE_CONTROLLER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/system/tray/system_nudge_controller.h"
  8. namespace ash {
  9. class SystemNudge;
  10. // Controls the showing and hiding of the dark/light mode educational nudge.
  11. // SystemNudgeController will control the animation, time duration etc of the
  12. // nudge.
  13. class ASH_EXPORT DarkLightModeNudgeController : public SystemNudgeController {
  14. public:
  15. DarkLightModeNudgeController();
  16. DarkLightModeNudgeController(const DarkLightModeNudgeController&) = delete;
  17. DarkLightModeNudgeController& operator=(const DarkLightModeNudgeController&) =
  18. delete;
  19. ~DarkLightModeNudgeController() override;
  20. // Gets the remaining number of times that the educational nudge can be shown.
  21. static int GetRemainingShownCount();
  22. // If possible, this will show the nudge that educates the user how to switch
  23. // between the dark and light mode.
  24. void MaybeShowNudge();
  25. // Called when the feature's state is toggled manually by the user.
  26. void ToggledByUser();
  27. void set_show_nudge_for_testing(bool value) {
  28. hide_nudge_for_testing_ = !value;
  29. }
  30. protected:
  31. // SystemNudgeController:
  32. std::unique_ptr<SystemNudge> CreateSystemNudge() override;
  33. private:
  34. // Returns true if the educational nudge should be shown.
  35. bool ShouldShowNudge() const;
  36. // Used to indicate whether to hide the nudge in tests. Will be initialized to
  37. // hide for ash tests through `set_show_nudge_for_testing` above. See
  38. // AshTestHelper::SetUp for more details.
  39. bool hide_nudge_for_testing_ = false;
  40. };
  41. } // namespace ash
  42. #endif // ASH_STYLE_DARK_LIGHT_MODE_NUDGE_CONTROLLER_H_