OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/password_manager/password_store.h" | 9 #include "chrome/browser/password_manager/password_store.h" |
10 #include "chrome/browser/password_manager/password_store_change.h" | 10 #include "chrome/browser/password_manager/password_store_change.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 PasswordStoreChangeList* changes = | 64 PasswordStoreChangeList* changes = |
65 Details<PasswordStoreChangeList>(details).ptr(); | 65 Details<PasswordStoreChangeList>(details).ptr(); |
66 for (PasswordStoreChangeList::iterator change = changes->begin(); | 66 for (PasswordStoreChangeList::iterator change = changes->begin(); |
67 change != changes->end(); ++change) { | 67 change != changes->end(); ++change) { |
68 std::string tag = PasswordModelAssociator::MakeTag(change->form()); | 68 std::string tag = PasswordModelAssociator::MakeTag(change->form()); |
69 switch (change->type()) { | 69 switch (change->type()) { |
70 case PasswordStoreChange::ADD: { | 70 case PasswordStoreChange::ADD: { |
71 sync_api::WriteNode sync_node(&trans); | 71 sync_api::WriteNode sync_node(&trans); |
72 if (!sync_node.InitUniqueByCreation(syncable::PASSWORD, | 72 if (!sync_node.InitUniqueByCreation(syncable::PASSWORDS, |
73 password_root, tag)) { | 73 password_root, tag)) { |
74 LOG(ERROR) << "Failed to create password sync node."; | 74 LOG(ERROR) << "Failed to create password sync node."; |
75 error_handler()->OnUnrecoverableError(); | 75 error_handler()->OnUnrecoverableError(); |
76 return; | 76 return; |
77 } | 77 } |
78 | 78 |
79 PasswordModelAssociator::WriteToSyncNode(change->form(), &sync_node); | 79 PasswordModelAssociator::WriteToSyncNode(change->form(), &sync_node); |
80 model_associator_->Associate(&tag, sync_node.GetId()); | 80 model_associator_->Associate(&tag, sync_node.GetId()); |
81 break; | 81 break; |
82 } | 82 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 sync_api::ReadNode sync_node(trans); | 145 sync_api::ReadNode sync_node(trans); |
146 if (!sync_node.InitByIdLookup(changes[i].id)) { | 146 if (!sync_node.InitByIdLookup(changes[i].id)) { |
147 LOG(ERROR) << "Password node lookup failed."; | 147 LOG(ERROR) << "Password node lookup failed."; |
148 error_handler()->OnUnrecoverableError(); | 148 error_handler()->OnUnrecoverableError(); |
149 return; | 149 return; |
150 } | 150 } |
151 | 151 |
152 // Check that the changed node is a child of the passwords folder. | 152 // Check that the changed node is a child of the passwords folder. |
153 DCHECK(password_root.GetId() == sync_node.GetParentId()); | 153 DCHECK(password_root.GetId() == sync_node.GetParentId()); |
154 DCHECK(syncable::PASSWORD == sync_node.GetModelType()); | 154 DCHECK(syncable::PASSWORDS == sync_node.GetModelType()); |
155 | 155 |
156 sync_pb::PasswordSpecificsData password_data; | 156 sync_pb::PasswordSpecificsData password_data; |
157 if (!sync_node.GetPasswordSpecifics(&password_data)) { | 157 if (!sync_node.GetPasswordSpecifics(&password_data)) { |
158 LOG(ERROR) << "Could not read password specifics"; | 158 LOG(ERROR) << "Could not read password specifics"; |
159 error_handler()->OnUnrecoverableError(); | 159 error_handler()->OnUnrecoverableError(); |
160 return; | 160 return; |
161 } | 161 } |
162 webkit_glue::PasswordForm password; | 162 webkit_glue::PasswordForm password; |
163 PasswordModelAssociator::CopyPassword(password_data, | 163 PasswordModelAssociator::CopyPassword(password_data, |
164 &password); | 164 &password); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 void PasswordChangeProcessor::StopObserving() { | 206 void PasswordChangeProcessor::StopObserving() { |
207 DCHECK(expected_loop_ == MessageLoop::current()); | 207 DCHECK(expected_loop_ == MessageLoop::current()); |
208 notification_registrar_.Remove(this, | 208 notification_registrar_.Remove(this, |
209 NotificationType::LOGINS_CHANGED, | 209 NotificationType::LOGINS_CHANGED, |
210 NotificationService::AllSources()); | 210 NotificationService::AllSources()); |
211 } | 211 } |
212 | 212 |
213 } // namespace browser_sync | 213 } // namespace browser_sync |
OLD | NEW |