| 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 "chrome/browser/sync/glue/password_change_processor.h" | 5 #include "chrome/browser/sync/glue/password_change_processor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 PasswordStoreChangeList* changes = | 77 PasswordStoreChangeList* changes = |
| 78 content::Details<PasswordStoreChangeList>(details).ptr(); | 78 content::Details<PasswordStoreChangeList>(details).ptr(); |
| 79 for (PasswordStoreChangeList::iterator change = changes->begin(); | 79 for (PasswordStoreChangeList::iterator change = changes->begin(); |
| 80 change != changes->end(); ++change) { | 80 change != changes->end(); ++change) { |
| 81 std::string tag = PasswordModelAssociator::MakeTag(change->form()); | 81 std::string tag = PasswordModelAssociator::MakeTag(change->form()); |
| 82 switch (change->type()) { | 82 switch (change->type()) { |
| 83 case PasswordStoreChange::ADD: { | 83 case PasswordStoreChange::ADD: { |
| 84 syncer::WriteNode sync_node(&trans); | 84 syncer::WriteNode sync_node(&trans); |
| 85 syncer::WriteNode::InitUniqueByCreationResult result = | 85 syncer::WriteNode::InitUniqueByCreationResult result = |
| 86 sync_node.InitUniqueByCreation(syncable::PASSWORDS, password_root, | 86 sync_node.InitUniqueByCreation(syncer::PASSWORDS, password_root, |
| 87 tag); | 87 tag); |
| 88 if (result == syncer::WriteNode::INIT_SUCCESS) { | 88 if (result == syncer::WriteNode::INIT_SUCCESS) { |
| 89 PasswordModelAssociator::WriteToSyncNode(change->form(), &sync_node); | 89 PasswordModelAssociator::WriteToSyncNode(change->form(), &sync_node); |
| 90 model_associator_->Associate(&tag, sync_node.GetId()); | 90 model_associator_->Associate(&tag, sync_node.GetId()); |
| 91 break; | 91 break; |
| 92 } else { | 92 } else { |
| 93 // Maybe this node already exists and we should update it. | 93 // Maybe this node already exists and we should update it. |
| 94 // | 94 // |
| 95 // If the PasswordStore is told to add an entry but an entry with the | 95 // If the PasswordStore is told to add an entry but an entry with the |
| 96 // same name already exists, it will overwrite it. It will report | 96 // same name already exists, it will overwrite it. It will report |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 syncer::ReadNode sync_node(trans); | 202 syncer::ReadNode sync_node(trans); |
| 203 if (sync_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) { | 203 if (sync_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) { |
| 204 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, | 204 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, |
| 205 "Password node lookup failed."); | 205 "Password node lookup failed."); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Check that the changed node is a child of the passwords folder. | 209 // Check that the changed node is a child of the passwords folder. |
| 210 DCHECK_EQ(password_root.GetId(), sync_node.GetParentId()); | 210 DCHECK_EQ(password_root.GetId(), sync_node.GetParentId()); |
| 211 DCHECK_EQ(syncable::PASSWORDS, sync_node.GetModelType()); | 211 DCHECK_EQ(syncer::PASSWORDS, sync_node.GetModelType()); |
| 212 | 212 |
| 213 const sync_pb::PasswordSpecificsData& password_data = | 213 const sync_pb::PasswordSpecificsData& password_data = |
| 214 sync_node.GetPasswordSpecifics(); | 214 sync_node.GetPasswordSpecifics(); |
| 215 webkit::forms::PasswordForm password; | 215 webkit::forms::PasswordForm password; |
| 216 PasswordModelAssociator::CopyPassword(password_data, &password); | 216 PasswordModelAssociator::CopyPassword(password_data, &password); |
| 217 | 217 |
| 218 if (syncer::ChangeRecord::ACTION_ADD == it->action) { | 218 if (syncer::ChangeRecord::ACTION_ADD == it->action) { |
| 219 std::string tag(PasswordModelAssociator::MakeTag(password)); | 219 std::string tag(PasswordModelAssociator::MakeTag(password)); |
| 220 model_associator_->Associate(&tag, sync_node.GetId()); | 220 model_associator_->Associate(&tag, sync_node.GetId()); |
| 221 new_passwords_.push_back(password); | 221 new_passwords_.push_back(password); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 void PasswordChangeProcessor::StopObserving() { | 268 void PasswordChangeProcessor::StopObserving() { |
| 269 DCHECK(expected_loop_ == MessageLoop::current()); | 269 DCHECK(expected_loop_ == MessageLoop::current()); |
| 270 notification_registrar_.Remove( | 270 notification_registrar_.Remove( |
| 271 this, | 271 this, |
| 272 chrome::NOTIFICATION_LOGINS_CHANGED, | 272 chrome::NOTIFICATION_LOGINS_CHANGED, |
| 273 content::Source<PasswordStore>(password_store_)); | 273 content::Source<PasswordStore>(password_store_)); |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace browser_sync | 276 } // namespace browser_sync |
| OLD | NEW |