Commit 34855a14 authored by thestig's avatar thestig Committed by Commit bot

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}
parent 8bd42c20
......@@ -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));
}
......
......@@ -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;
......
......@@ -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 {
......
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment