| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/html/FormData.h" | 31 #include "core/html/FormData.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptState.h" |
| 33 #include "core/fileapi/Blob.h" | 34 #include "core/fileapi/Blob.h" |
| 34 #include "core/fileapi/File.h" | 35 #include "core/fileapi/File.h" |
| 35 #include "core/frame/UseCounter.h" | 36 #include "core/frame/UseCounter.h" |
| 36 #include "core/html/HTMLFormElement.h" | 37 #include "core/html/HTMLFormElement.h" |
| 37 #include "platform/network/FormDataEncoder.h" | 38 #include "platform/network/FormDataEncoder.h" |
| 38 #include "platform/text/LineEnding.h" | 39 #include "platform/text/LineEnding.h" |
| 39 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 94 |
| 94 DEFINE_TRACE(FormData) { | 95 DEFINE_TRACE(FormData) { |
| 95 visitor->trace(m_entries); | 96 visitor->trace(m_entries); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void FormData::append(const String& name, const String& value) { | 99 void FormData::append(const String& name, const String& value) { |
| 99 m_entries.push_back( | 100 m_entries.push_back( |
| 100 new Entry(encodeAndNormalize(name), encodeAndNormalize(value))); | 101 new Entry(encodeAndNormalize(name), encodeAndNormalize(value))); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void FormData::append(ExecutionContext* context, | 104 void FormData::append(ScriptState* scriptState, |
| 104 const String& name, | 105 const String& name, |
| 105 Blob* blob, | 106 Blob* blob, |
| 106 const String& filename) { | 107 const String& filename) { |
| 107 if (!blob) | 108 if (!blob) { |
| 108 UseCounter::count(context, UseCounter::FormDataAppendNull); | 109 UseCounter::count(scriptState->getExecutionContext(), |
| 110 UseCounter::FormDataAppendNull); |
| 111 } |
| 109 append(name, blob, filename); | 112 append(name, blob, filename); |
| 110 } | 113 } |
| 111 | 114 |
| 112 void FormData::deleteEntry(const String& name) { | 115 void FormData::deleteEntry(const String& name) { |
| 113 const CString encodedName = encodeAndNormalize(name); | 116 const CString encodedName = encodeAndNormalize(name); |
| 114 size_t i = 0; | 117 size_t i = 0; |
| 115 while (i < m_entries.size()) { | 118 while (i < m_entries.size()) { |
| 116 if (m_entries[i]->name() == encodedName) { | 119 if (m_entries[i]->name() == encodedName) { |
| 117 m_entries.remove(i); | 120 m_entries.remove(i); |
| 118 } else { | 121 } else { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 return file->clone(filename()); | 328 return file->clone(filename()); |
| 326 } | 329 } |
| 327 | 330 |
| 328 String filename = m_filename; | 331 String filename = m_filename; |
| 329 if (filename.isNull()) | 332 if (filename.isNull()) |
| 330 filename = "blob"; | 333 filename = "blob"; |
| 331 return File::create(filename, currentTimeMS(), blob()->blobDataHandle()); | 334 return File::create(filename, currentTimeMS(), blob()->blobDataHandle()); |
| 332 } | 335 } |
| 333 | 336 |
| 334 } // namespace blink | 337 } // namespace blink |
| OLD | NEW |