Index: Source/core/html/DOMFormData.cpp |
diff --git a/Source/core/html/DOMFormData.cpp b/Source/core/html/DOMFormData.cpp |
index 92fb7695d5cb5641b7f7ca0bb310c061bcaf71b9..34503e0a7a467e73b58c491b3dd624531aca335c 100644 |
--- a/Source/core/html/DOMFormData.cpp |
+++ b/Source/core/html/DOMFormData.cpp |
@@ -31,7 +31,10 @@ |
#include "config.h" |
#include "core/html/DOMFormData.h" |
+#include "bindings/core/v8/V8Binding.h" |
+#include "bindings/core/v8/V8File.h" |
#include "core/fileapi/Blob.h" |
+#include "core/fileapi/File.h" |
#include "core/html/HTMLFormElement.h" |
#include "wtf/text/TextEncoding.h" |
#include "wtf/text/WTFString.h" |
@@ -68,4 +71,54 @@ void DOMFormData::append(const String& name, Blob* blob, const String& filename) |
appendBlob(name, blob, filename); |
} |
+void DOMFormData::deleteFunction(const String& name) |
+{ |
+ return deleteItem(name); |
+} |
+ |
+ScriptValue DOMFormData::get(ScriptState* scriptState, const String& name) |
+{ |
+ FormDataList::EntryValue entry = getItem(name); |
+ if (entry.isString()) |
+ return ScriptValue(scriptState, v8String(scriptState->isolate(), entry.string())); |
+ if (entry.isFile()) |
+ return ScriptValue(scriptState, toV8(entry.file(), scriptState->context()->Global(), scriptState->isolate())); |
+ ASSERT(entry.isNone()); |
+ return ScriptValue(scriptState, v8::Null(scriptState->isolate())); |
+} |
+ |
+Vector<ScriptValue> DOMFormData::getAll(ScriptState* scriptState, const String& name) |
+{ |
+ Vector<ScriptValue> results; |
+ Vector<FormDataList::EntryValue> entries = FormDataList::getAll(name); |
+ for (size_t i = 0; i < entries.size(); ++i) { |
+ const FormDataList::EntryValue& entry = entries[i]; |
+ if (entry.isString()) |
+ results.append(ScriptValue(scriptState, v8String(scriptState->isolate(), entry.string()))); |
+ else if (entry.isFile()) |
+ results.append(ScriptValue(scriptState, toV8(entry.file(), scriptState->context()->Global(), scriptState->isolate()))); |
+ else |
+ ASSERT_NOT_REACHED(); |
+ } |
+ ASSERT(results.size() == entries.size()); |
+ return results; |
+} |
+ |
+bool DOMFormData::has(const String& name) |
+{ |
+ return hasItem(name); |
+} |
+ |
+void DOMFormData::set(const String& name, const String& value) |
+{ |
+ if (!name.isEmpty()) |
+ setData(name, value); |
+} |
+ |
+void DOMFormData::set(const String& name, Blob* blob, const String& filename) |
+{ |
+ if (!name.isEmpty()) |
+ setBlob(name, blob, filename); |
+} |
+ |
} // namespace blink |