// static PassRefPtrWillBeRawPtr<Entry> DataTransferItemFileSystem::webkitGetAsEntry(ExecutionContext* executionContext, DataTransferItem& item) { if (!item.dataObjectItem()->isFilename()) return nullptr; // For dragged files getAsFile must be pretty lightweight. Blob* file = item.getAsFile().get(); // The clipboard may not be in a readable state. if (!file) return nullptr; ASSERT(file->isFile()); DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(item.clipboard()->dataObject().get()); DOMFileSystem* domFileSystem = filesystem ? filesystem->getDOMFileSystem(executionContext) : 0; if (!filesystem) { // IsolatedFileSystem may not be enabled. return nullptr; } ASSERT(domFileSystem); // The dropped entries are mapped as top-level entries in the isolated filesystem. String virtualPath = DOMFilePath::append("/", toFile(file)->name()); // FIXME: This involves synchronous file operation. Consider passing file type data when we dispatch drag event. FileMetadata metadata; if (!getFileMetadata(toFile(file)->path(), metadata)) return nullptr; if (metadata.type == FileMetadata::TypeDirectory) return DirectoryEntry::create(domFileSystem, virtualPath); return FileEntry::create(domFileSystem, virtualPath); }
String DragData::droppedFileSystemId() const { DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_platformDragData); if (!filesystem) return String(); return filesystem->filesystemId(); }
// static void DataTransferItemFileSystem::webkitGetAsEntry(DataTransferItem* item, ScriptExecutionContext* scriptExecutionContext, PassRefPtr<EntryCallback> callback) { DataTransferItemPolicyWrapper* itemPolicyWrapper = static_cast<DataTransferItemPolicyWrapper*>(item); if (!callback || !itemPolicyWrapper->dataObjectItem()->isFilename()) return; // For dragged files getAsFile must be pretty lightweight. Blob* file = itemPolicyWrapper->getAsFile().get(); // The clipboard may not be in a readable state. if (!file) return; ASSERT(file->isFile()); DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(itemPolicyWrapper->clipboard()->dataObject().get()); DOMFileSystem* domFileSystem = filesystem ? filesystem->getDOMFileSystem(scriptExecutionContext) : 0; if (!filesystem) { // IsolatedFileSystem may not be enabled. DOMFileSystem::scheduleCallback(scriptExecutionContext, callback, adoptRef(static_cast<Entry*>(0))); return; } ASSERT(domFileSystem); // The dropped entries are mapped as top-level entries in the isolated filesystem. String virtualPath = DOMFilePath::append("/", static_cast<File*>(file)->name()); domFileSystem->asyncFileSystem()->readMetadata(domFileSystem->createFileSystemURL(virtualPath), GetAsEntryCallbacks::create(domFileSystem, virtualPath, callback)); }