OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/dom/URLSearchParams.h" | 6 #include "core/dom/URLSearchParams.h" |
7 | 7 |
| 8 #include "platform/network/FormDataEncoder.h" |
8 #include "platform/weborigin/KURL.h" | 9 #include "platform/weborigin/KURL.h" |
9 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
10 #include "wtf/text/TextEncoding.h" | 11 #include "wtf/text/TextEncoding.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 class URLSearchParamsIterationSource final : public PairIterable<String, String>
::IterationSource { | 17 class URLSearchParamsIterationSource final : public PairIterable<String, String>
::IterationSource { |
17 public: | 18 public: |
(...skipping 151 matching lines...) Loading... |
169 } | 170 } |
170 } else { | 171 } else { |
171 i++; | 172 i++; |
172 } | 173 } |
173 } | 174 } |
174 // Otherwise, append a new name-value pair to the list. | 175 // Otherwise, append a new name-value pair to the list. |
175 if (!foundMatch) | 176 if (!foundMatch) |
176 append(name, value); | 177 append(name, value); |
177 } | 178 } |
178 | 179 |
| 180 PassRefPtr<EncodedFormData> URLSearchParams::encodeFormData() const |
| 181 { |
| 182 RefPtr<EncodedFormData> data = EncodedFormData::create(); |
| 183 Vector<char> encodedData; |
| 184 for (const auto& param : m_params) |
| 185 FormDataEncoder::addKeyValuePairAsFormData(encodedData, param.first.utf8
(), param.second.utf8(), EncodedFormData::FormURLEncoded); |
| 186 data->appendData(encodedData.data(), encodedData.size()); |
| 187 return data.release(); |
| 188 } |
| 189 |
179 DEFINE_TRACE(URLSearchParams) | 190 DEFINE_TRACE(URLSearchParams) |
180 { | 191 { |
181 } | 192 } |
182 | 193 |
183 PairIterable<String, String>::IterationSource* URLSearchParams::startIteration(S
criptState*, ExceptionState&) | 194 PairIterable<String, String>::IterationSource* URLSearchParams::startIteration(S
criptState*, ExceptionState&) |
184 { | 195 { |
185 return new URLSearchParamsIterationSource(m_params); | 196 return new URLSearchParamsIterationSource(m_params); |
186 } | 197 } |
187 | 198 |
188 } // namespace blink | 199 } // namespace blink |
OLD | NEW |