fast_pair_enabled_provider.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_ENABLED_PROVIDER_H_
  5. #define ASH_QUICK_PAIR_FEATURE_STATUS_TRACKER_FAST_PAIR_ENABLED_PROVIDER_H_
  6. #include "ash/quick_pair/feature_status_tracker/base_enabled_provider.h"
  7. #include "ash/quick_pair/feature_status_tracker/bluetooth_enabled_provider.h"
  8. #include "ash/quick_pair/feature_status_tracker/fast_pair_pref_enabled_provider.h"
  9. #include "ash/quick_pair/feature_status_tracker/google_api_key_availability_provider.h"
  10. #include "ash/quick_pair/feature_status_tracker/logged_in_user_enabled_provider.h"
  11. #include "ash/quick_pair/feature_status_tracker/screen_state_enabled_provider.h"
  12. #include "base/memory/weak_ptr.h"
  13. namespace ash {
  14. namespace quick_pair {
  15. // Exposes an |is_enabled()| method and callback to query and observe when the
  16. // Fast Pair feature is enabled/disabled.
  17. class FastPairEnabledProvider : public BaseEnabledProvider {
  18. public:
  19. explicit FastPairEnabledProvider(
  20. std::unique_ptr<BluetoothEnabledProvider> bluetooth_enabled_provider,
  21. std::unique_ptr<FastPairPrefEnabledProvider>
  22. fast_pair_pref_enabled_provider,
  23. std::unique_ptr<LoggedInUserEnabledProvider>
  24. logged_in_user_enabled_provider,
  25. std::unique_ptr<ScreenStateEnabledProvider> screen_state_enabled_provider,
  26. std::unique_ptr<GoogleApiKeyAvailabilityProvider>
  27. google_api_key_availability_provider);
  28. ~FastPairEnabledProvider() override;
  29. private:
  30. bool AreSubProvidersEnabled();
  31. void OnSubProviderEnabledChanged(bool);
  32. std::unique_ptr<BluetoothEnabledProvider> bluetooth_enabled_provider_;
  33. std::unique_ptr<FastPairPrefEnabledProvider> fast_pair_pref_enabled_provider_;
  34. std::unique_ptr<LoggedInUserEnabledProvider> logged_in_user_enabled_provider_;
  35. std::unique_ptr<ScreenStateEnabledProvider> screen_state_enabled_provider_;
  36. std::unique_ptr<GoogleApiKeyAvailabilityProvider>
  37. google_api_key_availability_provider_;
  38. base::WeakPtrFactory<FastPairEnabledProvider> weak_factory_{this};
  39. };
  40. } // namespace quick_pair
  41. } // namespace ash
  42. #endif // ASH_QUICK_PAIR_FEATURE_STATUS_TRACKER_FAST_PAIR_ENABLED_PROVIDER_H_