Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/HTMLInputElementFileSystem.cpp

Issue 2297043002: Web expose FileSystemFileEntry, FileSystemDirectoryEntry and friends (Closed)
Patch Set: Rebased Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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
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 "modules/filesystem/HTMLInputElementFileSystem.h" 31 #include "modules/filesystem/HTMLInputElementFileSystem.h"
32 32
33 #include "core/fileapi/FileList.h" 33 #include "core/fileapi/FileList.h"
34 #include "core/html/HTMLInputElement.h" 34 #include "core/html/HTMLInputElement.h"
35 #include "modules/filesystem/DOMFilePath.h" 35 #include "modules/filesystem/DOMFilePath.h"
36 #include "modules/filesystem/DOMFileSystem.h" 36 #include "modules/filesystem/FileSystem.h"
37 #include "modules/filesystem/DirectoryEntry.h" 37 #include "modules/filesystem/FileSystemDirectoryEntry.h"
38 #include "modules/filesystem/Entry.h" 38 #include "modules/filesystem/FileSystemEntry.h"
39 #include "modules/filesystem/FileEntry.h" 39 #include "modules/filesystem/FileSystemFileEntry.h"
40 #include "platform/FileMetadata.h" 40 #include "platform/FileMetadata.h"
41 #include "platform/heap/Handle.h" 41 #include "platform/heap/Handle.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 // static 45 // static
46 EntryHeapVector HTMLInputElementFileSystem::webkitEntries( 46 EntryHeapVector HTMLInputElementFileSystem::webkitEntries(
47 ExecutionContext* executionContext, 47 ExecutionContext* executionContext,
48 HTMLInputElement& input) { 48 HTMLInputElement& input) {
49 EntryHeapVector entries; 49 EntryHeapVector entries;
50 FileList* files = input.files(); 50 FileList* files = input.files();
51 51
52 if (!files) 52 if (!files)
53 return entries; 53 return entries;
54 54
55 DOMFileSystem* filesystem = DOMFileSystem::createIsolatedFileSystem( 55 FileSystem* filesystem = FileSystem::createIsolatedFileSystem(
56 executionContext, input.droppedFileSystemId()); 56 executionContext, input.droppedFileSystemId());
57 if (!filesystem) { 57 if (!filesystem) {
58 // Drag-drop isolated filesystem is not available. 58 // Drag-drop isolated filesystem is not available.
59 return entries; 59 return entries;
60 } 60 }
61 61
62 for (unsigned i = 0; i < files->length(); ++i) { 62 for (unsigned i = 0; i < files->length(); ++i) {
63 File* file = files->item(i); 63 File* file = files->item(i);
64 64
65 // FIXME: This involves synchronous file operation. 65 // FIXME: This involves synchronous file operation.
66 FileMetadata metadata; 66 FileMetadata metadata;
67 if (!getFileMetadata(file->path(), metadata)) 67 if (!getFileMetadata(file->path(), metadata))
68 continue; 68 continue;
69 69
70 // The dropped entries are mapped as top-level entries in the isolated 70 // The dropped entries are mapped as top-level entries in the isolated
71 // filesystem. 71 // filesystem.
72 String virtualPath = DOMFilePath::append("/", file->name()); 72 String virtualPath = DOMFilePath::append("/", file->name());
73 if (metadata.type == FileMetadata::TypeDirectory) 73 if (metadata.type == FileMetadata::TypeDirectory)
74 entries.append(DirectoryEntry::create(filesystem, virtualPath)); 74 entries.append(FileSystemDirectoryEntry::create(filesystem, virtualPath));
75 else 75 else
76 entries.append(FileEntry::create(filesystem, virtualPath)); 76 entries.append(FileSystemFileEntry::create(filesystem, virtualPath));
77 } 77 }
78 return entries; 78 return entries;
79 } 79 }
80 80
81 } // namespace blink 81 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698