Add diagnostics_writer.cc to the list of files allowed to printf.
[chromium-blink-merge.git] / components / autofill / content / renderer / form_cache.h
blobed7f654654c8140ab78225d8a945345831579880
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_
8 #include <map>
9 #include <set>
10 #include <vector>
12 #include "base/strings/string16.h"
14 namespace blink {
15 class WebDocument;
16 class WebFormControlElement;
17 class WebFormElement;
18 class WebFrame;
19 class WebInputElement;
20 class WebSelectElement;
23 namespace autofill {
25 struct FormData;
26 struct FormDataPredictions;
28 // Manages the forms in a RenderView.
29 class FormCache {
30 public:
31 FormCache();
32 ~FormCache();
34 // Scans the DOM in |frame| extracting and storing forms that have not been
35 // seen before. Fills |forms| with extracted forms.
36 void ExtractNewForms(const blink::WebFrame& frame,
37 std::vector<FormData>* forms);
39 // Resets the forms for the specified |frame|.
40 void ResetFrame(const blink::WebFrame& frame);
42 // Clears the values of all input elements in the form that contains
43 // |element|. Returns false if the form is not found.
44 bool ClearFormWithElement(const blink::WebFormControlElement& element);
46 // 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
48 // heuristic type, server type, and signature; as well as the form's signature
49 // and the experiment id for the server predictions.
50 bool ShowPredictions(const FormDataPredictions& form);
52 private:
53 // The cached web frames.
54 std::set<blink::WebDocument> web_documents_;
56 // The cached forms per frame. Used to prevent re-extraction of forms.
57 std::map<const blink::WebFrame*, std::set<FormData> > parsed_forms_;
59 // The cached initial values for <select> elements.
60 std::map<const blink::WebSelectElement, base::string16>
61 initial_select_values_;
63 // The cached initial values for checkable <input> elements.
64 std::map<const blink::WebInputElement, bool> initial_checked_state_;
66 DISALLOW_COPY_AND_ASSIGN(FormCache);
69 } // namespace autofill
71 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_