| 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/internal_api/syncapi_internal.h" | 5 #include "sync/internal_api/syncapi_internal.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "sync/protocol/attachments.pb.h" | 12 #include "sync/protocol/attachments.pb.h" |
| 12 #include "sync/protocol/password_specifics.pb.h" | 13 #include "sync/protocol/password_specifics.pb.h" |
| 13 #include "sync/protocol/sync.pb.h" | 14 #include "sync/protocol/sync.pb.h" |
| 14 #include "sync/util/cryptographer.h" | 15 #include "sync/util/cryptographer.h" |
| 15 | 16 |
| 16 namespace syncer { | 17 namespace syncer { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 bool EndsWithSpace(const std::string& string) { | 21 bool EndsWithSpace(const std::string& string) { |
| 21 return !string.empty() && *string.rbegin() == ' '; | 22 return !string.empty() && *string.rbegin() == ' '; |
| 22 } | 23 } |
| 23 | 24 |
| 24 } | 25 } |
| 25 | 26 |
| 26 sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( | 27 sync_pb::PasswordSpecificsData* DecryptPasswordSpecifics( |
| 27 const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) { | 28 const sync_pb::EntitySpecifics& specifics, Cryptographer* crypto) { |
| 28 if (!specifics.has_password()) | 29 if (!specifics.has_password()) |
| 29 return NULL; | 30 return NULL; |
| 30 const sync_pb::PasswordSpecifics& password_specifics = specifics.password(); | 31 const sync_pb::PasswordSpecifics& password_specifics = specifics.password(); |
| 31 if (!password_specifics.has_encrypted()) | 32 if (!password_specifics.has_encrypted()) |
| 32 return NULL; | 33 return NULL; |
| 33 const sync_pb::EncryptedData& encrypted = password_specifics.encrypted(); | 34 const sync_pb::EncryptedData& encrypted = password_specifics.encrypted(); |
| 34 scoped_ptr<sync_pb::PasswordSpecificsData> data( | 35 std::unique_ptr<sync_pb::PasswordSpecificsData> data( |
| 35 new sync_pb::PasswordSpecificsData); | 36 new sync_pb::PasswordSpecificsData); |
| 36 if (!crypto->CanDecrypt(encrypted)) | 37 if (!crypto->CanDecrypt(encrypted)) |
| 37 return NULL; | 38 return NULL; |
| 38 if (!crypto->Decrypt(encrypted, data.get())) | 39 if (!crypto->Decrypt(encrypted, data.get())) |
| 39 return NULL; | 40 return NULL; |
| 40 return data.release(); | 41 return data.release(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 // The list of names which are reserved for use by the server. | 44 // The list of names which are reserved for use by the server. |
| 44 static const char* kForbiddenServerNames[] = { "", ".", ".." }; | 45 static const char* kForbiddenServerNames[] = { "", ".", ".." }; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 113 |
| 113 bool AreAttachmentMetadataEqual(const sync_pb::AttachmentMetadata& left, | 114 bool AreAttachmentMetadataEqual(const sync_pb::AttachmentMetadata& left, |
| 114 const sync_pb::AttachmentMetadata& right) { | 115 const sync_pb::AttachmentMetadata& right) { |
| 115 if (left.SerializeAsString() == right.SerializeAsString()) { | 116 if (left.SerializeAsString() == right.SerializeAsString()) { |
| 116 return true; | 117 return true; |
| 117 } | 118 } |
| 118 return false; | 119 return false; |
| 119 } | 120 } |
| 120 | 121 |
| 121 } // namespace syncer | 122 } // namespace syncer |
| OLD | NEW |