autozoom_nudge_controller.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_SYSTEM_CAMERA_AUTOZOOM_NUDGE_CONTROLLER_H_
  5. #define ASH_SYSTEM_CAMERA_AUTOZOOM_NUDGE_CONTROLLER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/session/session_observer.h"
  8. #include "ash/system/camera/autozoom_observer.h"
  9. #include "ash/system/tray/system_nudge_controller.h"
  10. #include "base/time/time.h"
  11. class PrefService;
  12. class PrefRegistrySimple;
  13. namespace ash {
  14. class AutozoomControllerImpl;
  15. class ASH_EXPORT AutozoomNudgeController : public SystemNudgeController,
  16. public AutozoomObserver,
  17. public SessionObserver {
  18. public:
  19. explicit AutozoomNudgeController(AutozoomControllerImpl* controller);
  20. AutozoomNudgeController(const AutozoomNudgeController&) = delete;
  21. AutozoomNudgeController& operator=(const AutozoomNudgeController&) = delete;
  22. ~AutozoomNudgeController() override;
  23. // SessionObserver:
  24. void OnActiveUserPrefServiceChanged(PrefService* prefs) override;
  25. // Registers profile prefs.
  26. static void RegisterProfilePrefs(PrefRegistrySimple* registry);
  27. protected:
  28. // SystemNudgeController:
  29. std::unique_ptr<SystemNudge> CreateSystemNudge() override;
  30. private:
  31. // Gets whether the user had enabled autozoom before.
  32. bool GetHadEnabled(PrefService* prefs);
  33. // Gets the number of times the nudge has been shown.
  34. int GetShownCount(PrefService* prefs);
  35. // Gets the last time the nudge was shown.
  36. base::Time GetLastShownTime(PrefService* prefs);
  37. // Checks whether another nudge can be shown.
  38. bool ShouldShowNudge(PrefService* prefs);
  39. // Gets the current time.
  40. base::Time GetTime();
  41. // Resets nudge state and show nudge timer.
  42. void HandleNudgeShown();
  43. // AutozoomObserver:
  44. void OnAutozoomStateChanged(
  45. cros::mojom::CameraAutoFramingState state) override;
  46. void OnAutozoomControlEnabledChanged(bool enabled) override;
  47. // Owned by ash/Shell.
  48. AutozoomControllerImpl* const autozoom_controller_;
  49. };
  50. } // namespace ash
  51. #endif // ASH_SYSTEM_CAMERA_AUTOZOOM_NUDGE_CONTROLLER_H_