1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_PREFS_PREF_REGISTRY_SIMPLE_H_ 6 #define COMPONENTS_PREFS_PREF_REGISTRY_SIMPLE_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 #include <string> 12 13 #include "base/time/time.h" 14 #include "base/values.h" 15 #include "components/prefs/pref_registry.h" 16 #include "components/prefs/prefs_export.h" 17 18 namespace base { 19 class FilePath; 20 } 21 22 // A simple implementation of PrefRegistry. 23 class COMPONENTS_PREFS_EXPORT PrefRegistrySimple : public PrefRegistry { 24 public: 25 PrefRegistrySimple(); 26 27 PrefRegistrySimple(const PrefRegistrySimple&) = delete; 28 PrefRegistrySimple& operator=(const PrefRegistrySimple&) = delete; 29 30 // For each of these registration methods, |flags| is an optional bitmask of 31 // PrefRegistrationFlags. 32 void RegisterBooleanPref(const std::string& path, 33 bool default_value, 34 uint32_t flags = NO_REGISTRATION_FLAGS); 35 36 void RegisterIntegerPref(const std::string& path, 37 int default_value, 38 uint32_t flags = NO_REGISTRATION_FLAGS); 39 40 void RegisterDoublePref(const std::string& path, 41 double default_value, 42 uint32_t flags = NO_REGISTRATION_FLAGS); 43 44 void RegisterStringPref(const std::string& path, 45 const std::string& default_value, 46 uint32_t flags = NO_REGISTRATION_FLAGS); 47 48 void RegisterFilePathPref(const std::string& path, 49 const base::FilePath& default_value, 50 uint32_t flags = NO_REGISTRATION_FLAGS); 51 52 void RegisterListPref(const std::string& path, 53 uint32_t flags = NO_REGISTRATION_FLAGS); 54 55 void RegisterListPref(const std::string& path, 56 base::Value::List default_value, 57 uint32_t flags = NO_REGISTRATION_FLAGS); 58 59 void RegisterDictionaryPref(const std::string& path, 60 uint32_t flags = NO_REGISTRATION_FLAGS); 61 62 void RegisterDictionaryPref(const std::string& path, 63 base::Value::Dict default_value, 64 uint32_t flags = NO_REGISTRATION_FLAGS); 65 66 void RegisterInt64Pref(const std::string& path, 67 int64_t default_value, 68 uint32_t flags = NO_REGISTRATION_FLAGS); 69 70 void RegisterUint64Pref(const std::string& path, 71 uint64_t default_value, 72 uint32_t flags = NO_REGISTRATION_FLAGS); 73 74 void RegisterTimePref(const std::string& path, 75 base::Time default_value, 76 uint32_t flags = NO_REGISTRATION_FLAGS); 77 78 void RegisterTimeDeltaPref(const std::string& path, 79 base::TimeDelta default_value, 80 uint32_t flags = NO_REGISTRATION_FLAGS); 81 82 protected: 83 ~PrefRegistrySimple() override; 84 }; 85 86 #endif // COMPONENTS_PREFS_PREF_REGISTRY_SIMPLE_H_ 87