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..8ff39c2f1d70e6f9a8cfd6cab40f76e73fd1ff60 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
@@ -166,17 +166,20 @@ void GetBillingInfoFromOutputs(const DetailOutputMap& output, |
// Special case CVC as CreditCard just swallows it. |
if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) { |
- *cvc = trimmed; |
+ if (cvc) |
+ 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 |
+ if (AutofillType(it->first->type).group() == AutofillType::CREDIT_CARD) { |
+ if (card) |
+ card->SetRawInfo(it->first->type, trimmed); |
+ } else if (profile) { |
profile->SetRawInfo(it->first->type, trimmed); |
+ } |
} |
} |
} |
@@ -595,16 +598,23 @@ scoped_ptr<DataModelWrapper> AutofillDialogControllerImpl::CreateWrapper( |
return wrapper.Pass(); |
if (IsPayingWithWallet()) { |
- int index; |
- bool success = base::StringToInt(item_key, &index); |
- DCHECK(success); |
- |
- if (section == SECTION_CC_BILLING) { |
- wrapper.reset( |
- new WalletInstrumentWrapper(wallet_items_->instruments()[index])); |
+ if (did_submit_ && full_wallet_.get()) { |
+ if (section == SECTION_CC_BILLING) |
+ wrapper.reset(new FullWalletBillingWrapper(full_wallet_.get())); |
+ else |
+ wrapper.reset(new FullWalletShippingWrapper(full_wallet_.get())); |
} else { |
- wrapper.reset( |
- new WalletAddressWrapper(wallet_items_->addresses()[index])); |
+ int index; |
+ bool success = base::StringToInt(item_key, &index); |
+ DCHECK(success); |
+ |
+ if (section == SECTION_CC_BILLING) { |
+ wrapper.reset( |
+ new WalletInstrumentWrapper(wallet_items_->instruments()[index])); |
+ } else { |
+ wrapper.reset( |
+ new WalletAddressWrapper(wallet_items_->addresses()[index])); |
+ } |
} |
} else if (section == SECTION_CC) { |
CreditCard* card = GetManager()->GetCreditCardByGUID(item_key); |
@@ -1330,52 +1340,47 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
return; |
if (!IsManuallyEditingSection(section)) { |
- if (section == SECTION_CC_BILLING) { |
- // TODO(dbeam): implement. |
- } else { |
- scoped_ptr<DataModelWrapper> model = CreateWrapper(section); |
- // Only fill in data that is associated with this section. |
- const DetailInputs& inputs = RequestedFieldsForSection(section); |
- model->FillFormStructure(inputs, compare, &form_structure_); |
- |
- // CVC needs special-casing because the CreditCard class doesn't store |
- // or handle them. |
- if (section == SECTION_CC) |
- SetCvcResult(view_->GetCvc()); |
- } |
+ scoped_ptr<DataModelWrapper> model = CreateWrapper(section); |
+ // Only fill in data that is associated with this section. |
+ const DetailInputs& inputs = RequestedFieldsForSection(section); |
+ model->FillFormStructure(inputs, compare, &form_structure_); |
+ |
+ // CVC needs special-casing because the CreditCard class doesn't store |
+ // or handle them. |
+ if (section == SECTION_CC) |
+ SetCvcResult(view_->GetCvc()); |
} else { |
// The user manually input data. |
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 (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 (SaveDetailsLocally()) |
+ GetManager()->SaveImportedProfile(profile); |
+ |
+ FillFormStructureForSection(profile, 0, section, compare); |
} |
} |
@@ -1508,6 +1513,10 @@ bool AutofillDialogControllerImpl::UseBillingForShipping() { |
return false; |
} |
+bool AutofillDialogControllerImpl::SaveDetailsLocally() { |
+ return !IsPayingWithWallet() && view_->SaveDetailsLocally(); |
+} |
+ |
void AutofillDialogControllerImpl::SubmitWithWallet() { |
// TODO(dbeam): disallow interacting with the dialog while submitting. |