| 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/network/FormDataEncoder.h" |
| 9 #include "platform/weborigin/KURL.h" | 9 #include "platform/weborigin/KURL.h" |
| 10 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 i++; | 172 i++; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 // Otherwise, append a new name-value pair to the list. | 175 // Otherwise, append a new name-value pair to the list. |
| 176 if (!foundMatch) | 176 if (!foundMatch) |
| 177 append(name, value); | 177 append(name, value); |
| 178 } | 178 } |
| 179 | 179 |
| 180 PassRefPtr<EncodedFormData> URLSearchParams::encodeFormData() const | 180 PassRefPtr<EncodedFormData> URLSearchParams::encodeFormData() const |
| 181 { | 181 { |
| 182 RefPtr<EncodedFormData> data = EncodedFormData::create(); | |
| 183 Vector<char> encodedData; | 182 Vector<char> encodedData; |
| 184 for (const auto& param : m_params) | 183 for (const auto& param : m_params) |
| 185 FormDataEncoder::addKeyValuePairAsFormData(encodedData, param.first.utf8
(), param.second.utf8(), EncodedFormData::FormURLEncoded); | 184 FormDataEncoder::addKeyValuePairAsFormData(encodedData, param.first.utf8
(), param.second.utf8(), EncodedFormData::FormURLEncoded); |
| 186 data->appendData(encodedData.data(), encodedData.size()); | 185 return EncodedFormData::create(encodedData.data(), encodedData.size()); |
| 187 return data.release(); | |
| 188 } | 186 } |
| 189 | 187 |
| 190 DEFINE_TRACE(URLSearchParams) | 188 DEFINE_TRACE(URLSearchParams) |
| 191 { | 189 { |
| 192 } | 190 } |
| 193 | 191 |
| 194 PairIterable<String, String>::IterationSource* URLSearchParams::startIteration(S
criptState*, ExceptionState&) | 192 PairIterable<String, String>::IterationSource* URLSearchParams::startIteration(S
criptState*, ExceptionState&) |
| 195 { | 193 { |
| 196 return new URLSearchParamsIterationSource(m_params); | 194 return new URLSearchParamsIterationSource(m_params); |
| 197 } | 195 } |
| 198 | 196 |
| 199 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |