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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 12815002: requestAutocomplete: Fill |form_structure_| from Online Wallet data (including (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index a2ad411eb6103c197bbb6e6959d6b707bbe00c39..a61b34286527c491f971e9269811828d2e336157 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -165,18 +165,21 @@ void GetBillingInfoFromOutputs(const DetailOutputMap& output,
TrimWhitespace(it->second, TRIM_ALL, &trimmed);
// Special case CVC as CreditCard just swallows it.
- if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) {
- *cvc = trimmed;
+ if (cvc && it->first->type == CREDIT_CARD_VERIFICATION_CODE) {
Evan Stade 2013/03/13 01:54:10 shouldn't you put the if (cvc) check inside this b
Dan Beam 2013/03/13 03:05:47 Done.
+ cvc->assign(trimmed);
} else {
// Copy the credit card name to |profile| in addition to |card| as
// wallet::Instrument requires a recipient name for its billing address.
- if (it->first->type == CREDIT_CARD_NAME)
+ if (profile && it->first->type == CREDIT_CARD_NAME)
profile->SetRawInfo(NAME_FULL, trimmed);
- if (AutofillType(it->first->type).group() == AutofillType::CREDIT_CARD)
- card->SetRawInfo(it->first->type, trimmed);
- else
- profile->SetRawInfo(it->first->type, trimmed);
+ if (AutofillType(it->first->type).group() == AutofillType::CREDIT_CARD) {
+ if (card)
+ card->SetRawInfo(it->first->type, trimmed);
+ } else {
Evan Stade 2013/03/13 01:54:10 merge else { if into else if
Dan Beam 2013/03/13 03:05:47 Done.
+ if (profile)
+ profile->SetRawInfo(it->first->type, trimmed);
+ }
}
}
}
@@ -1330,8 +1333,19 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator(
return;
if (!IsManuallyEditingSection(section)) {
- if (section == SECTION_CC_BILLING) {
- // TODO(dbeam): implement.
+ if (IsPayingWithWallet()) {
+ bool is_billing = section == SECTION_SHIPPING ||
+ section == SECTION_CC_BILLING;
+ const DetailInputs& inputs = RequestedFieldsForSection(section);
+ for (size_t i = 0; i < form_structure_.field_count(); ++i) {
+ AutofillField* field = form_structure_.field(i);
+ for (size_t j = 0; j < inputs.size(); ++j) {
+ if (compare.Run(inputs[j], *field)) {
+ field->value = full_wallet_->GetInfo(field->type(), is_billing);
+ break;
+ }
+ }
+ }
} else {
scoped_ptr<DataModelWrapper> model = CreateWrapper(section);
// Only fill in data that is associated with this section.
@@ -1348,34 +1362,33 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator(
DetailOutputMap output;
view_->GetUserInput(section, &output);
- if (IsPayingWithWallet()) {
- // TODO(dbeam): implement.
- } else {
- // Save the info as new or edited data and fill it into |form_structure_|.
- if (section == SECTION_CC) {
- CreditCard card;
- FillFormGroupFromOutputs(output, &card);
+ scoped_ptr<CreditCard> card;
+ scoped_ptr<string16> cvc;
+ if (section == SECTION_CC || section == SECTION_CC_BILLING) {
+ card.reset(new CreditCard());
+ cvc.reset(new string16());
+ }
- if (view_->SaveDetailsLocally())
- GetManager()->SaveImportedCreditCard(card);
+ AutofillProfile profile;
+ GetBillingInfoFromOutputs(output, card.get(), cvc.get(), &profile);
- FillFormStructureForSection(card, 0, section, compare);
+ // TODO(estade): we should probably edit the existing profile in the cases
+ // where the input data is based on an existing profile (user clicked "Edit"
+ // or autofill popup filled in the form).
+ if (card.get()) {
+ if (view_->SaveDetailsLocally())
+ GetManager()->SaveImportedCreditCard(*card);
- // Again, CVC needs special-casing. Fill it in directly from |output|.
- SetCvcResult(GetValueForType(output, CREDIT_CARD_VERIFICATION_CODE));
- } else {
- AutofillProfile profile;
- FillFormGroupFromOutputs(output, &profile);
+ FillFormStructureForSection(*card, 0, section, compare);
+ }
- // TODO(estade): we should probably edit the existing profile in the
- // cases where the input data is based on an existing profile (user
- // clicked "Edit" or autofill popup filled in the form).
- if (view_->SaveDetailsLocally())
- GetManager()->SaveImportedProfile(profile);
+ if (cvc.get() && !cvc->empty())
+ SetCvcResult(*cvc);
- FillFormStructureForSection(profile, 0, section, compare);
- }
- }
+ if (view_->SaveDetailsLocally())
+ GetManager()->SaveImportedProfile(profile);
+
+ FillFormStructureForSection(profile, 0, section, compare);
}
}
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/data_model_wrapper.h » ('j') | chrome/browser/ui/autofill/data_model_wrapper.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698