blob: ca67e9f9ada1cf528455cfb1e50eba2cd0f48a15 [file] [log] [blame]
[email protected]de7d61ff2013-08-20 11:30:411// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]98d6f152011-09-29 19:35:512// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]de7d61ff2013-08-20 11:30:415#ifndef CONTENT_SHELL_BROWSER_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
6#define CONTENT_SHELL_BROWSER_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
[email protected]98d6f152011-09-29 19:35:517
avi66a07722015-12-25 23:38:128#include <stdint.h>
9
[email protected]7cef82172013-12-17 06:58:3710#include "base/callback_forward.h"
[email protected]98d6f152011-09-29 19:35:5111#include "base/compiler_specific.h"
avi66a07722015-12-25 23:38:1212#include "base/macros.h"
[email protected]7cef82172013-12-17 06:58:3713#include "base/memory/weak_ptr.h"
[email protected]1bd0ef12011-10-20 05:24:1714#include "content/public/browser/download_manager_delegate.h"
[email protected]98d6f152011-09-29 19:35:5115
[email protected]98d6f152011-09-29 19:35:5116namespace content {
17
[email protected]e582fdd2011-12-20 16:48:1718class DownloadManager;
19
[email protected]7cef82172013-12-17 06:58:3720class ShellDownloadManagerDelegate : public DownloadManagerDelegate {
[email protected]98d6f152011-09-29 19:35:5121 public:
22 ShellDownloadManagerDelegate();
dchenge933b3e2014-10-21 11:44:0923 ~ShellDownloadManagerDelegate() override;
[email protected]98d6f152011-09-29 19:35:5124
[email protected]9bb54ee2011-10-12 17:43:3525 void SetDownloadManager(DownloadManager* manager);
[email protected]98d6f152011-09-29 19:35:5126
dchenge933b3e2014-10-21 11:44:0927 void Shutdown() override;
Min Qina9f487872018-02-09 20:43:2328 bool DetermineDownloadTarget(download::DownloadItem* download,
danakja3cfb8332019-12-10 21:13:3329 DownloadTargetCallback* callback) override;
Min Qina9f487872018-02-09 20:43:2330 bool ShouldOpenDownload(download::DownloadItem* item,
danakj8c70a442019-12-10 22:48:2431 DownloadOpenDelayedCallback callback) override;
danakja6dd6f52019-12-10 19:04:5232 void GetNextId(DownloadIdCallback callback) override;
[email protected]a558b43a2012-08-30 17:09:2733
34 // Inhibits prompting and sets the default download path.
35 void SetDownloadBehaviorForTesting(
[email protected]d30a36f2013-02-07 04:16:2636 const base::FilePath& default_download_path);
[email protected]98d6f152011-09-29 19:35:5137
38 private:
39 friend class base::RefCountedThreadSafe<ShellDownloadManagerDelegate>;
40
danakja9fe91c2019-05-01 19:02:2941 using FilenameDeterminedCallback =
42 base::OnceCallback<void(const base::FilePath&)>;
[email protected]98d6f152011-09-29 19:35:5143
[email protected]7cef82172013-12-17 06:58:3744 static void GenerateFilename(const GURL& url,
45 const std::string& content_disposition,
46 const std::string& suggested_filename,
47 const std::string& mime_type,
48 const base::FilePath& suggested_directory,
danakja9fe91c2019-05-01 19:02:2949 FilenameDeterminedCallback callback);
avi66a07722015-12-25 23:38:1250 void OnDownloadPathGenerated(uint32_t download_id,
danakja3cfb8332019-12-10 21:13:3351 DownloadTargetCallback callback,
[email protected]d30a36f2013-02-07 04:16:2652 const base::FilePath& suggested_path);
avi66a07722015-12-25 23:38:1253 void ChooseDownloadPath(uint32_t download_id,
danakja3cfb8332019-12-10 21:13:3354 DownloadTargetCallback callback,
[email protected]d30a36f2013-02-07 04:16:2655 const base::FilePath& suggested_path);
[email protected]98d6f152011-09-29 19:35:5156
57 DownloadManager* download_manager_;
[email protected]d30a36f2013-02-07 04:16:2658 base::FilePath default_download_path_;
[email protected]a558b43a2012-08-30 17:09:2759 bool suppress_prompting_;
Jeremy Roman3bca4bf2019-07-11 03:41:2560 base::WeakPtrFactory<ShellDownloadManagerDelegate> weak_ptr_factory_{this};
[email protected]98d6f152011-09-29 19:35:5161
62 DISALLOW_COPY_AND_ASSIGN(ShellDownloadManagerDelegate);
63};
64
65} // namespace content
66
[email protected]de7d61ff2013-08-20 11:30:4167#endif // CONTENT_SHELL_BROWSER_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_