| 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" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 | 12 |
| 13 class FilePath; | 13 class FilePath; |
| 14 class TabContents; | |
| 15 class SavePackage; | 14 class SavePackage; |
| 16 | 15 |
| 17 namespace content { | 16 namespace content { |
| 18 | 17 |
| 19 class DownloadItem; | 18 class DownloadItem; |
| 20 class WebContents; | 19 class WebContents; |
| 21 | 20 |
| 22 // Browser's download manager: manages all downloads and destination view. | 21 // Browser's download manager: manages all downloads and destination view. |
| 23 class DownloadManagerDelegate { | 22 class DownloadManagerDelegate { |
| 24 public: | 23 public: |
| 25 virtual ~DownloadManagerDelegate() {} | 24 virtual ~DownloadManagerDelegate() {} |
| 26 | 25 |
| 27 // Lets the delegate know that the download manager is shutting down. | 26 // Lets the delegate know that the download manager is shutting down. |
| 28 virtual void Shutdown() = 0; | 27 virtual void Shutdown() = 0; |
| 29 | 28 |
| 30 // Notifies the delegate that a download is starting. The delegate can return | 29 // Notifies the delegate that a download is starting. The delegate can return |
| 31 // false to delay the start of the download, in which case it should call | 30 // false to delay the start of the download, in which case it should call |
| 32 // DownloadManager::RestartDownload when it's ready. | 31 // DownloadManager::RestartDownload when it's ready. |
| 33 virtual bool ShouldStartDownload(int32 download_id) = 0; | 32 virtual bool ShouldStartDownload(int32 download_id) = 0; |
| 34 | 33 |
| 35 // Asks the user for the path for a download. The delegate calls | 34 // Asks the user for the path for a download. The delegate calls |
| 36 // DownloadManager::FileSelected or DownloadManager::FileSelectionCanceled to | 35 // DownloadManager::FileSelected or DownloadManager::FileSelectionCanceled to |
| 37 // give the answer. | 36 // give the answer. |
| 38 virtual void ChooseDownloadPath(TabContents* tab_contents, | 37 virtual void ChooseDownloadPath(WebContents* web_contents, |
| 39 const FilePath& suggested_path, | 38 const FilePath& suggested_path, |
| 40 void* data) = 0; | 39 void* data) = 0; |
| 41 | 40 |
| 42 // Allows the embedder to override the file path for the download while it's | 41 // Allows the embedder to override the file path for the download while it's |
| 43 // progress. Return false to leave the filename as item->full_path(), or | 42 // progress. Return false to leave the filename as item->full_path(), or |
| 44 // return true and set |intermediate_path| with the intermediate path. | 43 // return true and set |intermediate_path| with the intermediate path. |
| 45 virtual bool OverrideIntermediatePath(DownloadItem* item, | 44 virtual bool OverrideIntermediatePath(DownloadItem* item, |
| 46 FilePath* intermediate_path) = 0; | 45 FilePath* intermediate_path) = 0; |
| 47 | 46 |
| 48 // Called when the download system wants to alert a TabContents that a | 47 // Called when the download system wants to alert a WebContents that a |
| 49 // download has started, but the TabConetnts has gone away. This lets an | 48 // download has started, but the TabConetnts has gone away. This lets an |
| 50 // delegate return an alternative TabContents. The delegate can return NULL. | 49 // delegate return an alternative WebContents. The delegate can return NULL. |
| 51 virtual WebContents* GetAlternativeTabContentsToNotifyForDownload() = 0; | 50 virtual WebContents* GetAlternativeWebContentsToNotifyForDownload() = 0; |
| 52 | 51 |
| 53 // Tests if a file type should be opened automatically. | 52 // Tests if a file type should be opened automatically. |
| 54 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) = 0; | 53 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) = 0; |
| 55 | 54 |
| 56 // Allows the delegate to override completion of the download. If this | 55 // Allows the delegate to override completion of the download. If this |
| 57 // function returns false, the download completion is delayed and the | 56 // function returns false, the download completion is delayed and the |
| 58 // delegate is responsible for making sure that | 57 // delegate is responsible for making sure that |
| 59 // DownloadItem::MaybeCompleteDownload is called at some point in the | 58 // DownloadItem::MaybeCompleteDownload is called at some point in the |
| 60 // future. Note that at that point this function will be called again, | 59 // future. Note that at that point this function will be called again, |
| 61 // and is responsible for returning true when it really is ok for the | 60 // and is responsible for returning true when it really is ok for the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Notifies the delegate that it should remove the download item from its | 95 // Notifies the delegate that it should remove the download item from its |
| 97 // persistent store. | 96 // persistent store. |
| 98 virtual void RemoveItemFromPersistentStore(DownloadItem* item) = 0; | 97 virtual void RemoveItemFromPersistentStore(DownloadItem* item) = 0; |
| 99 | 98 |
| 100 // Notifies the delegate to remove downloads from the given time range. | 99 // Notifies the delegate to remove downloads from the given time range. |
| 101 virtual void RemoveItemsFromPersistentStoreBetween( | 100 virtual void RemoveItemsFromPersistentStoreBetween( |
| 102 base::Time remove_begin, | 101 base::Time remove_begin, |
| 103 base::Time remove_end) = 0; | 102 base::Time remove_end) = 0; |
| 104 | 103 |
| 105 // Retrieve the directories to save html pages and downloads to. | 104 // Retrieve the directories to save html pages and downloads to. |
| 106 virtual void GetSaveDir(TabContents* tab_contents, | 105 virtual void GetSaveDir(WebContents* web_contents, |
| 107 FilePath* website_save_dir, | 106 FilePath* website_save_dir, |
| 108 FilePath* download_save_dir) = 0; | 107 FilePath* download_save_dir) = 0; |
| 109 | 108 |
| 110 // Asks the user for the path to save a page. The delegate calls | 109 // Asks the user for the path to save a page. The delegate calls |
| 111 // SavePackage::OnPathPicked to give the answer. | 110 // SavePackage::OnPathPicked to give the answer. |
| 112 virtual void ChooseSavePath(const base::WeakPtr<SavePackage>& save_package, | 111 virtual void ChooseSavePath(const base::WeakPtr<SavePackage>& save_package, |
| 113 const FilePath& suggested_path, | 112 const FilePath& suggested_path, |
| 114 bool can_save_as_complete) = 0; | 113 bool can_save_as_complete) = 0; |
| 115 | 114 |
| 116 // Informs the delegate that the progress of downloads has changed. | 115 // Informs the delegate that the progress of downloads has changed. |
| 117 virtual void DownloadProgressUpdated() = 0; | 116 virtual void DownloadProgressUpdated() = 0; |
| 118 | 117 |
| 119 protected: | 118 protected: |
| 120 DownloadManagerDelegate() {} | 119 DownloadManagerDelegate() {} |
| 121 | 120 |
| 122 DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate); | 121 DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate); |
| 123 }; | 122 }; |
| 124 | 123 |
| 125 } // namespace content | 124 } // namespace content |
| 126 | 125 |
| 127 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ | 126 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ |
| OLD | NEW |