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_
12 #include "base/strings/string16.h"
16 class WebFormControlElement;
18 class WebInputElement;
19 class WebSelectElement;
25 struct FormDataPredictions;
27 // Manages the forms in a RenderView.
33 // Scans the DOM in |frame| extracting and storing forms that have not been
34 // seen before. Returns the extracted forms.
35 std::vector<FormData> ExtractNewForms(const blink::WebFrame& frame);
37 // Resets the forms for the specified |frame|.
38 void ResetFrame(const blink::WebFrame& frame);
40 // Clears the values of all input elements in the form that contains
41 // |element|. Returns false if the form is not found.
42 bool ClearFormWithElement(const blink::WebFormControlElement& element);
44 // For each field in the |form|, sets the field's placeholder text to the
45 // field's overall predicted type. Also sets the title to include the field's
46 // heuristic type, server type, and signature; as well as the form's signature
47 // and the experiment id for the server predictions.
48 bool ShowPredictions(const FormDataPredictions& form);
51 // Scans |control_elements| and returns the number of editable elements.
52 // Also remembers the initial <select> and <input> element states, and
53 // logs warning messages for deprecated attribute if
54 // |log_deprecation_messages| is set.
55 size_t ScanFormControlElements(
56 const std::vector<blink::WebFormControlElement>& control_elements,
57 bool log_deprecation_messages);
59 // The cached web frames.
60 std::set<blink::WebDocument> web_documents_;
62 // The cached forms per frame. Used to prevent re-extraction of forms.
63 std::map<const blink::WebFrame*, std::set<FormData> > parsed_forms_;
65 // The cached initial values for <select> elements.
66 std::map<const blink::WebSelectElement, base::string16>
67 initial_select_values_;
69 // The cached initial values for checkable <input> elements.
70 std::map<const blink::WebInputElement, bool> initial_checked_state_;
72 DISALLOW_COPY_AND_ASSIGN(FormCache);
75 } // namespace autofill
77 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_