summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/personal_data_manager.cc
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-04 22:18:06 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-04 22:18:06 +0000
commite5f5cf7ce7ee329a3e4e7a497337492c4736984f (patch)
tree0ccab7962636b53645a00ba479f5abd6a8ef6712 /chrome/browser/autofill/personal_data_manager.cc
parent4a99b4659bd041ee8c4050a819db91b4a930220b (diff)
downloadchromium_src-e5f5cf7ce7ee329a3e4e7a497337492c4736984f.zip
chromium_src-e5f5cf7ce7ee329a3e4e7a497337492c4736984f.tar.gz
chromium_src-e5f5cf7ce7ee329a3e4e7a497337492c4736984f.tar.bz2
Don't show the "Save credit card for Autofill?" infobar unnecessarily.
BUG=98968, 98991 TEST=unit_tests --gtest_filter=PersonalDataManager.*CreditCard* Review URL: http://codereview.chromium.org/8114031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103994 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/personal_data_manager.cc')
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc47
1 files changed, 24 insertions, 23 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index b063b3a..db27ffb 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -307,11 +307,15 @@ bool PersonalDataManager::ImportFormData(
}
// Don't import if we already have this info.
+ // Don't present an infobar if we have already saved this card number.
+ bool merged_credit_card = false;
if (local_imported_credit_card.get()) {
for (std::vector<CreditCard*>::const_iterator iter = credit_cards_.begin();
iter != credit_cards_.end();
++iter) {
- if (local_imported_credit_card->IsSubsetOf(**iter)) {
+ if ((*iter)->UpdateFromImportedCard(*local_imported_credit_card.get())) {
+ merged_credit_card = true;
+ UpdateCreditCard(**iter);
local_imported_credit_card.reset();
break;
}
@@ -324,7 +328,7 @@ bool PersonalDataManager::ImportFormData(
}
*imported_credit_card = local_imported_credit_card.release();
- if (imported_profile.get() || *imported_credit_card) {
+ if (imported_profile.get() || *imported_credit_card || merged_credit_card) {
return true;
} else {
FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_,
@@ -845,8 +849,12 @@ void PersonalDataManager::CancelPendingQuery(WebDataService::Handle* handle) {
void PersonalDataManager::SaveImportedProfile(
const AutofillProfile& imported_profile) {
- if (profile_->IsOffTheRecord())
+ if (profile_->IsOffTheRecord()) {
+ // The |IsOffTheRecord| check should happen earlier in the import process,
+ // upon form submission.
+ NOTREACHED();
return;
+ }
// Don't save a web profile if the data in the profile is a subset of an
// auxiliary profile.
@@ -865,34 +873,27 @@ void PersonalDataManager::SaveImportedProfile(
void PersonalDataManager::SaveImportedCreditCard(
const CreditCard& imported_credit_card) {
- if (profile_->IsOffTheRecord())
+ DCHECK(!imported_credit_card.number().empty());
+ if (profile_->IsOffTheRecord()) {
+ // The |IsOffTheRecord| check should happen earlier in the import process,
+ // upon form submission.
+ NOTREACHED();
return;
+ }
// Set to true if |imported_credit_card| is merged into the credit card list.
bool merged = false;
std::vector<CreditCard> creditcards;
- for (std::vector<CreditCard*>::const_iterator iter = credit_cards_.begin();
- iter != credit_cards_.end();
- ++iter) {
- if (imported_credit_card.IsSubsetOf(**iter)) {
- // In this case, the existing credit card already contains all of the data
- // in |imported_credit_card|, so consider the credit cards already
- // merged.
- merged = true;
- } else if ((*iter)->IntersectionOfTypesHasEqualValues(
- imported_credit_card)) {
- // |imported_credit_card| contains all of the data in this credit card,
- // plus more.
+ for (std::vector<CreditCard*>::const_iterator card = credit_cards_.begin();
+ card != credit_cards_.end();
+ ++card) {
+ // If |imported_credit_card| has not yet been merged, check whether it
+ // should be with the current |card|.
+ if (!merged && (*card)->UpdateFromImportedCard(imported_credit_card))
merged = true;
- (*iter)->MergeWith(imported_credit_card);
- } else if (!imported_credit_card.number().empty() &&
- (*iter)->number() == imported_credit_card.number()) {
- merged = true;
- (*iter)->OverwriteWith(imported_credit_card);
- }
- creditcards.push_back(**iter);
+ creditcards.push_back(**card);
}
if (!merged)