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

Unified Diff: chrome/browser/autofill/autofill_manager.cc

Issue 11415221: Add support for autofilling radio buttons and checkboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix the nit. 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
Index: chrome/browser/autofill/autofill_manager.cc
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 89ce8f4fb6a026a71914655b1490de436798b652..e6a76f7e761871bc003e65aa5c936c4e8a8b1287 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -654,6 +654,26 @@ void AutofillManager::OnFillAutofillFormData(int query_id,
// Mark the cached field as autofilled, so that we can detect when a user
// edits an autofilled field (for metrics).
form_structure->field(i)->is_autofilled = true;
+ } else if (cached_field->type() == FIELD_WITH_DEFAULT_VALUE &&
+ cached_field->is_checkable) {
+ // For a form with radio buttons, like:
+ // <form>
+ // <input type="radio" name="sex" value="male">Male<br>
+ // <input type="radio" name="sex" value="female">Female
+ // </form>
+ // If the default value specified at the server is "female", then
+ // Autofill server responds back with following field mappings
+ // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female")
+ // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female")
+ // Note that, the field mapping is repeated twice to respond to both the
+ // input elements with the same name/signature in the form.
+ string16 default_value = UTF8ToUTF16(cached_field->default_value());
+ // Mark the field checked if server says the default value of the field
+ // to be this field's value.
+ result.fields[i].is_checked = (default_value == result.fields[i].value);
+ // Mark the cached field as autofilled, so that we can detect when a user
+ // edits an autofilled field (for metrics).
+ form_structure->field(i)->is_autofilled = true;
}
}

Powered by Google App Engine
This is Rietveld 408576698