[email protected] | 84d5741 | 2012-03-03 08:59:55 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ |
| 6 | #define CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 7 | |
| 8 | #include "base/compiler_specific.h" |
| 9 | #include "base/memory/ref_counted.h" |
[email protected] | 1bd0ef1 | 2011-10-20 05:24:17 | [diff] [blame] | 10 | #include "content/public/browser/download_manager_delegate.h" |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 11 | |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 12 | namespace content { |
| 13 | |
[email protected] | e582fdd | 2011-12-20 16:48:17 | [diff] [blame] | 14 | class DownloadManager; |
| 15 | |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 16 | class ShellDownloadManagerDelegate |
| 17 | : public DownloadManagerDelegate, |
| 18 | public base::RefCountedThreadSafe<ShellDownloadManagerDelegate> { |
| 19 | public: |
| 20 | ShellDownloadManagerDelegate(); |
| 21 | |
[email protected] | 9bb54ee | 2011-10-12 17:43:35 | [diff] [blame] | 22 | void SetDownloadManager(DownloadManager* manager); |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 23 | |
[email protected] | 854e131 | 2012-07-30 17:26:30 | [diff] [blame] | 24 | virtual void Shutdown() OVERRIDE; |
[email protected] | 4766544 | 2012-07-27 02:31:22 | [diff] [blame] | 25 | virtual bool DetermineDownloadTarget( |
| 26 | DownloadItem* download, |
| 27 | const DownloadTargetCallback& callback) OVERRIDE; |
[email protected] | e666930 | 2013-03-25 14:31:16 | [diff] [blame] | 28 | virtual bool ShouldOpenDownload( |
| 29 | DownloadItem* item, |
| 30 | const DownloadOpenDelayedCallback& callback) OVERRIDE; |
[email protected] | a558b43a | 2012-08-30 17:09:27 | [diff] [blame] | 31 | |
| 32 | // Inhibits prompting and sets the default download path. |
| 33 | void SetDownloadBehaviorForTesting( |
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 34 | const base::FilePath& default_download_path); |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 35 | |
[email protected] | d682597 | 2012-11-10 01:22:52 | [diff] [blame] | 36 | protected: |
| 37 | // To allow subclasses for testing. |
| 38 | virtual ~ShellDownloadManagerDelegate(); |
| 39 | |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 40 | private: |
| 41 | friend class base::RefCountedThreadSafe<ShellDownloadManagerDelegate>; |
| 42 | |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 43 | |
| 44 | void GenerateFilename(int32 download_id, |
[email protected] | 4766544 | 2012-07-27 02:31:22 | [diff] [blame] | 45 | const DownloadTargetCallback& callback, |
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 46 | const base::FilePath& generated_name, |
| 47 | const base::FilePath& suggested_directory); |
[email protected] | a558b43a | 2012-08-30 17:09:27 | [diff] [blame] | 48 | void OnDownloadPathGenerated(int32 download_id, |
| 49 | const DownloadTargetCallback& callback, |
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 50 | const base::FilePath& suggested_path); |
[email protected] | 4766544 | 2012-07-27 02:31:22 | [diff] [blame] | 51 | void ChooseDownloadPath(int32 download_id, |
| 52 | const DownloadTargetCallback& callback, |
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 53 | const base::FilePath& suggested_path); |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 54 | |
| 55 | DownloadManager* download_manager_; |
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 56 | base::FilePath default_download_path_; |
[email protected] | a558b43a | 2012-08-30 17:09:27 | [diff] [blame] | 57 | bool suppress_prompting_; |
[email protected] | 98d6f15 | 2011-09-29 19:35:51 | [diff] [blame] | 58 | |
| 59 | DISALLOW_COPY_AND_ASSIGN(ShellDownloadManagerDelegate); |
| 60 | }; |
| 61 | |
| 62 | } // namespace content |
| 63 | |
| 64 | #endif // CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ |