#pragma once
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/ListHashSet.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class FormKeyGenerator;
class HTMLFormControlElementWithState;
class HTMLFormElement;
class SavedFormState;
using FormControlState = Vector<String>;
class FormController {
WTF_MAKE_FAST_ALLOCATED;
public:
FormController();
~FormController();
void registerFormElementWithState(HTMLFormControlElementWithState&);
void unregisterFormElementWithState(HTMLFormControlElementWithState&);
unsigned formElementsCharacterCount() const;
Vector<String> formElementsState() const;
void setStateForNewFormElements(const Vector<String>&);
void willDeleteForm(HTMLFormElement&);
void restoreControlStateFor(HTMLFormControlElementWithState&);
void restoreControlStateIn(HTMLFormElement&);
bool hasFormStateToRestore() const;
WEBCORE_EXPORT static Vector<String> referencedFilePaths(const Vector<String>& stateVector);
private:
typedef ListHashSet<RefPtr<HTMLFormControlElementWithState>> FormElementListHashSet;
typedef HashMap<RefPtr<AtomStringImpl>, std::unique_ptr<SavedFormState>> SavedFormStateMap;
static std::unique_ptr<SavedFormStateMap> createSavedFormStateMap(const FormElementListHashSet&);
FormControlState takeStateForFormElement(const HTMLFormControlElementWithState&);
static void formStatesFromStateVector(const Vector<String>&, SavedFormStateMap&);
FormElementListHashSet m_formElementsWithState;
SavedFormStateMap m_savedFormStateMap;
std::unique_ptr<FormKeyGenerator> m_formKeyGenerator;
};
}