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_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 virtual FilePath GetIntermediatePath(const FilePath& suggested_path); | 61 virtual FilePath GetIntermediatePath(const FilePath& suggested_path); |
62 | 62 |
63 // Called when the download system wants to alert a WebContents that a | 63 // Called when the download system wants to alert a WebContents that a |
64 // download has started, but the TabConetnts has gone away. This lets an | 64 // download has started, but the TabConetnts has gone away. This lets an |
65 // delegate return an alternative WebContents. The delegate can return NULL. | 65 // delegate return an alternative WebContents. The delegate can return NULL. |
66 virtual WebContents* GetAlternativeWebContentsToNotifyForDownload(); | 66 virtual WebContents* GetAlternativeWebContentsToNotifyForDownload(); |
67 | 67 |
68 // Tests if a file type should be opened automatically. | 68 // Tests if a file type should be opened automatically. |
69 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); | 69 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); |
70 | 70 |
71 // Allows the delegate to override completion of the download. If this | 71 // Allows the delegate to delay completion of the download. This function |
72 // function returns false, the download completion is delayed and the | 72 // will either return true (in which case the download is ready to complete) |
73 // delegate is responsible for making sure that | 73 // or arrange for complete_callback to be called at some point in the future |
74 // DownloadItem::MaybeCompleteDownload is called at some point in the | 74 // when the download is ready to complete. |
75 // future. Note that at that point this function will be called again, | 75 // |
76 // and is responsible for returning true when it really is ok for the | 76 // ShouldCompleteDownload() may be called multiple times; if it is, only the |
77 // download to complete. | 77 // last callback specified (while the delegate is delaying completion) will be |
78 virtual bool ShouldCompleteDownload(DownloadItem* item); | 78 // run. Calls made after the callback is run are guaranteed to return true. |
| 79 virtual bool ShouldCompleteDownload( |
| 80 DownloadItem* item, |
| 81 const base::Closure& complete_callback); |
79 | 82 |
80 // Allows the delegate to override opening the download. If this function | 83 // Allows the delegate to override opening the download. If this function |
81 // returns false, the delegate needs to call | 84 // returns false, the delegate needs to call |
82 // DownloadItem::DelayedDownloadOpened when it's done with the item, | 85 // DownloadItem::DelayedDownloadOpened when it's done with the item, |
83 // and is responsible for opening it. This function is called | 86 // and is responsible for opening it. This function is called |
84 // after the final rename, but before the download state is set to COMPLETED. | 87 // after the final rename, but before the download state is set to COMPLETED. |
85 virtual bool ShouldOpenDownload(DownloadItem* item); | 88 virtual bool ShouldOpenDownload(DownloadItem* item); |
86 | 89 |
87 // Returns true if we need to generate a binary hash for downloads. | 90 // Returns true if we need to generate a binary hash for downloads. |
88 virtual bool GenerateFileHash(); | 91 virtual bool GenerateFileHash(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 const FilePath& suggested_path, | 128 const FilePath& suggested_path, |
126 const FilePath::StringType& default_extension, | 129 const FilePath::StringType& default_extension, |
127 bool can_save_as_complete, | 130 bool can_save_as_complete, |
128 const SavePackagePathPickedCallback& callback) { | 131 const SavePackagePathPickedCallback& callback) { |
129 } | 132 } |
130 }; | 133 }; |
131 | 134 |
132 } // namespace content | 135 } // namespace content |
133 | 136 |
134 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ | 137 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ |
OLD | NEW |