Chromium Code Reviews| 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/autofill/autofill_manager.h" | 5 #include "chrome/browser/autofill/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 } else { | 554 } else { |
| 555 DCHECK_EQ(AutofillType::CREDIT_CARD, field_group_type); | 555 DCHECK_EQ(AutofillType::CREDIT_CARD, field_group_type); |
| 556 FillCreditCardFormField(credit_card, field_type, &result.fields[j]); | 556 FillCreditCardFormField(credit_card, field_type, &result.fields[j]); |
| 557 } | 557 } |
| 558 } | 558 } |
| 559 | 559 |
| 560 // We found a matching field in the |form_structure| so we | 560 // We found a matching field in the |form_structure| so we |
| 561 // proceed to the next |result| field, and the next |form_structure|. | 561 // proceed to the next |result| field, and the next |form_structure|. |
| 562 ++i; | 562 ++i; |
| 563 } | 563 } |
| 564 autofilled_forms_signatures_.push_front(form_structure->FormSignature()); | 564 |
| 565 autofilled_form_signatures_.push_front(form_structure->FormSignature()); | |
| 566 if (autofilled_form_signatures_.size() > 3) | |
|
dhollowa
2011/05/06 03:06:20
It is not clear why this is here. Could you expla
Ilya Sherman
2011/05/06 03:33:07
Made '3' a named constant, and added a brief comme
| |
| 567 autofilled_form_signatures_.pop_back(); | |
| 565 | 568 |
| 566 host->Send(new AutofillMsg_FormDataFilled( | 569 host->Send(new AutofillMsg_FormDataFilled( |
| 567 host->routing_id(), query_id, result)); | 570 host->routing_id(), query_id, result)); |
| 568 } | 571 } |
| 569 | 572 |
| 570 void AutofillManager::OnShowAutofillDialog() { | 573 void AutofillManager::OnShowAutofillDialog() { |
| 571 Browser* browser = BrowserList::GetLastActive(); | 574 Browser* browser = BrowserList::GetLastActive(); |
| 572 if (browser) | 575 if (browser) |
| 573 browser->ShowOptionsTab(chrome::kAutofillSubPage); | 576 browser->ShowOptionsTab(chrome::kAutofillSubPage); |
| 574 } | 577 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 635 if (imported_credit_card && tab_contents()) { | 638 if (imported_credit_card && tab_contents()) { |
| 636 tab_contents()->AddInfoBar( | 639 tab_contents()->AddInfoBar( |
| 637 new AutofillCCInfoBarDelegate(tab_contents(), | 640 new AutofillCCInfoBarDelegate(tab_contents(), |
| 638 scoped_credit_card.release(), | 641 scoped_credit_card.release(), |
| 639 personal_data_, | 642 personal_data_, |
| 640 metric_logger_.get())); | 643 metric_logger_.get())); |
| 641 } | 644 } |
| 642 } | 645 } |
| 643 | 646 |
| 644 void AutofillManager::UploadFormData(const FormStructure& submitted_form) { | 647 void AutofillManager::UploadFormData(const FormStructure& submitted_form) { |
| 645 if (!disable_download_manager_requests_) { | 648 if (disable_download_manager_requests_) |
| 646 bool was_autofilled = false; | 649 return; |
| 647 // Check if the form among last 3 forms that were auto-filled. | 650 |
| 648 // Clear older signatures. | 651 // Check if the form is among the forms that were recently auto-filled. |
| 649 std::list<std::string>::iterator it; | 652 bool was_autofilled = false; |
| 650 int total_form_checked = 0; | 653 for (std::list<std::string>::const_iterator it = |
| 651 for (it = autofilled_forms_signatures_.begin(); | 654 autofilled_form_signatures_.begin(); |
| 652 it != autofilled_forms_signatures_.end() && total_form_checked < 3; | 655 it != autofilled_form_signatures_.end() && !was_autofilled; |
| 653 ++it, ++total_form_checked) { | 656 ++it) { |
| 654 if (*it == submitted_form.FormSignature()) | 657 if (*it == submitted_form.FormSignature()) |
| 655 was_autofilled = true; | 658 was_autofilled = true; |
| 656 } | |
| 657 // Remove outdated form signatures. | |
| 658 if (total_form_checked == 3 && it != autofilled_forms_signatures_.end()) { | |
| 659 autofilled_forms_signatures_.erase(it, | |
| 660 autofilled_forms_signatures_.end()); | |
| 661 } | |
| 662 download_manager_.StartUploadRequest(submitted_form, was_autofilled); | |
| 663 } | 659 } |
| 660 | |
| 661 FieldTypeSet available_types; | |
| 662 personal_data_->GetAvailableFieldTypes(&available_types); | |
| 663 | |
| 664 download_manager_.StartUploadRequest(submitted_form, was_autofilled, | |
| 665 available_types); | |
| 664 } | 666 } |
| 665 | 667 |
| 666 void AutofillManager::Reset() { | 668 void AutofillManager::Reset() { |
| 667 form_structures_.reset(); | 669 form_structures_.reset(); |
| 668 has_logged_autofill_enabled_ = false; | 670 has_logged_autofill_enabled_ = false; |
| 669 has_logged_address_suggestions_count_ = false; | 671 has_logged_address_suggestions_count_ = false; |
| 670 } | 672 } |
| 671 | 673 |
| 672 AutofillManager::AutofillManager(TabContents* tab_contents, | 674 AutofillManager::AutofillManager(TabContents* tab_contents, |
| 673 PersonalDataManager* personal_data) | 675 PersonalDataManager* personal_data) |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 void AutofillManager::UnpackGUIDs(int id, | 1020 void AutofillManager::UnpackGUIDs(int id, |
| 1019 GUIDPair* cc_guid, | 1021 GUIDPair* cc_guid, |
| 1020 GUIDPair* profile_guid) { | 1022 GUIDPair* profile_guid) { |
| 1021 int cc_id = id >> std::numeric_limits<unsigned short>::digits & | 1023 int cc_id = id >> std::numeric_limits<unsigned short>::digits & |
| 1022 std::numeric_limits<unsigned short>::max(); | 1024 std::numeric_limits<unsigned short>::max(); |
| 1023 int profile_id = id & std::numeric_limits<unsigned short>::max(); | 1025 int profile_id = id & std::numeric_limits<unsigned short>::max(); |
| 1024 | 1026 |
| 1025 *cc_guid = IDToGUID(cc_id); | 1027 *cc_guid = IDToGUID(cc_id); |
| 1026 *profile_guid = IDToGUID(profile_id); | 1028 *profile_guid = IDToGUID(profile_id); |
| 1027 } | 1029 } |
| OLD | NEW |