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