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 15 matching lines...) Expand all Loading... |
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 "config.h" | 31 #include "config.h" |
32 #include "core/html/DOMFormData.h" | 32 #include "core/html/DOMFormData.h" |
33 | 33 |
34 #include "core/fileapi/Blob.h" | 34 #include "core/fileapi/Blob.h" |
35 #include "core/fileapi/File.h" | 35 #include "core/fileapi/File.h" |
| 36 #include "core/frame/UseCounter.h" |
36 #include "core/html/HTMLFormElement.h" | 37 #include "core/html/HTMLFormElement.h" |
37 #include "wtf/text/TextEncoding.h" | 38 #include "wtf/text/TextEncoding.h" |
38 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
44 class DOMFormDataIterationSource final : public PairIterable<String, FormDataEnt
ryValue>::IterationSource { | 45 class DOMFormDataIterationSource final : public PairIterable<String, FormDataEnt
ryValue>::IterationSource { |
45 public: | 46 public: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (!toHTMLElement(element)->isDisabledFormControl()) | 91 if (!toHTMLElement(element)->isDisabledFormControl()) |
91 element->appendFormData(*this, true); | 92 element->appendFormData(*this, true); |
92 } | 93 } |
93 } | 94 } |
94 | 95 |
95 void DOMFormData::append(const String& name, const String& value) | 96 void DOMFormData::append(const String& name, const String& value) |
96 { | 97 { |
97 appendData(name, value); | 98 appendData(name, value); |
98 } | 99 } |
99 | 100 |
100 void DOMFormData::append(const String& name, Blob* blob, const String& filename) | 101 void DOMFormData::append(ExecutionContext* context, const String& name, Blob* bl
ob, const String& filename) |
101 { | 102 { |
| 103 if (blob) { |
| 104 if (blob->isFile()) { |
| 105 if (filename.isNull()) |
| 106 UseCounter::count(context, UseCounter::FormDataAppendFile); |
| 107 else |
| 108 UseCounter::count(context, UseCounter::FormDataAppendFileWithFil
ename); |
| 109 } else { |
| 110 if (filename.isNull()) |
| 111 UseCounter::count(context, UseCounter::FormDataAppendBlob); |
| 112 else |
| 113 UseCounter::count(context, UseCounter::FormDataAppendBlobWithFil
ename); |
| 114 } |
| 115 } else { |
| 116 UseCounter::count(context, UseCounter::FormDataAppendNull); |
| 117 } |
102 appendBlob(name, blob, filename); | 118 appendBlob(name, blob, filename); |
103 } | 119 } |
104 | 120 |
105 void DOMFormData::get(const String& name, FormDataEntryValue& result) | 121 void DOMFormData::get(const String& name, FormDataEntryValue& result) |
106 { | 122 { |
107 Entry entry = getEntry(name); | 123 Entry entry = getEntry(name); |
108 if (entry.isString()) | 124 if (entry.isString()) |
109 result.setUSVString(entry.string()); | 125 result.setUSVString(entry.string()); |
110 else if (entry.isFile()) | 126 else if (entry.isFile()) |
111 result.setFile(entry.file()); | 127 result.setFile(entry.file()); |
(...skipping 29 matching lines...) Expand all Loading... |
141 { | 157 { |
142 setBlob(name, blob, filename); | 158 setBlob(name, blob, filename); |
143 } | 159 } |
144 | 160 |
145 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte
ration(ScriptState*, ExceptionState&) | 161 PairIterable<String, FormDataEntryValue>::IterationSource* DOMFormData::startIte
ration(ScriptState*, ExceptionState&) |
146 { | 162 { |
147 return new DOMFormDataIterationSource(this); | 163 return new DOMFormDataIterationSource(this); |
148 } | 164 } |
149 | 165 |
150 } // namespace blink | 166 } // namespace blink |
OLD | NEW |