diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 17:55:12 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 17:55:12 +0000 |
commit | eeb7bdff95f4db2384885384ca56ce05494027fb (patch) | |
tree | 862af95695e6d1e414054bb3b6cb6b71210bab39 /chrome/renderer | |
parent | eaa4226c0d2c9d8d108fbbb698408c087a43874a (diff) | |
download | chromium_src-eeb7bdff95f4db2384885384ca56ce05494027fb.zip chromium_src-eeb7bdff95f4db2384885384ca56ce05494027fb.tar.gz chromium_src-eeb7bdff95f4db2384885384ca56ce05494027fb.tar.bz2 |
Revert 77296 -
Convert autofill messages to use the new IPC macros. This requires
changing the FormField class to a struct with publically-visible members,
which was what should have been done in the first place, instead of the
trivial setters/getters which are accessed in various combinations
independently of each other throughout the code.
Review URL: http://codereview.chromium.org/6633001
TBR=tsepez@chromium.org
Review URL: http://codereview.chromium.org/6623086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/autofill/autofill_agent.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_autocomplete_browsertest.cc | 12 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_manager.cc | 34 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_manager.h | 2 | ||||
-rw-r--r-- | chrome/renderer/autofill/form_manager_browsertest.cc | 92 | ||||
-rw-r--r-- | chrome/renderer/autofill/password_autofill_manager.cc | 20 |
6 files changed, 82 insertions, 82 deletions
diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc index 2c087a6..da8e2c3 100644 --- a/chrome/renderer/autofill/autofill_agent.cc +++ b/chrome/renderer/autofill/autofill_agent.cc @@ -351,7 +351,7 @@ void AutoFillAgent::FillAutoFillFormData(const WebNode& node, return; autofill_action_ = action; - was_query_node_autofilled_ = field.is_autofilled; + was_query_node_autofilled_ = field.is_autofilled(); Send(new AutoFillHostMsg_FillAutoFillFormData( routing_id(), autofill_query_id_, form, field, unique_id)); } @@ -381,7 +381,7 @@ bool AutoFillAgent::FindFormAndFieldForNode(const WebNode& node, // label, so find the label here. // TODO(jhawkins): Add form and field identities so we can use the cached form // data in FormManager. - field->label = FormManager::LabelForElement(element); + field->set_label(FormManager::LabelForElement(element)); return true; } diff --git a/chrome/renderer/autofill/form_autocomplete_browsertest.cc b/chrome/renderer/autofill/form_autocomplete_browsertest.cc index 15b4c92..1041e76 100644 --- a/chrome/renderer/autofill/form_autocomplete_browsertest.cc +++ b/chrome/renderer/autofill/form_autocomplete_browsertest.cc @@ -40,12 +40,12 @@ TEST_F(FormAutocompleteTest, NormalFormSubmit) { ASSERT_EQ(2U, forms.a.fields.size()); webkit_glue::FormField& form_field = forms.a.fields[0]; - EXPECT_EQ(WebString("fname"), form_field.name); - EXPECT_EQ(WebString("Rick"), form_field.value); + EXPECT_EQ(WebString("fname"), form_field.name()); + EXPECT_EQ(WebString("Rick"), form_field.value()); form_field = forms.a.fields[1]; - EXPECT_EQ(WebString("lname"), form_field.name); - EXPECT_EQ(WebString("Deckard"), form_field.value); + EXPECT_EQ(WebString("lname"), form_field.name()); + EXPECT_EQ(WebString("Deckard"), form_field.value()); } // Tests that submitting a form that has autocomplete="off" does not generate a @@ -88,8 +88,8 @@ TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) { ASSERT_EQ(1U, forms.a.fields.size()); webkit_glue::FormField& form_field = forms.a.fields[0]; - EXPECT_EQ(WebString("fname"), form_field.name); - EXPECT_EQ(WebString("Rick"), form_field.value); + EXPECT_EQ(WebString("fname"), form_field.name()); + EXPECT_EQ(WebString("Rick"), form_field.value()); } // Tests that submitting a form that has been dynamically set as autocomplete diff --git a/chrome/renderer/autofill/form_manager.cc b/chrome/renderer/autofill/form_manager.cc index 889b4cc..5c41eb6 100644 --- a/chrome/renderer/autofill/form_manager.cc +++ b/chrome/renderer/autofill/form_manager.cc @@ -334,23 +334,23 @@ void FormManager::WebFormControlElementToFormField( // The label is not officially part of a WebFormControlElement; however, the // labels for all form control elements are scraped from the DOM and set in // WebFormElementToFormData. - field->name = element.nameForAutofill(); - field->form_control_type = element.formControlType(); + field->set_name(element.nameForAutofill()); + field->set_form_control_type(element.formControlType()); if (!IsAutoFillableElement(element)) return; const WebInputElement* input_element = toWebInputElement(&element); if (IsTextInput(input_element)) { - field->max_length = input_element->maxLength(); - field->is_autofilled = input_element->isAutofilled(); + field->set_max_length(input_element->maxLength()); + field->set_autofilled(input_element->isAutofilled()); } else if (extract_mask & EXTRACT_OPTIONS) { // Set option strings on the field if available. DCHECK(IsSelectElement(element)); const WebSelectElement select_element = element.toConst<WebSelectElement>(); std::vector<string16> option_strings; GetOptionStringsFromElement(select_element, &option_strings); - field->option_strings = option_strings; + field->set_option_strings(option_strings); } if (!(extract_mask & EXTRACT_VALUE)) @@ -387,7 +387,7 @@ void FormManager::WebFormControlElementToFormField( if (value.size() > kMaxDataLength) value = value.substr(0, kMaxDataLength); - field->value = value; + field->set_value(value); } // static @@ -468,7 +468,7 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element, // 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 // an id() method to WebFormControlElement and use that here. - name_map[field->name] = field; + name_map[field->name()] = field; fields_extracted[i] = true; } @@ -494,7 +494,7 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element, std::map<string16, FormField*>::iterator iter = name_map.find(field_element.nameForAutofill()); if (iter != name_map.end()) - iter->second->label = FindChildText(label); + iter->second->set_label(FindChildText(label)); } // Loop through the form control elements, extracting the label text from the @@ -509,8 +509,8 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element, continue; const WebFormControlElement& control_element = control_elements[i]; - if (form_fields[field_idx]->label.empty()) - form_fields[field_idx]->label = InferLabelForElement(control_element); + if (form_fields[field_idx]->label().empty()) + form_fields[field_idx]->set_label(InferLabelForElement(control_element)); ++field_idx; } @@ -833,13 +833,13 @@ void FormManager::ForEachMatchingFormField(FormElement* form, // Search forward in the |form| for a corresponding field. size_t k = j; - while (k < data.fields.size() && element_name != data.fields[k].name) + while (k < data.fields.size() && element_name != data.fields[k].name()) k++; if (k >= data.fields.size()) continue; - DCHECK_EQ(data.fields[k].name, element_name); + DCHECK_EQ(data.fields[k].name(), element_name); bool is_initiating_node = false; @@ -880,7 +880,7 @@ void FormManager::FillFormField(WebFormControlElement* field, const FormField* data, bool is_initiating_node) { // Nothing to fill. - if (data->value.empty()) + if (data->value().empty()) return; WebInputElement* input_element = toWebInputElement(field); @@ -888,7 +888,7 @@ void FormManager::FillFormField(WebFormControlElement* field, // If the maxlength attribute contains a negative value, maxLength() // returns the default maxlength value. input_element->setValue( - data->value.substr(0, input_element->maxLength())); + data->value().substr(0, input_element->maxLength())); input_element->setAutofilled(true); if (is_initiating_node) { int length = input_element->value().length(); @@ -897,7 +897,7 @@ void FormManager::FillFormField(WebFormControlElement* field, } else { DCHECK(IsSelectElement(*field)); WebSelectElement select_element = field->to<WebSelectElement>(); - select_element.setValue(data->value); + select_element.setValue(data->value()); } } @@ -905,7 +905,7 @@ void FormManager::PreviewFormField(WebFormControlElement* field, const FormField* data, bool is_initiating_node) { // Nothing to preview. - if (data->value.empty()) + if (data->value().empty()) return; // Only preview input fields. @@ -916,7 +916,7 @@ void FormManager::PreviewFormField(WebFormControlElement* field, // If the maxlength attribute contains a negative value, maxLength() // returns the default maxlength value. input_element->setSuggestedValue( - data->value.substr(0, input_element->maxLength())); + data->value().substr(0, input_element->maxLength())); input_element->setAutofilled(true); if (is_initiating_node) { // Select the part of the text that the user didn't type. diff --git a/chrome/renderer/autofill/form_manager.h b/chrome/renderer/autofill/form_manager.h index 0558bbb..18110c3 100644 --- a/chrome/renderer/autofill/form_manager.h +++ b/chrome/renderer/autofill/form_manager.h @@ -16,7 +16,7 @@ namespace webkit_glue { struct FormData; -struct FormField; +class FormField; } // namespace webkit_glue namespace WebKit { diff --git a/chrome/renderer/autofill/form_manager_browsertest.cc b/chrome/renderer/autofill/form_manager_browsertest.cc index d8e18ba..a89b6ba 100644 --- a/chrome/renderer/autofill/form_manager_browsertest.cc +++ b/chrome/renderer/autofill/form_manager_browsertest.cc @@ -249,9 +249,9 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldSelect) { ASCIIToUTF16("select-one"), 0, false))); - ASSERT_EQ(2U, result3.option_strings.size()); - EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_strings[0]); - EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_strings[1]); + ASSERT_EQ(2U, result3.option_strings().size()); + EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_strings()[0]); + EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_strings()[1]); } // We should be not extract the value for non-text and non-select fields. @@ -793,11 +793,11 @@ TEST_F(FormManagerTest, FillForm) { fields[4]); // Fill the form. - form.fields[0].value = ASCIIToUTF16("Wyatt"); - form.fields[1].value = ASCIIToUTF16("Earp"); - form.fields[2].value = ASCIIToUTF16("Alpha"); - form.fields[3].value = ASCIIToUTF16("Beta"); - form.fields[4].value = ASCIIToUTF16("Gamma"); + form.fields[0].set_value(ASCIIToUTF16("Wyatt")); + form.fields[1].set_value(ASCIIToUTF16("Earp")); + form.fields[2].set_value(ASCIIToUTF16("Alpha")); + form.fields[3].set_value(ASCIIToUTF16("Beta")); + form.fields[4].set_value(ASCIIToUTF16("Gamma")); EXPECT_TRUE(form_manager.FillForm(form, input_element)); // Verify the filled elements. @@ -905,11 +905,11 @@ TEST_F(FormManagerTest, PreviewForm) { fields[4]); // Preview the form. - form.fields[0].value = ASCIIToUTF16("Wyatt"); - form.fields[1].value = ASCIIToUTF16("Earp"); - form.fields[2].value = ASCIIToUTF16("Alpha"); - form.fields[3].value = ASCIIToUTF16("Beta"); - form.fields[4].value = ASCIIToUTF16("Gamma"); + form.fields[0].set_value(ASCIIToUTF16("Wyatt")); + form.fields[1].set_value(ASCIIToUTF16("Earp")); + form.fields[2].set_value(ASCIIToUTF16("Alpha")); + form.fields[3].set_value(ASCIIToUTF16("Beta")); + form.fields[4].set_value(ASCIIToUTF16("Gamma")); EXPECT_TRUE(form_manager.PreviewForm(form, input_element)); // Verify the previewed elements. @@ -1484,9 +1484,9 @@ TEST_F(FormManagerTest, FillFormMaxLength) { fields[2]); // Fill the form. - form.fields[0].value = ASCIIToUTF16("Brother"); - form.fields[1].value = ASCIIToUTF16("Jonathan"); - form.fields[2].value = ASCIIToUTF16("brotherj@example.com"); + form.fields[0].set_value(ASCIIToUTF16("Brother")); + form.fields[1].set_value(ASCIIToUTF16("Jonathan")); + form.fields[2].set_value(ASCIIToUTF16("brotherj@example.com")); EXPECT_TRUE(form_manager.FillForm(form, WebNode())); // Find the newly-filled form that contains the input element. @@ -1578,9 +1578,9 @@ TEST_F(FormManagerTest, FillFormNegativeMaxLength) { fields[2]); // Fill the form. - form.fields[0].value = ASCIIToUTF16("Brother"); - form.fields[1].value = ASCIIToUTF16("Jonathan"); - form.fields[2].value = ASCIIToUTF16("brotherj@example.com"); + form.fields[0].set_value(ASCIIToUTF16("Brother")); + form.fields[1].set_value(ASCIIToUTF16("Jonathan")); + form.fields[2].set_value(ASCIIToUTF16("brotherj@example.com")); EXPECT_TRUE(form_manager.FillForm(form, WebNode())); // Find the newly-filled form that contains the input element. @@ -1681,13 +1681,13 @@ TEST_F(FormManagerTest, FillFormMoreFormDataFields) { form->fields.insert(form->fields.begin() + 6, field4); // Fill the form. - form->fields[0].value = ASCIIToUTF16("Alpha"); - form->fields[1].value = ASCIIToUTF16("Brother"); - form->fields[2].value = ASCIIToUTF16("Abracadabra"); - form->fields[3].value = ASCIIToUTF16("Joseph"); - form->fields[4].value = ASCIIToUTF16("Beta"); - form->fields[5].value = ASCIIToUTF16("Jonathan"); - form->fields[6].value = ASCIIToUTF16("Omega"); + form->fields[0].set_value(ASCIIToUTF16("Alpha")); + form->fields[1].set_value(ASCIIToUTF16("Brother")); + form->fields[2].set_value(ASCIIToUTF16("Abracadabra")); + form->fields[3].set_value(ASCIIToUTF16("Joseph")); + form->fields[4].set_value(ASCIIToUTF16("Beta")); + form->fields[5].set_value(ASCIIToUTF16("Jonathan")); + form->fields[6].set_value(ASCIIToUTF16("Omega")); EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); // Get the input element we want to find. @@ -1764,9 +1764,9 @@ TEST_F(FormManagerTest, FillFormFewerFormDataFields) { form->fields.erase(form->fields.begin() + 3); // Fill the form. - form->fields[0].value = ASCIIToUTF16("Brother"); - form->fields[1].value = ASCIIToUTF16("Joseph"); - form->fields[2].value = ASCIIToUTF16("Jonathan"); + form->fields[0].set_value(ASCIIToUTF16("Brother")); + form->fields[1].set_value(ASCIIToUTF16("Joseph")); + form->fields[2].set_value(ASCIIToUTF16("Jonathan")); EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); // Get the input element we want to find. @@ -1863,13 +1863,13 @@ TEST_F(FormManagerTest, FillFormChangedFormDataFields) { FormData* form = &forms[0]; // Fill the form. - form->fields[0].value = ASCIIToUTF16("Brother"); - form->fields[1].value = ASCIIToUTF16("Joseph"); - form->fields[2].value = ASCIIToUTF16("Jonathan"); + form->fields[0].set_value(ASCIIToUTF16("Brother")); + form->fields[1].set_value(ASCIIToUTF16("Joseph")); + form->fields[2].set_value(ASCIIToUTF16("Jonathan")); // Alter the label and name used for matching. - form->fields[1].label = ASCIIToUTF16("bogus"); - form->fields[1].name = ASCIIToUTF16("bogus"); + form->fields[1].set_label(ASCIIToUTF16("bogus")); + form->fields[1].set_name(ASCIIToUTF16("bogus")); EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); @@ -1938,9 +1938,9 @@ TEST_F(FormManagerTest, FillFormExtraFieldInCache) { form->fields.pop_back(); // Fill the form. - form->fields[0].value = ASCIIToUTF16("Brother"); - form->fields[1].value = ASCIIToUTF16("Joseph"); - form->fields[2].value = ASCIIToUTF16("Jonathan"); + form->fields[0].set_value(ASCIIToUTF16("Brother")); + form->fields[1].set_value(ASCIIToUTF16("Joseph")); + form->fields[2].set_value(ASCIIToUTF16("Jonathan")); EXPECT_TRUE(form_manager.FillForm(*form, WebNode())); // Get the input element we want to find. @@ -2043,9 +2043,9 @@ TEST_F(FormManagerTest, FillFormEmptyName) { fields[2]); // Fill the form. - form.fields[0].value = ASCIIToUTF16("Wyatt"); - form.fields[1].value = ASCIIToUTF16("Earp"); - form.fields[2].value = ASCIIToUTF16("wyatt@example.com"); + form.fields[0].set_value(ASCIIToUTF16("Wyatt")); + form.fields[1].set_value(ASCIIToUTF16("Earp")); + form.fields[2].set_value(ASCIIToUTF16("wyatt@example.com")); EXPECT_TRUE(form_manager.FillForm(form, WebNode())); // Find the newly-filled form that contains the input element. @@ -2143,9 +2143,9 @@ TEST_F(FormManagerTest, FillFormEmptyFormNames) { fields[2]); // Fill the form. - form.fields[0].value = ASCIIToUTF16("Red"); - form.fields[1].value = ASCIIToUTF16("Yellow"); - form.fields[2].value = ASCIIToUTF16("Also Yellow"); + form.fields[0].set_value(ASCIIToUTF16("Red")); + form.fields[1].set_value(ASCIIToUTF16("Yellow")); + form.fields[2].set_value(ASCIIToUTF16("Also Yellow")); EXPECT_TRUE(form_manager.FillForm(form, WebNode())); // Find the newly-filled form that contains the input element. @@ -2386,9 +2386,9 @@ TEST_F(FormManagerTest, FillFormNonEmptyField) { fields[2]); // Preview the form and verify that the cursor position has been updated. - form.fields[0].value = ASCIIToUTF16("Wyatt"); - form.fields[1].value = ASCIIToUTF16("Earp"); - form.fields[2].value = ASCIIToUTF16("wyatt@example.com"); + form.fields[0].set_value(ASCIIToUTF16("Wyatt")); + form.fields[1].set_value(ASCIIToUTF16("Earp")); + form.fields[2].set_value(ASCIIToUTF16("wyatt@example.com")); EXPECT_TRUE(form_manager.PreviewForm(form, input_element)); EXPECT_EQ(2, input_element.selectionStart()); EXPECT_EQ(5, input_element.selectionEnd()); diff --git a/chrome/renderer/autofill/password_autofill_manager.cc b/chrome/renderer/autofill/password_autofill_manager.cc index a7e03fb..7b397fb 100644 --- a/chrome/renderer/autofill/password_autofill_manager.cc +++ b/chrome/renderer/autofill/password_autofill_manager.cc @@ -52,7 +52,7 @@ static bool FindFormInputElements(WebKit::WebFormElement* fe, // form; it can't be the right one. for (size_t j = 0; j < data.fields.size(); j++) { WebKit::WebVector<WebKit::WebNode> temp_elements; - fe->getNamedElements(data.fields[j].name, temp_elements); + fe->getNamedElements(data.fields[j].name(), temp_elements); // Match the first input element, if any. // |getNamedElements| may return non-input elements where the names match, @@ -73,7 +73,7 @@ static bool FindFormInputElements(WebKit::WebFormElement* fe, // one suffices and if some function needs to deal with multiple // matching elements it can get at them through the FormElement*. // Note: This assignment adds a reference to the InputElement. - result->input_elements[data.fields[j].name] = + result->input_elements[data.fields[j].name()] = temp_elements[i].to<WebKit::WebInputElement>(); found_input = true; } @@ -143,7 +143,7 @@ bool FillForm(FormElements* fe, const webkit_glue::FormData& data) { std::map<string16, string16> data_map; for (size_t i = 0; i < data.fields.size(); i++) - data_map[data.fields[i].name] = data.fields[i].value; + data_map[data.fields[i].name()] = data.fields[i].value(); for (FormInputElementMap::iterator it = fe->input_elements.begin(); it != fe->input_elements.end(); ++it) { @@ -409,12 +409,12 @@ void PasswordAutofillManager::OnFillPasswordForm( // Attach autocomplete listener to enable selecting alternate logins. // First, get pointers to username element. WebKit::WebInputElement username_element = - form_elements->input_elements[form_data.basic_data.fields[0].name]; + form_elements->input_elements[form_data.basic_data.fields[0].name()]; // Get pointer to password element. (We currently only support single // password forms). WebKit::WebInputElement password_element = - form_elements->input_elements[form_data.basic_data.fields[1].name]; + form_elements->input_elements[form_data.basic_data.fields[1].name()]; DCHECK(login_to_password_info_.find(username_element) == login_to_password_info_.end()); @@ -432,8 +432,8 @@ void PasswordAutofillManager::GetSuggestions( const webkit_glue::PasswordFormFillData& fill_data, const string16& input, std::vector<string16>* suggestions) { - if (StartsWith(fill_data.basic_data.fields[0].value, input, false)) - suggestions->push_back(fill_data.basic_data.fields[0].value); + if (StartsWith(fill_data.basic_data.fields[0].value(), input, false)) + suggestions->push_back(fill_data.basic_data.fields[0].value()); webkit_glue::PasswordFormFillData::LoginCollection::const_iterator iter; for (iter = fill_data.additional_logins.begin(); @@ -477,10 +477,10 @@ bool PasswordAutofillManager::FillUserNameAndPassword( string16 password; // Look for any suitable matches to current field text. - if (DoUsernamesMatch(fill_data.basic_data.fields[0].value, current_username, + if (DoUsernamesMatch(fill_data.basic_data.fields[0].value(), current_username, exact_username_match)) { - username = fill_data.basic_data.fields[0].value; - password = fill_data.basic_data.fields[1].value; + username = fill_data.basic_data.fields[0].value(); + password = fill_data.basic_data.fields[1].value(); } else { // Scan additional logins for a match. webkit_glue::PasswordFormFillData::LoginCollection::const_iterator iter; |