fast_pair_pref_enabled_provider.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2021 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_QUICK_PAIR_FEATURE_STATUS_TRACKER_FAST_PAIR_PREF_ENABLED_PROVIDER_H_
  5. #define ASH_QUICK_PAIR_FEATURE_STATUS_TRACKER_FAST_PAIR_PREF_ENABLED_PROVIDER_H_
  6. #include "ash/public/cpp/session/session_observer.h"
  7. #include "ash/quick_pair/feature_status_tracker/base_enabled_provider.h"
  8. #include "ash/session/session_controller_impl.h"
  9. #include "base/scoped_observation.h"
  10. class PrefChangeRegistrar;
  11. class PrefRegistrySimple;
  12. namespace ash {
  13. namespace quick_pair {
  14. // Observes whether a passed in boolean pref is enabled.
  15. class FastPairPrefEnabledProvider : public BaseEnabledProvider,
  16. public SessionObserver {
  17. public:
  18. FastPairPrefEnabledProvider();
  19. ~FastPairPrefEnabledProvider() override;
  20. static void RegisterProfilePrefs(PrefRegistrySimple* registry);
  21. // SessionObserver:
  22. void OnActiveUserPrefServiceChanged(PrefService* prefs) override;
  23. private:
  24. void OnFastPairPrefChanged();
  25. // Observes user profile prefs.
  26. std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
  27. base::ScopedObservation<SessionControllerImpl, SessionObserver>
  28. session_observation_{this};
  29. };
  30. } // namespace quick_pair
  31. } // namespace ash
  32. #endif // ASH_QUICK_PAIR_FEATURE_STATUS_TRACKER_FAST_PAIR_PREF_ENABLED_PROVIDER_H_