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.
5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_
6 #define CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_
10 #include "base/memory/scoped_ptr.h"
18 // Hash of hashes for each profile, used to validate the existing hashes when
19 // debating whether an unknown value is to be trusted, will be stored as a
21 // |kProfilePreferenceHashes|.|kHashOfHashesPref|.|hash_stored_id_|.
22 const char kHashOfHashesPref
[] = "hash_of_hashes";
24 } // namespace internals
26 // Stores hashes of and verifies preference values. To use, first call
27 // |InitializeTrackedValue| with each preference that should be tracked. Then
28 // call |OnPrefValueChanged| to update the hash store when preference values
32 virtual ~PrefHashStore() {}
35 // The preference value corresponds to its stored hash.
37 // The preference has been cleared since the last hash.
39 // The preference value corresponds to its stored hash, which was calculated
40 // using a legacy hash algorithm.
42 // The preference value has been changed since the last hash.
44 // No stored hash exists for the preference value.
45 UNTRUSTED_UNKNOWN_VALUE
,
46 // No stored hash exists for the preference value, but the current set of
47 // hashes stored is trusted and thus this value can safely be seeded. This
48 // happens when all hashes are already properly seeded and a newly
49 // tracked value needs to be seeded). NULL values are inherently trusted as
51 TRUSTED_UNKNOWN_VALUE
,
54 // Checks |initial_value| against the existing stored value hash.
55 virtual ValueState
CheckValue(
56 const std::string
& path
, const base::Value
* initial_value
) const = 0;
58 // Stores a hash of the current |value| of the preference at |path|.
59 virtual void StoreHash(const std::string
& path
,
60 const base::Value
* value
) = 0;
63 #endif // CHROME_BROWSER_PREFS_PREF_HASH_STORE_H_