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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2832313002: Exclude files from FileSelectChooser if they can't convert to WebStrings. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5750 matching lines...) Expand 10 before | Expand all | Expand 10 after
5761 void RenderFrameImpl::OnFileChooserResponse( 5761 void RenderFrameImpl::OnFileChooserResponse(
5762 const std::vector<content::FileChooserFileInfo>& files) { 5762 const std::vector<content::FileChooserFileInfo>& files) {
5763 // This could happen if we navigated to a different page before the user 5763 // This could happen if we navigated to a different page before the user
5764 // closed the chooser. 5764 // closed the chooser.
5765 if (file_chooser_completions_.empty()) 5765 if (file_chooser_completions_.empty())
5766 return; 5766 return;
5767 5767
5768 // Convert Chrome's SelectedFileInfo list to WebKit's. 5768 // Convert Chrome's SelectedFileInfo list to WebKit's.
5769 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files( 5769 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files(
5770 files.size()); 5770 files.size());
5771 size_t current_size = 0;
5771 for (size_t i = 0; i < files.size(); ++i) { 5772 for (size_t i = 0; i < files.size(); ++i) {
5772 blink::WebFileChooserCompletion::SelectedFileInfo selected_file; 5773 blink::WebFileChooserCompletion::SelectedFileInfo selected_file;
5773 selected_file.path = blink::FilePathToWebString(files[i].file_path); 5774 selected_file.path = blink::FilePathToWebString(files[i].file_path);
5775
5776 // Exclude files whose paths can't be converted into WebStrings. Blink won't
5777 // be able to handle these, and the browser process would kill the renderer
5778 // when it claims to have chosen an empty file path.
5779 if (selected_file.path.IsEmpty())
5780 continue;
5781
5774 selected_file.display_name = 5782 selected_file.display_name =
5775 blink::FilePathToWebString(base::FilePath(files[i].display_name)); 5783 blink::FilePathToWebString(base::FilePath(files[i].display_name));
5776 if (files[i].file_system_url.is_valid()) { 5784 if (files[i].file_system_url.is_valid()) {
5777 selected_file.file_system_url = files[i].file_system_url; 5785 selected_file.file_system_url = files[i].file_system_url;
5778 selected_file.length = files[i].length; 5786 selected_file.length = files[i].length;
5779 selected_file.modification_time = files[i].modification_time.ToDoubleT(); 5787 selected_file.modification_time = files[i].modification_time.ToDoubleT();
5780 selected_file.is_directory = files[i].is_directory; 5788 selected_file.is_directory = files[i].is_directory;
5781 } 5789 }
5782 selected_files[i] = selected_file; 5790
5791 selected_files[current_size] = selected_file;
5792 current_size++;
5793 }
5794
5795 // If not all files were included, truncate the WebVector.
5796 if (current_size < selected_files.size()) {
5797 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> truncated_list(
5798 selected_files.Data(), current_size);
5799 selected_files.Swap(truncated_list);
5783 } 5800 }
5784 5801
5785 if (file_chooser_completions_.front()->completion) { 5802 if (file_chooser_completions_.front()->completion) {
5786 file_chooser_completions_.front()->completion->DidChooseFile( 5803 file_chooser_completions_.front()->completion->DidChooseFile(
5787 selected_files); 5804 selected_files);
5788 } 5805 }
5789 file_chooser_completions_.pop_front(); 5806 file_chooser_completions_.pop_front();
5790 5807
5791 // If there are more pending file chooser requests, schedule one now. 5808 // If there are more pending file chooser requests, schedule one now.
5792 if (!file_chooser_completions_.empty()) { 5809 if (!file_chooser_completions_.empty()) {
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
6985 policy(info.default_policy), 7002 policy(info.default_policy),
6986 replaces_current_history_item(info.replaces_current_history_item), 7003 replaces_current_history_item(info.replaces_current_history_item),
6987 history_navigation_in_new_child_frame( 7004 history_navigation_in_new_child_frame(
6988 info.is_history_navigation_in_new_child_frame), 7005 info.is_history_navigation_in_new_child_frame),
6989 client_redirect(info.is_client_redirect), 7006 client_redirect(info.is_client_redirect),
6990 cache_disabled(info.is_cache_disabled), 7007 cache_disabled(info.is_cache_disabled),
6991 form(info.form), 7008 form(info.form),
6992 source_location(info.source_location) {} 7009 source_location(info.source_location) {}
6993 7010
6994 } // namespace content 7011 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698