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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 static int64_t next_identifier = | 60 static int64_t next_identifier = |
61 static_cast<int64_t>(CurrentTime() * 1000000.0); | 61 static_cast<int64_t>(CurrentTime() * 1000000.0); |
62 return ++next_identifier; | 62 return ++next_identifier; |
63 } | 63 } |
64 | 64 |
65 static void AppendMailtoPostFormDataToURL(KURL& url, | 65 static void AppendMailtoPostFormDataToURL(KURL& url, |
66 const EncodedFormData& data, | 66 const EncodedFormData& data, |
67 const String& encoding_type) { | 67 const String& encoding_type) { |
68 String body = data.FlattenToString(); | 68 String body = data.FlattenToString(); |
69 | 69 |
70 if (EqualIgnoringCase(encoding_type, "text/plain")) { | 70 if (DeprecatedEqualIgnoringCase(encoding_type, "text/plain")) { |
71 // Convention seems to be to decode, and s/&/\r\n/. Also, spaces are encoded | 71 // Convention seems to be to decode, and s/&/\r\n/. Also, spaces are encoded |
72 // as %20. | 72 // as %20. |
73 body = DecodeURLEscapeSequences( | 73 body = DecodeURLEscapeSequences( |
74 body.Replace('&', "\r\n").Replace('+', ' ') + "\r\n"); | 74 body.Replace('&', "\r\n").Replace('+', ' ') + "\r\n"); |
75 } | 75 } |
76 | 76 |
77 Vector<char> body_data; | 77 Vector<char> body_data; |
78 body_data.Append("body=", 5); | 78 body_data.Append("body=", 5); |
79 FormDataEncoder::EncodeStringAsFormData(body_data, body.Utf8(), | 79 FormDataEncoder::EncodeStringAsFormData(body_data, body.Utf8(), |
80 FormDataEncoder::kNormalizeCRLF); | 80 FormDataEncoder::kNormalizeCRLF); |
81 body = String(body_data.Data(), body_data.size()).Replace('+', "%20"); | 81 body = String(body_data.Data(), body_data.size()).Replace('+', "%20"); |
82 | 82 |
83 StringBuilder query; | 83 StringBuilder query; |
84 query.Append(url.Query()); | 84 query.Append(url.Query()); |
85 if (!query.IsEmpty()) | 85 if (!query.IsEmpty()) |
86 query.Append('&'); | 86 query.Append('&'); |
87 query.Append(body); | 87 query.Append(body); |
88 url.SetQuery(query.ToString()); | 88 url.SetQuery(query.ToString()); |
89 } | 89 } |
90 | 90 |
91 void FormSubmission::Attributes::ParseAction(const String& action) { | 91 void FormSubmission::Attributes::ParseAction(const String& action) { |
92 // m_action cannot be converted to KURL (bug https://crbug.com/388664) | 92 // m_action cannot be converted to KURL (bug https://crbug.com/388664) |
93 action_ = StripLeadingAndTrailingHTMLSpaces(action); | 93 action_ = StripLeadingAndTrailingHTMLSpaces(action); |
94 } | 94 } |
95 | 95 |
96 AtomicString FormSubmission::Attributes::ParseEncodingType(const String& type) { | 96 AtomicString FormSubmission::Attributes::ParseEncodingType(const String& type) { |
97 if (EqualIgnoringCase(type, "multipart/form-data")) | 97 if (DeprecatedEqualIgnoringCase(type, "multipart/form-data")) |
98 return AtomicString("multipart/form-data"); | 98 return AtomicString("multipart/form-data"); |
99 if (EqualIgnoringCase(type, "text/plain")) | 99 if (DeprecatedEqualIgnoringCase(type, "text/plain")) |
100 return AtomicString("text/plain"); | 100 return AtomicString("text/plain"); |
101 return AtomicString("application/x-www-form-urlencoded"); | 101 return AtomicString("application/x-www-form-urlencoded"); |
102 } | 102 } |
103 | 103 |
104 void FormSubmission::Attributes::UpdateEncodingType(const String& type) { | 104 void FormSubmission::Attributes::UpdateEncodingType(const String& type) { |
105 encoding_type_ = ParseEncodingType(type); | 105 encoding_type_ = ParseEncodingType(type); |
106 is_multi_part_form_ = (encoding_type_ == "multipart/form-data"); | 106 is_multi_part_form_ = (encoding_type_ == "multipart/form-data"); |
107 } | 107 } |
108 | 108 |
109 FormSubmission::SubmitMethod FormSubmission::Attributes::ParseMethodType( | 109 FormSubmission::SubmitMethod FormSubmission::Attributes::ParseMethodType( |
110 const String& type) { | 110 const String& type) { |
111 if (EqualIgnoringCase(type, "post")) | 111 if (DeprecatedEqualIgnoringCase(type, "post")) |
112 return FormSubmission::kPostMethod; | 112 return FormSubmission::kPostMethod; |
113 if (EqualIgnoringCase(type, "dialog")) | 113 if (DeprecatedEqualIgnoringCase(type, "dialog")) |
114 return FormSubmission::kDialogMethod; | 114 return FormSubmission::kDialogMethod; |
115 return FormSubmission::kGetMethod; | 115 return FormSubmission::kGetMethod; |
116 } | 116 } |
117 | 117 |
118 void FormSubmission::Attributes::UpdateMethodType(const String& type) { | 118 void FormSubmission::Attributes::UpdateMethodType(const String& type) { |
119 method_ = ParseMethodType(type); | 119 method_ = ParseMethodType(type); |
120 } | 120 } |
121 | 121 |
122 String FormSubmission::Attributes::MethodString(SubmitMethod method) { | 122 String FormSubmission::Attributes::MethodString(SubmitMethod method) { |
123 switch (method) { | 123 switch (method) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 307 |
308 frame_request.GetResourceRequest().SetURL(RequestURL()); | 308 frame_request.GetResourceRequest().SetURL(RequestURL()); |
309 | 309 |
310 frame_request.SetTriggeringEvent(event_); | 310 frame_request.SetTriggeringEvent(event_); |
311 frame_request.SetForm(form_); | 311 frame_request.SetForm(form_); |
312 | 312 |
313 return frame_request; | 313 return frame_request; |
314 } | 314 } |
315 | 315 |
316 } // namespace blink | 316 } // namespace blink |
OLD | NEW |