summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2015-02-18 16:46:58 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-19 00:47:33 +0000
commit34855a14235a5a533d8d98d1ba53175f54703b98 (patch)
treedf11fcc8e2d973fef656a1077a9135e3fce57dd0
parent8bd42c20b82615ed26a7791b94e79b55b9d93d19 (diff)
downloadchromium_src-34855a14235a5a533d8d98d1ba53175f54703b98.zip
chromium_src-34855a14235a5a533d8d98d1ba53175f54703b98.tar.gz
chromium_src-34855a14235a5a533d8d98d1ba53175f54703b98.tar.bz2
Autofill: Fix showing predictions for synthetic forms.
Also convert FormStructure::GetFieldTypePredictions() to return its data instead of using an out parameter. Review URL: https://codereview.chromium.org/934863003 Cr-Commit-Position: refs/heads/master@{#316938}
-rw-r--r--components/autofill/content/browser/content_autofill_driver.cc4
-rw-r--r--components/autofill/content/browser/content_autofill_driver_unittest.cc6
-rw-r--r--components/autofill/core/browser/form_structure.cc13
-rw-r--r--components/autofill/core/browser/form_structure.h9
4 files changed, 16 insertions, 16 deletions
diff --git a/components/autofill/content/browser/content_autofill_driver.cc b/components/autofill/content/browser/content_autofill_driver.cc
index 0bcd98b..5574f32 100644
--- a/components/autofill/content/browser/content_autofill_driver.cc
+++ b/components/autofill/content/browser/content_autofill_driver.cc
@@ -101,8 +101,8 @@ void ContentAutofillDriver::SendAutofillTypePredictionsToRenderer(
if (!RendererIsAvailable())
return;
- std::vector<FormDataPredictions> type_predictions;
- FormStructure::GetFieldTypePredictions(forms, &type_predictions);
+ std::vector<FormDataPredictions> type_predictions =
+ FormStructure::GetFieldTypePredictions(forms);
render_frame_host_->Send(new AutofillMsg_FieldTypePredictionsAvailable(
render_frame_host_->GetRoutingID(), type_predictions));
}
diff --git a/components/autofill/content/browser/content_autofill_driver_unittest.cc b/components/autofill/content/browser/content_autofill_driver_unittest.cc
index 0ade6e6..c376332 100644
--- a/components/autofill/content/browser/content_autofill_driver_unittest.cc
+++ b/components/autofill/content/browser/content_autofill_driver_unittest.cc
@@ -30,7 +30,7 @@ namespace autofill {
namespace {
-const std::string kAppLocale = "en-US";
+const char kAppLocale[] = "en-US";
const AutofillManager::AutofillDownloadManagerState kDownloadState =
AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER;
@@ -272,8 +272,8 @@ TEST_F(ContentAutofillDriverTest, TypePredictionsSentToRendererWhenEnabled) {
test::CreateTestAddressFormData(&form);
FormStructure form_structure(form);
std::vector<FormStructure*> forms(1, &form_structure);
- std::vector<FormDataPredictions> expected_type_predictions;
- FormStructure::GetFieldTypePredictions(forms, &expected_type_predictions);
+ std::vector<FormDataPredictions> expected_type_predictions =
+ FormStructure::GetFieldTypePredictions(forms);
driver_->SendAutofillTypePredictionsToRenderer(forms);
std::vector<FormDataPredictions> output_type_predictions;
diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc
index c546a11..e0ed585 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -624,17 +624,17 @@ void FormStructure::ParseQueryResponse(
}
// static
-void FormStructure::GetFieldTypePredictions(
- const std::vector<FormStructure*>& form_structures,
- std::vector<FormDataPredictions>* forms) {
- forms->clear();
- forms->reserve(form_structures.size());
+std::vector<FormDataPredictions> FormStructure::GetFieldTypePredictions(
+ const std::vector<FormStructure*>& form_structures) {
+ std::vector<FormDataPredictions> forms;
+ forms.reserve(form_structures.size());
for (size_t i = 0; i < form_structures.size(); ++i) {
FormStructure* form_structure = form_structures[i];
FormDataPredictions form;
form.data.name = form_structure->form_name_;
form.data.origin = form_structure->source_url_;
form.data.action = form_structure->target_url_;
+ form.data.is_form_tag = form_structure->is_form_tag_;
form.signature = form_structure->FormSignature();
for (std::vector<AutofillField*>::const_iterator field =
@@ -652,8 +652,9 @@ void FormStructure::GetFieldTypePredictions(
form.fields.push_back(annotated_field);
}
- forms->push_back(form);
+ forms.push_back(form);
}
+ return forms;
}
std::string FormStructure::FormSignature() const {
diff --git a/components/autofill/core/browser/form_structure.h b/components/autofill/core/browser/form_structure.h
index 119117a..2234719 100644
--- a/components/autofill/core/browser/form_structure.h
+++ b/components/autofill/core/browser/form_structure.h
@@ -76,11 +76,10 @@ class FormStructure {
static void ParseQueryResponse(const std::string& response_xml,
const std::vector<FormStructure*>& forms);
- // Fills |forms| with the details from the given |form_structures| and their
- // fields' predicted types.
- static void GetFieldTypePredictions(
- const std::vector<FormStructure*>& form_structures,
- std::vector<FormDataPredictions>* forms);
+ // Returns predictions using the details from the given |form_structures| and
+ // their fields' predicted types.
+ static std::vector<FormDataPredictions> GetFieldTypePredictions(
+ const std::vector<FormStructure*>& form_structures);
// The unique signature for this form, composed of the target url domain,
// the form name, and the form field names in a 64-bit hash.