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 // Each download is represented by a DownloadItem, and all DownloadItems | 5 // Each download is represented by a DownloadItem, and all DownloadItems |
6 // are owned by the DownloadManager which maintains a global list of all | 6 // are owned by the DownloadManager which maintains a global list of all |
7 // downloads. DownloadItems are created when a user initiates a download, | 7 // downloads. DownloadItems are created when a user initiates a download, |
8 // and exist for the duration of the browser life time. | 8 // and exist for the duration of the browser life time. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
11 // DownloadItem::Observer: | 11 // DownloadItem::Observer: |
12 // - allows observers to receive notifications about one download from start | 12 // - allows observers to receive notifications about one download from start |
13 // to completion | 13 // to completion |
14 // Use AddObserver() / RemoveObserver() on the appropriate download object to | 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to |
15 // receive state updates. | 15 // receive state updates. |
16 | 16 |
17 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 17 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
19 | 19 |
20 #include <map> | 20 #include <map> |
21 #include <string> | 21 #include <string> |
22 #include <vector> | 22 #include <vector> |
23 | 23 |
24 #include "base/file_path.h" | 24 #include "base/file_path.h" |
25 #include "base/string16.h" | 25 #include "base/string16.h" |
26 #include "content/public/browser/download_danger_type.h" | 26 #include "content/public/browser/download_danger_type.h" |
27 #include "content/public/browser/download_interrupt_reasons.h" | 27 #include "content/public/browser/download_interrupt_reasons.h" |
28 #include "content/public/common/page_transition_types.h" | 28 #include "content/public/common/page_transition_types.h" |
29 | 29 |
30 class DownloadFileManager; | |
31 class FilePath; | 30 class FilePath; |
32 class GURL; | 31 class GURL; |
33 struct DownloadCreateInfo; | 32 struct DownloadCreateInfo; |
34 | 33 |
35 namespace base { | 34 namespace base { |
36 class Time; | 35 class Time; |
37 class TimeDelta; | 36 class TimeDelta; |
38 } | 37 } |
39 | 38 |
40 namespace content { | 39 namespace content { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 virtual const FilePath& GetFullPath() const = 0; | 213 virtual const FilePath& GetFullPath() const = 0; |
215 | 214 |
216 // Target path of an in-progress download. We may be downloading to a | 215 // Target path of an in-progress download. We may be downloading to a |
217 // temporary or intermediate file (specified by |current_path_|. Once the | 216 // temporary or intermediate file (specified by |current_path_|. Once the |
218 // download completes, we will rename the file to |target_path_|. | 217 // download completes, we will rename the file to |target_path_|. |
219 virtual const FilePath& GetTargetFilePath() const = 0; | 218 virtual const FilePath& GetTargetFilePath() const = 0; |
220 | 219 |
221 // Get the target disposition. | 220 // Get the target disposition. |
222 virtual TargetDisposition GetTargetDisposition() const = 0; | 221 virtual TargetDisposition GetTargetDisposition() const = 0; |
223 | 222 |
224 // Called when the target path has been determined. |target_path| is the | |
225 // suggested target path. |disposition| indicates how the target path should | |
226 // be used (see TargetDisposition). |danger_type| is the danger level of | |
227 // |target_path| as determined by the caller. If |disposition| is | |
228 // TARGET_DISPOSITION_PROMPT, then OnTargetPathSelected() should be called | |
229 // subsequently with the user's selected target path. | |
230 virtual void OnTargetPathDetermined( | |
231 const FilePath& target_path, | |
232 TargetDisposition disposition, | |
233 content::DownloadDangerType danger_type) = 0; | |
234 | |
235 // This method should be called if and only if OnTargetPathDetermined() was | |
236 // called previously with disposition set to TARGET_DISPOSITION_PROMPT. | |
237 // |target_path| is the path that the user selected after being prompted for a | |
238 // target path. | |
239 virtual void OnTargetPathSelected(const FilePath& target_path) = 0; | |
240 | |
241 // Called if a check of the download contents was performed and the results of | 223 // Called if a check of the download contents was performed and the results of |
242 // the test are available. This should only be called after AllDataSaved() is | 224 // the test are available. This should only be called after AllDataSaved() is |
243 // true. | 225 // true. |
244 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0; | 226 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0; |
245 | 227 |
246 virtual void OnIntermediatePathDetermined(DownloadFileManager* file_manager, | |
247 const FilePath& path) = 0; | |
248 | |
249 virtual bool IsPersisted() const = 0; | 228 virtual bool IsPersisted() const = 0; |
250 | 229 |
251 // Accessors | 230 // Accessors |
252 virtual const std::string& GetHash() const = 0; | 231 virtual const std::string& GetHash() const = 0; |
253 virtual DownloadState GetState() const = 0; | 232 virtual DownloadState GetState() const = 0; |
254 virtual const GURL& GetURL() const = 0; | 233 virtual const GURL& GetURL() const = 0; |
255 virtual const std::vector<GURL>& GetUrlChain() const = 0; | 234 virtual const std::vector<GURL>& GetUrlChain() const = 0; |
256 virtual const GURL& GetOriginalUrl() const = 0; | 235 virtual const GURL& GetOriginalUrl() const = 0; |
257 virtual const GURL& GetReferrerUrl() const = 0; | 236 virtual const GURL& GetReferrerUrl() const = 0; |
258 virtual std::string GetSuggestedFilename() const = 0; | 237 virtual std::string GetSuggestedFilename() const = 0; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 virtual void SetExternalData(const void* key, ExternalData* data) = 0; | 308 virtual void SetExternalData(const void* key, ExternalData* data) = 0; |
330 | 309 |
331 virtual std::string DebugString(bool verbose) const = 0; | 310 virtual std::string DebugString(bool verbose) const = 0; |
332 | 311 |
333 virtual void MockDownloadOpenForTesting() = 0; | 312 virtual void MockDownloadOpenForTesting() = 0; |
334 }; | 313 }; |
335 | 314 |
336 } // namespace content | 315 } // namespace content |
337 | 316 |
338 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 317 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
OLD | NEW |