| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | // Copyright (c) 2014 GitHub, Inc. All rights reserved.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be
 | 
					
						
							|  |  |  | // found in the LICENSE file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef ATOM_BROWSER_WEB_DIALOG_HELPER_H_
 | 
					
						
							|  |  |  | #define ATOM_BROWSER_WEB_DIALOG_HELPER_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-12 06:30:43 +05:30
										 |  |  | #include <memory>
 | 
					
						
							| 
									
										
										
										
											2019-05-21 09:18:22 -07:00
										 |  |  | #include <vector>
 | 
					
						
							| 
									
										
										
										
											2019-01-12 06:30:43 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | #include "base/memory/weak_ptr.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-21 09:18:22 -07:00
										 |  |  | #include "net/base/directory_lister.h"
 | 
					
						
							| 
									
										
										
										
											2019-01-12 06:30:43 +05:30
										 |  |  | #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
 | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace base { | 
					
						
							|  |  |  | class FilePath; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace content { | 
					
						
							| 
									
										
										
										
											2019-01-12 06:30:43 +05:30
										 |  |  | class FileSelectListener; | 
					
						
							| 
									
										
										
										
											2016-09-06 17:24:37 +09:00
										 |  |  | class RenderFrameHost; | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | class WebContents; | 
					
						
							| 
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 |  |  | }  // namespace content
 | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace atom { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-21 09:18:22 -07:00
										 |  |  | class DirectoryListerHelperDelegate { | 
					
						
							|  |  |  |  public: | 
					
						
							|  |  |  |   virtual void OnDirectoryListerDone( | 
					
						
							|  |  |  |       std::vector<blink::mojom::FileChooserFileInfoPtr> file_info, | 
					
						
							|  |  |  |       base::FilePath base_dir) = 0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DirectoryListerHelper | 
					
						
							|  |  |  |     : public net::DirectoryLister::DirectoryListerDelegate { | 
					
						
							|  |  |  |  public: | 
					
						
							|  |  |  |   DirectoryListerHelper(base::FilePath base, | 
					
						
							|  |  |  |                         DirectoryListerHelperDelegate* helper); | 
					
						
							|  |  |  |   ~DirectoryListerHelper() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  private: | 
					
						
							|  |  |  |   void OnListFile( | 
					
						
							|  |  |  |       const net::DirectoryLister::DirectoryListerData& data) override; | 
					
						
							|  |  |  |   void OnListDone(int error) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   base::FilePath base_dir_; | 
					
						
							|  |  |  |   DirectoryListerHelperDelegate* delegate_; | 
					
						
							|  |  |  |   std::vector<base::FilePath> paths_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   DISALLOW_COPY_AND_ASSIGN(DirectoryListerHelper); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | class NativeWindow; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class WebDialogHelper { | 
					
						
							|  |  |  |  public: | 
					
						
							| 
									
										
										
										
											2017-11-13 16:13:54 +09:00
										 |  |  |   WebDialogHelper(NativeWindow* window, bool offscreen); | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  |   ~WebDialogHelper(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-06 17:24:37 +09:00
										 |  |  |   void RunFileChooser(content::RenderFrameHost* render_frame_host, | 
					
						
							| 
									
										
										
										
											2019-01-12 06:30:43 +05:30
										 |  |  |                       std::unique_ptr<content::FileSelectListener> listener, | 
					
						
							|  |  |  |                       const blink::mojom::FileChooserParams& params); | 
					
						
							| 
									
										
										
										
											2014-10-31 17:37:32 +08:00
										 |  |  |   void EnumerateDirectory(content::WebContents* web_contents, | 
					
						
							| 
									
										
										
										
											2019-01-12 06:30:43 +05:30
										 |  |  |                           std::unique_ptr<content::FileSelectListener> listener, | 
					
						
							| 
									
										
										
										
											2014-10-31 17:37:32 +08:00
										 |  |  |                           const base::FilePath& path); | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |  private: | 
					
						
							|  |  |  |   NativeWindow* window_; | 
					
						
							| 
									
										
										
										
											2017-11-02 22:50:04 +01:00
										 |  |  |   bool offscreen_; | 
					
						
							| 
									
										
										
										
											2014-10-31 00:37:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   base::WeakPtrFactory<WebDialogHelper> weak_factory_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   DISALLOW_COPY_AND_ASSIGN(WebDialogHelper); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }  // namespace atom
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif  // ATOM_BROWSER_WEB_DIALOG_HELPER_H_
 |