| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/sync/syncable/nigori_util.h" | 5 #include "components/sync/syncable/nigori_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 if ((!SpecificsNeedsEncryption(encrypted_types, new_specifics) && | 168 if ((!SpecificsNeedsEncryption(encrypted_types, new_specifics) && |
| 169 !was_encrypted) || | 169 !was_encrypted) || |
| 170 !cryptographer || !cryptographer->is_initialized()) { | 170 !cryptographer || !cryptographer->is_initialized()) { |
| 171 // No encryption required or we are unable to encrypt. | 171 // No encryption required or we are unable to encrypt. |
| 172 generated_specifics.CopyFrom(new_specifics); | 172 generated_specifics.CopyFrom(new_specifics); |
| 173 } else { | 173 } else { |
| 174 // Encrypt new_specifics into generated_specifics. | 174 // Encrypt new_specifics into generated_specifics. |
| 175 if (VLOG_IS_ON(2)) { | 175 if (VLOG_IS_ON(2)) { |
| 176 std::unique_ptr<base::DictionaryValue> value(entry->ToValue(NULL)); | 176 std::unique_ptr<base::DictionaryValue> value(entry->ToValue(nullptr)); |
| 177 std::string info; | 177 std::string info; |
| 178 base::JSONWriter::WriteWithOptions( | 178 base::JSONWriter::WriteWithOptions( |
| 179 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &info); | 179 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &info); |
| 180 DVLOG(2) << "Encrypting specifics of type " << ModelTypeToString(type) | 180 DVLOG(2) << "Encrypting specifics of type " << ModelTypeToString(type) |
| 181 << " with content: " << info; | 181 << " with content: " << info; |
| 182 } | 182 } |
| 183 // Only copy over the old specifics if it is of the right type and already | 183 // Only copy over the old specifics if it is of the right type and already |
| 184 // encrypted. The first time we encrypt a node we start from scratch, hence | 184 // encrypted. The first time we encrypt a node we start from scratch, hence |
| 185 // removing all the unencrypted data, but from then on we only want to | 185 // removing all the unencrypted data, but from then on we only want to |
| 186 // update the node if the data changes or the encryption key changes. | 186 // update the node if the data changes or the encryption key changes. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 encrypted_types.Put(ARC_PACKAGE); | 322 encrypted_types.Put(ARC_PACKAGE); |
| 323 if (nigori.encrypt_printers()) | 323 if (nigori.encrypt_printers()) |
| 324 encrypted_types.Put(PRINTERS); | 324 encrypted_types.Put(PRINTERS); |
| 325 if (nigori.encrypt_reading_list()) | 325 if (nigori.encrypt_reading_list()) |
| 326 encrypted_types.Put(READING_LIST); | 326 encrypted_types.Put(READING_LIST); |
| 327 return encrypted_types; | 327 return encrypted_types; |
| 328 } | 328 } |
| 329 | 329 |
| 330 } // namespace syncable | 330 } // namespace syncable |
| 331 } // namespace syncer | 331 } // namespace syncer |
| OLD | NEW |