1 // Copyright 2014 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.
5 #ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_
6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "components/user_prefs/tracked/hash_store_contents.h"
14 class PrefRegistrySimple
;
17 // Implements HashStoreContents by storing hashes in a PrefService. Multiple
18 // separate hash stores may coexist in the PrefService by using distinct hash
20 // TODO(erikwright): This class is only used to recreate preference state as in
21 // M35, to test migration behaviour. Remove this class when
22 // ProfilePrefStoreManagerTest no longer depends on it.
23 class PrefServiceHashStoreContents
: public HashStoreContents
{
25 // Constructs a HashStoreContents that stores hashes in |pref_service|.
26 // Multiple hash stores can use the same |pref_service| with distinct
29 // |pref_service| must have previously been configured using |RegisterPrefs|.
30 PrefServiceHashStoreContents(const std::string
& hash_store_id
,
31 PrefService
* pref_service
);
33 // A dictionary pref which maps profile names to dictionary values which hold
34 // hashes of profile prefs that we track to detect changes that happen outside
36 static const char kProfilePreferenceHashes
[];
38 // The name of a dict that is stored as a child of
39 // |prefs::kProfilePreferenceHashes|. Each child node is a string whose name
40 // is a hash store ID and whose value is the super MAC for the corresponding
42 static const char kHashOfHashesDict
[];
44 // The name of a dict that is stored as a child of
45 // |prefs::kProfilePreferenceHashes|. Each child node is a number whose name
46 // is a hash store ID and whose value is the version of the corresponding
48 static const char kStoreVersionsDict
[];
50 // Registers required preferences.
51 static void RegisterPrefs(PrefRegistrySimple
* registry
);
53 // Deletes stored hashes for all profiles from |pref_service|.
54 static void ResetAllPrefHashStores(PrefService
* pref_service
);
56 // HashStoreContents implementation
57 std::string
hash_store_id() const override
;
58 void Reset() override
;
59 bool IsInitialized() const override
;
60 const base::DictionaryValue
* GetContents() const override
;
61 scoped_ptr
<MutableDictionary
> GetMutableContents() override
;
62 std::string
GetSuperMac() const override
;
63 void SetSuperMac(const std::string
& super_mac
) override
;
66 const std::string hash_store_id_
;
67 PrefService
* pref_service_
;
69 DISALLOW_COPY_AND_ASSIGN(PrefServiceHashStoreContents
);
72 #endif // COMPONENTS_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_