| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 const blink::WebFormElement& form_element, | 109 const blink::WebFormElement& form_element, |
| 110 const blink::WebFormControlElement& form_control_element, | 110 const blink::WebFormControlElement& form_control_element, |
| 111 RequirementsMask requirements, | 111 RequirementsMask requirements, |
| 112 ExtractMask extract_mask, | 112 ExtractMask extract_mask, |
| 113 FormData* form, | 113 FormData* form, |
| 114 FormFieldData* field); | 114 FormFieldData* field); |
| 115 | 115 |
| 116 // Finds the form that contains |element| and returns it in |form|. Fills | 116 // Finds the form that contains |element| and returns it in |form|. Fills |
| 117 // |field| with the |FormField| representation for element. | 117 // |field| with the |FormField| representation for element. |
| 118 // Returns false if the form is not found or cannot be serialized. | 118 // Returns false if the form is not found or cannot be serialized. |
| 119 bool FindFormAndFieldForInputElement(const blink::WebInputElement& element, | 119 bool FindFormAndFieldForFormControlElement( |
| 120 FormData* form, | 120 const blink::WebFormControlElement& element, |
| 121 FormFieldData* field, | 121 FormData* form, |
| 122 RequirementsMask requirements); | 122 FormFieldData* field, |
| 123 RequirementsMask requirements); |
| 123 | 124 |
| 124 // Fills the form represented by |form|. |element| is the input element that | 125 // Fills the form represented by |form|. |element| is the input element that |
| 125 // initiated the auto-fill process. | 126 // initiated the auto-fill process. |
| 126 void FillForm(const FormData& form, | 127 void FillForm(const FormData& form, |
| 127 const blink::WebInputElement& element); | 128 const blink::WebFormControlElement& element); |
| 128 | 129 |
| 129 // Fills focusable and non-focusable form control elements within |form_element| | 130 // Fills focusable and non-focusable form control elements within |form_element| |
| 130 // with field data from |form_data|. | 131 // with field data from |form_data|. |
| 131 void FillFormIncludingNonFocusableElements( | 132 void FillFormIncludingNonFocusableElements( |
| 132 const FormData& form_data, | 133 const FormData& form_data, |
| 133 const blink::WebFormElement& form_element); | 134 const blink::WebFormElement& form_element); |
| 134 | 135 |
| 135 // Fills all (including disabled, read-only and non-focusable) form control | 136 // Fills all (including disabled, read-only and non-focusable) form control |
| 136 // elements within |form_element| with field data from |form_data|. | 137 // elements within |form_element| with field data from |form_data|. |
| 137 void FillFormForAllElements( | 138 void FillFormForAllElements( |
| 138 const FormData& form_data, | 139 const FormData& form_data, |
| 139 const blink::WebFormElement& form_element); | 140 const blink::WebFormElement& form_element); |
| 140 | 141 |
| 141 // Previews the form represented by |form|. |element| is the input element that | 142 // Previews the form represented by |form|. |element| is the input element that |
| 142 // initiated the preview process. | 143 // initiated the preview process. |
| 143 void PreviewForm(const FormData& form, | 144 void PreviewForm(const FormData& form, |
| 144 const blink::WebInputElement& element); | 145 const blink::WebFormControlElement& element); |
| 145 | 146 |
| 146 // Clears the placeholder values and the auto-filled background for any fields | 147 // Clears the placeholder values and the auto-filled background for any fields |
| 147 // in the form containing |node| that have been previewed. Resets the | 148 // in the form containing |node| that have been previewed. Resets the |
| 148 // autofilled state of |node| to |was_autofilled|. Returns false if the form is | 149 // autofilled state of |node| to |was_autofilled|. Returns false if the form is |
| 149 // not found. | 150 // not found. |
| 150 bool ClearPreviewedFormWithElement(const blink::WebInputElement& element, | 151 bool ClearPreviewedFormWithElement(const blink::WebFormControlElement& element, |
| 151 bool was_autofilled); | 152 bool was_autofilled); |
| 152 | 153 |
| 153 // Returns true if |form| has any auto-filled fields. | 154 // Returns true if |form| has any auto-filled fields. |
| 154 bool FormWithElementIsAutofilled(const blink::WebInputElement& element); | 155 bool FormWithElementIsAutofilled(const blink::WebInputElement& element); |
| 155 | 156 |
| 156 // Checks if the webpage is empty. | 157 // Checks if the webpage is empty. |
| 157 // This kind of webpage is considered as empty: | 158 // This kind of webpage is considered as empty: |
| 158 // <html> | 159 // <html> |
| 159 // <head> | 160 // <head> |
| 160 // <head/> | 161 // <head/> |
| 161 // <body> | 162 // <body> |
| 162 // <body/> | 163 // <body/> |
| 163 // <html/> | 164 // <html/> |
| 164 // Meta, script and title tags don't influence the emptiness of a webpage. | 165 // Meta, script and title tags don't influence the emptiness of a webpage. |
| 165 bool IsWebpageEmpty(const blink::WebFrame* frame); | 166 bool IsWebpageEmpty(const blink::WebFrame* frame); |
| 166 | 167 |
| 167 // This function checks whether the children of |element| | 168 // This function checks whether the children of |element| |
| 168 // are of the type <script>, <meta>, or <title>. | 169 // are of the type <script>, <meta>, or <title>. |
| 169 bool IsWebElementEmpty(const blink::WebElement& element); | 170 bool IsWebElementEmpty(const blink::WebElement& element); |
| 170 | 171 |
| 171 // Return a gfx::RectF that is the bounding box for |element| scaled by |scale|. | 172 // Return a gfx::RectF that is the bounding box for |element| scaled by |scale|. |
| 172 gfx::RectF GetScaledBoundingBox(float scale, blink::WebInputElement* element); | 173 gfx::RectF GetScaledBoundingBox(float scale, |
| 174 blink::WebFormControlElement* element); |
| 173 | 175 |
| 174 } // namespace autofill | 176 } // namespace autofill |
| 175 | 177 |
| 176 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ | 178 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ |
| OLD | NEW |