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"
13 #include "components/autofill/core/common/form_data.h"
18 class WebElementCollection
;
19 class WebFormControlElement
;
21 class WebInputElement
;
22 class WebSelectElement
;
27 struct FormDataPredictions
;
29 // Manages the forms in a single RenderFrame.
32 explicit FormCache(const blink::WebFrame
& frame
);
35 // Scans the DOM in |frame_| extracting and storing forms that have not been
36 // seen before. Returns the extracted forms.
37 std::vector
<FormData
> ExtractNewForms();
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 title to include the field's
47 // heuristic type, server type, and signature; as well as the form's signature
48 // and the experiment id for the server predictions.
49 bool ShowPredictions(const FormDataPredictions
& form
);
52 // Scans |control_elements| and returns the number of editable elements.
53 // Also remembers the initial <select> and <input> element states, and
54 // logs warning messages for deprecated attribute if
55 // |log_deprecation_messages| is set.
56 size_t ScanFormControlElements(
57 const std::vector
<blink::WebFormControlElement
>& control_elements
,
58 bool log_deprecation_messages
);
60 // Saves initial state of checkbox and select elements.
61 void SaveInitialValues(
62 const std::vector
<blink::WebFormControlElement
>& control_elements
);
64 // The frame this FormCache is associated with.
65 const blink::WebFrame
& frame_
;
67 // The cached forms. Used to prevent re-extraction of forms.
68 std::set
<FormData
> parsed_forms_
;
70 // The synthetic FormData is for all the fieldsets in the document without a
72 FormData synthetic_form_
;
74 // The cached initial values for <select> elements.
75 std::map
<const blink::WebSelectElement
, base::string16
>
76 initial_select_values_
;
78 // The cached initial values for checkable <input> elements.
79 std::map
<const blink::WebInputElement
, bool> initial_checked_state_
;
81 DISALLOW_COPY_AND_ASSIGN(FormCache
);
84 } // namespace autofill
86 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_