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 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
);
53 // Scans |control_elements| and returns the number of editable elements.
54 // Also remembers the initial <select> and <input> element states, and
55 // logs warning messages for deprecated attribute if
56 // |log_deprecation_messages| is set.
57 size_t ScanFormControlElements(
58 const std::vector
<blink::WebFormControlElement
>& control_elements
,
59 bool log_deprecation_messages
);
61 // The frame this FormCache is associated with.
62 const blink::WebFrame
& frame_
;
64 // The cached forms. Used to prevent re-extraction of forms.
65 std::set
<FormData
> parsed_forms_
;
67 // The synthetic FormData is for all the fieldsets in the document without a
69 FormData synthetic_form_
;
71 // The cached initial values for <select> elements.
72 std::map
<const blink::WebSelectElement
, base::string16
>
73 initial_select_values_
;
75 // The cached initial values for checkable <input> elements.
76 std::map
<const blink::WebInputElement
, bool> initial_checked_state_
;
78 DISALLOW_COPY_AND_ASSIGN(FormCache
);
81 } // namespace autofill
83 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_