| OLD | NEW |
| 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 #include "chrome/browser/sync/engine/syncer_util.h" | 5 #include "chrome/browser/sync/engine/syncer_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "chrome/browser/sync/engine/conflict_resolver.h" | 13 #include "chrome/browser/sync/engine/conflict_resolver.h" |
| 14 #include "chrome/browser/sync/engine/nigori_util.h" | 14 #include "chrome/browser/sync/encryption/nigori_util.h" |
| 15 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 15 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 16 #include "chrome/browser/sync/engine/syncer_types.h" | 16 #include "chrome/browser/sync/engine/syncer_types.h" |
| 17 #include "chrome/browser/sync/engine/syncproto.h" | 17 #include "chrome/browser/sync/engine/syncproto.h" |
| 18 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 18 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
| 19 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" | 19 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" |
| 20 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 20 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
| 21 #include "chrome/browser/sync/protocol/sync.pb.h" | 21 #include "chrome/browser/sync/protocol/sync.pb.h" |
| 22 #include "chrome/browser/sync/syncable/directory_manager.h" | 22 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 23 #include "chrome/browser/sync/syncable/model_type.h" | 23 #include "chrome/browser/sync/syncable/model_type.h" |
| 24 #include "chrome/browser/sync/syncable/syncable.h" | 24 #include "chrome/browser/sync/syncable/syncable.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // ChangeProcessor. | 294 // ChangeProcessor. |
| 295 const sync_pb::EntitySpecifics& specifics = entry->Get(SERVER_SPECIFICS); | 295 const sync_pb::EntitySpecifics& specifics = entry->Get(SERVER_SPECIFICS); |
| 296 if (specifics.HasExtension(sync_pb::nigori)) { | 296 if (specifics.HasExtension(sync_pb::nigori)) { |
| 297 const sync_pb::NigoriSpecifics& nigori = | 297 const sync_pb::NigoriSpecifics& nigori = |
| 298 specifics.GetExtension(sync_pb::nigori); | 298 specifics.GetExtension(sync_pb::nigori); |
| 299 cryptographer->Update(nigori); | 299 cryptographer->Update(nigori); |
| 300 | 300 |
| 301 // Make sure any unsynced changes are properly encrypted as necessary. | 301 // Make sure any unsynced changes are properly encrypted as necessary. |
| 302 syncable::ModelTypeSet encrypted_types = | 302 syncable::ModelTypeSet encrypted_types = |
| 303 cryptographer->GetEncryptedTypes(); | 303 cryptographer->GetEncryptedTypes(); |
| 304 if (!VerifyUnsyncedChangesAreEncrypted(trans, encrypted_types) && | 304 if (!browser_sync::encryption::VerifyUnsyncedChangesAreEncrypted( |
| 305 trans, encrypted_types) && |
| 305 (!cryptographer->is_ready() || | 306 (!cryptographer->is_ready() || |
| 306 !syncable::ProcessUnsyncedChangesForEncryption(trans, | 307 !browser_sync::encryption::ProcessUnsyncedChangesForEncryption(trans, |
| 307 cryptographer))) { | 308 cryptographer))) { |
| 308 // We were unable to encrypt the changes, possibly due to a missing | 309 // We were unable to encrypt the changes, possibly due to a missing |
| 309 // passphrase. We return conflict, even though the conflict is with the | 310 // passphrase. We return conflict, even though the conflict is with the |
| 310 // unsynced change and not the nigori node. We ensure foward progress | 311 // unsynced change and not the nigori node. We ensure foward progress |
| 311 // because the cryptographer already has the pending keys set, so once | 312 // because the cryptographer already has the pending keys set, so once |
| 312 // the new passphrase is entered we should be able to encrypt properly. | 313 // the new passphrase is entered we should be able to encrypt properly. |
| 313 // And, because this update will not be applied yet, next time around | 314 // And, because this update will not be applied yet, next time around |
| 314 // we will properly encrypt all appropriate unsynced data. | 315 // we will properly encrypt all appropriate unsynced data. |
| 315 // Note: we return CONFLICT_ENCRYPTION instead of CONFLICT. See | 316 // Note: we return CONFLICT_ENCRYPTION instead of CONFLICT. See |
| 316 // explanation below. | 317 // explanation below. |
| 317 VLOG(1) << "Marking nigori node update as conflicting due to being unable" | 318 VLOG(1) << "Marking nigori node update as conflicting due to being unable" |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 if (update.version() < target->Get(SERVER_VERSION)) { | 827 if (update.version() < target->Get(SERVER_VERSION)) { |
| 827 LOG(WARNING) << "Update older than current server version for " | 828 LOG(WARNING) << "Update older than current server version for " |
| 828 << *target << " Update:" | 829 << *target << " Update:" |
| 829 << SyncerProtoUtil::SyncEntityDebugString(update); | 830 << SyncerProtoUtil::SyncEntityDebugString(update); |
| 830 return VERIFY_SUCCESS; // Expected in new sync protocol. | 831 return VERIFY_SUCCESS; // Expected in new sync protocol. |
| 831 } | 832 } |
| 832 return VERIFY_UNDECIDED; | 833 return VERIFY_UNDECIDED; |
| 833 } | 834 } |
| 834 | 835 |
| 835 } // namespace browser_sync | 836 } // namespace browser_sync |
| OLD | NEW |