| 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 CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // DownloadItemModel objects could be wrapping the same DownloadItem. | 30 // DownloadItemModel objects could be wrapping the same DownloadItem. |
| 31 class DownloadItemModel { | 31 class DownloadItemModel { |
| 32 public: | 32 public: |
| 33 // Constructs a DownloadItemModel. The caller must ensure that |download| | 33 // Constructs a DownloadItemModel. The caller must ensure that |download| |
| 34 // outlives this object. | 34 // outlives this object. |
| 35 explicit DownloadItemModel(content::DownloadItem* download); | 35 explicit DownloadItemModel(content::DownloadItem* download); |
| 36 ~DownloadItemModel(); | 36 ~DownloadItemModel(); |
| 37 | 37 |
| 38 // Returns a long descriptive string for a download that's in the INTERRUPTED | 38 // Returns a long descriptive string for a download that's in the INTERRUPTED |
| 39 // state. For other downloads, the returned string will be empty. | 39 // state. For other downloads, the returned string will be empty. |
| 40 string16 GetInterruptReasonText() const; | 40 base::string16 GetInterruptReasonText() const; |
| 41 | 41 |
| 42 // Returns a short one-line status string for the download. | 42 // Returns a short one-line status string for the download. |
| 43 string16 GetStatusText() const; | 43 base::string16 GetStatusText() const; |
| 44 | 44 |
| 45 // Returns the localized status text for an in-progress download. This | 45 // Returns the localized status text for an in-progress download. This |
| 46 // is the progress status used in the WebUI interface. | 46 // is the progress status used in the WebUI interface. |
| 47 string16 GetTabProgressStatusText() const; | 47 base::string16 GetTabProgressStatusText() const; |
| 48 | 48 |
| 49 // Returns a string suitable for use as a tooltip. For a regular download, the | 49 // Returns a string suitable for use as a tooltip. For a regular download, the |
| 50 // tooltip is the filename. For an interrupted download, the string states the | 50 // tooltip is the filename. For an interrupted download, the string states the |
| 51 // filename and a short description of the reason for interruption. For | 51 // filename and a short description of the reason for interruption. For |
| 52 // example: | 52 // example: |
| 53 // Report.pdf | 53 // Report.pdf |
| 54 // Network disconnected | 54 // Network disconnected |
| 55 // |font_list| and |max_width| are used to elide the filename and/or interrupt | 55 // |font_list| and |max_width| are used to elide the filename and/or interrupt |
| 56 // reason as necessary to keep the width of the tooltip text under | 56 // reason as necessary to keep the width of the tooltip text under |
| 57 // |max_width|. The tooltip will be at most 2 lines. | 57 // |max_width|. The tooltip will be at most 2 lines. |
| 58 string16 GetTooltipText(const gfx::FontList& font_list, int max_width) const; | 58 base::string16 GetTooltipText(const gfx::FontList& font_list, int max_width) c
onst; |
| 59 | 59 |
| 60 // Get the warning text to display for a dangerous download. The |base_width| | 60 // Get the warning text to display for a dangerous download. The |base_width| |
| 61 // is the maximum width of an embedded filename (if there is one). The metrics | 61 // is the maximum width of an embedded filename (if there is one). The metrics |
| 62 // for the filename will be based on |font_list|. Should only be called if | 62 // for the filename will be based on |font_list|. Should only be called if |
| 63 // IsDangerous() is true. | 63 // IsDangerous() is true. |
| 64 string16 GetWarningText(const gfx::FontList& font_list, int base_width) const; | 64 base::string16 GetWarningText(const gfx::FontList& font_list, int base_width)
const; |
| 65 | 65 |
| 66 // Get the caption text for a button for confirming a dangerous download | 66 // Get the caption text for a button for confirming a dangerous download |
| 67 // warning. | 67 // warning. |
| 68 string16 GetWarningConfirmButtonText() const; | 68 base::string16 GetWarningConfirmButtonText() const; |
| 69 | 69 |
| 70 // Get the number of bytes that has completed so far. Virtual for testing. | 70 // Get the number of bytes that has completed so far. Virtual for testing. |
| 71 int64 GetCompletedBytes() const; | 71 int64 GetCompletedBytes() const; |
| 72 | 72 |
| 73 // Get the total number of bytes for this download. Should return 0 if the | 73 // Get the total number of bytes for this download. Should return 0 if the |
| 74 // total size of the download is not known. Virual for testing. | 74 // total size of the download is not known. Virual for testing. |
| 75 int64 GetTotalBytes() const; | 75 int64 GetTotalBytes() const; |
| 76 | 76 |
| 77 // Rough percent complete. Returns -1 if the progress is unknown. | 77 // Rough percent complete. Returns -1 if the progress is unknown. |
| 78 int PercentComplete() const; | 78 int PercentComplete() const; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void OpenUsingPlatformHandler(); | 139 void OpenUsingPlatformHandler(); |
| 140 | 140 |
| 141 content::DownloadItem* download() { return download_; } | 141 content::DownloadItem* download() { return download_; } |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 // Returns a string representations of the current download progress sizes. If | 144 // Returns a string representations of the current download progress sizes. If |
| 145 // the total size of the download is known, this string looks like: "100/200 | 145 // the total size of the download is known, this string looks like: "100/200 |
| 146 // MB" where the numerator is the transferred size and the denominator is the | 146 // MB" where the numerator is the transferred size and the denominator is the |
| 147 // total size. If the total isn't known, returns the transferred size as a | 147 // total size. If the total isn't known, returns the transferred size as a |
| 148 // string (e.g.: "100 MB"). | 148 // string (e.g.: "100 MB"). |
| 149 string16 GetProgressSizesString() const; | 149 base::string16 GetProgressSizesString() const; |
| 150 | 150 |
| 151 // Returns a string indicating the status of an in-progress download. | 151 // Returns a string indicating the status of an in-progress download. |
| 152 string16 GetInProgressStatusString() const; | 152 base::string16 GetInProgressStatusString() const; |
| 153 | 153 |
| 154 // The DownloadItem that this model represents. Note that DownloadItemModel | 154 // The DownloadItem that this model represents. Note that DownloadItemModel |
| 155 // itself shouldn't maintain any state since there can be more than one | 155 // itself shouldn't maintain any state since there can be more than one |
| 156 // DownloadItemModel in use with the same DownloadItem. | 156 // DownloadItemModel in use with the same DownloadItem. |
| 157 content::DownloadItem* download_; | 157 content::DownloadItem* download_; |
| 158 | 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel); | 159 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel); |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ | 162 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ |
| OLD | NEW |