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: |
(...skipping 25 matching lines...) Expand all Loading... |
36 class Time; | 36 class Time; |
37 class TimeDelta; | 37 class TimeDelta; |
38 } | 38 } |
39 | 39 |
40 namespace content { | 40 namespace content { |
41 | 41 |
42 class BrowserContext; | 42 class BrowserContext; |
43 class DownloadId; | 43 class DownloadId; |
44 class DownloadManager; | 44 class DownloadManager; |
45 class WebContents; | 45 class WebContents; |
46 struct DownloadPersistentStoreInfo; | |
47 | 46 |
48 // One DownloadItem per download. This is the model class that stores all the | 47 // One DownloadItem per download. This is the model class that stores all the |
49 // state for a download. Multiple views, such as a tab's download shelf and the | 48 // state for a download. Multiple views, such as a tab's download shelf and the |
50 // Destination tab's download view, may refer to a given DownloadItem. | 49 // Destination tab's download view, may refer to a given DownloadItem. |
51 // | 50 // |
52 // This is intended to be used only on the UI thread. | 51 // This is intended to be used only on the UI thread. |
53 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData { | 52 class CONTENT_EXPORT DownloadItem : public base::SupportsUserData { |
54 public: | 53 public: |
55 enum DownloadState { | 54 enum DownloadState { |
56 // Download is actively progressing. | 55 // Download is actively progressing. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 virtual const FilePath& GetTargetFilePath() const = 0; | 215 virtual const FilePath& GetTargetFilePath() const = 0; |
217 | 216 |
218 // Get the target disposition. | 217 // Get the target disposition. |
219 virtual TargetDisposition GetTargetDisposition() const = 0; | 218 virtual TargetDisposition GetTargetDisposition() const = 0; |
220 | 219 |
221 // Called if a check of the download contents was performed and the results of | 220 // Called if a check of the download contents was performed and the results of |
222 // the test are available. This should only be called after AllDataSaved() is | 221 // the test are available. This should only be called after AllDataSaved() is |
223 // true. | 222 // true. |
224 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0; | 223 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0; |
225 | 224 |
226 virtual bool IsPersisted() const = 0; | |
227 | |
228 // Accessors | 225 // Accessors |
229 virtual const std::string& GetHash() const = 0; | 226 virtual const std::string& GetHash() const = 0; |
230 virtual DownloadState GetState() const = 0; | 227 virtual DownloadState GetState() const = 0; |
231 virtual const GURL& GetURL() const = 0; | 228 virtual const GURL& GetURL() const = 0; |
232 virtual const std::vector<GURL>& GetUrlChain() const = 0; | 229 virtual const std::vector<GURL>& GetUrlChain() const = 0; |
233 virtual const GURL& GetOriginalUrl() const = 0; | 230 virtual const GURL& GetOriginalUrl() const = 0; |
234 virtual const GURL& GetReferrerUrl() const = 0; | 231 virtual const GURL& GetReferrerUrl() const = 0; |
235 virtual std::string GetSuggestedFilename() const = 0; | 232 virtual std::string GetSuggestedFilename() const = 0; |
236 virtual std::string GetContentDisposition() const = 0; | 233 virtual std::string GetContentDisposition() const = 0; |
237 virtual std::string GetMimeType() const = 0; | 234 virtual std::string GetMimeType() const = 0; |
238 virtual std::string GetOriginalMimeType() const = 0; | 235 virtual std::string GetOriginalMimeType() const = 0; |
239 virtual std::string GetReferrerCharset() const = 0; | 236 virtual std::string GetReferrerCharset() const = 0; |
240 virtual std::string GetRemoteAddress() const = 0; | 237 virtual std::string GetRemoteAddress() const = 0; |
241 virtual int64 GetTotalBytes() const = 0; | 238 virtual int64 GetTotalBytes() const = 0; |
242 virtual int64 GetReceivedBytes() const = 0; | 239 virtual int64 GetReceivedBytes() const = 0; |
243 virtual const std::string& GetHashState() const = 0; | 240 virtual const std::string& GetHashState() const = 0; |
244 virtual int32 GetId() const = 0; | 241 virtual int32 GetId() const = 0; |
245 virtual DownloadId GetGlobalId() const = 0; | 242 virtual DownloadId GetGlobalId() const = 0; |
246 virtual base::Time GetStartTime() const = 0; | 243 virtual base::Time GetStartTime() const = 0; |
247 virtual base::Time GetEndTime() const = 0; | 244 virtual base::Time GetEndTime() const = 0; |
248 virtual int64 GetDbHandle() const = 0; | |
249 virtual bool IsPaused() const = 0; | 245 virtual bool IsPaused() const = 0; |
250 virtual bool GetOpenWhenComplete() const = 0; | 246 virtual bool GetOpenWhenComplete() const = 0; |
251 virtual void SetOpenWhenComplete(bool open) = 0; | 247 virtual void SetOpenWhenComplete(bool open) = 0; |
252 virtual bool GetFileExternallyRemoved() const = 0; | 248 virtual bool GetFileExternallyRemoved() const = 0; |
253 virtual SafetyState GetSafetyState() const = 0; | 249 virtual SafetyState GetSafetyState() const = 0; |
254 // Why |safety_state_| is not SAFE. | 250 // Why |safety_state_| is not SAFE. |
255 virtual DownloadDangerType GetDangerType() const = 0; | 251 virtual DownloadDangerType GetDangerType() const = 0; |
256 virtual bool IsDangerous() const = 0; | 252 virtual bool IsDangerous() const = 0; |
257 | 253 |
258 virtual bool GetAutoOpened() = 0; | 254 virtual bool GetAutoOpened() = 0; |
259 virtual FilePath GetTargetName() const = 0; | 255 virtual FilePath GetTargetName() const = 0; |
260 virtual const FilePath& GetForcedFilePath() const = 0; | 256 virtual const FilePath& GetForcedFilePath() const = 0; |
261 virtual bool HasUserGesture() const = 0; | 257 virtual bool HasUserGesture() const = 0; |
262 virtual PageTransition GetTransitionType() const = 0; | 258 virtual PageTransition GetTransitionType() const = 0; |
263 virtual bool IsTemporary() const = 0; | 259 virtual bool IsTemporary() const = 0; |
264 virtual void SetIsTemporary(bool temporary) = 0; | 260 virtual void SetIsTemporary(bool temporary) = 0; |
265 virtual void SetOpened(bool opened) = 0; | 261 virtual void SetOpened(bool opened) = 0; |
266 virtual bool GetOpened() const = 0; | 262 virtual bool GetOpened() const = 0; |
267 | 263 |
268 virtual const std::string& GetLastModifiedTime() const = 0; | 264 virtual const std::string& GetLastModifiedTime() const = 0; |
269 virtual const std::string& GetETag() const = 0; | 265 virtual const std::string& GetETag() const = 0; |
270 | 266 |
271 virtual DownloadInterruptReason GetLastReason() const = 0; | 267 virtual DownloadInterruptReason GetLastReason() const = 0; |
272 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; | |
273 virtual BrowserContext* GetBrowserContext() const = 0; | 268 virtual BrowserContext* GetBrowserContext() const = 0; |
274 virtual WebContents* GetWebContents() const = 0; | 269 virtual WebContents* GetWebContents() const = 0; |
275 | 270 |
276 // Returns the file-name that should be reported to the user. If a display | 271 // Returns the file-name that should be reported to the user. If a display |
277 // name has been explicitly set using SetDisplayName(), this function returns | 272 // name has been explicitly set using SetDisplayName(), this function returns |
278 // that display name. Otherwise returns the final target filename. | 273 // that display name. Otherwise returns the final target filename. |
279 virtual FilePath GetFileNameToReportUser() const = 0; | 274 virtual FilePath GetFileNameToReportUser() const = 0; |
280 | 275 |
281 // Set a display name for the download that will be independent of the target | 276 // Set a display name for the download that will be independent of the target |
282 // filename. If |name| is not empty, then GetFileNameToReportUser() will | 277 // filename. If |name| is not empty, then GetFileNameToReportUser() will |
283 // return |name|. Has no effect on the final target filename. | 278 // return |name|. Has no effect on the final target filename. |
284 virtual void SetDisplayName(const FilePath& name) = 0; | 279 virtual void SetDisplayName(const FilePath& name) = 0; |
285 | 280 |
286 // Returns the user-verified target file path for the download. | 281 // Returns the user-verified target file path for the download. |
287 // This returns the same path as GetTargetFilePath() for safe downloads | 282 // This returns the same path as GetTargetFilePath() for safe downloads |
288 // but does not for dangerous downloads until the name is verified. | 283 // but does not for dangerous downloads until the name is verified. |
289 virtual FilePath GetUserVerifiedFilePath() const = 0; | 284 virtual FilePath GetUserVerifiedFilePath() const = 0; |
290 | 285 |
291 virtual std::string DebugString(bool verbose) const = 0; | 286 virtual std::string DebugString(bool verbose) const = 0; |
292 | 287 |
293 virtual void MockDownloadOpenForTesting() = 0; | 288 virtual void MockDownloadOpenForTesting() = 0; |
294 }; | 289 }; |
295 | 290 |
296 } // namespace content | 291 } // namespace content |
297 | 292 |
298 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 293 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
OLD | NEW |