OLD | NEW |
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 <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 30 matching lines...) Expand all Loading... |
41 // be destroyed on the UI thread. References to FileSelectHelper may be passed | 41 // be destroyed on the UI thread. References to FileSelectHelper may be passed |
42 // on to other threads. | 42 // on to other threads. |
43 class FileSelectHelper : public base::RefCountedThreadSafe< | 43 class FileSelectHelper : public base::RefCountedThreadSafe< |
44 FileSelectHelper, | 44 FileSelectHelper, |
45 content::BrowserThread::DeleteOnUIThread>, | 45 content::BrowserThread::DeleteOnUIThread>, |
46 public ui::SelectFileDialog::Listener, | 46 public ui::SelectFileDialog::Listener, |
47 public content::WebContentsObserver, | 47 public content::WebContentsObserver, |
48 public content::NotificationObserver { | 48 public content::NotificationObserver { |
49 public: | 49 public: |
50 // Show the file chooser dialog. | 50 // Show the file chooser dialog. |
51 static void RunFileChooser(content::WebContents* tab, | 51 static void RunFileChooser(content::RenderFrameHost* render_frame_host, |
52 const content::FileChooserParams& params); | 52 const content::FileChooserParams& params); |
53 | 53 |
54 // Enumerates all the files in directory. | 54 // Enumerates all the files in directory. |
55 static void EnumerateDirectory(content::WebContents* tab, | 55 static void EnumerateDirectory(content::WebContents* tab, |
56 int request_id, | 56 int request_id, |
57 const base::FilePath& path); | 57 const base::FilePath& path); |
58 | 58 |
59 private: | 59 private: |
60 friend class base::RefCountedThreadSafe<FileSelectHelper>; | 60 friend class base::RefCountedThreadSafe<FileSelectHelper>; |
61 friend class base::DeleteHelper<FileSelectHelper>; | 61 friend class base::DeleteHelper<FileSelectHelper>; |
(...skipping 20 matching lines...) Expand all Loading... |
82 void OnListDone(int error) override; | 82 void OnListDone(int error) override; |
83 | 83 |
84 private: | 84 private: |
85 // This FileSelectHelper owns this object. | 85 // This FileSelectHelper owns this object. |
86 FileSelectHelper* parent_; | 86 FileSelectHelper* parent_; |
87 int id_; | 87 int id_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate); | 89 DISALLOW_COPY_AND_ASSIGN(DirectoryListerDispatchDelegate); |
90 }; | 90 }; |
91 | 91 |
92 void RunFileChooser(content::RenderViewHost* render_view_host, | 92 void RunFileChooser(content::RenderFrameHost* render_frame_host, |
93 content::WebContents* web_contents, | |
94 std::unique_ptr<content::FileChooserParams> params); | 93 std::unique_ptr<content::FileChooserParams> params); |
95 void GetFileTypesOnFileThread( | 94 void GetFileTypesOnFileThread( |
96 std::unique_ptr<content::FileChooserParams> params); | 95 std::unique_ptr<content::FileChooserParams> params); |
97 void GetSanitizedFilenameOnUIThread( | 96 void GetSanitizedFilenameOnUIThread( |
98 std::unique_ptr<content::FileChooserParams> params); | 97 std::unique_ptr<content::FileChooserParams> params); |
99 #if defined(FULL_SAFE_BROWSING) | 98 #if defined(FULL_SAFE_BROWSING) |
100 void CheckDownloadRequestWithSafeBrowsing( | 99 void CheckDownloadRequestWithSafeBrowsing( |
101 const base::FilePath& default_path, | 100 const base::FilePath& default_path, |
102 std::unique_ptr<content::FileChooserParams> params); | 101 std::unique_ptr<content::FileChooserParams> params); |
103 void ProceedWithSafeBrowsingVerdict( | 102 void ProceedWithSafeBrowsingVerdict( |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // filename. | 213 // filename. |
215 // | 214 // |
216 // Otherwise, returns |suggested_path| with any invalid characters will be | 215 // Otherwise, returns |suggested_path| with any invalid characters will be |
217 // replaced with a suitable replacement character. | 216 // replaced with a suitable replacement character. |
218 static base::FilePath GetSanitizedFileName( | 217 static base::FilePath GetSanitizedFileName( |
219 const base::FilePath& suggested_path); | 218 const base::FilePath& suggested_path); |
220 | 219 |
221 // Profile used to set/retrieve the last used directory. | 220 // Profile used to set/retrieve the last used directory. |
222 Profile* profile_; | 221 Profile* profile_; |
223 | 222 |
224 // The RenderViewHost and WebContents for the page showing a file dialog | 223 // The RenderFrameHost and WebContents for the page showing a file dialog |
225 // (may only be one such dialog). | 224 // (may only be one such dialog). |
226 content::RenderViewHost* render_view_host_; | 225 content::RenderFrameHost* render_frame_host_; |
227 content::WebContents* web_contents_; | 226 content::WebContents* web_contents_; |
228 | 227 |
229 // Dialog box used for choosing files to upload from file form fields. | 228 // Dialog box used for choosing files to upload from file form fields. |
230 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 229 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
231 std::unique_ptr<ui::SelectFileDialog::FileTypeInfo> select_file_types_; | 230 std::unique_ptr<ui::SelectFileDialog::FileTypeInfo> select_file_types_; |
232 | 231 |
233 // The type of file dialog last shown. | 232 // The type of file dialog last shown. |
234 ui::SelectFileDialog::Type dialog_type_; | 233 ui::SelectFileDialog::Type dialog_type_; |
235 | 234 |
236 // The mode of file dialog last shown. | 235 // The mode of file dialog last shown. |
237 content::FileChooserParams::Mode dialog_mode_; | 236 content::FileChooserParams::Mode dialog_mode_; |
238 | 237 |
239 // Maintain a list of active directory enumerations. These could come from | 238 // Maintain a list of active directory enumerations. These could come from |
240 // the file select dialog or from drag-and-drop of directories, so there could | 239 // the file select dialog or from drag-and-drop of directories, so there could |
241 // be more than one going on at a time. | 240 // be more than one going on at a time. |
242 struct ActiveDirectoryEnumeration; | 241 struct ActiveDirectoryEnumeration; |
243 std::map<int, ActiveDirectoryEnumeration*> directory_enumerations_; | 242 std::map<int, ActiveDirectoryEnumeration*> directory_enumerations_; |
244 | 243 |
245 // Registrar for notifications regarding our RenderViewHost. | 244 // Registrar for notifications regarding our RenderViewHost. |
246 content::NotificationRegistrar notification_registrar_; | 245 content::NotificationRegistrar notification_registrar_; |
247 | 246 |
248 // Temporary files only used on OSX. This class is responsible for deleting | 247 // Temporary files only used on OSX. This class is responsible for deleting |
249 // these files when they are no longer needed. | 248 // these files when they are no longer needed. |
250 std::vector<base::FilePath> temporary_files_; | 249 std::vector<base::FilePath> temporary_files_; |
251 | 250 |
252 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); | 251 DISALLOW_COPY_AND_ASSIGN(FileSelectHelper); |
253 }; | 252 }; |
254 | 253 |
255 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ | 254 #endif // CHROME_BROWSER_FILE_SELECT_HELPER_H_ |
OLD | NEW |