// Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_PREFS_WRAP_WITH_PREFIX_PREF_STORE_H_ #define COMPONENTS_PREFS_WRAP_WITH_PREFIX_PREF_STORE_H_ #include <optional> #include <string> #include <string_view> #include "base/observer_list.h" #include "components/prefs/persistent_pref_store.h" // This is a wrapper over another PersistentPrefStore. // This can be used to implement a pref store over a dictionary in the // PersistentPrefStore. // For example, consider the following JSON being handled by a JsonPrefStore: // { // "foo": "Hello World", // "bar": { // "foobar": "Goodbye World" // } // } // // A WrapWithPrefixPrefStore can help operate on the dict for "bar", directly. // That is, any query for "foobar" on this store will correspond to a query for // "bar.foobar" in the JsonPrefStore. // // This is achieved by prefixing all the queries with the provided prefix. // // This can be used to merge separate pref stores into one single storage under // separate dictionary items. // // NOTE: Users are responsible for ensuring the prefix is not an existing pref. class COMPONENTS_PREFS_EXPORT WrapWithPrefixPrefStore : public PersistentPrefStore, public PrefStore::Observer { … }; #endif // COMPONENTS_PREFS_WRAP_WITH_PREFIX_PREF_STORE_H_