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
3 // found in the LICENSE file.
5 #ifndef CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
6 #define CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/public/browser/download_manager_delegate.h"
13 class DownloadManager
;
14 struct DownloadStateInfo
;
18 class ShellDownloadManagerDelegate
19 : public DownloadManagerDelegate
,
20 public base::RefCountedThreadSafe
<ShellDownloadManagerDelegate
> {
22 ShellDownloadManagerDelegate();
24 void SetDownloadManager(DownloadManager
* manager
);
26 virtual void Shutdown() OVERRIDE
;
27 virtual bool ShouldStartDownload(int32 download_id
) OVERRIDE
;
28 virtual void ChooseDownloadPath(TabContents
* tab_contents
,
29 const FilePath
& suggested_path
,
31 virtual bool OverrideIntermediatePath(DownloadItem
* item
,
32 FilePath
* intermediate_path
) OVERRIDE
;
33 virtual TabContents
* GetAlternativeTabContentsToNotifyForDownload() OVERRIDE
;
34 virtual bool ShouldOpenFileBasedOnExtension(const FilePath
& path
) OVERRIDE
;
35 virtual bool ShouldCompleteDownload(DownloadItem
* item
) OVERRIDE
;
36 virtual bool ShouldOpenDownload(DownloadItem
* item
) OVERRIDE
;
37 virtual bool GenerateFileHash() OVERRIDE
;
38 virtual void OnResponseCompleted(DownloadItem
* item
) OVERRIDE
;
39 virtual void AddItemToPersistentStore(DownloadItem
* item
) OVERRIDE
;
40 virtual void UpdateItemInPersistentStore(DownloadItem
* item
) OVERRIDE
;
41 virtual void UpdatePathForItemInPersistentStore(
43 const FilePath
& new_path
) OVERRIDE
;
44 virtual void RemoveItemFromPersistentStore(DownloadItem
* item
) OVERRIDE
;
45 virtual void RemoveItemsFromPersistentStoreBetween(
46 const base::Time remove_begin
,
47 const base::Time remove_end
) OVERRIDE
;
48 virtual void GetSaveDir(TabContents
* tab_contents
,
49 FilePath
* website_save_dir
,
50 FilePath
* download_save_dir
) OVERRIDE
;
51 virtual void ChooseSavePath(const base::WeakPtr
<SavePackage
>& save_package
,
52 const FilePath
& suggested_path
,
53 bool can_save_as_complete
) OVERRIDE
;
54 virtual void DownloadProgressUpdated() OVERRIDE
;
57 friend class base::RefCountedThreadSafe
<ShellDownloadManagerDelegate
>;
59 virtual ~ShellDownloadManagerDelegate();
61 void GenerateFilename(int32 download_id
,
62 DownloadStateInfo state
,
63 const FilePath
& generated_name
);
64 void RestartDownload(int32 download_id
,
65 DownloadStateInfo state
);
67 DownloadManager
* download_manager_
;
69 DISALLOW_COPY_AND_ASSIGN(ShellDownloadManagerDelegate
);
72 } // namespace content
74 #endif // CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_