Index: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java |
index 90c80dbb8778fa085ad6e0ce0992e29de01d7e83..517194dd0e60d070d737896818772a6570c96571 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java |
@@ -15,6 +15,7 @@ import org.chromium.chrome.browser.download.DownloadItem; |
import org.chromium.chrome.browser.download.DownloadUtils; |
import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadItem; |
import org.chromium.chrome.browser.widget.DateDividedAdapter.TimedItem; |
+import org.chromium.content_public.browser.DownloadState; |
import org.chromium.ui.widget.Toast; |
import java.io.File; |
@@ -67,6 +68,9 @@ public abstract class DownloadHistoryItemWrapper implements TimedItem { |
/** @return The mime type or null if the item doesn't have one. */ |
public abstract String getMimeType(); |
+ /** @return How much of the download has completed, or -1 if there is no progress. */ |
+ public abstract int getDownloadProgress(); |
+ |
/** Called when the user wants to open the file. */ |
abstract void open(); |
@@ -144,7 +148,11 @@ public abstract class DownloadHistoryItemWrapper implements TimedItem { |
@Override |
public long getFileSize() { |
- return mItem.getDownloadInfo().getContentLength(); |
+ if (mItem.getDownloadInfo().state() == DownloadState.COMPLETE) { |
+ return mItem.getDownloadInfo().getContentLength(); |
+ } else { |
+ return 0; |
+ } |
} |
@Override |
@@ -163,6 +171,11 @@ public abstract class DownloadHistoryItemWrapper implements TimedItem { |
} |
@Override |
+ public int getDownloadProgress() { |
+ return mItem.getDownloadInfo().getPercentCompleted(); |
+ } |
+ |
+ @Override |
public void open() { |
Context context = ContextUtils.getApplicationContext(); |
@@ -266,6 +279,11 @@ public abstract class DownloadHistoryItemWrapper implements TimedItem { |
} |
@Override |
+ public int getDownloadProgress() { |
+ return -1; |
+ } |
+ |
+ @Override |
public void open() { |
mBackendProvider.getOfflinePageBridge().openItem(getId(), mComponentName); |
recordOpenSuccess(); |