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

Side by Side Diff: Source/web/WebSearchableFormData.cpp

Issue 1311923004: Rename FormData/FormDataBuilder to EncodedFormData/FormDataEncoder respectively. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update comments Created 5 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebHistoryItem.cpp ('k') | public/platform/WebHTTPBody.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 22 matching lines...) Expand all
33 33
34 #include "core/HTMLNames.h" 34 #include "core/HTMLNames.h"
35 #include "core/InputTypeNames.h" 35 #include "core/InputTypeNames.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/html/DOMFormData.h" 37 #include "core/html/DOMFormData.h"
38 #include "core/html/HTMLFormControlElement.h" 38 #include "core/html/HTMLFormControlElement.h"
39 #include "core/html/HTMLFormElement.h" 39 #include "core/html/HTMLFormElement.h"
40 #include "core/html/HTMLInputElement.h" 40 #include "core/html/HTMLInputElement.h"
41 #include "core/html/HTMLOptionElement.h" 41 #include "core/html/HTMLOptionElement.h"
42 #include "core/html/HTMLSelectElement.h" 42 #include "core/html/HTMLSelectElement.h"
43 #include "platform/network/FormDataBuilder.h" 43 #include "platform/network/FormDataEncoder.h"
44 #include "public/web/WebFormElement.h" 44 #include "public/web/WebFormElement.h"
45 #include "public/web/WebInputElement.h" 45 #include "public/web/WebInputElement.h"
46 #include "wtf/text/TextEncoding.h" 46 #include "wtf/text/TextEncoding.h"
47 47
48 namespace blink { 48 namespace blink {
49 49
50 using namespace HTMLNames; 50 using namespace HTMLNames;
51 51
52 namespace { 52 namespace {
53 53
54 // Gets the encoding for the form. 54 // Gets the encoding for the form.
55 // TODO(tkent): Use FormDataBuilder::encodingFromAcceptCharset(). 55 // TODO(tkent): Use FormDataEncoder::encodingFromAcceptCharset().
56 void getFormEncoding(const HTMLFormElement& form, WTF::TextEncoding* encoding) 56 void getFormEncoding(const HTMLFormElement& form, WTF::TextEncoding* encoding)
57 { 57 {
58 String str(form.fastGetAttribute(HTMLNames::accept_charsetAttr)); 58 String str(form.fastGetAttribute(HTMLNames::accept_charsetAttr));
59 str.replace(',', ' '); 59 str.replace(',', ' ');
60 Vector<String> charsets; 60 Vector<String> charsets;
61 str.split(' ', charsets); 61 str.split(' ', charsets);
62 for (const String& charset : charsets) { 62 for (const String& charset : charsets) {
63 *encoding = WTF::TextEncoding(charset); 63 *encoding = WTF::TextEncoding(charset);
64 if (encoding->isValid()) 64 if (encoding->isValid())
65 return; 65 return;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (control.isDisabledFormControl() || control.name().isNull()) 210 if (control.isDisabledFormControl() || control.name().isNull())
211 continue; 211 continue;
212 212
213 DOMFormData* formData = DOMFormData::create(encoding); 213 DOMFormData* formData = DOMFormData::create(encoding);
214 if (!control.appendFormData(*formData, false)) 214 if (!control.appendFormData(*formData, false))
215 continue; 215 continue;
216 216
217 for (const FormDataList::Item& item : formData->items()) { 217 for (const FormDataList::Item& item : formData->items()) {
218 if (!encodedString->isEmpty()) 218 if (!encodedString->isEmpty())
219 encodedString->append('&'); 219 encodedString->append('&');
220 FormDataBuilder::encodeStringAsFormData(*encodedString, item.key()); 220 FormDataEncoder::encodeStringAsFormData(*encodedString, item.key());
221 encodedString->append('='); 221 encodedString->append('=');
222 if (&control == textElement) { 222 if (&control == textElement) {
223 encodedString->append("{searchTerms}", 13); 223 encodedString->append("{searchTerms}", 13);
224 isElementFound = true; 224 isElementFound = true;
225 } else { 225 } else {
226 FormDataBuilder::encodeStringAsFormData(*encodedString, item.dat a()); 226 FormDataEncoder::encodeStringAsFormData(*encodedString, item.dat a());
227 } 227 }
228 } 228 }
229 } 229 }
230 return isElementFound; 230 return isElementFound;
231 } 231 }
232 232
233 } // namespace 233 } // namespace
234 234
235 WebSearchableFormData::WebSearchableFormData(const WebFormElement& form, const W ebInputElement& selectedInputElement) 235 WebSearchableFormData::WebSearchableFormData(const WebFormElement& form, const W ebInputElement& selectedInputElement)
236 { 236 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 if (firstSubmitButton) 276 if (firstSubmitButton)
277 firstSubmitButton->setActivatedSubmit(false); 277 firstSubmitButton->setActivatedSubmit(false);
278 278
279 // Return if the search string is not valid. 279 // Return if the search string is not valid.
280 if (!isValidSearchString) 280 if (!isValidSearchString)
281 return; 281 return;
282 282
283 String action(formElement->action()); 283 String action(formElement->action());
284 KURL url(formElement->document().completeURL(action.isNull() ? "" : action)) ; 284 KURL url(formElement->document().completeURL(action.isNull() ? "" : action)) ;
285 RefPtr<FormData> formData = FormData::create(encodedString); 285 RefPtr<EncodedFormData> formData = EncodedFormData::create(encodedString);
286 url.setQuery(formData->flattenToString()); 286 url.setQuery(formData->flattenToString());
287 m_url = url; 287 m_url = url;
288 m_encoding = String(encoding.name()); 288 m_encoding = String(encoding.name());
289 } 289 }
290 290
291 } // namespace blink 291 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebHistoryItem.cpp ('k') | public/platform/WebHTTPBody.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698