Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: third_party/WebKit/Source/core/dom/URLSearchParams.cpp

Issue 1456553002: Support 'URLSearchParams' as the body of a Request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLSearchParams
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698