| 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/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // be left unimplemented. | 21 // be left unimplemented. |
| 22 class CONTENT_EXPORT DownloadItemImplDelegate { | 22 class CONTENT_EXPORT DownloadItemImplDelegate { |
| 23 public: | 23 public: |
| 24 DownloadItemImplDelegate(); | 24 DownloadItemImplDelegate(); |
| 25 virtual ~DownloadItemImplDelegate(); | 25 virtual ~DownloadItemImplDelegate(); |
| 26 | 26 |
| 27 // Used for catching use-after-free errors. | 27 // Used for catching use-after-free errors. |
| 28 void Attach(); | 28 void Attach(); |
| 29 void Detach(); | 29 void Detach(); |
| 30 | 30 |
| 31 // Start the delegate's portion of the download; called when the | 31 // Tests if a file type should be opened automatically. |
| 32 // download item is ready for the delegate to take over. | 32 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); |
| 33 // Pure virtual because if the delegate doesn't do something the | |
| 34 // DownloadItemImpl is dead in the water. | |
| 35 // TODO(rdsmith): The machinery of running the download should be | |
| 36 // moved into the DownloadItem, and this should be changed into | |
| 37 // a probe as to whether to start and if not, provide a callback | |
| 38 // to call when it's time to start. | |
| 39 virtual void DelegateStart(DownloadItemImpl* download) = 0; | |
| 40 | 33 |
| 41 // Allows the delegate to override the opening of a download. If it returns | 34 // Allows the delegate to override the opening of a download. If it returns |
| 42 // true then it's reponsible for opening the item. | 35 // true then it's reponsible for opening the item. |
| 43 virtual bool ShouldOpenDownload(DownloadItemImpl* download); | 36 virtual bool ShouldOpenDownload(DownloadItemImpl* download); |
| 44 | 37 |
| 45 // Tests if a file type should be opened automatically. | |
| 46 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); | |
| 47 | |
| 48 // Checks whether a downloaded file still exists and updates the | 38 // Checks whether a downloaded file still exists and updates the |
| 49 // file's state if the file is already removed. | 39 // file's state if the file is already removed. |
| 50 // The check may or may not result in a later asynchronous call | 40 // The check may or may not result in a later asynchronous call |
| 51 // to OnDownloadedFileRemoved(). | 41 // to OnDownloadedFileRemoved(). |
| 52 virtual void CheckForFileRemoval(DownloadItemImpl* download_item); | 42 virtual void CheckForFileRemoval(DownloadItemImpl* download_item); |
| 53 | 43 |
| 54 // If all pre-requisites have been met, complete download processing. | 44 // If all pre-requisites have been met, complete download processing. |
| 55 // TODO(rdsmith): Move into DownloadItem. | 45 // TODO(rdsmith): Move into DownloadItem. |
| 56 virtual void MaybeCompleteDownload(DownloadItemImpl* download); | 46 virtual void MaybeCompleteDownload(DownloadItemImpl* download); |
| 57 | 47 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 75 virtual void AssertStateConsistent(DownloadItemImpl* download) const; | 65 virtual void AssertStateConsistent(DownloadItemImpl* download) const; |
| 76 | 66 |
| 77 private: | 67 private: |
| 78 // For "Outlives attached DownloadItemImpl" invariant assertion. | 68 // For "Outlives attached DownloadItemImpl" invariant assertion. |
| 79 int count_; | 69 int count_; |
| 80 | 70 |
| 81 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); | 71 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); |
| 82 }; | 72 }; |
| 83 | 73 |
| 84 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ | 74 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ |
| OLD | NEW |