| 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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/password_manager/password_store.h" | 13 #include "chrome/browser/password_manager/password_store.h" |
| 14 #include "chrome/browser/password_manager/password_store_change.h" | 14 #include "chrome/browser/password_manager/password_store_change.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/sync/glue/password_model_associator.h" | 16 #include "chrome/browser/sync/glue/password_model_associator.h" |
| 17 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
| 18 #include "components/autofill/core/common/password_form.h" |
| 18 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
| 19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 20 #include "content/public/common/password_form.h" | |
| 21 #include "sync/internal_api/public/change_record.h" | 21 #include "sync/internal_api/public/change_record.h" |
| 22 #include "sync/internal_api/public/read_node.h" | 22 #include "sync/internal_api/public/read_node.h" |
| 23 #include "sync/internal_api/public/write_node.h" | 23 #include "sync/internal_api/public/write_node.h" |
| 24 #include "sync/internal_api/public/write_transaction.h" | 24 #include "sync/internal_api/public/write_transaction.h" |
| 25 #include "sync/protocol/password_specifics.pb.h" | 25 #include "sync/protocol/password_specifics.pb.h" |
| 26 | 26 |
| 27 using content::BrowserThread; | 27 using content::BrowserThread; |
| 28 | 28 |
| 29 namespace browser_sync { | 29 namespace browser_sync { |
| 30 | 30 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 for (syncer::ChangeRecordList::const_iterator it = | 185 for (syncer::ChangeRecordList::const_iterator it = |
| 186 changes.Get().begin(); it != changes.Get().end(); ++it) { | 186 changes.Get().begin(); it != changes.Get().end(); ++it) { |
| 187 if (syncer::ChangeRecord::ACTION_DELETE == | 187 if (syncer::ChangeRecord::ACTION_DELETE == |
| 188 it->action) { | 188 it->action) { |
| 189 DCHECK(it->specifics.has_password()) | 189 DCHECK(it->specifics.has_password()) |
| 190 << "Password specifics data not present on delete!"; | 190 << "Password specifics data not present on delete!"; |
| 191 DCHECK(it->extra.get()); | 191 DCHECK(it->extra.get()); |
| 192 syncer::ExtraPasswordChangeRecordData* extra = | 192 syncer::ExtraPasswordChangeRecordData* extra = |
| 193 it->extra.get(); | 193 it->extra.get(); |
| 194 const sync_pb::PasswordSpecificsData& password = extra->unencrypted(); | 194 const sync_pb::PasswordSpecificsData& password = extra->unencrypted(); |
| 195 content::PasswordForm form; | 195 autofill::PasswordForm form; |
| 196 PasswordModelAssociator::CopyPassword(password, &form); | 196 PasswordModelAssociator::CopyPassword(password, &form); |
| 197 deleted_passwords_.push_back(form); | 197 deleted_passwords_.push_back(form); |
| 198 model_associator_->Disassociate(it->id); | 198 model_associator_->Disassociate(it->id); |
| 199 continue; | 199 continue; |
| 200 } | 200 } |
| 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(syncer::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 content::PasswordForm password; | 215 autofill::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); |
| 222 } else { | 222 } else { |
| 223 DCHECK_EQ(syncer::ChangeRecord::ACTION_UPDATE, it->action); | 223 DCHECK_EQ(syncer::ChangeRecord::ACTION_UPDATE, it->action); |
| 224 updated_passwords_.push_back(password); | 224 updated_passwords_.push_back(password); |
| 225 } | 225 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 void PasswordChangeProcessor::StopObserving() { | 272 void PasswordChangeProcessor::StopObserving() { |
| 273 DCHECK(expected_loop_ == base::MessageLoop::current()); | 273 DCHECK(expected_loop_ == base::MessageLoop::current()); |
| 274 notification_registrar_.Remove( | 274 notification_registrar_.Remove( |
| 275 this, | 275 this, |
| 276 chrome::NOTIFICATION_LOGINS_CHANGED, | 276 chrome::NOTIFICATION_LOGINS_CHANGED, |
| 277 content::Source<PasswordStore>(password_store_)); | 277 content::Source<PasswordStore>(password_store_)); |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace browser_sync | 280 } // namespace browser_sync |
| OLD | NEW |