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 COMPONENTS_AUTOFILL_RENDERER_FORM_CACHE_H_ | |
6 #define COMPONENTS_AUTOFILL_RENDERER_FORM_CACHE_H_ | |
7 | |
8 #include <map> | |
9 #include <set> | |
10 #include <vector> | |
11 | |
12 #include "base/string16.h" | |
13 | |
14 namespace WebKit { | |
15 class WebDocument; | |
16 class WebFormElement; | |
17 class WebFrame; | |
18 class WebInputElement; | |
19 class WebSelectElement; | |
20 } | |
21 | |
22 namespace autofill { | |
23 | |
24 struct FormData; | |
25 struct FormDataPredictions; | |
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 // Fills |forms| with 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 // Fills |forms| with extracted forms and |web_form_elements| with associated | |
40 // web form elements. Returns true if there are unextracted forms due to | |
41 // |minimum_required_fields| limit, else false. | |
42 bool ExtractFormsAndFormElements( | |
43 const WebKit::WebFrame& frame, | |
44 size_t minimum_required_fields, | |
45 std::vector<FormData>* forms, | |
46 std::vector<WebKit::WebFormElement>* web_form_elements); | |
47 | |
48 // Resets the forms for the specified |frame|. | |
49 void ResetFrame(const WebKit::WebFrame& frame); | |
50 | |
51 // Clears the values of all input elements in the form that contains | |
52 // |element|. Returns false if the form is not found. | |
53 bool ClearFormWithElement(const WebKit::WebInputElement& element); | |
54 | |
55 // For each field in the |form|, sets the field's placeholder text to the | |
56 // field's overall predicted type. Also sets the title to include the field's | |
57 // heuristic type, server type, and signature; as well as the form's signature | |
58 // and the experiment id for the server predictions. | |
59 bool ShowPredictions(const FormDataPredictions& form); | |
60 | |
61 private: | |
62 // The cached web frames. | |
63 std::set<WebKit::WebDocument> web_documents_; | |
64 | |
65 // The cached initial values for <select> elements. | |
66 std::map<const WebKit::WebSelectElement, base::string16> | |
67 initial_select_values_; | |
68 | |
69 // The cached initial values for checkable <input> elements. | |
70 std::map<const WebKit::WebInputElement, bool> initial_checked_state_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(FormCache); | |
73 }; | |
74 | |
75 } // namespace autofill | |
76 | |
77 #endif // COMPONENTS_AUTOFILL_RENDERER_FORM_CACHE_H_ | |
OLD | NEW |