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

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

Issue 2502113002: [Download Home] More cleaning (Closed)
Patch Set: Comment 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 86dd0bc7a61b7f27ef3cc328fb75b5a86438880b..08c96918c7abbdff85cd9074d95c71de09247081 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
@@ -71,6 +71,9 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
/** @return How much of the download has completed, or -1 if there is no progress. */
public abstract int getDownloadProgress();
+ /** @return Whether or not the file is completely downloaded. */
+ public abstract boolean isComplete();
+
/** Called when the user wants to open the file. */
abstract void open();
@@ -105,14 +108,11 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
/** Wraps a {@link DownloadItem}. */
public static class DownloadItemWrapper extends DownloadHistoryItemWrapper {
private final DownloadItem mItem;
- private final boolean mIsOffTheRecord;
private File mFile;
- DownloadItemWrapper(DownloadItem item, boolean isOffTheRecord, BackendProvider provider,
- ComponentName component) {
+ DownloadItemWrapper(DownloadItem item, BackendProvider provider, ComponentName component) {
super(provider, component);
mItem = item;
- mIsOffTheRecord = isOffTheRecord;
}
@Override
@@ -185,7 +185,7 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
return;
}
- if (DownloadUtils.openFile(getFile(), getMimeType(), mIsOffTheRecord)) {
+ if (DownloadUtils.openFile(getFile(), getMimeType(), isOffTheRecord())) {
recordOpenSuccess();
} else {
recordOpenFailure();
@@ -195,7 +195,7 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
@Override
public boolean remove() {
// Tell the DownloadManager to remove the file from history.
- mBackendProvider.getDownloadDelegate().removeDownload(getId(), mIsOffTheRecord);
+ mBackendProvider.getDownloadDelegate().removeDownload(getId(), isOffTheRecord());
return false;
}
@@ -206,7 +206,12 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
@Override
boolean isOffTheRecord() {
- return mIsOffTheRecord;
+ return mItem.getDownloadInfo().isOffTheRecord();
+ }
+
+ @Override
+ public boolean isComplete() {
+ return mItem.getDownloadInfo().state() == DownloadState.COMPLETE;
}
}
@@ -305,5 +310,11 @@ public abstract class DownloadHistoryItemWrapper extends TimedItem {
boolean isOffTheRecord() {
return false;
}
+
+ @Override
+ public boolean isComplete() {
+ // Incomplete offline pages aren't shown yet.
+ return true;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698