OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 FilePath* intermediate_path) = 0; | 44 FilePath* intermediate_path) = 0; |
45 | 45 |
46 // Called when the download system wants to alert a TabContents that a | 46 // Called when the download system wants to alert a TabContents that a |
47 // download has started, but the TabConetnts has gone away. This lets an | 47 // download has started, but the TabConetnts has gone away. This lets an |
48 // delegate return an alternative TabContents. The delegate can return NULL. | 48 // delegate return an alternative TabContents. The delegate can return NULL. |
49 virtual TabContents* GetAlternativeTabContentsToNotifyForDownload() = 0; | 49 virtual TabContents* GetAlternativeTabContentsToNotifyForDownload() = 0; |
50 | 50 |
51 // Tests if a file type should be opened automatically. | 51 // Tests if a file type should be opened automatically. |
52 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) = 0; | 52 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) = 0; |
53 | 53 |
54 // Allows the delegate to override the opening of a download. If it returns | 54 // Allows the delegate to override completion of the download. If this |
55 // true then it's reponsible for opening the item. | 55 // function returns false, the download completion is delayed and the |
| 56 // delegate is responsible for making sure that |
| 57 // DownloadManager::MaybeCompleteDownload is called at some point in the |
| 58 // future. Note that at that point this function will be called again, |
| 59 // and is responsible for returning true when it really is ok for the |
| 60 // download to complete. |
| 61 virtual bool ShouldCompleteDownload(DownloadItem* item) = 0; |
| 62 |
| 63 // Allows the delegate to override opening the download. If this function |
| 64 // returns false, the delegate needs to call |
| 65 // DownloadItem::DelayedDownloadOpened when it's done with the item, |
| 66 // and is responsible for opening it. This function is called |
| 67 // after the final rename, but before the download state is set to COMPLETED. |
56 virtual bool ShouldOpenDownload(DownloadItem* item) = 0; | 68 virtual bool ShouldOpenDownload(DownloadItem* item) = 0; |
57 | 69 |
58 // Allows the delegate to override completing the download. The delegate needs | |
59 // to call DownloadItem::CompleteDelayedDownload when it's done with the item, | |
60 // and is responsible for opening it. | |
61 virtual bool ShouldCompleteDownload(DownloadItem* item) = 0; | |
62 | |
63 // Returns true if we need to generate a binary hash for downloads. | 70 // Returns true if we need to generate a binary hash for downloads. |
64 virtual bool GenerateFileHash() = 0; | 71 virtual bool GenerateFileHash() = 0; |
65 | 72 |
66 // Informs the delegate that given download has finishd downloading, and gives | 73 // Informs the delegate that given download has finishd downloading, and gives |
67 // it the hash (if it chose to compute it from GenerateFileHash()). | 74 // it the hash (if it chose to compute it from GenerateFileHash()). |
68 virtual void OnResponseCompleted(DownloadItem* item, | 75 virtual void OnResponseCompleted(DownloadItem* item, |
69 const std::string& hash) = 0; | 76 const std::string& hash) = 0; |
70 | 77 |
71 // Notifies the delegate that a new download item is created. The | 78 // Notifies the delegate that a new download item is created. The |
72 // DownloadManager waits for the delegate to add information about this | 79 // DownloadManager waits for the delegate to add information about this |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 118 |
112 protected: | 119 protected: |
113 DownloadManagerDelegate() {} | 120 DownloadManagerDelegate() {} |
114 | 121 |
115 DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate); | 122 DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate); |
116 }; | 123 }; |
117 | 124 |
118 } // namespace content | 125 } // namespace content |
119 | 126 |
120 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ | 127 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ |
OLD | NEW |