OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 #include "core/html/HTMLFormControlElement.h" | 37 #include "core/html/HTMLFormControlElement.h" |
38 #include "core/html/HTMLFormElement.h" | 38 #include "core/html/HTMLFormElement.h" |
39 #include "core/html/HTMLInputElement.h" | 39 #include "core/html/HTMLInputElement.h" |
40 #include "core/html/HTMLOptionElement.h" | 40 #include "core/html/HTMLOptionElement.h" |
41 #include "core/html/HTMLSelectElement.h" | 41 #include "core/html/HTMLSelectElement.h" |
42 #include "platform/network/FormDataBuilder.h" | 42 #include "platform/network/FormDataBuilder.h" |
43 #include "public/web/WebFormElement.h" | 43 #include "public/web/WebFormElement.h" |
44 #include "public/web/WebInputElement.h" | 44 #include "public/web/WebInputElement.h" |
45 #include "wtf/text/TextEncoding.h" | 45 #include "wtf/text/TextEncoding.h" |
46 | 46 |
47 using namespace blink; | 47 namespace blink { |
| 48 |
48 using namespace HTMLNames; | 49 using namespace HTMLNames; |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 // Gets the encoding for the form. | 53 // Gets the encoding for the form. |
53 void GetFormEncoding(const HTMLFormElement* form, WTF::TextEncoding* encoding) | 54 void GetFormEncoding(const HTMLFormElement* form, WTF::TextEncoding* encoding) |
54 { | 55 { |
55 String str(form->getAttribute(HTMLNames::accept_charsetAttr)); | 56 String str(form->getAttribute(HTMLNames::accept_charsetAttr)); |
56 str.replace(',', ' '); | 57 str.replace(',', ' '); |
57 Vector<String> charsets; | 58 Vector<String> charsets; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 encodedString->append("{searchTerms}", 13); | 225 encodedString->append("{searchTerms}", 13); |
225 isElementFound = true; | 226 isElementFound = true; |
226 } else | 227 } else |
227 FormDataBuilder::encodeStringAsFormData(*encodedString, j->data(
)); | 228 FormDataBuilder::encodeStringAsFormData(*encodedString, j->data(
)); |
228 } | 229 } |
229 } | 230 } |
230 return isElementFound; | 231 return isElementFound; |
231 } | 232 } |
232 } // namespace | 233 } // namespace |
233 | 234 |
234 namespace blink { | |
235 | |
236 WebSearchableFormData::WebSearchableFormData(const WebFormElement& form, const W
ebInputElement& selectedInputElement) | 235 WebSearchableFormData::WebSearchableFormData(const WebFormElement& form, const W
ebInputElement& selectedInputElement) |
237 { | 236 { |
238 RefPtrWillBeRawPtr<HTMLFormElement> formElement = static_cast<PassRefPtrWill
BeRawPtr<HTMLFormElement> >(form); | 237 RefPtrWillBeRawPtr<HTMLFormElement> formElement = static_cast<PassRefPtrWill
BeRawPtr<HTMLFormElement> >(form); |
239 HTMLInputElement* inputElement = static_cast<PassRefPtrWillBeRawPtr<HTMLInpu
tElement> >(selectedInputElement).get(); | 238 HTMLInputElement* inputElement = static_cast<PassRefPtrWillBeRawPtr<HTMLInpu
tElement> >(selectedInputElement).get(); |
240 | 239 |
241 // Only consider forms that GET data. | 240 // Only consider forms that GET data. |
242 // Allow HTTPS only when an input element is provided. | 241 // Allow HTTPS only when an input element is provided. |
243 if (equalIgnoringCase(formElement->getAttribute(methodAttr), "post") | 242 if (equalIgnoringCase(formElement->getAttribute(methodAttr), "post") |
244 || (!IsHTTPFormSubmit(formElement.get()) && !inputElement)) | 243 || (!IsHTTPFormSubmit(formElement.get()) && !inputElement)) |
245 return; | 244 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 283 |
285 String action(formElement->action()); | 284 String action(formElement->action()); |
286 KURL url(formElement->document().completeURL(action.isNull() ? "" : action))
; | 285 KURL url(formElement->document().completeURL(action.isNull() ? "" : action))
; |
287 RefPtr<FormData> formData = FormData::create(encodedString); | 286 RefPtr<FormData> formData = FormData::create(encodedString); |
288 url.setQuery(formData->flattenToString()); | 287 url.setQuery(formData->flattenToString()); |
289 m_url = url; | 288 m_url = url; |
290 m_encoding = String(encoding.name()); | 289 m_encoding = String(encoding.name()); |
291 } | 290 } |
292 | 291 |
293 } // namespace blink | 292 } // namespace blink |
OLD | NEW |