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