OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 void FormSubmission::Attributes::parseAction(const String& action) | 85 void FormSubmission::Attributes::parseAction(const String& action) |
86 { | 86 { |
87 // m_action cannot be converted to KURL (bug https://crbug.com/388664) | 87 // m_action cannot be converted to KURL (bug https://crbug.com/388664) |
88 m_action = stripLeadingAndTrailingHTMLSpaces(action); | 88 m_action = stripLeadingAndTrailingHTMLSpaces(action); |
89 } | 89 } |
90 | 90 |
91 AtomicString FormSubmission::Attributes::parseEncodingType(const String& type) | 91 AtomicString FormSubmission::Attributes::parseEncodingType(const String& type) |
92 { | 92 { |
93 if (equalIgnoringCase(type, "multipart/form-data")) | 93 if (equalIgnoringCase(type, "multipart/form-data")) |
94 return AtomicString("multipart/form-data", AtomicString::ConstructFromLi
teral); | 94 return AtomicString("multipart/form-data"); |
95 if (equalIgnoringCase(type, "text/plain")) | 95 if (equalIgnoringCase(type, "text/plain")) |
96 return AtomicString("text/plain", AtomicString::ConstructFromLiteral); | 96 return AtomicString("text/plain"); |
97 return AtomicString("application/x-www-form-urlencoded", AtomicString::Const
ructFromLiteral); | 97 return AtomicString("application/x-www-form-urlencoded"); |
98 } | 98 } |
99 | 99 |
100 void FormSubmission::Attributes::updateEncodingType(const String& type) | 100 void FormSubmission::Attributes::updateEncodingType(const String& type) |
101 { | 101 { |
102 m_encodingType = parseEncodingType(type); | 102 m_encodingType = parseEncodingType(type); |
103 m_isMultiPartForm = (m_encodingType == "multipart/form-data"); | 103 m_isMultiPartForm = (m_encodingType == "multipart/form-data"); |
104 } | 104 } |
105 | 105 |
106 FormSubmission::SubmitMethod FormSubmission::Attributes::parseMethodType(const S
tring& type) | 106 FormSubmission::SubmitMethod FormSubmission::Attributes::parseMethodType(const S
tring& type) |
107 { | 107 { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 Document& document = form->document(); | 197 Document& document = form->document(); |
198 KURL actionURL = document.completeURL(copiedAttributes.action().isEmpty() ?
document.url().getString() : copiedAttributes.action()); | 198 KURL actionURL = document.completeURL(copiedAttributes.action().isEmpty() ?
document.url().getString() : copiedAttributes.action()); |
199 bool isMailtoForm = actionURL.protocolIs("mailto"); | 199 bool isMailtoForm = actionURL.protocolIs("mailto"); |
200 bool isMultiPartForm = false; | 200 bool isMultiPartForm = false; |
201 AtomicString encodingType = copiedAttributes.encodingType(); | 201 AtomicString encodingType = copiedAttributes.encodingType(); |
202 | 202 |
203 if (copiedAttributes.method() == PostMethod) { | 203 if (copiedAttributes.method() == PostMethod) { |
204 isMultiPartForm = copiedAttributes.isMultiPartForm(); | 204 isMultiPartForm = copiedAttributes.isMultiPartForm(); |
205 if (isMultiPartForm && isMailtoForm) { | 205 if (isMultiPartForm && isMailtoForm) { |
206 encodingType = AtomicString("application/x-www-form-urlencoded", Ato
micString::ConstructFromLiteral); | 206 encodingType = AtomicString("application/x-www-form-urlencoded"); |
207 isMultiPartForm = false; | 207 isMultiPartForm = false; |
208 } | 208 } |
209 } | 209 } |
210 WTF::TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataEnc
oder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document.encod
ing()); | 210 WTF::TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataEnc
oder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document.encod
ing()); |
211 FormData* domFormData = FormData::create(dataEncoding.encodingForFormSubmiss
ion()); | 211 FormData* domFormData = FormData::create(dataEncoding.encodingForFormSubmiss
ion()); |
212 | 212 |
213 bool containsPasswordData = false; | 213 bool containsPasswordData = false; |
214 for (unsigned i = 0; i < form->associatedElements().size(); ++i) { | 214 for (unsigned i = 0; i < form->associatedElements().size(); ++i) { |
215 FormAssociatedElement* control = form->associatedElements()[i]; | 215 FormAssociatedElement* control = form->associatedElements()[i]; |
216 ASSERT(control); | 216 ASSERT(control); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if (m_boundary.isEmpty()) | 274 if (m_boundary.isEmpty()) |
275 frameRequest.resourceRequest().setHTTPContentType(m_contentType); | 275 frameRequest.resourceRequest().setHTTPContentType(m_contentType); |
276 else | 276 else |
277 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); | 277 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); |
278 } | 278 } |
279 | 279 |
280 frameRequest.resourceRequest().setURL(requestURL()); | 280 frameRequest.resourceRequest().setURL(requestURL()); |
281 } | 281 } |
282 | 282 |
283 } // namespace blink | 283 } // namespace blink |
OLD | NEW |