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/autofill/autofill_manager.h" | 5 #include "chrome/browser/autofill/autofill_manager.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 FillCreditCardFormField(credit_card, autofill_type, &result.fields[j]); | 402 FillCreditCardFormField(credit_card, autofill_type, &result.fields[j]); |
403 } else if (profile && | 403 } else if (profile && |
404 autofill_type.group() != AutoFillType::CREDIT_CARD) { | 404 autofill_type.group() != AutoFillType::CREDIT_CARD) { |
405 FillFormField(profile, autofill_type, &result.fields[j]); | 405 FillFormField(profile, autofill_type, &result.fields[j]); |
406 } | 406 } |
407 | 407 |
408 // We found a matching field in the |form_structure| so we | 408 // We found a matching field in the |form_structure| so we |
409 // proceed to the next |result| field, and the next |form_structure|. | 409 // proceed to the next |result| field, and the next |form_structure|. |
410 ++i; | 410 ++i; |
411 } | 411 } |
412 autofilled_forms_signatures_.push_front(form_structure->FormSignature()); | 412 AutofilledFormInfo form_info; |
| 413 form_info.form_signature = form_structure->FormSignature(); |
| 414 form_info.profile_guid = profile_guid; |
| 415 form_info.cc_guid = cc_guid; |
| 416 autofilled_forms_signatures_.push_front(form_info); |
413 | 417 |
414 host->Send(new ViewMsg_AutoFillFormDataFilled( | 418 host->Send(new ViewMsg_AutoFillFormDataFilled( |
415 host->routing_id(), query_id, result)); | 419 host->routing_id(), query_id, result)); |
416 } | 420 } |
417 | 421 |
418 void AutoFillManager::OnShowAutoFillDialog() { | 422 void AutoFillManager::OnShowAutoFillDialog() { |
419 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 423 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
420 switches::kDisableTabbedOptions)) { | 424 switches::kDisableTabbedOptions)) { |
421 Browser* browser = BrowserList::GetLastActive(); | 425 Browser* browser = BrowserList::GetLastActive(); |
422 if (browser) | 426 if (browser) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 tab_contents_->AddInfoBar(new AutoFillCCInfoBarDelegate(tab_contents_, | 541 tab_contents_->AddInfoBar(new AutoFillCCInfoBarDelegate(tab_contents_, |
538 this)); | 542 this)); |
539 } | 543 } |
540 } | 544 } |
541 | 545 |
542 void AutoFillManager::UploadFormData() { | 546 void AutoFillManager::UploadFormData() { |
543 if (!disable_download_manager_requests_ && upload_form_structure_.get()) { | 547 if (!disable_download_manager_requests_ && upload_form_structure_.get()) { |
544 bool was_autofilled = false; | 548 bool was_autofilled = false; |
545 // Check if the form among last 3 forms that were auto-filled. | 549 // Check if the form among last 3 forms that were auto-filled. |
546 // Clear older signatures. | 550 // Clear older signatures. |
547 std::list<std::string>::iterator it; | 551 std::list<AutofilledFormInfo>::iterator it; |
548 int total_form_checked = 0; | 552 int total_form_checked = 0; |
| 553 std::string profile_guid, cc_guid; |
549 for (it = autofilled_forms_signatures_.begin(); | 554 for (it = autofilled_forms_signatures_.begin(); |
550 it != autofilled_forms_signatures_.end() && total_form_checked < 3; | 555 it != autofilled_forms_signatures_.end() && total_form_checked < 3; |
551 ++it, ++total_form_checked) { | 556 ++it, ++total_form_checked) { |
552 if (*it == upload_form_structure_->FormSignature()) | 557 if (it->form_signature == upload_form_structure_->FormSignature()) { |
553 was_autofilled = true; | 558 was_autofilled = true; |
| 559 profile_guid = it->profile_guid; |
| 560 cc_guid = it->cc_guid; |
| 561 } |
554 } | 562 } |
555 // Remove outdated form signatures. | 563 // Remove outdated form signatures. |
556 if (total_form_checked == 3 && it != autofilled_forms_signatures_.end()) { | 564 if (total_form_checked == 3 && it != autofilled_forms_signatures_.end()) { |
557 autofilled_forms_signatures_.erase(it, | 565 autofilled_forms_signatures_.erase(it, |
558 autofilled_forms_signatures_.end()); | 566 autofilled_forms_signatures_.end()); |
559 } | 567 } |
560 download_manager_.StartUploadRequest(*(upload_form_structure_.get()), | 568 download_manager_.StartUploadRequest(*(upload_form_structure_.get()), |
561 was_autofilled); | 569 was_autofilled, |
| 570 personal_data_->PresentData(profile_guid, cc_guid).c_str()); |
562 } | 571 } |
563 } | 572 } |
564 | 573 |
565 void AutoFillManager::Reset() { | 574 void AutoFillManager::Reset() { |
566 upload_form_structure_.reset(); | 575 upload_form_structure_.reset(); |
567 form_structures_.reset(); | 576 form_structures_.reset(); |
568 } | 577 } |
569 | 578 |
570 void AutoFillManager::OnInfoBarClosed(bool should_save) { | 579 void AutoFillManager::OnInfoBarClosed(bool should_save) { |
571 if (should_save) | 580 if (should_save) |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 return std::string(); | 868 return std::string(); |
860 | 869 |
861 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); | 870 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); |
862 if (iter == id_guid_map_.end()) { | 871 if (iter == id_guid_map_.end()) { |
863 NOTREACHED(); | 872 NOTREACHED(); |
864 return std::string(); | 873 return std::string(); |
865 } | 874 } |
866 | 875 |
867 return iter->second; | 876 return iter->second; |
868 } | 877 } |
OLD | NEW |