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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2811533002: Exclude files from FileSelectChooser if they can't convert to WebStrings. (Closed)
Patch Set: Update comment. Created 3 years, 8 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: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 9cfedcf3d3cd1f8e59ae3c803f5cd51dda910520..2ff5f4b8d799ad9e1d16dbe8f878262df0fce214 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -5755,19 +5755,30 @@ void RenderFrameImpl::OnFileChooserResponse(
if (file_chooser_completions_.empty())
return;
+ // Exclude files whose paths can't be converted into WebStrings. Blink won't
+ // be able to handle these, and the browser process would kill the renderer
+ // when it claims to have chosen an empty file path.
+ std::vector<content::FileChooserFileInfo> filtered_files;
+ for (const auto& file : files) {
+ if (!blink::FilePathToWebString(file.file_path).IsEmpty())
+ filtered_files.push_back(file);
+ }
+
// Convert Chrome's SelectedFileInfo list to WebKit's.
WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files(
- files.size());
- for (size_t i = 0; i < files.size(); ++i) {
+ filtered_files.size());
+ for (size_t i = 0; i < filtered_files.size(); ++i) {
blink::WebFileChooserCompletion::SelectedFileInfo selected_file;
- selected_file.path = blink::FilePathToWebString(files[i].file_path);
- selected_file.display_name =
- blink::FilePathToWebString(base::FilePath(files[i].display_name));
- if (files[i].file_system_url.is_valid()) {
- selected_file.file_system_url = files[i].file_system_url;
- selected_file.length = files[i].length;
- selected_file.modification_time = files[i].modification_time.ToDoubleT();
- selected_file.is_directory = files[i].is_directory;
+ selected_file.path =
+ blink::FilePathToWebString(filtered_files[i].file_path);
asanka 2017/04/20 03:05:11 Nit: Why not skip test with selected_file.path.IsE
Charlie Reis 2017/04/20 19:00:38 Heh, I did try that at first. :) AFAICT, WebVect
+ selected_file.display_name = blink::FilePathToWebString(
+ base::FilePath(filtered_files[i].display_name));
+ if (filtered_files[i].file_system_url.is_valid()) {
+ selected_file.file_system_url = filtered_files[i].file_system_url;
+ selected_file.length = filtered_files[i].length;
+ selected_file.modification_time =
+ filtered_files[i].modification_time.ToDoubleT();
+ selected_file.is_directory = filtered_files[i].is_directory;
}
selected_files[i] = selected_file;
}

Powered by Google App Engine
This is Rietveld 408576698