Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Side by Side Diff: components/sync/syncable/write_node.cc

Issue 2294913009: Fill the un-encrypted metadata field in password specifics. (Closed)
Patch Set: rebased Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/sync/syncable/base_transaction.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/syncable/write_node.h" 5 #include "components/sync/syncable/write_node.h"
6 6
7 #include <memory> 7 #include <memory>
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/base/sync_features.h"
13 #include "components/sync/engine/engine_util.h" 14 #include "components/sync/engine/engine_util.h"
14 #include "components/sync/protocol/bookmark_specifics.pb.h" 15 #include "components/sync/protocol/bookmark_specifics.pb.h"
15 #include "components/sync/protocol/typed_url_specifics.pb.h" 16 #include "components/sync/protocol/typed_url_specifics.pb.h"
16 #include "components/sync/syncable/base_transaction.h" 17 #include "components/sync/syncable/base_transaction.h"
17 #include "components/sync/syncable/mutable_entry.h" 18 #include "components/sync/syncable/mutable_entry.h"
18 #include "components/sync/syncable/nigori_util.h" 19 #include "components/sync/syncable/nigori_util.h"
19 #include "components/sync/syncable/syncable_util.h" 20 #include "components/sync/syncable/syncable_util.h"
20 #include "components/sync/syncable/write_transaction.h" 21 #include "components/sync/syncable/write_transaction.h"
21 22
22 using std::string; 23 using std::string;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(kFillPasswordMetadata) &&
144 password_specifics->unencrypted_metadata().url() != metadata_url) {
145 password_specifics->mutable_unencrypted_metadata()->set_url(metadata_url);
146 }
147
139 // This will only update password_specifics if the underlying unencrypted blob 148 // This will only update password_specifics if the underlying unencrypted blob
140 // was different from |data| or was not encrypted with the proper passphrase. 149 // was different from |data| or was not encrypted with the proper passphrase.
141 if (!cryptographer->Encrypt(data, password_specifics->mutable_encrypted())) { 150 if (!cryptographer->Encrypt(data, password_specifics->mutable_encrypted())) {
142 LOG(ERROR) << "Failed to encrypt password, possibly due to sync node " 151 LOG(ERROR) << "Failed to encrypt password, possibly due to sync node "
143 << "corruption"; 152 << "corruption";
144 return; 153 return;
145 } 154 }
146 SetEntitySpecifics(entity_specifics); 155 SetEntitySpecifics(entity_specifics);
147 } 156 }
148 157
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 syncable::Id predecessor_id = 478 syncable::Id predecessor_id =
470 predecessor ? predecessor->GetSyncId() : syncable::Id(); 479 predecessor ? predecessor->GetSyncId() : syncable::Id();
471 return entry_->PutPredecessor(predecessor_id); 480 return entry_->PutPredecessor(predecessor_id);
472 } 481 }
473 482
474 void WriteNode::MarkForSyncing() { 483 void WriteNode::MarkForSyncing() {
475 syncable::MarkForSyncing(entry_); 484 syncable::MarkForSyncing(entry_);
476 } 485 }
477 486
478 } // namespace syncer 487 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/base_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698