Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / prefs / pref_hash_store.h
blobe7357c1c1fd19ee9f1c2632d3942112f8874ab3b
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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
12 namespace base {
13 class Value;
14 } // namespace base
16 namespace internals {
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
20 // string under
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
29 // change.
30 class PrefHashStore {
31 public:
32 virtual ~PrefHashStore() {}
34 enum ValueState {
35 // The preference value corresponds to its stored hash.
36 UNCHANGED,
37 // The preference has been cleared since the last hash.
38 CLEARED,
39 // The preference value corresponds to its stored hash, which was calculated
40 // using a legacy hash algorithm.
41 MIGRATED,
42 // The preference value has been changed since the last hash.
43 CHANGED,
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
50 // well.
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_