| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 3 * rights reserved. |
| 3 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 4 * | 5 * |
| 5 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 9 * | 10 * |
| 10 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 159 |
| 159 bool FileInputType::canSetStringValue() const { | 160 bool FileInputType::canSetStringValue() const { |
| 160 return false; | 161 return false; |
| 161 } | 162 } |
| 162 | 163 |
| 163 FileList* FileInputType::files() { | 164 FileList* FileInputType::files() { |
| 164 return m_fileList.get(); | 165 return m_fileList.get(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 bool FileInputType::canSetValue(const String& value) { | 168 bool FileInputType::canSetValue(const String& value) { |
| 168 // For security reasons, we don't allow setting the filename, but we do allow
clearing it. | 169 // For security reasons, we don't allow setting the filename, but we do allow |
| 169 // The HTML5 spec (as of the 10/24/08 working draft) says that the value attri
bute isn't | 170 // clearing it. The HTML5 spec (as of the 10/24/08 working draft) says that |
| 170 // applicable to the file upload control at all, but for now we are keeping th
is behavior | 171 // the value attribute isn't applicable to the file upload control at all, but |
| 171 // to avoid breaking existing websites that may be relying on this. | 172 // for now we are keeping this behavior to avoid breaking existing websites |
| 173 // that may be relying on this. |
| 172 return value.isEmpty(); | 174 return value.isEmpty(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 bool FileInputType::getTypeSpecificValue(String& value) { | 177 bool FileInputType::getTypeSpecificValue(String& value) { |
| 176 if (m_fileList->isEmpty()) { | 178 if (m_fileList->isEmpty()) { |
| 177 value = String(); | 179 value = String(); |
| 178 return true; | 180 return true; |
| 179 } | 181 } |
| 180 | 182 |
| 181 // HTML5 tells us that we're supposed to use this goofy value for | 183 // HTML5 tells us that we're supposed to use this goofy value for |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 for (size_t i = 1; i < size; ++i) { | 218 for (size_t i = 1; i < size; ++i) { |
| 217 while (!files[i].path.startsWith(rootPath)) | 219 while (!files[i].path.startsWith(rootPath)) |
| 218 rootPath = directoryName(rootPath); | 220 rootPath = directoryName(rootPath); |
| 219 } | 221 } |
| 220 rootPath = directoryName(rootPath); | 222 rootPath = directoryName(rootPath); |
| 221 DCHECK(rootPath.length()); | 223 DCHECK(rootPath.length()); |
| 222 int rootLength = rootPath.length(); | 224 int rootLength = rootPath.length(); |
| 223 if (rootPath[rootLength - 1] != '\\' && rootPath[rootLength - 1] != '/') | 225 if (rootPath[rootLength - 1] != '\\' && rootPath[rootLength - 1] != '/') |
| 224 rootLength += 1; | 226 rootLength += 1; |
| 225 for (size_t i = 0; i < size; ++i) { | 227 for (size_t i = 0; i < size; ++i) { |
| 226 // Normalize backslashes to slashes before exposing the relative path to s
cript. | 228 // Normalize backslashes to slashes before exposing the relative path to |
| 229 // script. |
| 227 String relativePath = | 230 String relativePath = |
| 228 files[i].path.substring(rootLength).replace('\\', '/'); | 231 files[i].path.substring(rootLength).replace('\\', '/'); |
| 229 fileList->append( | 232 fileList->append( |
| 230 File::createWithRelativePath(files[i].path, relativePath)); | 233 File::createWithRelativePath(files[i].path, relativePath)); |
| 231 } | 234 } |
| 232 return fileList; | 235 return fileList; |
| 233 } | 236 } |
| 234 | 237 |
| 235 for (size_t i = 0; i < size; ++i) { | 238 for (size_t i = 0; i < size; ++i) { |
| 236 if (files[i].fileSystemURL.isEmpty()) { | 239 if (files[i].fileSystemURL.isEmpty()) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 StringBuilder names; | 391 StringBuilder names; |
| 389 for (size_t i = 0; i < listSize; ++i) { | 392 for (size_t i = 0; i < listSize; ++i) { |
| 390 names.append(fileList->item(i)->name()); | 393 names.append(fileList->item(i)->name()); |
| 391 if (i != listSize - 1) | 394 if (i != listSize - 1) |
| 392 names.append('\n'); | 395 names.append('\n'); |
| 393 } | 396 } |
| 394 return names.toString(); | 397 return names.toString(); |
| 395 } | 398 } |
| 396 | 399 |
| 397 } // namespace blink | 400 } // namespace blink |
| OLD | NEW |