summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/form_manager.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 01:25:22 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 01:25:22 +0000
commit5af8043eb24ad60251d8a4e33192e3e6f59246a3 (patch)
tree68adeef38efa7efdc2e680062b1743c3e1b083c3 /chrome/renderer/form_manager.cc
parenta3a375dab9d4c3fffc9fcc83ccdd07edc5d8d207 (diff)
downloadchromium_src-5af8043eb24ad60251d8a4e33192e3e6f59246a3.zip
chromium_src-5af8043eb24ad60251d8a4e33192e3e6f59246a3.tar.gz
chromium_src-5af8043eb24ad60251d8a4e33192e3e6f59246a3.tar.bz2
autofill: Use a bit-field mask instead of two boolean parameters.
(Note: This was a TODO for jhawkins). BUG=None TEST=trybots Review URL: http://codereview.chromium.org/4168010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/form_manager.cc')
-rw-r--r--chrome/renderer/form_manager.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc
index 092fa4b..3fdd604 100644
--- a/chrome/renderer/form_manager.cc
+++ b/chrome/renderer/form_manager.cc
@@ -258,8 +258,7 @@ FormManager::~FormManager() {
// static
void FormManager::WebFormControlElementToFormField(
const WebFormControlElement& element,
- bool get_value,
- bool get_options,
+ ExtractMask extract_mask,
FormField* field) {
DCHECK(field);
@@ -269,7 +268,7 @@ void FormManager::WebFormControlElementToFormField(
field->set_name(element.nameForAutofill());
field->set_form_control_type(element.formControlType());
- if (get_options) {
+ if (extract_mask & EXTRACT_OPTIONS) {
// Set option strings on the field if available.
std::vector<string16> option_strings;
GetOptionStringsFromElement(element, &option_strings);
@@ -281,7 +280,7 @@ void FormManager::WebFormControlElementToFormField(
field->set_size(input_element.size());
}
- if (!get_value)
+ if (!(extract_mask & EXTRACT_VALUE))
return;
// TODO(jhawkins): In WebKit, move value() and setValue() to
@@ -333,8 +332,7 @@ string16 FormManager::LabelForElement(const WebFormControlElement& element) {
// static
bool FormManager::WebFormElementToFormData(const WebFormElement& element,
RequirementsMask requirements,
- bool get_values,
- bool get_options,
+ ExtractMask extract_mask,
FormData* form) {
DCHECK(form);
@@ -386,8 +384,7 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element,
// Create a new FormField, fill it out and map it to the field's name.
FormField* field = new FormField;
- WebFormControlElementToFormField(
- control_element, get_values, get_options, field);
+ WebFormControlElementToFormField(control_element, extract_mask, field);
form_fields.push_back(field);
// TODO(jhawkins): A label element is mapped to a form control element's id.
// field->name() will contain the id only if the name does not exist. Add
@@ -509,7 +506,7 @@ void FormManager::GetFormsInFrame(const WebFrame* frame,
FormData form;
WebFormElementToFormData(
- form_element->form_element, requirements, true, false, &form);
+ form_element->form_element, requirements, EXTRACT_VALUE, &form);
if (form.fields.size() >= kRequiredAutoFillFields)
forms->push_back(form);
}
@@ -536,8 +533,10 @@ bool FormManager::FindFormWithFormControlElement(
form_element->control_elements.begin();
iter != form_element->control_elements.end(); ++iter) {
if (iter->nameForAutofill() == element.nameForAutofill()) {
+ ExtractMask extract_mask = static_cast<ExtractMask>(
+ EXTRACT_VALUE | EXTRACT_OPTIONS);
WebFormElementToFormData(
- form_element->form_element, requirements, true, true, form);
+ form_element->form_element, requirements, extract_mask, form);
return true;
}
}