OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/form_manager.h" | 5 #include "chrome/renderer/form_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/scoped_vector.h" | 8 #include "base/scoped_vector.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 void FormManager::ExtractForms(const WebFrame* frame) { | 482 void FormManager::ExtractForms(const WebFrame* frame) { |
483 DCHECK(frame); | 483 DCHECK(frame); |
484 | 484 |
485 // Reset the vector of FormElements for this frame. | 485 // Reset the vector of FormElements for this frame. |
486 ResetFrame(frame); | 486 ResetFrame(frame); |
487 | 487 |
488 WebVector<WebFormElement> web_forms; | 488 WebVector<WebFormElement> web_forms; |
489 frame->forms(web_forms); | 489 frame->forms(web_forms); |
490 | 490 |
491 for (size_t i = 0; i < web_forms.size(); ++i) { | 491 for (size_t i = 0; i < web_forms.size(); ++i) { |
492 FormElement* form_element = new FormElement; | 492 FormElement* form_elements = new FormElement; |
493 form_element->form_element = web_forms[i]; | 493 form_elements->form_element = web_forms[i]; |
494 | 494 |
495 WebVector<WebFormControlElement> control_elements; | 495 WebVector<WebFormControlElement> control_elements; |
496 form_element->form_element.getFormControlElements(control_elements); | 496 form_elements->form_element.getFormControlElements(control_elements); |
497 for (size_t j = 0; j < control_elements.size(); ++j) { | 497 for (size_t j = 0; j < control_elements.size(); ++j) { |
498 WebFormControlElement element = control_elements[j]; | 498 WebFormControlElement element = control_elements[j]; |
499 form_element->control_elements.push_back(element); | 499 form_elements->control_elements.push_back(element); |
500 | 500 |
501 // Save original values of "select-one" inputs so we can restore them | 501 // Save original values of "select-one" inputs so we can restore them |
502 // when |ClearFormWithNode()| is invoked. | 502 // when |ClearFormWithNode()| is invoked. |
503 if (element.formControlType() == WebString::fromUTF8("select-one")) { | 503 if (element.formControlType() == WebString::fromUTF8("select-one")) { |
504 WebFormControlElement& e = const_cast<WebFormControlElement&>(element); | 504 WebFormControlElement& e = const_cast<WebFormControlElement&>(element); |
505 WebSelectElement select_element = e.to<WebSelectElement>(); | 505 WebSelectElement select_element = e.to<WebSelectElement>(); |
506 string16 value = select_element.value(); | 506 string16 value = select_element.value(); |
507 form_element->control_values.push_back(value); | 507 form_elements->control_values.push_back(value); |
508 } else { | 508 } else { |
509 form_element->control_values.push_back(string16()); | 509 form_elements->control_values.push_back(string16()); |
510 } | 510 } |
511 } | 511 } |
512 | 512 |
513 form_elements_.push_back(form_element); | 513 form_elements_.push_back(form_elements); |
514 } | 514 } |
515 } | 515 } |
516 | 516 |
517 void FormManager::GetFormsInFrame(const WebFrame* frame, | 517 void FormManager::GetFormsInFrame(const WebFrame* frame, |
518 RequirementsMask requirements, | 518 RequirementsMask requirements, |
519 std::vector<FormData>* forms) { | 519 std::vector<FormData>* forms) { |
520 DCHECK(frame); | 520 DCHECK(frame); |
521 DCHECK(forms); | 521 DCHECK(forms); |
522 | 522 |
523 for (FormElementList::const_iterator form_iter = | 523 for (FormElementList::const_iterator form_iter = |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 WebInputElement input_element = field->to<WebInputElement>(); | 896 WebInputElement input_element = field->to<WebInputElement>(); |
897 | 897 |
898 // If the maxlength attribute contains a negative value, maxLength() | 898 // If the maxlength attribute contains a negative value, maxLength() |
899 // returns the default maxlength value. | 899 // returns the default maxlength value. |
900 input_element.setSuggestedValue( | 900 input_element.setSuggestedValue( |
901 data->value().substr(0, input_element.maxLength())); | 901 data->value().substr(0, input_element.maxLength())); |
902 input_element.setAutofilled(true); | 902 input_element.setAutofilled(true); |
903 if (is_initiating_node) | 903 if (is_initiating_node) |
904 input_element.setSelectionRange(0, input_element.suggestedValue().length()); | 904 input_element.setSelectionRange(0, input_element.suggestedValue().length()); |
905 } | 905 } |
OLD | NEW |