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

Unified Diff: third_party/WebKit/Source/core/html/forms/FileInputType.cpp

Issue 2098703003: DevTools: protocol setting files properly handles mimetypes and directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/forms/FileInputType.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/FileInputType.cpp b/third_party/WebKit/Source/core/html/forms/FileInputType.cpp
index 98353fbca72a2cd287551efe12602637088a6d75..3bae496cd71ba5878d044be047db4c84553ceffb 100644
--- a/third_party/WebKit/Source/core/html/forms/FileInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/FileInputType.cpp
@@ -317,35 +317,31 @@ void FileInputType::filesChosen(const Vector<FileChooserFileInfo>& files)
setFiles(createFileList(files, element().fastHasAttribute(webkitdirectoryAttr)));
}
-void FileInputType::receiveDropForDirectoryUpload(const Vector<String>& paths)
+void FileInputType::setFilesFromDirectory(const String& path)
{
if (ChromeClient* chromeClient = this->chromeClient()) {
FileChooserSettings settings;
HTMLInputElement& input = element();
settings.allowsDirectoryUpload = true;
settings.allowsMultipleFiles = true;
- settings.selectedFiles.append(paths[0]);
+ settings.selectedFiles.append(path);
settings.acceptMIMETypes = input.acceptMIMETypes();
settings.acceptFileExtensions = input.acceptFileExtensions();
chromeClient->enumerateChosenDirectory(newFileChooser(settings));
}
}
-bool FileInputType::receiveDroppedFiles(const DragData* dragData)
+void FileInputType::setFilesFromPaths(const Vector<String>& paths)
{
- Vector<String> paths;
- dragData->asFilePaths(paths);
if (paths.isEmpty())
- return false;
+ return;
HTMLInputElement& input = element();
if (input.fastHasAttribute(webkitdirectoryAttr)) {
- receiveDropForDirectoryUpload(paths);
- return true;
+ setFilesFromDirectory(paths[0]);
+ return;
}
- m_droppedFileSystemId = dragData->droppedFileSystemId();
-
Vector<FileChooserFileInfo> files;
for (unsigned i = 0; i < paths.size(); ++i)
files.append(FileChooserFileInfo(paths[i]));
@@ -357,6 +353,19 @@ bool FileInputType::receiveDroppedFiles(const DragData* dragData)
firstFileOnly.append(files[0]);
filesChosen(firstFileOnly);
}
+}
+
+bool FileInputType::receiveDroppedFiles(const DragData* dragData)
+{
+ Vector<String> paths;
+ dragData->asFilePaths(paths);
+ if (paths.isEmpty())
+ return false;
+
+ if (!element().fastHasAttribute(webkitdirectoryAttr)) {
+ m_droppedFileSystemId = dragData->droppedFileSystemId();
+ }
+ setFilesFromPaths(paths);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698