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

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

Issue 11299323: [imperative autofill] handle filling in <select> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo fix Created 8 years 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
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller.h ('k') | chrome/renderer/autofill/autofill_agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/autofill/autofill_dialog_controller.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller.cc b/chrome/browser/ui/autofill/autofill_dialog_controller.cc
index 0aa8aa8132421e2ea0bfde025963b7a4e0f1bc5b..be941480a5ea3ade6b8de06d9e8bde555903d0a7 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller.cc
@@ -320,9 +320,11 @@ void AutofillDialogController::ViewClosed(DialogAction action) {
} else {
FillOutputForSection(SECTION_SHIPPING);
}
+ callback_.Run(&form_structure_);
+ } else {
+ callback_.Run(NULL);
Dan Beam 2012/12/04 03:31:51 this part lgtm :)
}
- callback_.Run(&form_structure_);
delete this;
}
@@ -389,47 +391,41 @@ void AutofillDialogController::FillOutputForSectionWithComparator(
if (!form_group)
return;
- for (size_t i = 0; i < form_structure_.field_count(); ++i) {
- AutofillField* field = form_structure_.field(i);
- // Only fill in data that is associated with this section.
- const DetailInputs& inputs = RequestedFieldsForSection(section);
- for (size_t j = 0; j < inputs.size(); ++j) {
- if (compare.Run(inputs[j], *field)) {
- form_group->FillFormField(*field, 0, field);
- break;
- }
- }
- }
+ FillFormStructureForSection(*form_group, section, compare);
} else {
// The user manually input data.
DetailOutputMap output;
view_->GetUserInput(section, &output);
- // First fill in |form_structure_| to return to the page.
- for (size_t i = 0; i < form_structure_.field_count(); ++i) {
- AutofillField* field = form_structure_.field(i);
- for (DetailOutputMap::iterator iter = output.begin();
- iter != output.end(); ++iter) {
- if (!iter->second.empty() && compare.Run(*iter->first, *field)) {
- // TODO(estade): handle select controls and such. Also, canonicalize
- // the entered data.
- field->value = iter->second;
- break;
- }
- }
- }
-
- // Next, save the info as new or edited data.
+ // Save the info as new or edited data, then fill it into |form_structure_|.
PersonalDataManager* manager =
PersonalDataManagerFactory::GetForProfile(profile_);
if (section == SECTION_CC) {
CreditCard card;
FillFormGroupFromOutputs(output, &card);
manager->SaveImportedCreditCard(card);
+ FillFormStructureForSection(card, section, compare);
+
+ // CVC needs special-casing because the CreditCard class doesn't store
+ // or handle them. Fill it in directly from |output|.
+ for (size_t i = 0; i < form_structure_.field_count(); ++i) {
+ AutofillField* field = form_structure_.field(i);
+ if (field->type() != CREDIT_CARD_VERIFICATION_CODE)
+ continue;
+
+ for (DetailOutputMap::iterator iter = output.begin();
+ iter != output.end(); ++iter) {
+ if (!iter->second.empty() && compare.Run(*iter->first, *field)) {
+ field->value = iter->second;
+ break;
+ }
+ }
+ }
} else {
AutofillProfile profile;
FillFormGroupFromOutputs(output, &profile);
manager->SaveImportedProfile(profile);
+ FillFormStructureForSection(profile, section, compare);
}
}
}
@@ -439,6 +435,23 @@ void AutofillDialogController::FillOutputForSection(DialogSection section) {
base::Bind(DetailInputMatchesField));
}
+void AutofillDialogController::FillFormStructureForSection(
+ const FormGroup& form_group,
+ DialogSection section,
+ const InputFieldComparator& compare) {
+ for (size_t i = 0; i < form_structure_.field_count(); ++i) {
+ AutofillField* field = form_structure_.field(i);
+ // Only fill in data that is associated with this section.
+ const DetailInputs& inputs = RequestedFieldsForSection(section);
+ for (size_t j = 0; j < inputs.size(); ++j) {
+ if (compare.Run(inputs[j], *field)) {
+ form_group.FillFormField(*field, 0, field);
+ break;
+ }
+ }
+ }
+}
+
SuggestionsComboboxModel* AutofillDialogController::SuggestionsModelForSection(
DialogSection section) {
switch (section) {
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller.h ('k') | chrome/renderer/autofill/autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698