Index: content/public/android/java/src/org/chromium/content/browser/DownloadController.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java |
index 9577ba173b10d342fe9fa8b539e3a622f8b0c039..cac5f97a2fd62b9c477b9e7c5627ce91a09ae8f1 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java |
@@ -7,16 +7,38 @@ package org.chromium.content.browser; |
import org.chromium.base.CalledByNative; |
import org.chromium.base.JNINamespace; |
+import android.content.Context; |
+ |
/** |
* Java counterpart of android DownloadController. |
* |
* Its a singleton class instantiated by the C++ DownloadController. |
*/ |
@JNINamespace("content") |
-class DownloadController { |
+public class DownloadController { |
private static final String LOGTAG = "DownloadController"; |
private static DownloadController sInstance; |
+ /** |
+ * Class for notifying the application that download has completed. |
+ */ |
+ public interface DownloadNotificationService { |
+ /** |
+ * Notify the host application that a download is finished. |
+ * @param context Application context. |
+ * @param url The full url to the content that was downloaded. |
+ * @param mimetype The mimetype of downloaded file. |
+ * @param path Path of the downloaded file. |
+ * @param description Description of the downloaded file. |
+ * @param contentLength The file size of the downloaded file (in bytes). |
+ * @param successful Whether the download succeeded. |
+ */ |
+ void onDownloadCompleted(Context context, String url, String mimetype, String path, |
+ String description, long contentLength, boolean successful); |
+ } |
+ |
+ private static DownloadNotificationService sDownloadNotificationService; |
+ |
@CalledByNative |
public static DownloadController getInstance() { |
if (sInstance == null) { |
@@ -33,6 +55,10 @@ class DownloadController { |
return view.getDownloadDelegate(); |
} |
+ public static void setDownloadNotificationService(DownloadNotificationService service) { |
+ sDownloadNotificationService = service; |
+ } |
+ |
/** |
* Notifies the download delegate of a new GET download and passes all the information |
* needed to download the file. |
@@ -54,13 +80,16 @@ class DownloadController { |
/** |
* Notifies the download delegate that a new download has started. This can |
* be either a POST download or a GET download with authentication. |
+ * @param view ContentViewCore associated with the download item. |
+ * @param filename File name of the downloaded file. |
+ * @param mimeType Mime of the downloaded item. |
*/ |
@CalledByNative |
- public void onDownloadStarted(ContentViewCore view) { |
+ public void onDownloadStarted(ContentViewCore view, String filename, String mimeType) { |
ContentViewDownloadDelegate downloadDelagate = downloadDelegateFromView(view); |
if (downloadDelagate != null) { |
- downloadDelagate.onDownloadStarted(); |
+ downloadDelagate.onDownloadStarted(filename, mimeType); |
} |
} |
@@ -69,14 +98,11 @@ class DownloadController { |
* download. This can be either a POST download or a GET download with authentication. |
*/ |
@CalledByNative |
- public void onDownloadCompleted(ContentViewCore view, String url, |
- String contentDisposition, String mimetype, String path, |
- long contentLength, boolean successful) { |
- ContentViewDownloadDelegate downloadDelagate = downloadDelegateFromView(view); |
- |
- if (downloadDelagate != null) { |
- downloadDelagate.onDownloadCompleted( |
- url, mimetype, path, contentLength, successful); |
+ public void onDownloadCompleted(Context context, String url, String mimetype, |
+ String filename, String path, long contentLength, boolean successful) { |
+ if (sDownloadNotificationService != null) { |
+ sDownloadNotificationService.onDownloadCompleted(context, url, mimetype, path, |
+ filename, contentLength, successful); |
} |
} |