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 "components/sync/core/write_node.h" | 5 #include "components/sync/core/write_node.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "components/sync/base/cryptographer.h" | 12 #include "components/sync/base/cryptographer.h" |
| 13 #include "components/sync/core/base_transaction.h" | 13 #include "components/sync/core/base_transaction.h" |
| 14 #include "components/sync/core/password_metadata_filling.h" | |
| 14 #include "components/sync/core/write_transaction.h" | 15 #include "components/sync/core/write_transaction.h" |
| 15 #include "components/sync/core_impl/syncapi_internal.h" | 16 #include "components/sync/core_impl/syncapi_internal.h" |
| 16 #include "components/sync/protocol/bookmark_specifics.pb.h" | 17 #include "components/sync/protocol/bookmark_specifics.pb.h" |
| 17 #include "components/sync/protocol/typed_url_specifics.pb.h" | 18 #include "components/sync/protocol/typed_url_specifics.pb.h" |
| 18 #include "components/sync/syncable/mutable_entry.h" | 19 #include "components/sync/syncable/mutable_entry.h" |
| 19 #include "components/sync/syncable/nigori_util.h" | 20 #include "components/sync/syncable/nigori_util.h" |
| 20 #include "components/sync/syncable/syncable_util.h" | 21 #include "components/sync/syncable/syncable_util.h" |
| 21 | 22 |
| 22 using std::string; | 23 using std::string; |
| 23 using std::vector; | 24 using std::vector; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 const sync_pb::EntitySpecifics& old_specifics = GetEntitySpecifics(); | 130 const sync_pb::EntitySpecifics& old_specifics = GetEntitySpecifics(); |
| 130 sync_pb::EntitySpecifics entity_specifics; | 131 sync_pb::EntitySpecifics entity_specifics; |
| 131 // Copy over the old specifics if they exist. | 132 // Copy over the old specifics if they exist. |
| 132 if (GetModelTypeFromSpecifics(old_specifics) == PASSWORDS) { | 133 if (GetModelTypeFromSpecifics(old_specifics) == PASSWORDS) { |
| 133 entity_specifics.CopyFrom(old_specifics); | 134 entity_specifics.CopyFrom(old_specifics); |
| 134 } else { | 135 } else { |
| 135 AddDefaultFieldValue(PASSWORDS, &entity_specifics); | 136 AddDefaultFieldValue(PASSWORDS, &entity_specifics); |
| 136 } | 137 } |
| 137 sync_pb::PasswordSpecifics* password_specifics = | 138 sync_pb::PasswordSpecifics* password_specifics = |
| 138 entity_specifics.mutable_password(); | 139 entity_specifics.mutable_password(); |
| 140 | |
| 141 const std::string metadata_url(data.signon_realm()); | |
| 142 if (!IsExplicitPassphrase(GetTransaction()->GetPassphraseType()) && | |
| 143 base::FeatureList::IsEnabled(kPasswordsMetadataFilling) && | |
| 144 password_specifics->unencrypted_metadata().url() != metadata_url) { | |
| 145 password_specifics->mutable_unencrypted_metadata()->set_url(metadata_url); | |
| 146 } | |
|
Nicolas Zea
2016/09/23 23:10:37
nit: newline after
melandory
2016/10/04 10:13:12
Done.
| |
| 139 // This will only update password_specifics if the underlying unencrypted blob | 147 // This will only update password_specifics if the underlying unencrypted blob |
| 140 // was different from |data| or was not encrypted with the proper passphrase. | 148 // was different from |data| or was not encrypted with the proper passphrase. |
| 141 if (!cryptographer->Encrypt(data, password_specifics->mutable_encrypted())) { | 149 if (!cryptographer->Encrypt(data, password_specifics->mutable_encrypted())) { |
| 142 LOG(ERROR) << "Failed to encrypt password, possibly due to sync node " | 150 LOG(ERROR) << "Failed to encrypt password, possibly due to sync node " |
| 143 << "corruption"; | 151 << "corruption"; |
| 144 return; | 152 return; |
| 145 } | 153 } |
| 146 SetEntitySpecifics(entity_specifics); | 154 SetEntitySpecifics(entity_specifics); |
| 147 } | 155 } |
| 148 | 156 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 syncable::Id predecessor_id = | 477 syncable::Id predecessor_id = |
| 470 predecessor ? predecessor->GetSyncId() : syncable::Id(); | 478 predecessor ? predecessor->GetSyncId() : syncable::Id(); |
| 471 return entry_->PutPredecessor(predecessor_id); | 479 return entry_->PutPredecessor(predecessor_id); |
| 472 } | 480 } |
| 473 | 481 |
| 474 void WriteNode::MarkForSyncing() { | 482 void WriteNode::MarkForSyncing() { |
| 475 syncable::MarkForSyncing(entry_); | 483 syncable::MarkForSyncing(entry_); |
| 476 } | 484 } |
| 477 | 485 |
| 478 } // namespace syncer | 486 } // namespace syncer |
| OLD | NEW |