| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ | 5 #ifndef CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ |
| 6 #define CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ | 6 #define CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 | 12 |
| 13 namespace webkit_glue { | 13 namespace webkit { |
| 14 namespace forms { |
| 14 struct FormData; | 15 struct FormData; |
| 15 struct FormField; | 16 struct FormField; |
| 16 } // namespace webkit_glue | 17 } |
| 18 } |
| 17 | 19 |
| 18 namespace WebKit { | 20 namespace WebKit { |
| 19 class WebFormElement; | 21 class WebFormElement; |
| 20 class WebFormControlElement; | 22 class WebFormControlElement; |
| 21 class WebInputElement; | 23 class WebInputElement; |
| 22 } // namespace WebKit | 24 } |
| 23 | 25 |
| 24 namespace autofill { | 26 namespace autofill { |
| 25 | 27 |
| 26 // A bit field mask for form requirements. | 28 // A bit field mask for form requirements. |
| 27 enum RequirementsMask { | 29 enum RequirementsMask { |
| 28 REQUIRE_NONE = 0, // No requirements. | 30 REQUIRE_NONE = 0, // No requirements. |
| 29 REQUIRE_AUTOCOMPLETE = 1, // Require that autocomplete != off. | 31 REQUIRE_AUTOCOMPLETE = 1, // Require that autocomplete != off. |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 // A bit field mask to extract data from WebFormControlElement. | 34 // A bit field mask to extract data from WebFormControlElement. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 void ExtractAutofillableElements( | 59 void ExtractAutofillableElements( |
| 58 const WebKit::WebFormElement& form_element, | 60 const WebKit::WebFormElement& form_element, |
| 59 RequirementsMask requirements, | 61 RequirementsMask requirements, |
| 60 std::vector<WebKit::WebFormControlElement>* autofillable_elements); | 62 std::vector<WebKit::WebFormControlElement>* autofillable_elements); |
| 61 | 63 |
| 62 // Fills out a FormField object from a given WebFormControlElement. | 64 // Fills out a FormField object from a given WebFormControlElement. |
| 63 // |extract_mask|: See the enum ExtractMask above for details. | 65 // |extract_mask|: See the enum ExtractMask above for details. |
| 64 void WebFormControlElementToFormField( | 66 void WebFormControlElementToFormField( |
| 65 const WebKit::WebFormControlElement& element, | 67 const WebKit::WebFormControlElement& element, |
| 66 ExtractMask extract_mask, | 68 ExtractMask extract_mask, |
| 67 webkit_glue::FormField* field); | 69 webkit::forms::FormField* field); |
| 68 | 70 |
| 69 // Fills |form| with the FormData object corresponding to the |form_element|. | 71 // Fills |form| with the FormData object corresponding to the |form_element|. |
| 70 // If |field| is non-NULL, also fills |field| with the FormField object | 72 // If |field| is non-NULL, also fills |field| with the FormField object |
| 71 // corresponding to the |form_control_element|. | 73 // corresponding to the |form_control_element|. |
| 72 // |extract_mask| controls what data is extracted. | 74 // |extract_mask| controls what data is extracted. |
| 73 // Returns true if |form| is filled out; it's possible that the |form_element| | 75 // Returns true if |form| is filled out; it's possible that the |form_element| |
| 74 // won't meet the |requirements|. Also returns false if there are no fields | 76 // won't meet the |requirements|. Also returns false if there are no fields |
| 75 // in the |form|. | 77 // in the |form|. |
| 76 bool WebFormElementToFormData( | 78 bool WebFormElementToFormData( |
| 77 const WebKit::WebFormElement& form_element, | 79 const WebKit::WebFormElement& form_element, |
| 78 const WebKit::WebFormControlElement& form_control_element, | 80 const WebKit::WebFormControlElement& form_control_element, |
| 79 RequirementsMask requirements, | 81 RequirementsMask requirements, |
| 80 ExtractMask extract_mask, | 82 ExtractMask extract_mask, |
| 81 webkit_glue::FormData* form, | 83 webkit::forms::FormData* form, |
| 82 webkit_glue::FormField* field); | 84 webkit::forms::FormField* field); |
| 83 | 85 |
| 84 // Finds the form that contains |element| and returns it in |form|. Fills | 86 // Finds the form that contains |element| and returns it in |form|. Fills |
| 85 // |field| with the |FormField| representation for element. | 87 // |field| with the |FormField| representation for element. |
| 86 // Returns false if the form is not found. | 88 // Returns false if the form is not found. |
| 87 bool FindFormAndFieldForInputElement(const WebKit::WebInputElement& element, | 89 bool FindFormAndFieldForInputElement(const WebKit::WebInputElement& element, |
| 88 webkit_glue::FormData* form, | 90 webkit::forms::FormData* form, |
| 89 webkit_glue::FormField* field, | 91 webkit::forms::FormField* field, |
| 90 RequirementsMask requirements); | 92 RequirementsMask requirements); |
| 91 | 93 |
| 92 // Fills the form represented by |form|. |element| is the input element that | 94 // Fills the form represented by |form|. |element| is the input element that |
| 93 // initiated the auto-fill process. | 95 // initiated the auto-fill process. |
| 94 void FillForm(const webkit_glue::FormData& form, | 96 void FillForm(const webkit::forms::FormData& form, |
| 95 const WebKit::WebInputElement& element); | 97 const WebKit::WebInputElement& element); |
| 96 | 98 |
| 97 // Previews the form represented by |form|. |element| is the input element that | 99 // Previews the form represented by |form|. |element| is the input element that |
| 98 // initiated the preview process. | 100 // initiated the preview process. |
| 99 void PreviewForm(const webkit_glue::FormData& form, | 101 void PreviewForm(const webkit::forms::FormData& form, |
| 100 const WebKit::WebInputElement& element); | 102 const WebKit::WebInputElement& element); |
| 101 | 103 |
| 102 // Clears the placeholder values and the auto-filled background for any fields | 104 // Clears the placeholder values and the auto-filled background for any fields |
| 103 // in the form containing |node| that have been previewed. Resets the | 105 // in the form containing |node| that have been previewed. Resets the |
| 104 // autofilled state of |node| to |was_autofilled|. Returns false if the form is | 106 // autofilled state of |node| to |was_autofilled|. Returns false if the form is |
| 105 // not found. | 107 // not found. |
| 106 bool ClearPreviewedFormWithElement(const WebKit::WebInputElement& element, | 108 bool ClearPreviewedFormWithElement(const WebKit::WebInputElement& element, |
| 107 bool was_autofilled); | 109 bool was_autofilled); |
| 108 | 110 |
| 109 // Returns true if |form| has any auto-filled fields. | 111 // Returns true if |form| has any auto-filled fields. |
| 110 bool FormWithElementIsAutofilled(const WebKit::WebInputElement& element); | 112 bool FormWithElementIsAutofilled(const WebKit::WebInputElement& element); |
| 111 | 113 |
| 112 } // namespace autofill | 114 } // namespace autofill |
| 113 | 115 |
| 114 #endif // CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ | 116 #endif // CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ |
| OLD | NEW |