| 
									
										
										
										
											2015-06-22 17:13:49 +05:30
										 |  |  | // Copyright (c) 2015 GitHub, Inc.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be
 | 
					
						
							|  |  |  | // found in the LICENSE file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef ATOM_BROWSER_ATOM_DOWNLOAD_MANAGER_DELEGATE_H_
 | 
					
						
							|  |  |  | #define ATOM_BROWSER_ATOM_DOWNLOAD_MANAGER_DELEGATE_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 15:51:06 +01:00
										 |  |  | #include "atom/browser/ui/file_dialog.h"
 | 
					
						
							| 
									
										
										
										
											2015-06-22 17:13:49 +05:30
										 |  |  | #include "base/memory/weak_ptr.h"
 | 
					
						
							|  |  |  | #include "content/public/browser/download_manager_delegate.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace content { | 
					
						
							|  |  |  | class DownloadManager; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace atom { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AtomDownloadManagerDelegate : public content::DownloadManagerDelegate { | 
					
						
							|  |  |  |  public: | 
					
						
							|  |  |  |   using CreateDownloadPathCallback = | 
					
						
							|  |  |  |       base::Callback<void(const base::FilePath&)>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   explicit AtomDownloadManagerDelegate(content::DownloadManager* manager); | 
					
						
							| 
									
										
										
										
											2018-04-17 16:03:51 -07:00
										 |  |  |   ~AtomDownloadManagerDelegate() override; | 
					
						
							| 
									
										
										
										
											2015-06-22 17:13:49 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |   // content::DownloadManagerDelegate:
 | 
					
						
							|  |  |  |   void Shutdown() override; | 
					
						
							|  |  |  |   bool DetermineDownloadTarget( | 
					
						
							| 
									
										
										
										
											2018-04-10 17:29:26 +02:00
										 |  |  |       download::DownloadItem* download, | 
					
						
							| 
									
										
										
										
											2015-06-22 17:13:49 +05:30
										 |  |  |       const content::DownloadTargetCallback& callback) override; | 
					
						
							|  |  |  |   bool ShouldOpenDownload( | 
					
						
							| 
									
										
										
										
											2018-04-10 17:29:26 +02:00
										 |  |  |       download::DownloadItem* download, | 
					
						
							| 
									
										
										
										
											2015-06-22 17:13:49 +05:30
										 |  |  |       const content::DownloadOpenDelayedCallback& callback) override; | 
					
						
							|  |  |  |   void GetNextId(const content::DownloadIdCallback& callback) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  private: | 
					
						
							| 
									
										
										
										
											2016-08-25 14:34:48 -07:00
										 |  |  |   // Get the save path set on the associated api::DownloadItem object
 | 
					
						
							| 
									
										
										
										
											2018-04-10 17:29:26 +02:00
										 |  |  |   void GetItemSavePath(download::DownloadItem* item, base::FilePath* path); | 
					
						
							| 
									
										
										
										
											2018-11-08 15:51:06 +01:00
										 |  |  |   void GetItemSaveDialogOptions(download::DownloadItem* item, | 
					
						
							|  |  |  |                                 file_dialog::DialogSettings* settings); | 
					
						
							| 
									
										
										
										
											2016-08-25 14:34:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-31 04:06:55 +02:00
										 |  |  |   void OnDownloadPathGenerated(uint32_t download_id, | 
					
						
							|  |  |  |                                const content::DownloadTargetCallback& callback, | 
					
						
							|  |  |  |                                const base::FilePath& default_path); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void OnDownloadSaveDialogDone( | 
					
						
							|  |  |  |       uint32_t download_id, | 
					
						
							|  |  |  |       const content::DownloadTargetCallback& download_callback, | 
					
						
							| 
									
										
										
										
											2019-05-14 15:46:53 -07:00
										 |  |  |       mate::Dictionary result); | 
					
						
							| 
									
										
										
										
											2019-01-31 04:06:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-22 17:13:49 +05:30
										 |  |  |   content::DownloadManager* download_manager_; | 
					
						
							|  |  |  |   base::WeakPtrFactory<AtomDownloadManagerDelegate> weak_ptr_factory_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   DISALLOW_COPY_AND_ASSIGN(AtomDownloadManagerDelegate); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }  // namespace atom
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif  // ATOM_BROWSER_ATOM_DOWNLOAD_MANAGER_DELEGATE_H_
 |