feature_status_provider.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2020 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_WEBUI_ECHE_APP_UI_FEATURE_STATUS_PROVIDER_H_
  5. #define ASH_WEBUI_ECHE_APP_UI_FEATURE_STATUS_PROVIDER_H_
  6. #include "ash/webui/eche_app_ui/feature_status.h"
  7. #include "base/observer_list.h"
  8. #include "base/observer_list_types.h"
  9. namespace ash {
  10. namespace eche_app {
  11. // Provides the current status of the eche feature and notifies observers
  12. // when the status changes.
  13. class FeatureStatusProvider {
  14. public:
  15. class Observer : public base::CheckedObserver {
  16. public:
  17. ~Observer() override = default;
  18. // Called when the status has changed; use GetStatus() for the new status.
  19. virtual void OnFeatureStatusChanged() = 0;
  20. };
  21. FeatureStatusProvider(const FeatureStatusProvider&) = delete;
  22. FeatureStatusProvider& operator=(const FeatureStatusProvider&) = delete;
  23. virtual ~FeatureStatusProvider();
  24. virtual FeatureStatus GetStatus() const = 0;
  25. void AddObserver(Observer* observer);
  26. void RemoveObserver(Observer* observer);
  27. protected:
  28. FeatureStatusProvider();
  29. void NotifyStatusChanged();
  30. private:
  31. base::ObserverList<Observer> observer_list_;
  32. };
  33. } // namespace eche_app
  34. } // namespace ash
  35. #endif // ASH_WEBUI_ECHE_APP_UI_FEATURE_STATUS_PROVIDER_H_