OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_AUTOFILL_FORM_CACHE_H_ | |
6 #define CHROME_RENDERER_AUTOFILL_FORM_CACHE_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 #include <vector> | |
11 | |
12 #include "base/string16.h" | |
13 | |
14 struct FormData; | |
15 struct FormDataPredictions; | |
16 | |
17 namespace WebKit { | |
18 class WebDocument; | |
19 class WebFormElement; | |
20 class WebFrame; | |
21 class WebInputElement; | |
22 class WebSelectElement; | |
23 } | |
24 | |
25 namespace autofill { | |
26 | |
27 // Manages the forms in a RenderView. | |
28 class FormCache { | |
29 public: | |
30 FormCache(); | |
31 ~FormCache(); | |
32 | |
33 // Scans the DOM in |frame| extracting and storing forms. | |
34 // Returns a vector of the extracted forms. | |
35 void ExtractForms(const WebKit::WebFrame& frame, | |
36 std::vector<FormData>* forms); | |
37 | |
38 // Scans the DOM in |frame| extracting and storing forms. | |
39 // Returns a vector of the extracted forms and vector of associated web | |
40 // form elements. | |
41 void ExtractFormsAndFormElements( | |
42 const WebKit::WebFrame& frame, | |
43 std::vector<FormData>* forms, | |
44 std::vector<WebKit::WebFormElement>* web_form_elements); | |
45 | |
46 // Resets the forms for the specified |frame|. | |
47 void ResetFrame(const WebKit::WebFrame& frame); | |
48 | |
49 // Clears the values of all input elements in the form that contains | |
50 // |element|. Returns false if the form is not found. | |
51 bool ClearFormWithElement(const WebKit::WebInputElement& element); | |
52 | |
53 // For each field in the |form|, sets the field's placeholder text to the | |
54 // field's overall predicted type. Also sets the title to include the field's | |
55 // heuristic type, server type, and signature; as well as the form's signature | |
56 // and the experiment id for the server predictions. | |
57 bool ShowPredictions(const FormDataPredictions& form); | |
58 | |
59 private: | |
60 // The cached web frames. | |
61 std::set<WebKit::WebDocument> web_documents_; | |
62 | |
63 // The cached initial values for <select> elements. | |
64 std::map<const WebKit::WebSelectElement, string16> initial_select_values_; | |
65 | |
66 // The cached initial values for checkable <input> elements. | |
67 std::map<const WebKit::WebInputElement, bool> initial_checked_state_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(FormCache); | |
70 }; | |
71 | |
72 } // namespace autofill | |
73 | |
74 #endif // CHROME_RENDERER_AUTOFILL_FORM_CACHE_H_ | |
OLD | NEW |