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

Side by Side Diff: chrome/browser/file_select_helper.cc

Issue 2811533002: 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 | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/file_select_helper.h" 5 #include "chrome/browser/file_select_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 file_system_context, site_instance->GetSiteURL(), files, 313 file_system_context, site_instance->GetSiteURL(), files,
314 base::Bind( 314 base::Bind(
315 &FileSelectHelper::NotifyRenderFrameHostAndEndAfterConversion, 315 &FileSelectHelper::NotifyRenderFrameHostAndEndAfterConversion,
316 this)); 316 this));
317 return; 317 return;
318 } 318 }
319 #endif // defined(OS_CHROMEOS) 319 #endif // defined(OS_CHROMEOS)
320 320
321 std::vector<content::FileChooserFileInfo> chooser_files; 321 std::vector<content::FileChooserFileInfo> chooser_files;
322 for (const auto& file : files) { 322 for (const auto& file : files) {
323 // Exclude files whose paths can't be converted into WebStrings, since Blink
324 // won't be able to handle those.
325 if (file.local_path.AsUTF8Unsafe().empty())
asanka 2017/04/13 17:21:22 Shall we move this logic to a static function and
Charlie Reis 2017/04/14 19:28:15 Thanks for the suggestion! If we're going to be f
326 continue;
327
323 content::FileChooserFileInfo chooser_file; 328 content::FileChooserFileInfo chooser_file;
324 chooser_file.file_path = file.local_path; 329 chooser_file.file_path = file.local_path;
325 chooser_file.display_name = file.display_name; 330 chooser_file.display_name = file.display_name;
326 chooser_files.push_back(chooser_file); 331 chooser_files.push_back(chooser_file);
327 } 332 }
328 333
329 NotifyRenderFrameHostAndEndAfterConversion(chooser_files); 334 NotifyRenderFrameHostAndEndAfterConversion(chooser_files);
330 } 335 }
331 336
332 void FileSelectHelper::NotifyRenderFrameHostAndEndAfterConversion( 337 void FileSelectHelper::NotifyRenderFrameHostAndEndAfterConversion(
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 698
694 // static 699 // static
695 base::FilePath FileSelectHelper::GetSanitizedFileName( 700 base::FilePath FileSelectHelper::GetSanitizedFileName(
696 const base::FilePath& suggested_filename) { 701 const base::FilePath& suggested_filename) {
697 if (suggested_filename.empty()) 702 if (suggested_filename.empty())
698 return base::FilePath(); 703 return base::FilePath();
699 return net::GenerateFileName( 704 return net::GenerateFileName(
700 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), 705 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(),
701 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 706 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
702 } 707 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698