blob: 7d13cced9a62bfef8b40cd15bf8762ff1f01d8fd [file] [log] [blame]
[email protected]98d6f152011-09-29 19:35:511// 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.
4
5#ifndef CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
6#define CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
7#pragma once
8
9#include "base/compiler_specific.h"
10#include "base/memory/ref_counted.h"
11#include "content/browser/download/download_manager_delegate.h"
12
13class DownloadManager;
14struct DownloadStateInfo;
15
16namespace content {
17
18class ShellDownloadManagerDelegate
19 : public DownloadManagerDelegate,
20 public base::RefCountedThreadSafe<ShellDownloadManagerDelegate> {
21 public:
22 ShellDownloadManagerDelegate();
23
[email protected]9bb54ee2011-10-12 17:43:3524 void SetDownloadManager(DownloadManager* manager);
[email protected]98d6f152011-09-29 19:35:5125
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,
30 void* data) OVERRIDE;
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 ShouldOpenDownload(DownloadItem* item) OVERRIDE;
36 virtual bool ShouldCompleteDownload(DownloadItem* item) OVERRIDE;
37 virtual bool GenerateFileHash() OVERRIDE;
38 virtual void OnResponseCompleted(DownloadItem* item,
39 const std::string& hash) OVERRIDE;
40 virtual void AddItemToPersistentStore(DownloadItem* item) OVERRIDE;
41 virtual void UpdateItemInPersistentStore(DownloadItem* item) OVERRIDE;
42 virtual void UpdatePathForItemInPersistentStore(
43 DownloadItem* item,
44 const FilePath& new_path) OVERRIDE;
45 virtual void RemoveItemFromPersistentStore(DownloadItem* item) OVERRIDE;
46 virtual void RemoveItemsFromPersistentStoreBetween(
47 const base::Time remove_begin,
48 const base::Time remove_end) OVERRIDE;
49 virtual void GetSaveDir(TabContents* tab_contents,
50 FilePath* website_save_dir,
51 FilePath* download_save_dir) OVERRIDE;
52 virtual void ChooseSavePath(const base::WeakPtr<SavePackage>& save_package,
53 const FilePath& suggested_path,
54 bool can_save_as_complete) OVERRIDE;
55 virtual void DownloadProgressUpdated() OVERRIDE;
56
57 private:
58 friend class base::RefCountedThreadSafe<ShellDownloadManagerDelegate>;
59
60 virtual ~ShellDownloadManagerDelegate();
61
62 void GenerateFilename(int32 download_id,
63 DownloadStateInfo state,
64 const FilePath& generated_name);
65 void RestartDownload(int32 download_id,
66 DownloadStateInfo state);
67
68 DownloadManager* download_manager_;
69
70 DISALLOW_COPY_AND_ASSIGN(ShellDownloadManagerDelegate);
71};
72
73} // namespace content
74
75#endif // CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_