OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/password_manager/password_store.h" |
12 #include "chrome/browser/password_manager/password_store_change.h" | 13 #include "chrome/browser/password_manager/password_store_change.h" |
13 #include "chrome/browser/password_manager/password_store.h" | |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/sync/glue/password_model_associator.h" | 15 #include "chrome/browser/sync/glue/password_model_associator.h" |
16 #include "chrome/browser/sync/internal_api/change_record.h" | 16 #include "chrome/browser/sync/internal_api/change_record.h" |
17 #include "chrome/browser/sync/internal_api/read_node.h" | 17 #include "chrome/browser/sync/internal_api/read_node.h" |
18 #include "chrome/browser/sync/internal_api/write_node.h" | 18 #include "chrome/browser/sync/internal_api/write_node.h" |
19 #include "chrome/browser/sync/internal_api/write_transaction.h" | 19 #include "chrome/browser/sync/internal_api/write_transaction.h" |
20 #include "chrome/browser/sync/profile_sync_service.h" | 20 #include "chrome/browser/sync/profile_sync_service.h" |
21 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 21 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
24 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
26 #include "webkit/glue/password_form.h" | 26 #include "webkit/forms/password_form.h" |
27 | 27 |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
29 | 29 |
30 namespace browser_sync { | 30 namespace browser_sync { |
31 | 31 |
32 PasswordChangeProcessor::PasswordChangeProcessor( | 32 PasswordChangeProcessor::PasswordChangeProcessor( |
33 PasswordModelAssociator* model_associator, | 33 PasswordModelAssociator* model_associator, |
34 PasswordStore* password_store, | 34 PasswordStore* password_store, |
35 UnrecoverableErrorHandler* error_handler) | 35 UnrecoverableErrorHandler* error_handler) |
36 : ChangeProcessor(error_handler), | 36 : ChangeProcessor(error_handler), |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 for (sync_api::ChangeRecordList::const_iterator it = | 174 for (sync_api::ChangeRecordList::const_iterator it = |
175 changes.Get().begin(); it != changes.Get().end(); ++it) { | 175 changes.Get().begin(); it != changes.Get().end(); ++it) { |
176 if (sync_api::ChangeRecord::ACTION_DELETE == | 176 if (sync_api::ChangeRecord::ACTION_DELETE == |
177 it->action) { | 177 it->action) { |
178 DCHECK(it->specifics.HasExtension(sync_pb::password)) | 178 DCHECK(it->specifics.HasExtension(sync_pb::password)) |
179 << "Password specifics data not present on delete!"; | 179 << "Password specifics data not present on delete!"; |
180 DCHECK(it->extra.get()); | 180 DCHECK(it->extra.get()); |
181 sync_api::ExtraPasswordChangeRecordData* extra = | 181 sync_api::ExtraPasswordChangeRecordData* extra = |
182 it->extra.get(); | 182 it->extra.get(); |
183 const sync_pb::PasswordSpecificsData& password = extra->unencrypted(); | 183 const sync_pb::PasswordSpecificsData& password = extra->unencrypted(); |
184 webkit_glue::PasswordForm form; | 184 webkit::forms::PasswordForm form; |
185 PasswordModelAssociator::CopyPassword(password, &form); | 185 PasswordModelAssociator::CopyPassword(password, &form); |
186 deleted_passwords_.push_back(form); | 186 deleted_passwords_.push_back(form); |
187 model_associator_->Disassociate(it->id); | 187 model_associator_->Disassociate(it->id); |
188 continue; | 188 continue; |
189 } | 189 } |
190 | 190 |
191 sync_api::ReadNode sync_node(trans); | 191 sync_api::ReadNode sync_node(trans); |
192 if (!sync_node.InitByIdLookup(it->id)) { | 192 if (!sync_node.InitByIdLookup(it->id)) { |
193 error_handler()->OnUnrecoverableError(FROM_HERE, | 193 error_handler()->OnUnrecoverableError(FROM_HERE, |
194 "Password node lookup failed."); | 194 "Password node lookup failed."); |
195 return; | 195 return; |
196 } | 196 } |
197 | 197 |
198 // Check that the changed node is a child of the passwords folder. | 198 // Check that the changed node is a child of the passwords folder. |
199 DCHECK_EQ(password_root.GetId(), sync_node.GetParentId()); | 199 DCHECK_EQ(password_root.GetId(), sync_node.GetParentId()); |
200 DCHECK_EQ(syncable::PASSWORDS, sync_node.GetModelType()); | 200 DCHECK_EQ(syncable::PASSWORDS, sync_node.GetModelType()); |
201 | 201 |
202 const sync_pb::PasswordSpecificsData& password_data = | 202 const sync_pb::PasswordSpecificsData& password_data = |
203 sync_node.GetPasswordSpecifics(); | 203 sync_node.GetPasswordSpecifics(); |
204 webkit_glue::PasswordForm password; | 204 webkit::forms::PasswordForm password; |
205 PasswordModelAssociator::CopyPassword(password_data, &password); | 205 PasswordModelAssociator::CopyPassword(password_data, &password); |
206 | 206 |
207 if (sync_api::ChangeRecord::ACTION_ADD == it->action) { | 207 if (sync_api::ChangeRecord::ACTION_ADD == it->action) { |
208 std::string tag(PasswordModelAssociator::MakeTag(password)); | 208 std::string tag(PasswordModelAssociator::MakeTag(password)); |
209 model_associator_->Associate(&tag, sync_node.GetId()); | 209 model_associator_->Associate(&tag, sync_node.GetId()); |
210 new_passwords_.push_back(password); | 210 new_passwords_.push_back(password); |
211 } else { | 211 } else { |
212 DCHECK_EQ(sync_api::ChangeRecord::ACTION_UPDATE, it->action); | 212 DCHECK_EQ(sync_api::ChangeRecord::ACTION_UPDATE, it->action); |
213 updated_passwords_.push_back(password); | 213 updated_passwords_.push_back(password); |
214 } | 214 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 void PasswordChangeProcessor::StopObserving() { | 254 void PasswordChangeProcessor::StopObserving() { |
255 DCHECK(expected_loop_ == MessageLoop::current()); | 255 DCHECK(expected_loop_ == MessageLoop::current()); |
256 notification_registrar_.Remove( | 256 notification_registrar_.Remove( |
257 this, | 257 this, |
258 chrome::NOTIFICATION_LOGINS_CHANGED, | 258 chrome::NOTIFICATION_LOGINS_CHANGED, |
259 content::Source<PasswordStore>(password_store_)); | 259 content::Source<PasswordStore>(password_store_)); |
260 } | 260 } |
261 | 261 |
262 } // namespace browser_sync | 262 } // namespace browser_sync |
OLD | NEW |