Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "sync/syncable/nigori_util.h" | 5 #include "sync/syncable/nigori_util.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 return SpecificsNeedsEncryption(encrypted_types, entry.Get(SPECIFICS)) || | 78 return SpecificsNeedsEncryption(encrypted_types, entry.Get(SPECIFICS)) || |
| 79 (encrypted_types.Has(type) && | 79 (encrypted_types.Has(type) && |
| 80 entry.Get(NON_UNIQUE_NAME) != kEncryptedString); | 80 entry.Get(NON_UNIQUE_NAME) != kEncryptedString); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, | 83 bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, |
| 84 const sync_pb::EntitySpecifics& specifics) { | 84 const sync_pb::EntitySpecifics& specifics) { |
| 85 const ModelType type = GetModelTypeFromSpecifics(specifics); | 85 const ModelType type = GetModelTypeFromSpecifics(specifics); |
| 86 if (type == PASSWORDS || type == NIGORI) | 86 if (type == PASSWORDS || type == NIGORI) |
| 87 return false; // These types have their own encryption schemes. | 87 return false; // These types have their own encryption schemes. |
| 88 if (!syncer::EncryptableTypes().Has(type)) | |
|
rlarocque
2012/08/11 01:31:52
This is a new concept that I'm introducing. We al
| |
| 89 return false; // These types can never be encrypted. | |
| 88 if (!encrypted_types.Has(type)) | 90 if (!encrypted_types.Has(type)) |
| 89 return false; // This type does not require encryption | 91 return false; // This type does not require encryption. |
| 90 return !specifics.has_encrypted(); | 92 return !specifics.has_encrypted(); |
| 91 } | 93 } |
| 92 | 94 |
| 93 // Mainly for testing. | 95 // Mainly for testing. |
| 94 bool VerifyDataTypeEncryptionForTest( | 96 bool VerifyDataTypeEncryptionForTest( |
| 95 BaseTransaction* const trans, | 97 BaseTransaction* const trans, |
| 96 Cryptographer* cryptographer, | 98 Cryptographer* cryptographer, |
| 97 ModelType type, | 99 ModelType type, |
| 98 bool is_encrypted) { | 100 bool is_encrypted) { |
| 99 if (type == PASSWORDS || type == NIGORI) { | 101 if (type == PASSWORDS || type == NIGORI) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 entry->Put(syncable::SPECIFICS, generated_specifics); | 243 entry->Put(syncable::SPECIFICS, generated_specifics); |
| 242 DVLOG(1) << "Overwriting specifics of type " | 244 DVLOG(1) << "Overwriting specifics of type " |
| 243 << ModelTypeToString(type) | 245 << ModelTypeToString(type) |
| 244 << " and marking for syncing."; | 246 << " and marking for syncing."; |
| 245 syncable::MarkForSyncing(entry); | 247 syncable::MarkForSyncing(entry); |
| 246 return true; | 248 return true; |
| 247 } | 249 } |
| 248 | 250 |
| 249 } // namespace syncable | 251 } // namespace syncable |
| 250 } // namespace syncer | 252 } // namespace syncer |
| OLD | NEW |