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_CACHE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 struct FormData; | 25 struct FormData; |
26 struct FormDataPredictions; | 26 struct FormDataPredictions; |
27 | 27 |
28 // Manages the forms in a RenderView. | 28 // Manages the forms in a RenderView. |
29 class FormCache { | 29 class FormCache { |
30 public: | 30 public: |
31 FormCache(); | 31 FormCache(); |
32 ~FormCache(); | 32 ~FormCache(); |
33 | 33 |
34 // Scans the DOM in |frame| extracting and storing forms that have not been | 34 // Scans the DOM in |frame| extracting and storing forms. |
35 // seen before. Fills |forms| with extracted forms. | 35 // Fills |forms| with extracted forms. |
36 void ExtractNewForms(const blink::WebFrame& frame, | 36 void ExtractForms(const blink::WebFrame& frame, |
37 std::vector<FormData>* forms); | 37 std::vector<FormData>* forms); |
| 38 |
| 39 // Scans the DOM in |frame| extracting and storing forms. |
| 40 // Fills |forms| with extracted forms and |web_form_elements| with associated |
| 41 // web form elements. Returns true if there are unextracted forms due to |
| 42 // |minimum_required_fields| limit, else false. |
| 43 bool ExtractFormsAndFormElements( |
| 44 const blink::WebFrame& frame, |
| 45 size_t minimum_required_fields, |
| 46 std::vector<FormData>* forms, |
| 47 std::vector<blink::WebFormElement>* web_form_elements); |
38 | 48 |
39 // Resets the forms for the specified |frame|. | 49 // Resets the forms for the specified |frame|. |
40 void ResetFrame(const blink::WebFrame& frame); | 50 void ResetFrame(const blink::WebFrame& frame); |
41 | 51 |
42 // Clears the values of all input elements in the form that contains | 52 // Clears the values of all input elements in the form that contains |
43 // |element|. Returns false if the form is not found. | 53 // |element|. Returns false if the form is not found. |
44 bool ClearFormWithElement(const blink::WebFormControlElement& element); | 54 bool ClearFormWithElement(const blink::WebFormControlElement& element); |
45 | 55 |
46 // For each field in the |form|, sets the field's placeholder text to the | 56 // For each field in the |form|, sets the field's placeholder text to the |
47 // field's overall predicted type. Also sets the title to include the field's | 57 // field's overall predicted type. Also sets the title to include the field's |
48 // heuristic type, server type, and signature; as well as the form's signature | 58 // heuristic type, server type, and signature; as well as the form's signature |
49 // and the experiment id for the server predictions. | 59 // and the experiment id for the server predictions. |
50 bool ShowPredictions(const FormDataPredictions& form); | 60 bool ShowPredictions(const FormDataPredictions& form); |
51 | 61 |
52 private: | 62 private: |
53 // The cached web frames. | 63 // The cached web frames. |
54 std::set<blink::WebDocument> web_documents_; | 64 std::set<blink::WebDocument> web_documents_; |
55 | 65 |
56 // The cached forms per frame. Used to prevent re-extraction of forms. | |
57 std::map<const blink::WebFrame*, std::set<FormData> > parsed_forms_; | |
58 | |
59 // The cached initial values for <select> elements. | 66 // The cached initial values for <select> elements. |
60 std::map<const blink::WebSelectElement, base::string16> | 67 std::map<const blink::WebSelectElement, base::string16> |
61 initial_select_values_; | 68 initial_select_values_; |
62 | 69 |
63 // The cached initial values for checkable <input> elements. | 70 // The cached initial values for checkable <input> elements. |
64 std::map<const blink::WebInputElement, bool> initial_checked_state_; | 71 std::map<const blink::WebInputElement, bool> initial_checked_state_; |
65 | 72 |
66 DISALLOW_COPY_AND_ASSIGN(FormCache); | 73 DISALLOW_COPY_AND_ASSIGN(FormCache); |
67 }; | 74 }; |
68 | 75 |
69 } // namespace autofill | 76 } // namespace autofill |
70 | 77 |
71 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ | 78 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ |
OLD | NEW |