OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR |
| 6 #define CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR |
| 7 |
| 8 #include <string> |
| 9 |
| 10 namespace base { |
| 11 class Value; |
| 12 } // namespace base |
| 13 |
| 14 // Calculates and validates preference value hashes. |
| 15 // This class is intentionally copy-constructable. |
| 16 class PrefHashCalculator { |
| 17 public: |
| 18 enum ValidationResult { |
| 19 INVALID, |
| 20 VALID, |
| 21 VALID_LEGACY |
| 22 }; |
| 23 |
| 24 // Constructs a PrefHashCalculator using |seed|. The same seed must be used in |
| 25 // order to successfully validate generated hashes. |
| 26 explicit PrefHashCalculator(const std::string& seed); |
| 27 |
| 28 // Calculates a hash value for the supplied preference path and value. |value| |
| 29 // may be null if the preference has no value. |
| 30 std::string Calculate(const std::string& path, const base::Value* value); |
| 31 |
| 32 // Validates the provided preference hash using current and legacy hashing |
| 33 // algorithms. |
| 34 ValidationResult Validate(const std::string& path, |
| 35 const base::Value* value, |
| 36 const std::string& hash); |
| 37 |
| 38 private: |
| 39 std::string seed_; |
| 40 }; |
| 41 |
| 42 #endif // CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR |
OLD | NEW |