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