Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: components/autofill/content/renderer/form_autofill_util.h

Issue 804443002: Autofill: Modify various utility function to deal with unowned form fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more tests Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "third_party/WebKit/public/platform/WebVector.h" 11 #include "third_party/WebKit/public/platform/WebVector.h"
12 #include "third_party/WebKit/public/web/WebElementCollection.h"
12 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
13 14
14 class GURL; 15 class GURL;
15 16
16 namespace blink { 17 namespace blink {
17 class WebDocument; 18 class WebDocument;
18 class WebElement; 19 class WebElement;
19 class WebFormElement; 20 class WebFormElement;
20 class WebFormControlElement; 21 class WebFormControlElement;
21 class WebFrame; 22 class WebFrame;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // won't meet the |requirements|. Also returns false if there are no fields or 108 // won't meet the |requirements|. Also returns false if there are no fields or
108 // too many fields in the |form|. 109 // too many fields in the |form|.
109 bool WebFormElementToFormData( 110 bool WebFormElementToFormData(
110 const blink::WebFormElement& form_element, 111 const blink::WebFormElement& form_element,
111 const blink::WebFormControlElement& form_control_element, 112 const blink::WebFormControlElement& form_control_element,
112 RequirementsMask requirements, 113 RequirementsMask requirements,
113 ExtractMask extract_mask, 114 ExtractMask extract_mask,
114 FormData* form, 115 FormData* form,
115 FormFieldData* field); 116 FormFieldData* field);
116 117
118 // Get all form control elements from |elements| that are not part of a form.
119 // If |fieldsets| is not NULL, also append the fieldsets encountered that are
120 // not part of a form.
121 std::vector<blink::WebFormControlElement>
122 GetUnownedAutofillableFormFieldElements(
123 const blink::WebElementCollection& elements,
124 std::vector<blink::WebElement>* fieldsets);
125
117 // Fills |form| with the form data derived from |fieldsets|, |control_elements| 126 // Fills |form| with the form data derived from |fieldsets|, |control_elements|
118 // and |origin|. |extract_mask| usage and the return value are the same as 127 // and |origin|. If |field| is non-NULL, fill it with the FormField
128 // representation for |element|.
129 // |extract_mask| usage and the return value are the same as
119 // WebFormElementToFormData() above. 130 // WebFormElementToFormData() above.
120 bool UnownedFormElementsAndFieldSetsToFormData( 131 bool UnownedFormElementsAndFieldSetsToFormData(
121 const std::vector<blink::WebElement>& fieldsets, 132 const std::vector<blink::WebElement>& fieldsets,
122 const std::vector<blink::WebFormControlElement>& control_elements, 133 const std::vector<blink::WebFormControlElement>& control_elements,
134 const blink::WebFormControlElement* element,
123 const GURL& origin, 135 const GURL& origin,
136 RequirementsMask requirements,
124 ExtractMask extract_mask, 137 ExtractMask extract_mask,
125 FormData* form); 138 FormData* form,
139 FormFieldData* field);
126 140
127 // Finds the form that contains |element| and returns it in |form|. Fills 141 // Finds the form that contains |element| and returns it in |form|. If |field|
128 // |field| with the |FormField| representation for element. 142 // is non-NULL, fill it with the FormField representation for |element|.
129 // Returns false if the form is not found or cannot be serialized. 143 // Returns false if the form is not found or cannot be serialized.
130 bool FindFormAndFieldForFormControlElement( 144 bool FindFormAndFieldForFormControlElement(
131 const blink::WebFormControlElement& element, 145 const blink::WebFormControlElement& element,
132 FormData* form, 146 FormData* form,
133 FormFieldData* field, 147 FormFieldData* field,
134 RequirementsMask requirements); 148 RequirementsMask requirements);
135 149
136 // Fills the form represented by |form|. |element| is the input element that 150 // Fills the form represented by |form|. |element| is the input element that
137 // initiated the auto-fill process. 151 // initiated the auto-fill process.
138 void FillForm(const FormData& form, 152 void FillForm(const FormData& form,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // are of the type <script>, <meta>, or <title>. 185 // are of the type <script>, <meta>, or <title>.
172 bool IsWebElementEmpty(const blink::WebElement& element); 186 bool IsWebElementEmpty(const blink::WebElement& element);
173 187
174 // Return a gfx::RectF that is the bounding box for |element| scaled by |scale|. 188 // Return a gfx::RectF that is the bounding box for |element| scaled by |scale|.
175 gfx::RectF GetScaledBoundingBox(float scale, 189 gfx::RectF GetScaledBoundingBox(float scale,
176 blink::WebFormControlElement* element); 190 blink::WebFormControlElement* element);
177 191
178 } // namespace autofill 192 } // namespace autofill
179 193
180 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_ 194 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_AUTOFILL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698