Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: components/user_prefs/tracked/pref_hash_calculator.h

Issue 1227973003: Componentize //chrome/browser/prefs/tracked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_HASH_CALCULATOR_H_ 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_
6 #define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ 6 #define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 11
12 namespace base { 12 namespace base {
13 class Value; 13 class Value;
14 } // namespace base 14 } // namespace base
15 15
16 // Calculates and validates preference value hashes. 16 // Calculates and validates preference value hashes.
17 class PrefHashCalculator { 17 class PrefHashCalculator {
18 public: 18 public:
19 enum ValidationResult { 19 enum ValidationResult {
20 INVALID, 20 INVALID,
21 VALID, 21 VALID,
22 // Valid under a deprecated but as secure algorithm. 22 // Valid under a deprecated but as secure algorithm.
23 VALID_SECURE_LEGACY, 23 VALID_SECURE_LEGACY,
24 }; 24 };
25 25
26 // Constructs a PrefHashCalculator using |seed| and |device_id|. The same 26 // Constructs a PrefHashCalculator using |seed| and |device_id|. The same
27 // parameters must be used in order to successfully validate generated hashes. 27 // parameters must be used in order to successfully validate generated hashes.
28 // |device_id| may be empty. 28 // |device_id| may be empty.
29 PrefHashCalculator(const std::string& seed, const std::string& device_id); 29 PrefHashCalculator(const std::string& seed, const std::string& device_id);
30 30
31 ~PrefHashCalculator(); 31 ~PrefHashCalculator();
32 32
33 // Calculates a hash value for the supplied preference |path| and |value|. 33 // Calculates a hash value for the supplied preference |path| and |value|.
34 // |value| may be null if the preference has no value. 34 // |value| may be null if the preference has no value.
35 std::string Calculate(const std::string& path, const base::Value* value) 35 std::string Calculate(const std::string& path,
36 const; 36 const base::Value* value) const;
37 37
38 // Validates the provided preference hash using current and legacy hashing 38 // Validates the provided preference hash using current and legacy hashing
39 // algorithms. 39 // algorithms.
40 ValidationResult Validate(const std::string& path, 40 ValidationResult Validate(const std::string& path,
41 const base::Value* value, 41 const base::Value* value,
42 const std::string& hash) const; 42 const std::string& hash) const;
43 43
44 private: 44 private:
45 const std::string seed_; 45 const std::string seed_;
46 const std::string device_id_; 46 const std::string device_id_;
47 const std::string legacy_device_id_; 47 const std::string legacy_device_id_;
48 48
49 DISALLOW_COPY_AND_ASSIGN(PrefHashCalculator); 49 DISALLOW_COPY_AND_ASSIGN(PrefHashCalculator);
50 }; 50 };
51 51
52 #endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ 52 #endif // COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_
OLDNEW
« no previous file with comments | « components/user_prefs/tracked/mock_validation_delegate.cc ('k') | components/user_prefs/tracked/pref_hash_calculator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698