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

Side by Side 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, 1 month 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 | chrome/browser/file_select_helper.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 #ifndef CHROME_BROWSER_FILE_SELECT_HELPER_H_ 5 #ifndef CHROME_BROWSER_FILE_SELECT_HELPER_H_
6 #define CHROME_BROWSER_FILE_SELECT_HELPER_H_ 6 #define CHROME_BROWSER_FILE_SELECT_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // Enumerates all the files in directory. 45 // Enumerates all the files in directory.
46 static void EnumerateDirectory(content::WebContents* tab, 46 static void EnumerateDirectory(content::WebContents* tab,
47 int request_id, 47 int request_id,
48 const base::FilePath& path); 48 const base::FilePath& path);
49 49
50 private: 50 private:
51 friend class base::RefCountedThreadSafe<FileSelectHelper>; 51 friend class base::RefCountedThreadSafe<FileSelectHelper>;
52 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid); 52 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, IsAcceptTypeValid);
53 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage); 53 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, ZipPackage);
54 FRIEND_TEST_ALL_PREFIXES(FileSelectHelperTest, GetSanitizedFileName);
54 explicit FileSelectHelper(Profile* profile); 55 explicit FileSelectHelper(Profile* profile);
55 ~FileSelectHelper() override; 56 ~FileSelectHelper() override;
56 57
57 // Utility class which can listen for directory lister events and relay 58 // Utility class which can listen for directory lister events and relay
58 // them to the main object with the correct tracking id. 59 // them to the main object with the correct tracking id.
59 class DirectoryListerDispatchDelegate 60 class DirectoryListerDispatchDelegate
60 : public net::DirectoryLister::DirectoryListerDelegate { 61 : public net::DirectoryLister::DirectoryListerDelegate {
61 public: 62 public:
62 DirectoryListerDispatchDelegate(FileSelectHelper* parent, int id) 63 DirectoryListerDispatchDelegate(FileSelectHelper* parent, int id)
63 : parent_(parent), 64 : parent_(parent),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // |accept_types| contains only valid lowercased MIME types or file extensions 171 // |accept_types| contains only valid lowercased MIME types or file extensions
171 // beginning with a period (.). 172 // beginning with a period (.).
172 static scoped_ptr<ui::SelectFileDialog::FileTypeInfo> 173 static scoped_ptr<ui::SelectFileDialog::FileTypeInfo>
173 GetFileTypesFromAcceptType( 174 GetFileTypesFromAcceptType(
174 const std::vector<base::string16>& accept_types); 175 const std::vector<base::string16>& accept_types);
175 176
176 // Check the accept type is valid. It is expected to be all lower case with 177 // Check the accept type is valid. It is expected to be all lower case with
177 // no whitespace. 178 // no whitespace.
178 static bool IsAcceptTypeValid(const std::string& accept_type); 179 static bool IsAcceptTypeValid(const std::string& accept_type);
179 180
181 // Get a sanitized filename suitable for use as a default filename. The
182 // suggested filename coming over the IPC may contain invalid characters or
183 // may result in a filename that's reserved on the current platform.
184 //
185 // If |suggested_path| is empty, the return value is also empty.
186 //
187 // If |suggested_path| is non-empty, but can't be safely converted to UTF-8,
188 // or is entirely lost during the sanitization process (e.g. because it
189 // consists entirely of invalid characters), it's replaced with a default
190 // filename.
191 //
192 // Otherwise, returns |suggested_path| with any invalid characters will be
193 // replaced with a suitable replacement character.
194 static base::FilePath GetSanitizedFileName(
195 const base::FilePath& suggested_path);
196
180 // Profile used to set/retrieve the last used directory. 197 // Profile used to set/retrieve the last used directory.
181 Profile* profile_; 198 Profile* profile_;
182 199
183 // The RenderViewHost and WebContents for the page showing a file dialog 200 // The RenderViewHost and WebContents for the page showing a file dialog
184 // (may only be one such dialog). 201 // (may only be one such dialog).
185 content::RenderViewHost* render_view_host_; 202 content::RenderViewHost* render_view_host_;
186 content::WebContents* web_contents_; 203 content::WebContents* web_contents_;
187 204
188 // Dialog box used for choosing files to upload from file form fields. 205 // Dialog box used for choosing files to upload from file form fields.
189 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; 206 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
(...skipping 15 matching lines...) Expand all
205 content::NotificationRegistrar notification_registrar_; 222 content::NotificationRegistrar notification_registrar_;
206 223
207 // Temporary files only used on OSX. This class is responsible for deleting 224 // Temporary files only used on OSX. This class is responsible for deleting
208 // these files when they are no longer needed. 225 // these files when they are no longer needed.
209 std::vector<base::FilePath> temporary_files_; 226 std::vector<base::FilePath> temporary_files_;
210 227
211 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); 228 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper);
212 }; 229 };
213 230
214 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ 231 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_
OLDNEW
« 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