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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 if (!input_element.isEnabled()) | 611 if (!input_element.isEnabled()) |
612 continue; | 612 continue; |
613 | 613 |
614 input_element.setValue(string16()); | 614 input_element.setValue(string16()); |
615 input_element.setAutofilled(false); | 615 input_element.setAutofilled(false); |
616 } | 616 } |
617 | 617 |
618 return true; | 618 return true; |
619 } | 619 } |
620 | 620 |
621 bool FormManager::ClearPreviewedForm(const FormData& form) { | 621 bool FormManager::ClearPreviewedFormWithNode(const WebKit::WebNode& node) { |
622 FormElement* form_element = NULL; | 622 FormElement* form_element = NULL; |
623 if (!FindCachedFormElement(form, &form_element)) | 623 if (!FindCachedFormElementWithNode(node, &form_element)) |
624 return false; | 624 return false; |
625 | 625 |
626 for (size_t i = 0; i < form_element->control_elements.size(); ++i) { | 626 for (size_t i = 0; i < form_element->control_elements.size(); ++i) { |
627 WebFormControlElement* element = &form_element->control_elements[i]; | 627 WebFormControlElement* element = &form_element->control_elements[i]; |
628 | 628 |
629 // Only input elements can be previewed. | 629 // Only input elements can be previewed. |
630 if (element->formControlType() != WebString::fromUTF8("text")) | 630 if (element->formControlType() != WebString::fromUTF8("text")) |
631 continue; | 631 continue; |
632 | 632 |
633 // If the input element has not been auto-filled, FormManager has not | 633 // If the input element has not been auto-filled, FormManager has not |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 return; | 894 return; |
895 | 895 |
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 } | 903 } |
OLD | NEW |