| 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 "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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 scoped_ptr<base::DictionaryValue> value(entry->ToValue(NULL)); | 176 scoped_ptr<base::DictionaryValue> value(entry->ToValue(NULL)); |
| 177 std::string info; | 177 std::string info; |
| 178 base::JSONWriter::WriteWithOptions(value.get(), | 178 base::JSONWriter::WriteWithOptions( |
| 179 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 179 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &info); |
| 180 &info); | |
| 181 DVLOG(2) << "Encrypting specifics of type " | 180 DVLOG(2) << "Encrypting specifics of type " |
| 182 << ModelTypeToString(type) | 181 << ModelTypeToString(type) |
| 183 << " with content: " | 182 << " with content: " |
| 184 << info; | 183 << info; |
| 185 } | 184 } |
| 186 // Only copy over the old specifics if it is of the right type and already | 185 // Only copy over the old specifics if it is of the right type and already |
| 187 // encrypted. The first time we encrypt a node we start from scratch, hence | 186 // encrypted. The first time we encrypt a node we start from scratch, hence |
| 188 // removing all the unencrypted data, but from then on we only want to | 187 // removing all the unencrypted data, but from then on we only want to |
| 189 // update the node if the data changes or the encryption key changes. | 188 // update the node if the data changes or the encryption key changes. |
| 190 if (GetModelTypeFromSpecifics(old_specifics) == type && | 189 if (GetModelTypeFromSpecifics(old_specifics) == type && |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 encrypted_types.Put(FAVICON_TRACKING); | 313 encrypted_types.Put(FAVICON_TRACKING); |
| 315 if (nigori.encrypt_articles()) | 314 if (nigori.encrypt_articles()) |
| 316 encrypted_types.Put(ARTICLES); | 315 encrypted_types.Put(ARTICLES); |
| 317 if (nigori.encrypt_app_list()) | 316 if (nigori.encrypt_app_list()) |
| 318 encrypted_types.Put(APP_LIST); | 317 encrypted_types.Put(APP_LIST); |
| 319 return encrypted_types; | 318 return encrypted_types; |
| 320 } | 319 } |
| 321 | 320 |
| 322 } // namespace syncable | 321 } // namespace syncable |
| 323 } // namespace syncer | 322 } // namespace syncer |
| OLD | NEW |