OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool FormDataList::hasEntry(const String& key) const | 114 bool FormDataList::hasEntry(const String& key) const |
115 { | 115 { |
116 const CString keyData = encodeAndNormalize(key); | 116 const CString keyData = encodeAndNormalize(key); |
117 for (const Item& item : items()) { | 117 for (const Item& item : items()) { |
118 if (item.key() == keyData) | 118 if (item.key() == keyData) |
119 return true; | 119 return true; |
120 } | 120 } |
121 return false; | 121 return false; |
122 } | 122 } |
123 | 123 |
124 void FormDataList::setBlob(const String& key, Blob* blob, const String& filename
) | |
125 { | |
126 setEntry(Item(encodeAndNormalize(key), blob, filename)); | |
127 } | |
128 | |
129 void FormDataList::setData(const String& key, const String& value) | |
130 { | |
131 setEntry(Item(encodeAndNormalize(key), encodeAndNormalize(value))); | |
132 } | |
133 | |
134 void FormDataList::setEntry(const Item& item) | |
135 { | |
136 const CString keyData = item.key(); | |
137 bool found = false; | |
138 size_t i = 0; | |
139 while (i < m_items.size()) { | |
140 if (m_items[i].key() != keyData) { | |
141 ++i; | |
142 } else if (found) { | |
143 m_items.remove(i); | |
144 } else { | |
145 found = true; | |
146 m_items[i] = item; | |
147 ++i; | |
148 } | |
149 } | |
150 if (!found) | |
151 m_items.append(item); | |
152 return; | |
153 } | |
154 | |
155 PassRefPtr<FormData> FormDataList::createFormData(FormData::EncodingType encodin
gType) | 124 PassRefPtr<FormData> FormDataList::createFormData(FormData::EncodingType encodin
gType) |
156 { | 125 { |
157 RefPtr<FormData> result = FormData::create(); | 126 RefPtr<FormData> result = FormData::create(); |
158 appendKeyValuePairItemsTo(result.get(), m_encoding, false, encodingType); | 127 appendKeyValuePairItemsTo(result.get(), m_encoding, false, encodingType); |
159 return result.release(); | 128 return result.release(); |
160 } | 129 } |
161 | 130 |
162 PassRefPtr<FormData> FormDataList::createMultiPartFormData() | 131 PassRefPtr<FormData> FormDataList::createMultiPartFormData() |
163 { | 132 { |
164 RefPtr<FormData> result = FormData::create(); | 133 RefPtr<FormData> result = FormData::create(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 { | 224 { |
256 visitor->trace(m_file); | 225 visitor->trace(m_file); |
257 } | 226 } |
258 | 227 |
259 DEFINE_TRACE(FormDataList::Item) | 228 DEFINE_TRACE(FormDataList::Item) |
260 { | 229 { |
261 visitor->trace(m_blob); | 230 visitor->trace(m_blob); |
262 } | 231 } |
263 | 232 |
264 } // namespace blink | 233 } // namespace blink |
OLD | NEW |