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

Side by Side Diff: chrome/browser/sync/util/cryptographer.h

Issue 8919021: [Sync] Rename ModelEnumSet to ModelTypeSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SYNC_UTIL_CRYPTOGRAPHER_H_ 5 #ifndef CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_
6 #define CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ 6 #define CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // types. 55 // types.
56 // 56 //
57 // |encrypted_types| will always be a superset of 57 // |encrypted_types| will always be a superset of
58 // SensitiveTypes(). If |encrypt_everything| is true, 58 // SensitiveTypes(). If |encrypt_everything| is true,
59 // |encrypted_types| will be the set of all known types. 59 // |encrypted_types| will be the set of all known types.
60 // 60 //
61 // Until this function is called, observers can assume that the 61 // Until this function is called, observers can assume that the
62 // set of encrypted types is SensitiveTypes() and that the encrypt 62 // set of encrypted types is SensitiveTypes() and that the encrypt
63 // everything flag is false. 63 // everything flag is false.
64 virtual void OnEncryptedTypesChanged( 64 virtual void OnEncryptedTypesChanged(
65 syncable::ModelEnumSet encrypted_types, 65 syncable::ModelTypeSet encrypted_types,
66 bool encrypt_everything) = 0; 66 bool encrypt_everything) = 0;
67 67
68 protected: 68 protected:
69 virtual ~Observer(); 69 virtual ~Observer();
70 }; 70 };
71 71
72 Cryptographer(); 72 Cryptographer();
73 ~Cryptographer(); 73 ~Cryptographer();
74 74
75 // When update on cryptographer is called this enum tells if the 75 // When update on cryptographer is called this enum tells if the
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // can't be created (i.e. if this Cryptograhper doesn't have valid keys). 156 // can't be created (i.e. if this Cryptograhper doesn't have valid keys).
157 bool GetBootstrapToken(std::string* token) const; 157 bool GetBootstrapToken(std::string* token) const;
158 158
159 // Update the cryptographer based on the contents of the nigori specifics. 159 // Update the cryptographer based on the contents of the nigori specifics.
160 // This updates both the encryption keys and the set of encrypted types. 160 // This updates both the encryption keys and the set of encrypted types.
161 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys, 161 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys,
162 // SUCCESS otherwise. 162 // SUCCESS otherwise.
163 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori); 163 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori);
164 164
165 // The set of types that are always encrypted. 165 // The set of types that are always encrypted.
166 static syncable::ModelEnumSet SensitiveTypes(); 166 static syncable::ModelTypeSet SensitiveTypes();
167 167
168 // Reset our set of encrypted types based on the contents of the nigori 168 // Reset our set of encrypted types based on the contents of the nigori
169 // specifics. 169 // specifics.
170 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori); 170 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori);
171 171
172 // Update the nigori to reflect the current set of encrypted types. 172 // Update the nigori to reflect the current set of encrypted types.
173 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const; 173 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const;
174 174
175 // Setter/getter for whether all current and future datatypes should 175 // Setter/getter for whether all current and future datatypes should
176 // be encrypted. Once set you cannot unset without reading from a 176 // be encrypted. Once set you cannot unset without reading from a
177 // new nigori node. set_encrypt_everything() emits a notification 177 // new nigori node. set_encrypt_everything() emits a notification
178 // the first time it's called. 178 // the first time it's called.
179 void set_encrypt_everything(); 179 void set_encrypt_everything();
180 bool encrypt_everything() const; 180 bool encrypt_everything() const;
181 181
182 // Return the set of encrypted types. 182 // Return the set of encrypted types.
183 syncable::ModelEnumSet GetEncryptedTypes() const; 183 syncable::ModelTypeSet GetEncryptedTypes() const;
184 184
185 // Forwards to MergeEncryptedTypes. 185 // Forwards to MergeEncryptedTypes.
186 void MergeEncryptedTypesForTest( 186 void MergeEncryptedTypesForTest(
187 syncable::ModelEnumSet encrypted_types); 187 syncable::ModelTypeSet encrypted_types);
188 188
189 private: 189 private:
190 FRIEND_TEST_ALL_PREFIXES(CryptographerTest, PackUnpack); 190 FRIEND_TEST_ALL_PREFIXES(CryptographerTest, PackUnpack);
191 typedef std::map<std::string, linked_ptr<const Nigori> > NigoriMap; 191 typedef std::map<std::string, linked_ptr<const Nigori> > NigoriMap;
192 192
193 // Merges the given set of encrypted types with the existing set and emits a 193 // Merges the given set of encrypted types with the existing set and emits a
194 // notification if necessary. 194 // notification if necessary.
195 void MergeEncryptedTypes(syncable::ModelEnumSet encrypted_types); 195 void MergeEncryptedTypes(syncable::ModelTypeSet encrypted_types);
196 196
197 void EmitEncryptedTypesChangedNotification(); 197 void EmitEncryptedTypesChangedNotification();
198 198
199 // Helper method to instantiate Nigori instances for each set of key 199 // Helper method to instantiate Nigori instances for each set of key
200 // parameters in |bag| and setting the default encryption key to 200 // parameters in |bag| and setting the default encryption key to
201 // |default_key_name|. 201 // |default_key_name|.
202 void InstallKeys(const std::string& default_key_name, 202 void InstallKeys(const std::string& default_key_name,
203 const sync_pb::NigoriKeyBag& bag); 203 const sync_pb::NigoriKeyBag& bag);
204 204
205 bool AddKeyImpl(Nigori* nigori); 205 bool AddKeyImpl(Nigori* nigori);
206 206
207 // Functions to serialize + encrypt a Nigori object in an opaque format for 207 // Functions to serialize + encrypt a Nigori object in an opaque format for
208 // persistence by sync infrastructure. 208 // persistence by sync infrastructure.
209 bool PackBootstrapToken(const Nigori* nigori, std::string* pack_into) const; 209 bool PackBootstrapToken(const Nigori* nigori, std::string* pack_into) const;
210 Nigori* UnpackBootstrapToken(const std::string& token) const; 210 Nigori* UnpackBootstrapToken(const std::string& token) const;
211 211
212 ObserverList<Observer> observers_; 212 ObserverList<Observer> observers_;
213 213
214 NigoriMap nigoris_; // The Nigoris we know about, mapped by key name. 214 NigoriMap nigoris_; // The Nigoris we know about, mapped by key name.
215 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. 215 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption.
216 216
217 scoped_ptr<sync_pb::EncryptedData> pending_keys_; 217 scoped_ptr<sync_pb::EncryptedData> pending_keys_;
218 218
219 syncable::ModelEnumSet encrypted_types_; 219 syncable::ModelTypeSet encrypted_types_;
220 bool encrypt_everything_; 220 bool encrypt_everything_;
221 221
222 DISALLOW_COPY_AND_ASSIGN(Cryptographer); 222 DISALLOW_COPY_AND_ASSIGN(Cryptographer);
223 }; 223 };
224 224
225 } // namespace browser_sync 225 } // namespace browser_sync
226 226
227 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ 227 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/tools/sync_listen_notifications.cc ('k') | chrome/browser/sync/util/cryptographer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698