| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ | 5 #ifndef CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ |
| 6 #define CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ | 6 #define CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/public/browser/download_manager_delegate.h" | 11 #include "content/public/browser/download_manager_delegate.h" |
| 12 | 12 |
| 13 struct DownloadStateInfo; | 13 struct DownloadStateInfo; |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class DownloadManager; | 17 class DownloadManager; |
| 18 | 18 |
| 19 class ShellDownloadManagerDelegate | 19 class ShellDownloadManagerDelegate |
| 20 : public DownloadManagerDelegate, | 20 : public DownloadManagerDelegate, |
| 21 public base::RefCountedThreadSafe<ShellDownloadManagerDelegate> { | 21 public base::RefCountedThreadSafe<ShellDownloadManagerDelegate> { |
| 22 public: | 22 public: |
| 23 ShellDownloadManagerDelegate(); | 23 ShellDownloadManagerDelegate(); |
| 24 | 24 |
| 25 void SetDownloadManager(DownloadManager* manager); | 25 void SetDownloadManager(DownloadManager* manager); |
| 26 | 26 |
| 27 virtual void Shutdown() OVERRIDE; | 27 virtual void Shutdown() OVERRIDE; |
| 28 virtual bool ShouldStartDownload(int32 download_id) OVERRIDE; | 28 virtual bool ShouldStartDownload(int32 download_id) OVERRIDE; |
| 29 virtual void ChooseDownloadPath(TabContents* tab_contents, | 29 virtual void ChooseDownloadPath(WebContents* web_contents, |
| 30 const FilePath& suggested_path, | 30 const FilePath& suggested_path, |
| 31 void* data) OVERRIDE; | 31 void* data) OVERRIDE; |
| 32 virtual bool OverrideIntermediatePath(DownloadItem* item, | 32 virtual bool OverrideIntermediatePath(DownloadItem* item, |
| 33 FilePath* intermediate_path) OVERRIDE; | 33 FilePath* intermediate_path) OVERRIDE; |
| 34 virtual WebContents* GetAlternativeTabContentsToNotifyForDownload() OVERRIDE; | 34 virtual WebContents* GetAlternativeWebContentsToNotifyForDownload() OVERRIDE; |
| 35 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; | 35 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; |
| 36 virtual bool ShouldCompleteDownload(DownloadItem* item) OVERRIDE; | 36 virtual bool ShouldCompleteDownload(DownloadItem* item) OVERRIDE; |
| 37 virtual bool ShouldOpenDownload(DownloadItem* item) OVERRIDE; | 37 virtual bool ShouldOpenDownload(DownloadItem* item) OVERRIDE; |
| 38 virtual bool GenerateFileHash() OVERRIDE; | 38 virtual bool GenerateFileHash() OVERRIDE; |
| 39 virtual void OnResponseCompleted(DownloadItem* item) OVERRIDE; | 39 virtual void OnResponseCompleted(DownloadItem* item) OVERRIDE; |
| 40 virtual void AddItemToPersistentStore(DownloadItem* item) OVERRIDE; | 40 virtual void AddItemToPersistentStore(DownloadItem* item) OVERRIDE; |
| 41 virtual void UpdateItemInPersistentStore(DownloadItem* item) OVERRIDE; | 41 virtual void UpdateItemInPersistentStore(DownloadItem* item) OVERRIDE; |
| 42 virtual void UpdatePathForItemInPersistentStore( | 42 virtual void UpdatePathForItemInPersistentStore( |
| 43 DownloadItem* item, | 43 DownloadItem* item, |
| 44 const FilePath& new_path) OVERRIDE; | 44 const FilePath& new_path) OVERRIDE; |
| 45 virtual void RemoveItemFromPersistentStore(DownloadItem* item) OVERRIDE; | 45 virtual void RemoveItemFromPersistentStore(DownloadItem* item) OVERRIDE; |
| 46 virtual void RemoveItemsFromPersistentStoreBetween( | 46 virtual void RemoveItemsFromPersistentStoreBetween( |
| 47 base::Time remove_begin, | 47 base::Time remove_begin, |
| 48 base::Time remove_end) OVERRIDE; | 48 base::Time remove_end) OVERRIDE; |
| 49 virtual void GetSaveDir(TabContents* tab_contents, | 49 virtual void GetSaveDir(WebContents* web_contents, |
| 50 FilePath* website_save_dir, | 50 FilePath* website_save_dir, |
| 51 FilePath* download_save_dir) OVERRIDE; | 51 FilePath* download_save_dir) OVERRIDE; |
| 52 virtual void ChooseSavePath(const base::WeakPtr<SavePackage>& save_package, | 52 virtual void ChooseSavePath(const base::WeakPtr<SavePackage>& save_package, |
| 53 const FilePath& suggested_path, | 53 const FilePath& suggested_path, |
| 54 bool can_save_as_complete) OVERRIDE; | 54 bool can_save_as_complete) OVERRIDE; |
| 55 virtual void DownloadProgressUpdated() OVERRIDE; | 55 virtual void DownloadProgressUpdated() OVERRIDE; |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 friend class base::RefCountedThreadSafe<ShellDownloadManagerDelegate>; | 58 friend class base::RefCountedThreadSafe<ShellDownloadManagerDelegate>; |
| 59 | 59 |
| 60 virtual ~ShellDownloadManagerDelegate(); | 60 virtual ~ShellDownloadManagerDelegate(); |
| 61 | 61 |
| 62 void GenerateFilename(int32 download_id, | 62 void GenerateFilename(int32 download_id, |
| 63 DownloadStateInfo state, | 63 DownloadStateInfo state, |
| 64 const FilePath& generated_name); | 64 const FilePath& generated_name); |
| 65 void RestartDownload(int32 download_id, | 65 void RestartDownload(int32 download_id, |
| 66 DownloadStateInfo state); | 66 DownloadStateInfo state); |
| 67 | 67 |
| 68 DownloadManager* download_manager_; | 68 DownloadManager* download_manager_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(ShellDownloadManagerDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(ShellDownloadManagerDelegate); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace content | 73 } // namespace content |
| 74 | 74 |
| 75 #endif // CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ | 75 #endif // CONTENT_SHELL_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_ |
| OLD | NEW |