2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef FormSubmission_h
32 #define FormSubmission_h
34 #include "core/loader/FormState.h"
35 #include "platform/weborigin/KURL.h"
36 #include "platform/weborigin/Referrer.h"
47 struct FrameLoadRequest;
48 class HTMLFormElement;
50 class FormSubmission : public RefCounted<FormSubmission> {
52 enum Method { GetMethod, PostMethod, DialogMethod };
55 WTF_MAKE_NONCOPYABLE(Attributes);
59 , m_isMultiPartForm(false)
60 , m_encodingType("application/x-www-form-urlencoded", AtomicString::ConstructFromLiteral)
64 Method method() const { return m_method; }
65 static Method parseMethodType(const String&);
66 void updateMethodType(const String&);
67 static String methodString(Method);
69 const String& action() const { return m_action; }
70 void parseAction(const String&);
72 const AtomicString& target() const { return m_target; }
73 void setTarget(const AtomicString& target) { m_target = target; }
75 const AtomicString& encodingType() const { return m_encodingType; }
76 static AtomicString parseEncodingType(const String&);
77 void updateEncodingType(const String&);
78 bool isMultiPartForm() const { return m_isMultiPartForm; }
80 const String& acceptCharset() const { return m_acceptCharset; }
81 void setAcceptCharset(const String& value) { m_acceptCharset = value; }
83 void copyFrom(const Attributes&);
87 bool m_isMultiPartForm;
90 AtomicString m_target;
91 AtomicString m_encodingType;
92 String m_acceptCharset;
95 static PassRefPtr<FormSubmission> create(HTMLFormElement*, const Attributes&, PassRefPtr<Event> event, FormSubmissionTrigger);
97 void populateFrameLoadRequest(FrameLoadRequest&);
99 KURL requestURL() const;
101 Method method() const { return m_method; }
102 const KURL& action() const { return m_action; }
103 const AtomicString& target() const { return m_target; }
104 void clearTarget() { m_target = nullAtom; }
105 const AtomicString& contentType() const { return m_contentType; }
106 FormState* state() const { return m_formState.get(); }
107 FormData* data() const { return m_formData.get(); }
108 const String boundary() const { return m_boundary; }
109 Event* event() const { return m_event.get(); }
111 const Referrer& referrer() const { return m_referrer; }
112 void setReferrer(const Referrer& referrer) { m_referrer = referrer; }
113 const String& origin() const { return m_origin; }
114 void setOrigin(const String& origin) { m_origin = origin; }
116 const String& result() const { return m_result; }
119 FormSubmission(Method, const KURL& action, const AtomicString& target, const AtomicString& contentType, PassRefPtr<FormState>, PassRefPtr<FormData>, const String& boundary, PassRefPtr<Event>);
120 // FormSubmission for DialogMethod
121 FormSubmission(const String& result);
123 // FIXME: Hold an instance of Attributes instead of individual members.
126 AtomicString m_target;
127 AtomicString m_contentType;
128 RefPtr<FormState> m_formState;
129 RefPtr<FormData> m_formData;
131 RefPtr<Event> m_event;
139 #endif // FormSubmission_h