Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3374)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java

Issue 2493543003: [Downloads] Pass more DownloadItem state to java (Closed)
Patch Set: Removed dependency Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698