Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 5737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5748 suppress_further_dialogs_ = true; | 5748 suppress_further_dialogs_ = true; |
| 5749 } | 5749 } |
| 5750 | 5750 |
| 5751 void RenderFrameImpl::OnFileChooserResponse( | 5751 void RenderFrameImpl::OnFileChooserResponse( |
| 5752 const std::vector<content::FileChooserFileInfo>& files) { | 5752 const std::vector<content::FileChooserFileInfo>& files) { |
| 5753 // This could happen if we navigated to a different page before the user | 5753 // This could happen if we navigated to a different page before the user |
| 5754 // closed the chooser. | 5754 // closed the chooser. |
| 5755 if (file_chooser_completions_.empty()) | 5755 if (file_chooser_completions_.empty()) |
| 5756 return; | 5756 return; |
| 5757 | 5757 |
| 5758 // Exclude files whose paths can't be converted into WebStrings. Blink won't | |
| 5759 // be able to handle these, and the browser process would kill the renderer | |
| 5760 // when it claims to have chosen an empty file path. | |
| 5761 std::vector<content::FileChooserFileInfo> filtered_files; | |
| 5762 for (const auto& file : files) { | |
| 5763 if (!blink::FilePathToWebString(file.file_path).IsEmpty()) | |
| 5764 filtered_files.push_back(file); | |
| 5765 } | |
| 5766 | |
| 5758 // Convert Chrome's SelectedFileInfo list to WebKit's. | 5767 // Convert Chrome's SelectedFileInfo list to WebKit's. |
| 5759 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files( | 5768 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files( |
| 5760 files.size()); | 5769 filtered_files.size()); |
| 5761 for (size_t i = 0; i < files.size(); ++i) { | 5770 for (size_t i = 0; i < filtered_files.size(); ++i) { |
| 5762 blink::WebFileChooserCompletion::SelectedFileInfo selected_file; | 5771 blink::WebFileChooserCompletion::SelectedFileInfo selected_file; |
| 5763 selected_file.path = blink::FilePathToWebString(files[i].file_path); | 5772 selected_file.path = |
| 5764 selected_file.display_name = | 5773 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
| |
| 5765 blink::FilePathToWebString(base::FilePath(files[i].display_name)); | 5774 selected_file.display_name = blink::FilePathToWebString( |
| 5766 if (files[i].file_system_url.is_valid()) { | 5775 base::FilePath(filtered_files[i].display_name)); |
| 5767 selected_file.file_system_url = files[i].file_system_url; | 5776 if (filtered_files[i].file_system_url.is_valid()) { |
| 5768 selected_file.length = files[i].length; | 5777 selected_file.file_system_url = filtered_files[i].file_system_url; |
| 5769 selected_file.modification_time = files[i].modification_time.ToDoubleT(); | 5778 selected_file.length = filtered_files[i].length; |
| 5770 selected_file.is_directory = files[i].is_directory; | 5779 selected_file.modification_time = |
| 5780 filtered_files[i].modification_time.ToDoubleT(); | |
| 5781 selected_file.is_directory = filtered_files[i].is_directory; | |
| 5771 } | 5782 } |
| 5772 selected_files[i] = selected_file; | 5783 selected_files[i] = selected_file; |
| 5773 } | 5784 } |
| 5774 | 5785 |
| 5775 if (file_chooser_completions_.front()->completion) { | 5786 if (file_chooser_completions_.front()->completion) { |
| 5776 file_chooser_completions_.front()->completion->DidChooseFile( | 5787 file_chooser_completions_.front()->completion->DidChooseFile( |
| 5777 selected_files); | 5788 selected_files); |
| 5778 } | 5789 } |
| 5779 file_chooser_completions_.pop_front(); | 5790 file_chooser_completions_.pop_front(); |
| 5780 | 5791 |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6975 policy(info.default_policy), | 6986 policy(info.default_policy), |
| 6976 replaces_current_history_item(info.replaces_current_history_item), | 6987 replaces_current_history_item(info.replaces_current_history_item), |
| 6977 history_navigation_in_new_child_frame( | 6988 history_navigation_in_new_child_frame( |
| 6978 info.is_history_navigation_in_new_child_frame), | 6989 info.is_history_navigation_in_new_child_frame), |
| 6979 client_redirect(info.is_client_redirect), | 6990 client_redirect(info.is_client_redirect), |
| 6980 cache_disabled(info.is_cache_disabled), | 6991 cache_disabled(info.is_cache_disabled), |
| 6981 form(info.form), | 6992 form(info.form), |
| 6982 source_location(info.source_location) {} | 6993 source_location(info.source_location) {} |
| 6983 | 6994 |
| 6984 } // namespace content | 6995 } // namespace content |
| OLD | NEW |