OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Recursively checks whether |node| or any of its children have a non-empty | 73 // Recursively checks whether |node| or any of its children have a non-empty |
74 // bounding box. | 74 // bounding box. |
75 bool IsWebNodeVisible(const blink::WebNode& node); | 75 bool IsWebNodeVisible(const blink::WebNode& node); |
76 | 76 |
77 // Returns the form's |name| attribute if non-empty; otherwise the form's |id| | 77 // Returns the form's |name| attribute if non-empty; otherwise the form's |id| |
78 // attribute. | 78 // attribute. |
79 const base::string16 GetFormIdentifier(const blink::WebFormElement& form); | 79 const base::string16 GetFormIdentifier(const blink::WebFormElement& form); |
80 | 80 |
81 // Returns all the auto-fillable form control elements in |control_elements|. | 81 // Returns all the auto-fillable form control elements in |control_elements|. |
82 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsFromSet( | 82 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsFromSet( |
83 const blink::WebVector<blink::WebFormControlElement>& control_elements, | 83 const blink::WebVector<blink::WebFormControlElement>& control_elements); |
84 RequirementsMask requirements); | |
85 | 84 |
86 // Returns all the auto-fillable form control elements in |form_element|. | 85 // Returns all the auto-fillable form control elements in |form_element|. |
87 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsInForm( | 86 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsInForm( |
88 const blink::WebFormElement& form_element, | 87 const blink::WebFormElement& form_element); |
89 RequirementsMask requirements); | |
90 | 88 |
91 // Fills out a FormField object from a given WebFormControlElement. | 89 // Fills out a FormField object from a given WebFormControlElement. |
92 // |extract_mask|: See the enum ExtractMask above for details. | 90 // |extract_mask|: See the enum ExtractMask above for details. |
93 void WebFormControlElementToFormField( | 91 void WebFormControlElementToFormField( |
94 const blink::WebFormControlElement& element, | 92 const blink::WebFormControlElement& element, |
95 ExtractMask extract_mask, | 93 ExtractMask extract_mask, |
96 FormFieldData* field); | 94 FormFieldData* field); |
97 | 95 |
98 // Fills |form| with the FormData object corresponding to the |form_element|. | 96 // Fills |form| with the FormData object corresponding to the |form_element|. |
99 // If |field| is non-NULL, also fills |field| with the FormField object | 97 // If |field| is non-NULL, also fills |field| with the FormField object |
100 // corresponding to the |form_control_element|. | 98 // corresponding to the |form_control_element|. |extract_mask| controls what |
101 // |extract_mask| controls what data is extracted. | 99 // data is extracted. Returns true if |form| is filled out. Also returns false |
102 // Returns true if |form| is filled out; it's possible that the |form_element| | 100 // if there are no fields or too many fields in the |form|. |
103 // won't meet the |requirements|. Also returns false if there are no fields or | |
104 // too many fields in the |form|. | |
105 bool WebFormElementToFormData( | 101 bool WebFormElementToFormData( |
106 const blink::WebFormElement& form_element, | 102 const blink::WebFormElement& form_element, |
107 const blink::WebFormControlElement& form_control_element, | 103 const blink::WebFormControlElement& form_control_element, |
108 RequirementsMask requirements, | |
109 ExtractMask extract_mask, | 104 ExtractMask extract_mask, |
110 FormData* form, | 105 FormData* form, |
111 FormFieldData* field); | 106 FormFieldData* field); |
112 | 107 |
113 // Get all form control elements from |elements| that are not part of a form. | 108 // Get all form control elements from |elements| that are not part of a form. |
114 // If |fieldsets| is not NULL, also append the fieldsets encountered that are | 109 // If |fieldsets| is not NULL, also append the fieldsets encountered that are |
115 // not part of a form. | 110 // not part of a form. |
116 std::vector<blink::WebFormControlElement> | 111 std::vector<blink::WebFormControlElement> |
117 GetUnownedAutofillableFormFieldElements( | 112 GetUnownedAutofillableFormFieldElements( |
118 const blink::WebElementCollection& elements, | 113 const blink::WebElementCollection& elements, |
119 std::vector<blink::WebElement>* fieldsets); | 114 std::vector<blink::WebElement>* fieldsets); |
120 | 115 |
121 // Fills |form| with the form data derived from |fieldsets|, |control_elements| | 116 // Fills |form| with the form data derived from |fieldsets|, |control_elements| |
122 // and |origin|. If |field| is non-NULL, fill it with the FormField | 117 // and |origin|. If |field| is non-NULL, fill it with the FormField |
123 // representation for |element|. | 118 // representation for |element|. |
124 // |extract_mask| usage and the return value are the same as | 119 // |extract_mask| usage and the return value are the same as |
125 // WebFormElementToFormData() above. | 120 // WebFormElementToFormData() above. |
126 bool UnownedFormElementsAndFieldSetsToFormData( | 121 bool UnownedFormElementsAndFieldSetsToFormData( |
127 const std::vector<blink::WebElement>& fieldsets, | 122 const std::vector<blink::WebElement>& fieldsets, |
128 const std::vector<blink::WebFormControlElement>& control_elements, | 123 const std::vector<blink::WebFormControlElement>& control_elements, |
129 const blink::WebFormControlElement* element, | 124 const blink::WebFormControlElement* element, |
130 const GURL& origin, | 125 const GURL& origin, |
131 RequirementsMask requirements, | |
132 ExtractMask extract_mask, | 126 ExtractMask extract_mask, |
133 FormData* form, | 127 FormData* form, |
134 FormFieldData* field); | 128 FormFieldData* field); |
135 | 129 |
136 // Finds the form that contains |element| and returns it in |form|. If |field| | 130 // Finds the form that contains |element| and returns it in |form|. If |field| |
137 // is non-NULL, fill it with the FormField representation for |element|. | 131 // is non-NULL, fill it with the FormField representation for |element|. |
138 // Returns false if the form is not found or cannot be serialized. | 132 // Returns false if the form is not found or cannot be serialized. |
139 bool FindFormAndFieldForFormControlElement( | 133 bool FindFormAndFieldForFormControlElement( |
140 const blink::WebFormControlElement& element, | 134 const blink::WebFormControlElement& element, |
141 FormData* form, | 135 FormData* form, |
142 FormFieldData* field, | 136 FormFieldData* field); |
143 RequirementsMask requirements); | |
144 | 137 |
145 // Fills the form represented by |form|. |element| is the input element that | 138 // Fills the form represented by |form|. |element| is the input element that |
146 // initiated the auto-fill process. | 139 // initiated the auto-fill process. |
147 void FillForm(const FormData& form, | 140 void FillForm(const FormData& form, |
148 const blink::WebFormControlElement& element); | 141 const blink::WebFormControlElement& element); |
149 | 142 |
150 // Fills focusable and non-focusable form control elements within |form_element| | 143 // Fills focusable and non-focusable form control elements within |form_element| |
151 // with field data from |form_data|. | 144 // with field data from |form_data|. |
152 void FillFormIncludingNonFocusableElements( | 145 void FillFormIncludingNonFocusableElements( |
153 const FormData& form_data, | 146 const FormData& form_data, |
(...skipping 25 matching lines...) Expand all Loading... |
179 // This function checks whether the children of |element| | 172 // This function checks whether the children of |element| |
180 // are of the type <script>, <meta>, or <title>. | 173 // are of the type <script>, <meta>, or <title>. |
181 bool IsWebElementEmpty(const blink::WebElement& element); | 174 bool IsWebElementEmpty(const blink::WebElement& element); |
182 | 175 |
183 // Return a gfx::RectF that is the bounding box for |element| scaled by |scale|. | 176 // Return a gfx::RectF that is the bounding box for |element| scaled by |scale|. |
184 gfx::RectF GetScaledBoundingBox(float scale, blink::WebElement* element); | 177 gfx::RectF GetScaledBoundingBox(float scale, blink::WebElement* element); |
185 | 178 |
186 } // namespace autofill | 179 } // namespace autofill |
187 | 180 |
188 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ | 181 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ |
OLD | NEW |