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

Unified Diff: chrome/browser/file_select_helper.h

Issue 1409003002: [SafeBrowsing] Block dangerous unchecked downloads based on a Finch trial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/file_select_helper.h
diff --git a/chrome/browser/file_select_helper.h b/chrome/browser/file_select_helper.h
index 0067b8a11c5c4b804068fa930a83f4ce4089c568..f3f1266b437efd657dbb5c640c7e4b9ede214def 100644
--- a/chrome/browser/file_select_helper.h
+++ b/chrome/browser/file_select_helper.h
@@ -51,6 +51,7 @@ class FileSelectHelper : public base::RefCountedThreadSafe<FileSelectHelper>,
friend class base::RefCountedThreadSafe<FileSelectHelper>;
FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid);
FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage);
+ FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, GetSanitizedFileName);
explicit FileSelectHelper(Profile* profile);
~FileSelectHelper() override;
@@ -177,6 +178,22 @@ class FileSelectHelper : public base::RefCountedThreadSafe<FileSelectHelper>,
// no whitespace.
static bool IsAcceptTypeValid(const std::string& accept_type);
+ // Get a sanitized filename suitable for use as a default filename. The
+ // suggested filename coming over the IPC may contain invalid characters or
+ // may result in a filename that's reserved on the current platform.
+ //
+ // If |suggested_path| is empty, the return value is also empty.
+ //
+ // If |suggested_path| is non-empty, but can't be safely converted to UTF-8,
+ // or is entirely lost during the sanitization process (e.g. because it
+ // consists entirely of invalid characters), it's replaced with a default
+ // filename.
+ //
+ // Otherwise, returns |suggested_path| with any invalid characters will be
+ // replaced with a suitable replacement character.
+ static base::FilePath GetSanitizedFileName(
+ const base::FilePath& suggested_path);
+
// Profile used to set/retrieve the last used directory.
Profile* profile_;
« no previous file with comments | « no previous file | chrome/browser/file_select_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698