Chromium Code Reviews| 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; |
| } |