Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 6931029: Set datapresent string to contain precisely those field types available in stored Autofill data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Signed and delivered Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 using webkit_glue::FormData; 50 using webkit_glue::FormData;
51 using webkit_glue::FormField; 51 using webkit_glue::FormField;
52 52
53 namespace { 53 namespace {
54 54
55 // We only send a fraction of the forms to upload server. 55 // We only send a fraction of the forms to upload server.
56 // The rate for positive/negative matches potentially could be different. 56 // The rate for positive/negative matches potentially could be different.
57 const double kAutofillPositiveUploadRateDefaultValue = 0.20; 57 const double kAutofillPositiveUploadRateDefaultValue = 0.20;
58 const double kAutofillNegativeUploadRateDefaultValue = 0.20; 58 const double kAutofillNegativeUploadRateDefaultValue = 0.20;
59 59
60 const size_t kMaxRecentFormSignaturesToRemember = 3;
61
60 const string16::value_type kCreditCardPrefix[] = {'*', 0}; 62 const string16::value_type kCreditCardPrefix[] = {'*', 0};
61 63
62 // Removes duplicate suggestions whilst preserving their original order. 64 // Removes duplicate suggestions whilst preserving their original order.
63 void RemoveDuplicateSuggestions(std::vector<string16>* values, 65 void RemoveDuplicateSuggestions(std::vector<string16>* values,
64 std::vector<string16>* labels, 66 std::vector<string16>* labels,
65 std::vector<string16>* icons, 67 std::vector<string16>* icons,
66 std::vector<int>* unique_ids) { 68 std::vector<int>* unique_ids) {
67 DCHECK_EQ(values->size(), labels->size()); 69 DCHECK_EQ(values->size(), labels->size());
68 DCHECK_EQ(values->size(), icons->size()); 70 DCHECK_EQ(values->size(), icons->size());
69 DCHECK_EQ(values->size(), unique_ids->size()); 71 DCHECK_EQ(values->size(), unique_ids->size());
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } else { 556 } else {
555 DCHECK_EQ(AutofillType::CREDIT_CARD, field_group_type); 557 DCHECK_EQ(AutofillType::CREDIT_CARD, field_group_type);
556 FillCreditCardFormField(credit_card, field_type, &result.fields[j]); 558 FillCreditCardFormField(credit_card, field_type, &result.fields[j]);
557 } 559 }
558 } 560 }
559 561
560 // We found a matching field in the |form_structure| so we 562 // We found a matching field in the |form_structure| so we
561 // proceed to the next |result| field, and the next |form_structure|. 563 // proceed to the next |result| field, and the next |form_structure|.
562 ++i; 564 ++i;
563 } 565 }
564 autofilled_forms_signatures_.push_front(form_structure->FormSignature()); 566
567 autofilled_form_signatures_.push_front(form_structure->FormSignature());
568 // Only remember the last few forms that we've seen, both to avoid false
569 // positives and to avoid wasting memory.
570 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember)
571 autofilled_form_signatures_.pop_back();
565 572
566 host->Send(new AutofillMsg_FormDataFilled( 573 host->Send(new AutofillMsg_FormDataFilled(
567 host->routing_id(), query_id, result)); 574 host->routing_id(), query_id, result));
568 } 575 }
569 576
570 void AutofillManager::OnShowAutofillDialog() { 577 void AutofillManager::OnShowAutofillDialog() {
571 Browser* browser = BrowserList::GetLastActive(); 578 Browser* browser = BrowserList::GetLastActive();
572 if (browser) 579 if (browser)
573 browser->ShowOptionsTab(chrome::kAutofillSubPage); 580 browser->ShowOptionsTab(chrome::kAutofillSubPage);
574 } 581 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 if (imported_credit_card && tab_contents()) { 642 if (imported_credit_card && tab_contents()) {
636 tab_contents()->AddInfoBar( 643 tab_contents()->AddInfoBar(
637 new AutofillCCInfoBarDelegate(tab_contents(), 644 new AutofillCCInfoBarDelegate(tab_contents(),
638 scoped_credit_card.release(), 645 scoped_credit_card.release(),
639 personal_data_, 646 personal_data_,
640 metric_logger_.get())); 647 metric_logger_.get()));
641 } 648 }
642 } 649 }
643 650
644 void AutofillManager::UploadFormData(const FormStructure& submitted_form) { 651 void AutofillManager::UploadFormData(const FormStructure& submitted_form) {
645 if (!disable_download_manager_requests_) { 652 if (disable_download_manager_requests_)
646 bool was_autofilled = false; 653 return;
647 // Check if the form among last 3 forms that were auto-filled. 654
648 // Clear older signatures. 655 // Check if the form is among the forms that were recently auto-filled.
649 std::list<std::string>::iterator it; 656 bool was_autofilled = false;
650 int total_form_checked = 0; 657 for (std::list<std::string>::const_iterator it =
651 for (it = autofilled_forms_signatures_.begin(); 658 autofilled_form_signatures_.begin();
652 it != autofilled_forms_signatures_.end() && total_form_checked < 3; 659 it != autofilled_form_signatures_.end() && !was_autofilled;
653 ++it, ++total_form_checked) { 660 ++it) {
654 if (*it == submitted_form.FormSignature()) 661 if (*it == submitted_form.FormSignature())
655 was_autofilled = true; 662 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 } 663 }
664
665 FieldTypeSet available_types;
666 personal_data_->GetAvailableFieldTypes(&available_types);
667
668 download_manager_.StartUploadRequest(submitted_form, was_autofilled,
669 available_types);
664 } 670 }
665 671
666 void AutofillManager::Reset() { 672 void AutofillManager::Reset() {
667 form_structures_.reset(); 673 form_structures_.reset();
668 has_logged_autofill_enabled_ = false; 674 has_logged_autofill_enabled_ = false;
669 has_logged_address_suggestions_count_ = false; 675 has_logged_address_suggestions_count_ = false;
670 } 676 }
671 677
672 AutofillManager::AutofillManager(TabContents* tab_contents, 678 AutofillManager::AutofillManager(TabContents* tab_contents,
673 PersonalDataManager* personal_data) 679 PersonalDataManager* personal_data)
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 void AutofillManager::UnpackGUIDs(int id, 1024 void AutofillManager::UnpackGUIDs(int id,
1019 GUIDPair* cc_guid, 1025 GUIDPair* cc_guid,
1020 GUIDPair* profile_guid) { 1026 GUIDPair* profile_guid) {
1021 int cc_id = id >> std::numeric_limits<unsigned short>::digits & 1027 int cc_id = id >> std::numeric_limits<unsigned short>::digits &
1022 std::numeric_limits<unsigned short>::max(); 1028 std::numeric_limits<unsigned short>::max();
1023 int profile_id = id & std::numeric_limits<unsigned short>::max(); 1029 int profile_id = id & std::numeric_limits<unsigned short>::max();
1024 1030
1025 *cc_guid = IDToGUID(cc_id); 1031 *cc_guid = IDToGUID(cc_id);
1026 *profile_guid = IDToGUID(profile_id); 1032 *profile_guid = IDToGUID(profile_id);
1027 } 1033 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_merge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698