Index: chrome/browser/download/chrome_download_manager_delegate.h |
=================================================================== |
--- chrome/browser/download/chrome_download_manager_delegate.h (revision 96577) |
+++ chrome/browser/download/chrome_download_manager_delegate.h (working copy) |
@@ -7,31 +7,70 @@ |
#pragma once |
#include "base/compiler_specific.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/task.h" |
#include "chrome/browser/download/download_manager_delegate.h" |
+class DownloadItem; |
+class DownloadManager; |
+struct DownloadStateInfo; |
+ |
// Browser's download manager: manages all downloads and destination view. |
-class ChromeDownloadManagerDelegate : public DownloadManagerDelegate { |
+class ChromeDownloadManagerDelegate |
+ : public base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>, |
+ public DownloadManagerDelegate { |
public: |
ChromeDownloadManagerDelegate(); |
+ virtual bool ShouldStartDownload(int32 download_id) OVERRIDE; |
+ virtual void ChooseDownloadPath(TabContents* tab_contents, |
+ const FilePath& suggested_path, |
+ void* data) OVERRIDE; |
+ virtual TabContents* GetAlternativeTabContentsToNotifyForDownload() OVERRIDE; |
+ virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; |
virtual void GetSaveDir(TabContents* tab_contents, |
FilePath* website_save_dir, |
FilePath* download_save_dir) OVERRIDE; |
virtual void ChooseSavePath(const base::WeakPtr<SavePackage>& save_package, |
const FilePath& suggested_path, |
bool can_save_as_complete) OVERRIDE; |
- virtual void ChooseDownloadPath(DownloadManager* download_manager, |
- TabContents* tab_contents, |
- const FilePath& suggested_path, |
- void* data) OVERRIDE; |
- virtual TabContents* GetAlternativeTabContentsToNotifyForDownload( |
- DownloadManager* download_manager) OVERRIDE; |
void set_download_manager(DownloadManager* dm) { download_manager_ = dm; } |
private: |
- DownloadManager* download_manager_; |
+ friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; |
+ virtual ~ChromeDownloadManagerDelegate(); |
+ // Callback function after url is checked with safebrowsing service. |
+ void CheckDownloadUrlDone(int32 download_id, bool is_dangerous_url); |
+ |
+ // Callback function after we check whether the referrer URL has been visited |
+ // before today. |
+ void CheckVisitedReferrerBeforeDone(int32 download_id, |
+ bool visited_referrer_before); |
+ |
+ // Called on the download thread to check whether the suggested file path |
+ // exists. We don't check if the file exists on the UI thread to avoid UI |
+ // stalls from interacting with the file system. |
+ void CheckIfSuggestedPathExists(int32 download_id, |
+ DownloadStateInfo state, |
+ const FilePath& default_path); |
+ |
+ // Called on the UI thread once it's determined whether the suggested file |
+ // path exists. |
+ void OnPathExistenceAvailable(int32 download_id, |
+ const DownloadStateInfo& new_state); |
+ |
+ // Returns true if this download should show the "dangerous file" warning. |
+ // Various factors are considered, such as the type of the file, whether a |
+ // user action initiated the download, and whether the user has explicitly |
+ // marked the file type as "auto open". |
+ bool IsDangerousFile(const DownloadItem& download, |
+ const DownloadStateInfo& state, |
+ bool visited_referrer_before); |
+ |
+ scoped_refptr<DownloadManager> download_manager_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
}; |