Chromium Code Reviews| 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/autofill_change_processor2.h" | 5 #include "chrome/browser/sync/glue/autofill_change_processor2.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 model_associator_->Associate(&tag, sync_id); | 465 model_associator_->Associate(&tag, sync_id); |
| 466 if (!web_database_->AddAutoFillProfile(*p.get())) { | 466 if (!web_database_->AddAutoFillProfile(*p.get())) { |
| 467 NOTREACHED() << "Couldn't add autofill profile: " << profile.label(); | 467 NOTREACHED() << "Couldn't add autofill profile: " << profile.label(); |
| 468 return; | 468 return; |
| 469 } | 469 } |
| 470 break; | 470 break; |
| 471 } | 471 } |
| 472 case sync_api::SyncManager::ChangeRecord::ACTION_UPDATE: { | 472 case sync_api::SyncManager::ChangeRecord::ACTION_UPDATE: { |
| 473 AutoFillProfile* p = NULL; | 473 AutoFillProfile* p = NULL; |
| 474 string16 label = UTF8ToUTF16(profile.label()); | 474 string16 label = UTF8ToUTF16(profile.label()); |
| 475 if (!web_database_->GetAutoFillProfileForLabel(label, &p)) { | 475 if (!web_database_->GetAutoFillProfileForLabel(label, &p)) { |
|
lipalani
2010/12/09 19:45:25
check to make sure you are not conflicting with so
| |
| 476 NOTREACHED() << "Couldn't retrieve autofill profile: " << label; | 476 NOTREACHED() << "Couldn't retrieve autofill profile: " |
| 477 << UTF16ToUTF8(label); | |
| 477 return; | 478 return; |
| 478 } | 479 } |
| 479 AutofillModelAssociator2::OverwriteProfileWithServerData(p, profile); | 480 AutofillModelAssociator2::OverwriteProfileWithServerData(p, profile); |
| 480 if (!web_database_->UpdateAutoFillProfile(*p)) { | 481 if (!web_database_->UpdateAutoFillProfile(*p)) { |
| 481 NOTREACHED() << "Couldn't update autofill profile: " << label; | 482 NOTREACHED() << "Couldn't update autofill profile: " << |
| 483 UTF16ToUTF8(label); | |
| 482 return; | 484 return; |
| 483 } | 485 } |
| 484 delete p; | 486 delete p; |
| 485 break; | 487 break; |
| 486 } | 488 } |
| 487 default: | 489 default: |
| 488 NOTREACHED(); | 490 NOTREACHED(); |
| 489 } | 491 } |
| 490 } | 492 } |
| 491 | 493 |
| 492 void AutofillChangeProcessor2::ApplySyncAutofillProfileDelete( | 494 void AutofillChangeProcessor2::ApplySyncAutofillProfileDelete( |
| 493 const sync_pb::AutofillProfileSpecifics& profile, | 495 const sync_pb::AutofillProfileSpecifics& profile, |
| 494 int64 sync_id) { | 496 int64 sync_id) { |
| 495 string16 label(UTF8ToUTF16(profile.label())); | 497 string16 label(UTF8ToUTF16(profile.label())); |
| 496 AutoFillProfile* ptr = NULL; | 498 AutoFillProfile* ptr = NULL; |
| 497 bool get_success = web_database_->GetAutoFillProfileForLabel(label, &ptr); | 499 bool get_success = web_database_->GetAutoFillProfileForLabel(label, &ptr); |
| 498 scoped_ptr<AutoFillProfile> p(ptr); | 500 scoped_ptr<AutoFillProfile> p(ptr); |
| 499 if (!get_success) { | 501 if (!get_success) { |
| 500 NOTREACHED() << "Couldn't retrieve autofill profile: " << label; | 502 NOTREACHED() << "Couldn't retrieve autofill profile: " << UTF16ToUTF8( |
| 503 label); | |
| 501 return; | 504 return; |
| 502 } | 505 } |
| 503 if (!web_database_->RemoveAutoFillProfile(p->guid())) { | 506 if (!web_database_->RemoveAutoFillProfile(p->guid())) { |
| 504 NOTREACHED() << "Couldn't remove autofill profile: " << label; | 507 NOTREACHED() << "Couldn't remove autofill profile: " << UTF16ToUTF8( |
| 508 label); | |
| 505 return; | 509 return; |
| 506 } | 510 } |
| 507 model_associator_->Disassociate(sync_id); | 511 model_associator_->Disassociate(sync_id); |
| 508 } | 512 } |
| 509 | 513 |
| 510 void AutofillChangeProcessor2::StartImpl(Profile* profile) { | 514 void AutofillChangeProcessor2::StartImpl(Profile* profile) { |
| 511 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 512 observing_ = true; | 516 observing_ = true; |
| 513 } | 517 } |
| 514 | 518 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 AutoFillType(COMPANY_NAME)))); | 579 AutoFillType(COMPANY_NAME)))); |
| 576 s->set_phone_fax_whole_number(UTF16ToUTF8(profile.GetFieldText( | 580 s->set_phone_fax_whole_number(UTF16ToUTF8(profile.GetFieldText( |
| 577 AutoFillType(PHONE_FAX_WHOLE_NUMBER)))); | 581 AutoFillType(PHONE_FAX_WHOLE_NUMBER)))); |
| 578 s->set_phone_home_whole_number(UTF16ToUTF8(profile.GetFieldText( | 582 s->set_phone_home_whole_number(UTF16ToUTF8(profile.GetFieldText( |
| 579 AutoFillType(PHONE_HOME_WHOLE_NUMBER)))); | 583 AutoFillType(PHONE_HOME_WHOLE_NUMBER)))); |
| 580 node->SetAutofillSpecifics(autofill); | 584 node->SetAutofillSpecifics(autofill); |
| 581 } | 585 } |
| 582 | 586 |
| 583 } // namespace browser_sync | 587 } // namespace browser_sync |
| 584 | 588 |
| OLD | NEW |