pref_service_flags_storage.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2013 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 COMPONENTS_FLAGS_UI_PREF_SERVICE_FLAGS_STORAGE_H_
  5. #define COMPONENTS_FLAGS_UI_PREF_SERVICE_FLAGS_STORAGE_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "build/build_config.h"
  8. #include "build/chromeos_buildflags.h"
  9. #include "components/flags_ui/flags_storage.h"
  10. class PrefService;
  11. class PrefRegistrySimple;
  12. namespace user_prefs {
  13. class PrefRegistrySyncable;
  14. }
  15. namespace flags_ui {
  16. // Implements the FlagsStorage interface with a PrefService backend.
  17. // This is the implementation used on desktop Chrome for all users.
  18. class PrefServiceFlagsStorage : public FlagsStorage {
  19. public:
  20. explicit PrefServiceFlagsStorage(PrefService* prefs);
  21. PrefServiceFlagsStorage(const PrefServiceFlagsStorage&) = delete;
  22. PrefServiceFlagsStorage& operator=(const PrefServiceFlagsStorage&) = delete;
  23. ~PrefServiceFlagsStorage() override;
  24. std::set<std::string> GetFlags() const override;
  25. bool SetFlags(const std::set<std::string>& flags) override;
  26. void CommitPendingWrites() override;
  27. std::string GetOriginListFlag(
  28. const std::string& internal_entry_name) const override;
  29. void SetOriginListFlag(const std::string& internal_entry_name,
  30. const std::string& origin_list_value) override;
  31. static void RegisterPrefs(PrefRegistrySimple* registry);
  32. #if BUILDFLAG(IS_CHROMEOS_ASH)
  33. static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
  34. #endif // BUILDFLAG(IS_CHROMEOS_ASH)
  35. private:
  36. raw_ptr<PrefService> prefs_;
  37. };
  38. } // namespace flags_ui
  39. #endif // COMPONENTS_FLAGS_UI_PREF_SERVICE_FLAGS_STORAGE_H_