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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
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 sync_api::WriteNode sync_node(&trans); | 84 sync_api::WriteNode sync_node(&trans); |
85 if (sync_node.InitUniqueByCreation(syncable::PASSWORDS, | 85 sync_api::WriteNode::InitUniqueByCreationResult result = |
86 password_root, tag)) { | 86 sync_node.InitUniqueByCreation(syncable::PASSWORDS, password_root, |
| 87 tag); |
| 88 if (result == sync_api::WriteNode::INIT_SUCCESS) { |
87 PasswordModelAssociator::WriteToSyncNode(change->form(), &sync_node); | 89 PasswordModelAssociator::WriteToSyncNode(change->form(), &sync_node); |
88 model_associator_->Associate(&tag, sync_node.GetId()); | 90 model_associator_->Associate(&tag, sync_node.GetId()); |
89 break; | 91 break; |
90 } else { | 92 } else { |
91 // Maybe this node already exists and we should update it. | 93 // Maybe this node already exists and we should update it. |
92 // | 94 // |
93 // 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 |
94 // same name already exists, it will overwrite it. It will report | 96 // same name already exists, it will overwrite it. It will report |
95 // this change as an ADD rather than an UPDATE. Ideally, it would be | 97 // this change as an ADD rather than an UPDATE. Ideally, it would be |
96 // able to tell us what action was actually taken, rather than what | 98 // able to tell us what action was actually taken, rather than what |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 263 |
262 void PasswordChangeProcessor::StopObserving() { | 264 void PasswordChangeProcessor::StopObserving() { |
263 DCHECK(expected_loop_ == MessageLoop::current()); | 265 DCHECK(expected_loop_ == MessageLoop::current()); |
264 notification_registrar_.Remove( | 266 notification_registrar_.Remove( |
265 this, | 267 this, |
266 chrome::NOTIFICATION_LOGINS_CHANGED, | 268 chrome::NOTIFICATION_LOGINS_CHANGED, |
267 content::Source<PasswordStore>(password_store_)); | 269 content::Source<PasswordStore>(password_store_)); |
268 } | 270 } |
269 | 271 |
270 } // namespace browser_sync | 272 } // namespace browser_sync |
OLD | NEW |