OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The DownloadManager object manages the process of downloading, including | 5 // The DownloadManager object manages the process of downloading, including |
6 // updates to the history system and providing the information for displaying | 6 // updates to the history system and providing the information for displaying |
7 // the downloads view in the Destinations tab. There is one DownloadManager per | 7 // the downloads view in the Destinations tab. There is one DownloadManager per |
8 // active browser context in Chrome. | 8 // active browser context in Chrome. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 class CONTENT_EXPORT Observer { | 81 class CONTENT_EXPORT Observer { |
82 public: | 82 public: |
83 // New or deleted download, observers should query us for the current set | 83 // New or deleted download, observers should query us for the current set |
84 // of downloads. | 84 // of downloads. |
85 virtual void ModelChanged(DownloadManager* manager) = 0; | 85 virtual void ModelChanged(DownloadManager* manager) = 0; |
86 | 86 |
87 // Called when the DownloadManager is being destroyed to prevent Observers | 87 // Called when the DownloadManager is being destroyed to prevent Observers |
88 // from calling back to a stale pointer. | 88 // from calling back to a stale pointer. |
89 virtual void ManagerGoingDown(DownloadManager* manager) {} | 89 virtual void ManagerGoingDown(DownloadManager* manager) {} |
90 | 90 |
91 // Called immediately after the DownloadManager puts up a select file | |
92 // dialog. | |
93 // |id| indicates which download opened the dialog. | |
94 virtual void SelectFileDialogDisplayed( | |
95 DownloadManager* manager, int32 id) {} | |
96 | |
97 protected: | 91 protected: |
98 virtual ~Observer() {} | 92 virtual ~Observer() {} |
99 }; | 93 }; |
100 | 94 |
101 typedef std::vector<DownloadItem*> DownloadVector; | 95 typedef std::vector<DownloadItem*> DownloadVector; |
102 | 96 |
103 // If |dir_path| is empty, appends all temporary downloads to |*result|. | 97 // If |dir_path| is empty, appends all temporary downloads to |*result|. |
104 // Otherwise, appends all temporary downloads that reside in |dir_path| to | 98 // Otherwise, appends all temporary downloads that reside in |dir_path| to |
105 // |*result|. | 99 // |*result|. |
106 virtual void GetTemporaryDownloads(const FilePath& dir_path, | 100 virtual void GetTemporaryDownloads(const FilePath& dir_path, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Called by the embedder, in response to | 183 // Called by the embedder, in response to |
190 // DownloadManagerDelegate::AddItemToPersistentStore. | 184 // DownloadManagerDelegate::AddItemToPersistentStore. |
191 virtual void OnItemAddedToPersistentStore(int32 download_id, | 185 virtual void OnItemAddedToPersistentStore(int32 download_id, |
192 int64 db_handle) = 0; | 186 int64 db_handle) = 0; |
193 | 187 |
194 // The number of in progress (including paused) downloads. | 188 // The number of in progress (including paused) downloads. |
195 virtual int InProgressCount() const = 0; | 189 virtual int InProgressCount() const = 0; |
196 | 190 |
197 virtual BrowserContext* GetBrowserContext() const = 0; | 191 virtual BrowserContext* GetBrowserContext() const = 0; |
198 | 192 |
199 virtual FilePath LastDownloadPath() = 0; | |
200 | |
201 // Creates the download item. Must be called on the UI thread. | 193 // Creates the download item. Must be called on the UI thread. |
202 // Returns the |BoundNetLog| used by the |DownloadItem|. | 194 // Returns the |BoundNetLog| used by the |DownloadItem|. |
203 virtual net::BoundNetLog CreateDownloadItem(DownloadCreateInfo* info) = 0; | 195 virtual net::BoundNetLog CreateDownloadItem(DownloadCreateInfo* info) = 0; |
204 | 196 |
205 // Creates a download item for the SavePackage system. | 197 // Creates a download item for the SavePackage system. |
206 // Must be called on the UI thread. Note that the DownloadManager | 198 // Must be called on the UI thread. Note that the DownloadManager |
207 // retains ownership. | 199 // retains ownership. |
208 virtual DownloadItem* CreateSavePackageDownloadItem( | 200 virtual DownloadItem* CreateSavePackageDownloadItem( |
209 const FilePath& main_file_path, | 201 const FilePath& main_file_path, |
210 const GURL& page_url, | 202 const GURL& page_url, |
211 bool is_otr, | 203 bool is_otr, |
212 const std::string& mime_type, | 204 const std::string& mime_type, |
213 DownloadItem::Observer* observer) = 0; | 205 DownloadItem::Observer* observer) = 0; |
214 | 206 |
215 // Clears the last download path, used to initialize "save as" dialogs. | |
216 virtual void ClearLastDownloadPath() = 0; | |
217 | |
218 // Called by the delegate after the save as dialog is closed. | |
219 virtual void FileSelected(const FilePath& path, int32 download_id) = 0; | |
220 virtual void FileSelectionCanceled(int32 download_id) = 0; | |
221 | |
222 // Called by the delegate if it delayed the download in | |
223 // DownloadManagerDelegate::ShouldStartDownload and now is ready. | |
224 virtual void RestartDownload(int32 download_id) = 0; | |
225 | |
226 // Checks whether downloaded files still exist. Updates state of downloads | 207 // Checks whether downloaded files still exist. Updates state of downloads |
227 // that refer to removed files. The check runs in the background and may | 208 // that refer to removed files. The check runs in the background and may |
228 // finish asynchronously after this method returns. | 209 // finish asynchronously after this method returns. |
229 virtual void CheckForHistoryFilesRemoval() = 0; | 210 virtual void CheckForHistoryFilesRemoval() = 0; |
230 | 211 |
231 // Get the download item from the history map. Useful after the item has | 212 // Get the download item from the history map. Useful after the item has |
232 // been removed from the active map, or was retrieved from the history DB. | 213 // been removed from the active map, or was retrieved from the history DB. |
233 virtual DownloadItem* GetDownloadItem(int id) = 0; | 214 virtual DownloadItem* GetDownloadItem(int id) = 0; |
234 | 215 |
235 // Get the download item for |id| if present, no matter what type of download | 216 // Get the download item for |id| if present, no matter what type of download |
(...skipping 12 matching lines...) Expand all Loading... |
248 protected: | 229 protected: |
249 virtual ~DownloadManager() {} | 230 virtual ~DownloadManager() {} |
250 | 231 |
251 private: | 232 private: |
252 friend class base::RefCountedThreadSafe<DownloadManager>; | 233 friend class base::RefCountedThreadSafe<DownloadManager>; |
253 }; | 234 }; |
254 | 235 |
255 } // namespace content | 236 } // namespace content |
256 | 237 |
257 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 238 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
OLD | NEW |