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 d754eb5f22d1e05981e0ef1fd5380a715e011754..a106b02ad332bb8cb98f8144741d51ccf4bc3a29 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
@@ -2685,7 +2685,7 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
GetValueFromSection(SECTION_BILLING, NAME_FULL)); |
if (ShouldSaveDetailsLocally()) { |
- GetManager()->SaveImportedCreditCard(card); |
+ newly_saved_card_guid_ = GetManager()->SaveImportedCreditCard(card); |
DCHECK(!profile()->IsOffTheRecord()); |
newly_saved_card_.reset(new CreditCard(card)); |
} |
@@ -2702,8 +2702,15 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
profile.set_origin(kAutofillDialogOrigin); |
FillFormGroupFromOutputs(output, &profile); |
- if (ShouldSaveDetailsLocally()) |
- SaveProfileGleanedFromSection(profile, section); |
+ if (ShouldSaveDetailsLocally()) { |
+ std::string guid = GetManager()->SaveImportedProfile(profile); |
Evan Stade
2013/09/16 16:58:12
nit: I think the code might be a bit more concise
Ilya Sherman
2013/09/16 20:08:52
Good call. Done.
|
+ if (section == SECTION_BILLING) { |
+ newly_saved_billing_profile_guid_ = guid; |
+ } else { |
+ DCHECK_EQ(section, SECTION_SHIPPING); |
+ newly_saved_shipping_profile_guid_ = guid; |
+ } |
+ } |
AutofillProfileWrapper profile_wrapper(&profile); |
profile_wrapper.FillFormStructure(inputs, compare, &form_structure_); |
@@ -2756,12 +2763,6 @@ string16 AutofillDialogControllerImpl::GetValueFromSection( |
return string16(); |
} |
-void AutofillDialogControllerImpl::SaveProfileGleanedFromSection( |
- const AutofillProfile& profile, |
- DialogSection section) { |
- GetManager()->SaveImportedProfile(profile); |
-} |
- |
SuggestionsMenuModel* AutofillDialogControllerImpl:: |
SuggestionsMenuModelForSection(DialogSection section) { |
switch (section) { |
@@ -3150,8 +3151,18 @@ void AutofillDialogControllerImpl::DoFinishSubmit() { |
SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
std::string item_key = model->GetItemKeyForCheckedItem(); |
- if (IsASuggestionItemKey(item_key) || item_key == kSameAsBillingKey) |
+ if (IsASuggestionItemKey(item_key) || item_key == kSameAsBillingKey) { |
PersistAutofillChoice(section, item_key); |
+ } else if (item_key == kAddNewItemKey) { |
+ if (section == SECTION_CC) |
+ PersistAutofillChoice(section, newly_saved_card_guid_); |
+ else if (section == SECTION_BILLING) |
+ PersistAutofillChoice(section, newly_saved_billing_profile_guid_); |
+ else if (section == SECTION_SHIPPING) |
+ PersistAutofillChoice(section, newly_saved_shipping_profile_guid_); |
+ else |
+ NOTREACHED(); |
+ } |
} |
profile_->GetPrefs()->SetBoolean(::prefs::kAutofillDialogSaveData, |