Commit cfb8d519 authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Downloads : Implemented OCP::OpenItem

Provided implementation for DownloadOfflineContentProvider::OpenItem. It
will call DownloadItem::OpenDownload and eventually hits
ChromeDownloadManagerDelegate. We will also need to pass DownloadOpenSource
to this interface later for UMA purposes.

Bug: 855727
Change-Id: I86f4f802ab8711ea2162e512e18cbcbf93c1822f
Reviewed-on: https://chromium-review.googlesource.com/1114068
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571580}
parent 51780aec
...@@ -204,6 +204,15 @@ void DownloadManagerService::Observe( ...@@ -204,6 +204,15 @@ void DownloadManagerService::Observe(
} }
} }
void DownloadManagerService::OpenDownload(download::DownloadItem* download,
int source) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_item =
JNI_DownloadManagerService_CreateJavaDownloadItem(env, download);
Java_DownloadManagerService_openDownloadItem(env, java_ref_, j_item, source);
}
void DownloadManagerService::OpenDownload( void DownloadManagerService::OpenDownload(
JNIEnv* env, JNIEnv* env,
jobject obj, jobject obj,
...@@ -222,10 +231,7 @@ void DownloadManagerService::OpenDownload( ...@@ -222,10 +231,7 @@ void DownloadManagerService::OpenDownload(
if (!item) if (!item)
return; return;
ScopedJavaLocalRef<jobject> j_item = OpenDownload(item, source);
JNI_DownloadManagerService_CreateJavaDownloadItem(env, item);
Java_DownloadManagerService_openDownloadItem(env, java_ref_, j_item, source);
} }
void DownloadManagerService::ResumeDownload( void DownloadManagerService::ResumeDownload(
......
...@@ -57,6 +57,9 @@ class DownloadManagerService ...@@ -57,6 +57,9 @@ class DownloadManagerService
// Called to Initialize this object. // Called to Initialize this object.
void Init(JNIEnv* env, jobject obj); void Init(JNIEnv* env, jobject obj);
// Called to open a given download item.
void OpenDownload(download::DownloadItem* download, int source);
// Called to open a download item whose GUID is equal to |jdownload_guid|. // Called to open a download item whose GUID is equal to |jdownload_guid|.
void OpenDownload(JNIEnv* env, void OpenDownload(JNIEnv* env,
jobject obj, jobject obj,
......
...@@ -640,6 +640,15 @@ void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) { ...@@ -640,6 +640,15 @@ void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) {
MaybeSendDangerousDownloadOpenedReport(download, MaybeSendDangerousDownloadOpenedReport(download,
false /* show_download_in_folder */); false /* show_download_in_folder */);
#if defined(OS_ANDROID)
// TODO(shaktisahu@): Pull out to static helper method once
// DownloadManagerService goes away. Put the helper method in the download
// component.
DownloadManagerService::GetInstance()->OpenDownload(download,
0 /* download source */);
return;
#endif
if (!DownloadItemModel(download).ShouldPreferOpeningInBrowser()) { if (!DownloadItemModel(download).ShouldPreferOpeningInBrowser()) {
RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_PLATFORM); RecordDownloadOpenMethod(DOWNLOAD_OPEN_METHOD_DEFAULT_PLATFORM);
OpenDownloadUsingPlatformHandler(download); OpenDownloadUsingPlatformHandler(download);
......
...@@ -48,9 +48,11 @@ DownloadOfflineContentProvider::~DownloadOfflineContentProvider() { ...@@ -48,9 +48,11 @@ DownloadOfflineContentProvider::~DownloadOfflineContentProvider() {
manager_->GetBrowserContext()->IsOffTheRecord())); manager_->GetBrowserContext()->IsOffTheRecord()));
} }
// TODO(shaktisahu) : Pass DownloadOpenSource.
void DownloadOfflineContentProvider::OpenItem(const ContentId& id) { void DownloadOfflineContentProvider::OpenItem(const ContentId& id) {
// TODO(crbug.com/855727): Provide implementation. download::DownloadItem* item = manager_->GetDownloadByGuid(id.id);
NOTIMPLEMENTED(); if (item)
item->OpenDownload();
} }
void DownloadOfflineContentProvider::RemoveItem(const ContentId& id) { void DownloadOfflineContentProvider::RemoveItem(const ContentId& id) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment