| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ | |
| 6 #define COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <memory> | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/strings/string_piece.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class DictionaryValue; | |
| 16 class Value; | |
| 17 } // namespace base | |
| 18 | |
| 19 // Provides access to the contents of a preference hash store. The store | |
| 20 // contains the following data: | |
| 21 // Contents: a client-defined dictionary that should map preference names to | |
| 22 // MACs. | |
| 23 // Version: a client-defined version number for the format of Contents. | |
| 24 // Super MAC: a MAC that authenticates the entirety of Contents. | |
| 25 class HashStoreContents { | |
| 26 public: | |
| 27 virtual ~HashStoreContents() {} | |
| 28 | |
| 29 // Returns true if this implementation of HashStoreContents can be copied via | |
| 30 // MakeCopy(). | |
| 31 virtual bool IsCopyable() const = 0; | |
| 32 | |
| 33 // Returns a copy of this HashStoreContents. Must only be called on | |
| 34 // lightweight implementations (which return true from IsCopyable()) and only | |
| 35 // in scenarios where a copy cannot be avoided. | |
| 36 virtual std::unique_ptr<HashStoreContents> MakeCopy() const = 0; | |
| 37 | |
| 38 // Returns the suffix to be appended to UMA histograms for this store type. | |
| 39 // The returned value must either be an empty string or one of the values in | |
| 40 // histograms.xml's TrackedPreferencesExternalValidators. | |
| 41 virtual base::StringPiece GetUMASuffix() const = 0; | |
| 42 | |
| 43 // Discards all data related to this hash store. | |
| 44 virtual void Reset() = 0; | |
| 45 | |
| 46 // Outputs the MAC validating the preference at path. Returns true if a MAC | |
| 47 // was successfully read and false otherwise. | |
| 48 virtual bool GetMac(const std::string& path, std::string* out_value) = 0; | |
| 49 | |
| 50 // Outputs the MACS validating the split preference at path. Returns true if | |
| 51 // MACS were successfully read and false otherwise. | |
| 52 virtual bool GetSplitMacs(const std::string& path, | |
| 53 std::map<std::string, std::string>* out_value) = 0; | |
| 54 | |
| 55 // Set the MAC validating the preference at path. | |
| 56 virtual void SetMac(const std::string& path, const std::string& value) = 0; | |
| 57 | |
| 58 // Set the MAC validating the split preference at path and split_path. | |
| 59 // For example, |path| is 'extension' and |split_path| is some extenson id. | |
| 60 virtual void SetSplitMac(const std::string& path, | |
| 61 const std::string& split_path, | |
| 62 const std::string& value) = 0; | |
| 63 | |
| 64 // Sets the MAC for the preference at |path|. | |
| 65 // If |path| is a split preference |in_value| must be a DictionaryValue whose | |
| 66 // keys are keys in the split preference and whose values are MACs of the | |
| 67 // corresponding values in the split preference. | |
| 68 // If |path| is an atomic preference |in_value| must be a StringValue | |
| 69 // containing a MAC of the preference value. | |
| 70 virtual void ImportEntry(const std::string& path, | |
| 71 const base::Value* in_value) = 0; | |
| 72 | |
| 73 // Removes the MAC (for atomic preferences) or MACs (for split preferences) | |
| 74 // at |path|. Returns true if there was an entry at |path| which was | |
| 75 // successfully removed. | |
| 76 virtual bool RemoveEntry(const std::string& path) = 0; | |
| 77 | |
| 78 // Only needed if this store supports super MACs. | |
| 79 virtual const base::DictionaryValue* GetContents() const = 0; | |
| 80 | |
| 81 // Retrieves the super MAC value previously stored by SetSuperMac. May be | |
| 82 // empty if no super MAC has been stored or if this store does not support | |
| 83 // super MACs. | |
| 84 virtual std::string GetSuperMac() const = 0; | |
| 85 | |
| 86 // Stores a super MAC value for this hash store. | |
| 87 virtual void SetSuperMac(const std::string& super_mac) = 0; | |
| 88 }; | |
| 89 | |
| 90 #endif // COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ | |
| OLD | NEW |