| 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 <stdint.h> | 20 #include <stdint.h> |
| 21 | 21 |
| 22 #include <map> | 22 #include <map> |
| 23 #include <string> | 23 #include <string> |
| 24 #include <vector> | 24 #include <vector> |
| 25 | 25 |
| 26 #include "base/callback_forward.h" | 26 #include "base/callback_forward.h" |
| 27 #include "base/files/file_path.h" | 27 #include "base/files/file_path.h" |
| 28 #include "base/memory/ref_counted.h" |
| 28 #include "base/strings/string16.h" | 29 #include "base/strings/string16.h" |
| 29 #include "base/supports_user_data.h" | 30 #include "base/supports_user_data.h" |
| 30 #include "content/public/browser/download_danger_type.h" | 31 #include "content/public/browser/download_danger_type.h" |
| 31 #include "content/public/browser/download_interrupt_reasons.h" | 32 #include "content/public/browser/download_interrupt_reasons.h" |
| 32 #include "ui/base/page_transition_types.h" | 33 #include "ui/base/page_transition_types.h" |
| 33 | 34 |
| 34 class GURL; | 35 class GURL; |
| 35 | 36 |
| 36 namespace base { | 37 namespace base { |
| 37 class FilePath; | 38 class FilePath; |
| 38 class Time; | 39 class Time; |
| 39 class TimeDelta; | 40 class TimeDelta; |
| 40 } | 41 } |
| 41 | 42 |
| 43 namespace net { |
| 44 class HttpResponseHeaders; |
| 45 } |
| 46 |
| 42 namespace content { | 47 namespace content { |
| 43 | 48 |
| 44 class BrowserContext; | 49 class BrowserContext; |
| 45 class DownloadManager; | 50 class DownloadManager; |
| 46 class WebContents; | 51 class WebContents; |
| 47 | 52 |
| 48 // One DownloadItem per download. This is the model class that stores all the | 53 // 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 | 54 // 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. | 55 // Destination tab's download view, may refer to a given DownloadItem. |
| 51 // | 56 // |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // URL of the top level frame at the time the download was initiated. | 243 // URL of the top level frame at the time the download was initiated. |
| 239 virtual const GURL& GetTabUrl() const = 0; | 244 virtual const GURL& GetTabUrl() const = 0; |
| 240 | 245 |
| 241 // Referrer URL for top level frame. | 246 // Referrer URL for top level frame. |
| 242 virtual const GURL& GetTabReferrerUrl() const = 0; | 247 virtual const GURL& GetTabReferrerUrl() const = 0; |
| 243 | 248 |
| 244 // For downloads initiated via <a download>, this is the suggested download | 249 // For downloads initiated via <a download>, this is the suggested download |
| 245 // filename from the download attribute. | 250 // filename from the download attribute. |
| 246 virtual std::string GetSuggestedFilename() const = 0; | 251 virtual std::string GetSuggestedFilename() const = 0; |
| 247 | 252 |
| 253 // Returns the HTTP response headers. This contains a nullptr when the |
| 254 // response has not yet been received, and, because the headers are not being |
| 255 // persisted, only capture responses received during the lifetime of the |
| 256 // current process and profile. Only for consuming headers. |
| 257 virtual const scoped_refptr<const net::HttpResponseHeaders>& |
| 258 GetResponseHeaders() const = 0; |
| 259 |
| 248 // Content-Disposition header value from HTTP response. | 260 // Content-Disposition header value from HTTP response. |
| 249 virtual std::string GetContentDisposition() const = 0; | 261 virtual std::string GetContentDisposition() const = 0; |
| 250 | 262 |
| 251 // Effective MIME type of downloaded content. | 263 // Effective MIME type of downloaded content. |
| 252 virtual std::string GetMimeType() const = 0; | 264 virtual std::string GetMimeType() const = 0; |
| 253 | 265 |
| 254 // Content-Type header value from HTTP response. May be different from | 266 // Content-Type header value from HTTP response. May be different from |
| 255 // GetMimeType() if a different effective MIME type was chosen after MIME | 267 // GetMimeType() if a different effective MIME type was chosen after MIME |
| 256 // sniffing. | 268 // sniffing. |
| 257 virtual std::string GetOriginalMimeType() const = 0; | 269 virtual std::string GetOriginalMimeType() const = 0; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 // return |name|. Has no effect on the final target filename. | 452 // return |name|. Has no effect on the final target filename. |
| 441 virtual void SetDisplayName(const base::FilePath& name) = 0; | 453 virtual void SetDisplayName(const base::FilePath& name) = 0; |
| 442 | 454 |
| 443 // Debug/testing ------------------------------------------------------------- | 455 // Debug/testing ------------------------------------------------------------- |
| 444 virtual std::string DebugString(bool verbose) const = 0; | 456 virtual std::string DebugString(bool verbose) const = 0; |
| 445 }; | 457 }; |
| 446 | 458 |
| 447 } // namespace content | 459 } // namespace content |
| 448 | 460 |
| 449 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ | 461 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ |
| OLD | NEW |