diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 22:11:12 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 22:11:12 +0000 |
commit | 24086521ed9ed4a23459a80fe75dbfe2d5d04f76 (patch) | |
tree | 84729fd7177cf5d310b311edb86e853d320dceb3 /chrome/browser/autofill/personal_data_manager.cc | |
parent | 2f0e64ee55903b85df568529d7fe315a5fe4ff08 (diff) | |
download | chromium_src-24086521ed9ed4a23459a80fe75dbfe2d5d04f76.zip chromium_src-24086521ed9ed4a23459a80fe75dbfe2d5d04f76.tar.gz chromium_src-24086521ed9ed4a23459a80fe75dbfe2d5d04f76.tar.bz2 |
AutoFill Empty profiles and credit cards should not be saved
Changes PersonalDataManager to filter out empty profiles and credit card information before saving to the database.
BUG=47742
TEST=PersonalDataManagerTest.SetEmptyProfile, PersonalDataManagerTest.SetEmptyCreditCard
Review URL: http://codereview.chromium.org/2897005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/personal_data_manager.cc')
-rw-r--r-- | chrome/browser/autofill/personal_data_manager.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc index 9e85f88..69ade7b 100644 --- a/chrome/browser/autofill/personal_data_manager.cc +++ b/chrome/browser/autofill/personal_data_manager.cc @@ -27,6 +27,18 @@ const int kMinImportSize = 3; const char kUnlabeled[] = "Unlabeled"; +bool IsEmptyProfile(const AutoFillProfile& profile) { + FieldTypeSet types; + profile.GetAvailableFieldTypes(&types); + return types.empty(); +} + +bool IsEmptyCreditCard(const CreditCard& credit_card) { + FieldTypeSet types; + credit_card.GetAvailableFieldTypes(&types); + return types.empty() && credit_card.billing_address().empty(); +} + } // namespace PersonalDataManager::~PersonalDataManager() { @@ -237,6 +249,11 @@ void PersonalDataManager::SetProfiles(std::vector<AutoFillProfile>* profiles) { if (profile_->IsOffTheRecord()) return; + // Remove empty profiles from input. + profiles->erase( + std::remove_if(profiles->begin(), profiles->end(), IsEmptyProfile), + profiles->end()); + SetUniqueProfileLabels(profiles); WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); @@ -302,6 +319,12 @@ void PersonalDataManager::SetCreditCards( if (profile_->IsOffTheRecord()) return; + // Remove empty credit cards from input. + credit_cards->erase( + std::remove_if( + credit_cards->begin(), credit_cards->end(), IsEmptyCreditCard), + credit_cards->end()); + SetUniqueCreditCardLabels(credit_cards); WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); |