Chromium Code Reviews| Index: content/public/browser/download_manager_delegate.h |
| diff --git a/content/public/browser/download_manager_delegate.h b/content/public/browser/download_manager_delegate.h |
| index 0fd224374d64bb7d9c87324e197ae8c04fef70b6..1ea091a963c13dbfb891010e15e72906a19514b5 100644 |
| --- a/content/public/browser/download_manager_delegate.h |
| +++ b/content/public/browser/download_manager_delegate.h |
| @@ -12,12 +12,13 @@ |
| #include "base/logging.h" |
| #include "base/time.h" |
| #include "content/common/content_export.h" |
| +#include "content/public/browser/download_danger_type.h" |
| +#include "content/public/browser/download_item.h" |
| #include "content/public/browser/save_page_type.h" |
| namespace content { |
| class DownloadId; |
| -class DownloadItem; |
| class WebContents; |
| // Called by SavePackage when it creates a DownloadItem. |
| @@ -33,6 +34,12 @@ typedef base::Callback<void(const FilePath&, |
| const SavePackageDownloadCreatedCallback&)> |
| SavePackagePathPickedCallback; |
| +typedef base::Callback<void( |
| + const FilePath& target_path, |
| + content::DownloadItem::TargetDisposition disposition, |
| + content::DownloadDangerType danger_type, |
| + const FilePath& intermediate_path)> DownloadTargetCallback; |
| + |
| // Browser's download manager: manages all downloads and destination view. |
| class CONTENT_EXPORT DownloadManagerDelegate { |
| public: |
| @@ -42,23 +49,14 @@ class CONTENT_EXPORT DownloadManagerDelegate { |
| // Returns a new DownloadId. |
| virtual DownloadId GetNextId(); |
| - // Notifies the delegate that a download is starting. The delegate can return |
| - // false to delay the start of the download, in which case it should call |
| - // DownloadManager::RestartDownload when it's ready. |
| - virtual bool ShouldStartDownload(int32 download_id); |
| - |
| - // Asks the user for the path for a download. The delegate calls |
| - // DownloadManager::FileSelected or DownloadManager::FileSelectionCanceled to |
| - // give the answer. |
| - virtual void ChooseDownloadPath(DownloadItem* item) {} |
| - |
| - // Allows the embedder to set an intermediate name for the download until it's |
| - // complete. The return value is the intermediate path to use. If the embedder |
| - // doesn't want to set an intermediate path, it should return |
| - // item.GetTargetFilePath(). If there's already a file at the returned path, |
| - // it will not be overwritten. Instead the path will be uniquified by adding a |
| - // suffix to the filename. |
| - virtual FilePath GetIntermediatePath(const DownloadItem& item); |
| + // The delegate needs to generate a filename for the new download |item|. Once |
| + // the target information has been determined, the delegate is required to |
| + // call DownloadItem::OnDownloadTargetDetermined(). This function should |
|
Randy Smith (Not in Mondays)
2012/07/10 18:33:09
nit: "... required to call the callback."
asanka
2012/07/11 20:03:32
Done.
|
| + // return |true| if it has or will invoke |callback|. If it returns |false|, |
| + // the download manager will continue the download using a default, possibly |
| + // empty, target path. |
|
Randy Smith (Not in Mondays)
2012/07/10 18:33:09
nit: If you're allowing the callback to be invoked
asanka
2012/07/11 20:03:32
Done.
|
| + virtual bool DetermineDownloadTarget(DownloadItem* item, |
| + const DownloadTargetCallback& callback); |
| // Called when the download system wants to alert a WebContents that a |
| // download has started, but the TabConetnts has gone away. This lets an |
| @@ -117,6 +115,10 @@ class CONTENT_EXPORT DownloadManagerDelegate { |
| base::Time remove_begin, |
| base::Time remove_end) {} |
| + // Invoked when history is being cleared to clear the delegate's transient |
| + // state. |
| + virtual void ClearTransientState() {} |
| + |
| // Retrieve the directories to save html pages and downloads to. |
| virtual void GetSaveDir(WebContents* web_contents, |
| FilePath* website_save_dir, |