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

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

Issue 2811533002: Exclude files from FileSelectChooser if they can't convert to WebStrings. (Closed)
Patch Set: Optimize 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 5740 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Convert Chrome's SelectedFileInfo list to WebKit's. 5758 // Convert Chrome's SelectedFileInfo list to WebKit's.
5759 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files( 5759 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files(
5760 files.size()); 5760 files.size());
5761 size_t current_size = 0;
5761 for (size_t i = 0; i < files.size(); ++i) { 5762 for (size_t i = 0; i < files.size(); ++i) {
5762 blink::WebFileChooserCompletion::SelectedFileInfo selected_file; 5763 blink::WebFileChooserCompletion::SelectedFileInfo selected_file;
5763 selected_file.path = blink::FilePathToWebString(files[i].file_path); 5764 selected_file.path = blink::FilePathToWebString(files[i].file_path);
5765
5766 // Exclude files whose paths can't be converted into WebStrings. Blink won't
5767 // be able to handle these, and the browser process would kill the renderer
5768 // when it claims to have chosen an empty file path.
5769 if (selected_file.path.IsEmpty())
5770 continue;
5771
5764 selected_file.display_name = 5772 selected_file.display_name =
5765 blink::FilePathToWebString(base::FilePath(files[i].display_name)); 5773 blink::FilePathToWebString(base::FilePath(files[i].display_name));
5766 if (files[i].file_system_url.is_valid()) { 5774 if (files[i].file_system_url.is_valid()) {
5767 selected_file.file_system_url = files[i].file_system_url; 5775 selected_file.file_system_url = files[i].file_system_url;
5768 selected_file.length = files[i].length; 5776 selected_file.length = files[i].length;
5769 selected_file.modification_time = files[i].modification_time.ToDoubleT(); 5777 selected_file.modification_time = files[i].modification_time.ToDoubleT();
5770 selected_file.is_directory = files[i].is_directory; 5778 selected_file.is_directory = files[i].is_directory;
5771 } 5779 }
5772 selected_files[i] = selected_file; 5780
5781 selected_files[current_size] = selected_file;
5782 current_size++;
5783 }
5784
5785 // If not all files were included, truncate the WebVector.
5786 if (current_size < selected_files.size()) {
5787 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> truncated_list(
5788 selected_files.Data(), current_size);
5789 selected_files.Swap(truncated_list);
5773 } 5790 }
5774 5791
5775 if (file_chooser_completions_.front()->completion) { 5792 if (file_chooser_completions_.front()->completion) {
5776 file_chooser_completions_.front()->completion->DidChooseFile( 5793 file_chooser_completions_.front()->completion->DidChooseFile(
5777 selected_files); 5794 selected_files);
5778 } 5795 }
5779 file_chooser_completions_.pop_front(); 5796 file_chooser_completions_.pop_front();
5780 5797
5781 // If there are more pending file chooser requests, schedule one now. 5798 // If there are more pending file chooser requests, schedule one now.
5782 if (!file_chooser_completions_.empty()) { 5799 if (!file_chooser_completions_.empty()) {
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
6975 policy(info.default_policy), 6992 policy(info.default_policy),
6976 replaces_current_history_item(info.replaces_current_history_item), 6993 replaces_current_history_item(info.replaces_current_history_item),
6977 history_navigation_in_new_child_frame( 6994 history_navigation_in_new_child_frame(
6978 info.is_history_navigation_in_new_child_frame), 6995 info.is_history_navigation_in_new_child_frame),
6979 client_redirect(info.is_client_redirect), 6996 client_redirect(info.is_client_redirect),
6980 cache_disabled(info.is_cache_disabled), 6997 cache_disabled(info.is_cache_disabled),
6981 form(info.form), 6998 form(info.form),
6982 source_location(info.source_location) {} 6999 source_location(info.source_location) {}
6983 7000
6984 } // namespace content 7001 } // 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