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

Unified Diff: components/autofill/content/browser/request_autocomplete_manager.cc

Issue 614023002: [Password manager] Relplace the FormFieldData vector from autofill::FormData with named fields… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review comments. Created 6 years, 2 months 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
Index: components/autofill/content/browser/request_autocomplete_manager.cc
diff --git a/components/autofill/content/browser/request_autocomplete_manager.cc b/components/autofill/content/browser/request_autocomplete_manager.cc
index 89c08bf7823ff9dbc28dcca21e1f39e509bfe101..8e225c9473c10a50fb75cf0543886fc86091652d 100644
--- a/components/autofill/content/browser/request_autocomplete_manager.cc
+++ b/components/autofill/content/browser/request_autocomplete_manager.cc
@@ -35,6 +35,27 @@ blink::WebFormElement::AutocompleteResult ToWebkitAutocompleteResult(
return blink::WebFormElement::AutocompleteResultErrorDisabled;
}
+bool HasValue(const FormFieldData& field) {
+ return !field.value.empty();
+}
+
+// Helper function to set or reset the |is_autofilled| property of fields
+// present in |form_data|.
+void SetAutofillPropertyOfFields(FormData* form_data, bool is_autofilled) {
+ if (HasValue(form_data->username_field))
+ form_data->username_field.is_autofilled = is_autofilled;
+
+ if (HasValue(form_data->password_field))
+ form_data->password_field.is_autofilled = is_autofilled;
+
+ // TODO (pritam.nikam): Make sure we remove |fields|, and add form fields
+ // for all possible autofillable input fields (http://crbug.com/417295).
+ for (size_t i = 0; i < form_data->fields.size(); ++i) {
+ if (HasValue(form_data->fields[i]))
+ form_data->fields[i].is_autofilled = is_autofilled;
+ }
+}
+
} // namespace
RequestAutocompleteManager::RequestAutocompleteManager(
@@ -79,10 +100,7 @@ void RequestAutocompleteManager::ReturnAutocompleteResult(
FormData form_data;
if (form_structure) {
form_data = form_structure->ToFormData();
- for (size_t i = 0; i < form_data.fields.size(); ++i) {
- if(!form_data.fields[i].value.empty())
- form_data.fields[i].is_autofilled = true;
- }
+ SetAutofillPropertyOfFields(&form_data, true);
}
host->Send(new AutofillMsg_RequestAutocompleteResult(

Powered by Google App Engine
This is Rietveld 408576698