OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ |
6 #define CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ | 6 #define CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "chrome/browser/prefs/tracked/hash_store_contents.h" | 12 #include "chrome/browser/prefs/tracked/hash_store_contents.h" |
13 | 13 |
14 class PrefRegistrySimple; | 14 class PrefRegistrySimple; |
15 class PrefService; | 15 class PrefService; |
16 | 16 |
17 // Implements HashStoreContents by storing hashes in a PrefService. Multiple | 17 // Implements HashStoreContents by storing hashes in a PrefService. Multiple |
18 // separate hash stores may coexist in the PrefService by using distinct hash | 18 // separate hash stores may coexist in the PrefService by using distinct hash |
19 // store IDs. | 19 // store IDs. |
| 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. |
20 class PrefServiceHashStoreContents : public HashStoreContents { | 23 class PrefServiceHashStoreContents : public HashStoreContents { |
21 public: | 24 public: |
22 // Constructs a HashStoreContents that stores hashes in |pref_service|. | 25 // Constructs a HashStoreContents that stores hashes in |pref_service|. |
23 // Multiple hash stores can use the same |pref_service| with distinct | 26 // Multiple hash stores can use the same |pref_service| with distinct |
24 // |hash_store_id|s. | 27 // |hash_store_id|s. |
25 // | 28 // |
26 // |pref_service| must have previously been configured using |RegisterPrefs|. | 29 // |pref_service| must have previously been configured using |RegisterPrefs|. |
27 PrefServiceHashStoreContents(const std::string& hash_store_id, | 30 PrefServiceHashStoreContents(const std::string& hash_store_id, |
28 PrefService* pref_service); | 31 PrefService* pref_service); |
29 | 32 |
| 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 |
| 35 // of Chrome. |
| 36 static const char kProfilePreferenceHashes[]; |
| 37 |
30 // The name of a dict that is stored as a child of | 38 // The name of a dict that is stored as a child of |
31 // |prefs::kProfilePreferenceHashes|. Each child node is a string whose name | 39 // |prefs::kProfilePreferenceHashes|. Each child node is a string whose name |
32 // is a hash store ID and whose value is the super MAC for the corresponding | 40 // is a hash store ID and whose value is the super MAC for the corresponding |
33 // hash store. | 41 // hash store. |
34 static const char kHashOfHashesDict[]; | 42 static const char kHashOfHashesDict[]; |
35 | 43 |
36 // The name of a dict that is stored as a child of | 44 // The name of a dict that is stored as a child of |
37 // |prefs::kProfilePreferenceHashes|. Each child node is a number whose name | 45 // |prefs::kProfilePreferenceHashes|. Each child node is a number whose name |
38 // is a hash store ID and whose value is the version of the corresponding | 46 // is a hash store ID and whose value is the version of the corresponding |
39 // hash store. | 47 // hash store. |
40 static const char kStoreVersionsDict[]; | 48 static const char kStoreVersionsDict[]; |
41 | 49 |
42 // Registers required preferences. | 50 // Registers required preferences. |
43 static void RegisterPrefs(PrefRegistrySimple* registry); | 51 static void RegisterPrefs(PrefRegistrySimple* registry); |
44 | 52 |
45 // Deletes stored hashes for all profiles from |pref_service|. | 53 // Deletes stored hashes for all profiles from |pref_service|. |
46 static void ResetAllPrefHashStores(PrefService* pref_service); | 54 static void ResetAllPrefHashStores(PrefService* pref_service); |
47 | 55 |
48 // HashStoreContents implementation | 56 // HashStoreContents implementation |
49 virtual std::string hash_store_id() const OVERRIDE; | 57 virtual std::string hash_store_id() const OVERRIDE; |
50 virtual void Reset() OVERRIDE; | 58 virtual void Reset() OVERRIDE; |
51 virtual bool IsInitialized() const OVERRIDE; | 59 virtual bool IsInitialized() const OVERRIDE; |
52 virtual const base::DictionaryValue* GetContents() const OVERRIDE; | 60 virtual const base::DictionaryValue* GetContents() const OVERRIDE; |
53 virtual scoped_ptr<MutableDictionary> GetMutableContents() OVERRIDE; | 61 virtual scoped_ptr<MutableDictionary> GetMutableContents() OVERRIDE; |
54 virtual std::string GetSuperMac() const OVERRIDE; | 62 virtual std::string GetSuperMac() const OVERRIDE; |
55 virtual void SetSuperMac(const std::string& super_mac) OVERRIDE; | 63 virtual void SetSuperMac(const std::string& super_mac) OVERRIDE; |
56 virtual void CommitPendingWrite() OVERRIDE; | |
57 | 64 |
58 private: | 65 private: |
59 const std::string hash_store_id_; | 66 const std::string hash_store_id_; |
60 PrefService* pref_service_; | 67 PrefService* pref_service_; |
61 | 68 |
62 DISALLOW_COPY_AND_ASSIGN(PrefServiceHashStoreContents); | 69 DISALLOW_COPY_AND_ASSIGN(PrefServiceHashStoreContents); |
63 }; | 70 }; |
64 | 71 |
65 #endif // CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ | 72 #endif // CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ |
OLD | NEW |