Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1581)

Unified Diff: chrome/browser/download/chrome_download_manager_delegate.h

Issue 7640021: Move some Chrome-specific code paths out of DownloadManager and into the delegate. Getting rid of... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « no previous file | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698