| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/browser/download_danger_type.h" | 11 #include "content/public/browser/download_danger_type.h" |
| 12 #include "content/public/browser/download_item.h" | 12 #include "content/public/browser/download_item.h" |
| 13 #include "content/public/browser/download_url_parameters.h" | 13 #include "content/public/browser/download_url_parameters.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 class DownloadItemImpl; | 16 class DownloadItemImpl; |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 | 18 |
| 19 // Delegate for operations that a DownloadItemImpl can't do for itself. | 19 // Delegate for operations that a DownloadItemImpl can't do for itself. |
| 20 // The base implementation of this class does nothing (returning false | 20 // The base implementation of this class does nothing (returning false |
| 21 // on predicates) so interfaces not of interest to a derived class may | 21 // on predicates) so interfaces not of interest to a derived class may |
| 22 // be left unimplemented. | 22 // be left unimplemented. |
| 23 class CONTENT_EXPORT DownloadItemImplDelegate { | 23 class CONTENT_EXPORT DownloadItemImplDelegate { |
| 24 public: | 24 public: |
| 25 typedef base::Callback<void( | 25 typedef base::Callback<void( |
| 26 const FilePath&, // Target path | 26 const base::FilePath&, // Target path |
| 27 DownloadItem::TargetDisposition, // overwrite/uniquify target | 27 DownloadItem::TargetDisposition, // overwrite/uniquify target |
| 28 DownloadDangerType, | 28 DownloadDangerType, |
| 29 const FilePath& // Intermediate file path | 29 const base::FilePath& // Intermediate file path |
| 30 )> DownloadTargetCallback; | 30 )> DownloadTargetCallback; |
| 31 | 31 |
| 32 // The boolean argument indicates whether or not the download was | 32 // The boolean argument indicates whether or not the download was |
| 33 // actually opened. | 33 // actually opened. |
| 34 typedef base::Callback<void(bool)> ShouldOpenDownloadCallback; | 34 typedef base::Callback<void(bool)> ShouldOpenDownloadCallback; |
| 35 | 35 |
| 36 DownloadItemImplDelegate(); | 36 DownloadItemImplDelegate(); |
| 37 virtual ~DownloadItemImplDelegate(); | 37 virtual ~DownloadItemImplDelegate(); |
| 38 | 38 |
| 39 // Used for catching use-after-free errors. | 39 // Used for catching use-after-free errors. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 virtual bool ShouldCompleteDownload( | 51 virtual bool ShouldCompleteDownload( |
| 52 DownloadItemImpl* download, | 52 DownloadItemImpl* download, |
| 53 const base::Closure& complete_callback); | 53 const base::Closure& complete_callback); |
| 54 | 54 |
| 55 // Allows the delegate to override the opening of a download. If it returns | 55 // Allows the delegate to override the opening of a download. If it returns |
| 56 // true then it's reponsible for opening the item. | 56 // true then it's reponsible for opening the item. |
| 57 virtual bool ShouldOpenDownload( | 57 virtual bool ShouldOpenDownload( |
| 58 DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback); | 58 DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback); |
| 59 | 59 |
| 60 // Tests if a file type should be opened automatically. | 60 // Tests if a file type should be opened automatically. |
| 61 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); | 61 virtual bool ShouldOpenFileBasedOnExtension(const base::FilePath& path); |
| 62 | 62 |
| 63 // Checks whether a downloaded file still exists and updates the | 63 // Checks whether a downloaded file still exists and updates the |
| 64 // file's state if the file is already removed. | 64 // file's state if the file is already removed. |
| 65 // The check may or may not result in a later asynchronous call | 65 // The check may or may not result in a later asynchronous call |
| 66 // to OnDownloadedFileRemoved(). | 66 // to OnDownloadedFileRemoved(). |
| 67 virtual void CheckForFileRemoval(DownloadItemImpl* download_item); | 67 virtual void CheckForFileRemoval(DownloadItemImpl* download_item); |
| 68 | 68 |
| 69 // Called when an interrupted download is resumed. | 69 // Called when an interrupted download is resumed. |
| 70 virtual void ResumeInterruptedDownload( | 70 virtual void ResumeInterruptedDownload( |
| 71 scoped_ptr<content::DownloadUrlParameters> params, | 71 scoped_ptr<content::DownloadUrlParameters> params, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 96 private: | 96 private: |
| 97 // For "Outlives attached DownloadItemImpl" invariant assertion. | 97 // For "Outlives attached DownloadItemImpl" invariant assertion. |
| 98 int count_; | 98 int count_; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); | 100 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace content | 103 } // namespace content |
| 104 | 104 |
| 105 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ | 105 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ |
| OLD | NEW |