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

Unified Diff: chrome/browser/android/download/download_manager_service.cc

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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/StubbedProvider.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/download/download_manager_service.cc
diff --git a/chrome/browser/android/download/download_manager_service.cc b/chrome/browser/android/download/download_manager_service.cc
index 26639bdc650cefff2bfed73d35837b323aae33f0..07ee8e90ca3b6b0dd71ae0f841017de37129fb90 100644
--- a/chrome/browser/android/download/download_manager_service.cc
+++ b/chrome/browser/android/download/download_manager_service.cc
@@ -31,7 +31,7 @@ bool ShouldShowDownloadItem(content::DownloadItem* item) {
return !item->IsTemporary() &&
!item->GetFileNameToReportUser().empty() &&
!item->GetTargetFilePath().empty() &&
- item->GetState() == content::DownloadItem::COMPLETE;
+ item->GetState() != content::DownloadItem::CANCELLED;
}
void updateNotifier(DownloadManagerService* service,
@@ -62,6 +62,24 @@ void RemoveDownloadsFromDownloadManager(
}
}
+ScopedJavaLocalRef<jobject> CreateJavaDownloadItem(
+ JNIEnv* env, content::DownloadItem* item) {
+ return Java_DownloadManagerService_createDownloadItem(
+ env,
+ ConvertUTF8ToJavaString(env, item->GetGuid()),
+ ConvertUTF8ToJavaString(env,
+ item->GetFileNameToReportUser().value()),
+ ConvertUTF8ToJavaString(env, item->GetTargetFilePath().value()),
+ ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()),
+ ConvertUTF8ToJavaString(env, item->GetMimeType()),
+ item->GetStartTime().ToJavaTime(), item->GetTotalBytes(),
+ item->GetFileExternallyRemoved(),
+ item->GetBrowserContext()->IsOffTheRecord(),
+ item->GetState(),
+ item->PercentComplete(),
+ item->IsPaused());
+}
+
} // namespace
// static
@@ -178,15 +196,9 @@ void DownloadManagerService::GetAllDownloadsInternal(bool is_off_the_record) {
if (!ShouldShowDownloadItem(item))
continue;
+ ScopedJavaLocalRef<jobject> j_item = CreateJavaDownloadItem(env, item);
Java_DownloadManagerService_addDownloadItemToList(
- env, java_ref_, j_download_item_list,
- ConvertUTF8ToJavaString(env, item->GetGuid()),
- ConvertUTF8ToJavaString(env, item->GetFileNameToReportUser().value()),
- ConvertUTF8ToJavaString(env, item->GetTargetFilePath().value()),
- ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()),
- ConvertUTF8ToJavaString(env, item->GetMimeType()),
- item->GetStartTime().ToJavaTime(), item->GetTotalBytes(),
- item->GetFileExternallyRemoved());
+ env, java_ref_, j_download_item_list, j_item);
}
Java_DownloadManagerService_onAllDownloadsRetrieved(
@@ -274,21 +286,9 @@ void DownloadManagerService::OnDownloadUpdated(
return;
JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> j_item = CreateJavaDownloadItem(env, item);
Java_DownloadManagerService_onDownloadItemUpdated(
- env,
- java_ref_.obj(),
- item->GetState(),
- ConvertUTF8ToJavaString(env, item->GetGuid()).obj(),
- ConvertUTF8ToJavaString(
- env, item->GetFileNameToReportUser().value()).obj(),
- ConvertUTF8ToJavaString(
- env, item->GetTargetFilePath().value()).obj(),
- ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()).obj(),
- ConvertUTF8ToJavaString(env, item->GetMimeType()).obj(),
- item->GetStartTime().ToJavaTime(),
- item->GetTotalBytes(),
- item->GetBrowserContext()->IsOffTheRecord(),
- item->GetFileExternallyRemoved());
+ env, java_ref_.obj(), j_item);
}
void DownloadManagerService::OnDownloadRemoved(
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/StubbedProvider.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698