diff options
Diffstat (limited to 'content/public/android/java/src')
3 files changed, 43 insertions, 36 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewDownloadDelegate.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewDownloadDelegate.java index 4caff13..5153062 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewDownloadDelegate.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewDownloadDelegate.java @@ -26,9 +26,9 @@ public interface ContentViewDownloadDelegate { * Notify the host application that a download has an extension indicating * a dangerous file type. * @param filename File name of the downloaded file. - * @param downloadId The download id. + * @param downloadGuid The download GUID. */ - void onDangerousDownload(String filename, int downloadId); + void onDangerousDownload(String filename, String downloadGuid); /** * Called when file access has been requested to complete a download. 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 63a5eb7..5e2c29f 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 @@ -118,11 +118,13 @@ public class DownloadController { /** * Notifies the download delegate that a download completed and passes along info about the * download. This can be either a POST download or a GET download with authentication. + * TODO(qinmin): Generate the notificationId in the java side, the native downloadId is going + * to be deprecated. */ @CalledByNative private void onDownloadCompleted(String url, String mimeType, String filename, String path, - long contentLength, int downloadId, String originalUrl, String refererUrl, - boolean hasUserGesture) { + long contentLength, int notificationId, String downloadGuid, String originalUrl, + String refererUrl, boolean hasUserGesture) { if (sDownloadNotificationService == null) return; DownloadInfo downloadInfo = new DownloadInfo.Builder() .setUrl(url) @@ -131,8 +133,8 @@ public class DownloadController { .setFilePath(path) .setContentLength(contentLength) .setDescription(filename) - .setDownloadId(downloadId) - .setHasDownloadId(true) + .setNotificationId(notificationId) + .setDownloadGuid(downloadGuid) .setOriginalUrl(originalUrl) .setReferer(refererUrl) .setHasUserGesture(hasUserGesture) @@ -146,7 +148,8 @@ public class DownloadController { */ @CalledByNative private void onDownloadInterrupted(String url, String mimeType, String filename, String path, - long contentLength, int downloadId, boolean isResumable, boolean isAutoResumable) { + long contentLength, int notificationId, String downloadGuid, boolean isResumable, + boolean isAutoResumable) { if (sDownloadNotificationService == null) return; DownloadInfo downloadInfo = new DownloadInfo.Builder() .setUrl(url) @@ -155,8 +158,8 @@ public class DownloadController { .setFilePath(path) .setContentLength(contentLength) .setDescription(filename) - .setDownloadId(downloadId) - .setHasDownloadId(true) + .setNotificationId(notificationId) + .setDownloadGuid(downloadGuid) .setIsResumable(isResumable) .build(); sDownloadNotificationService.onDownloadInterrupted(downloadInfo, isAutoResumable); @@ -164,14 +167,17 @@ public class DownloadController { /** * Called when a download was cancelled. - * @param downloadId Id of the download item. + * @param notificationId Notification Id of the download item. + * @param downloadGuid GUID of the download item. + * TODO(qinmin): Generate the notificationId in the java side, the native downloadId is going + * to be deprecated. */ @CalledByNative - private void onDownloadCancelled(int downloadId) { + private void onDownloadCancelled(int notificationId, String downloadGuid) { if (sDownloadNotificationService == null) return; DownloadInfo downloadInfo = new DownloadInfo.Builder() - .setDownloadId(downloadId) - .setHasDownloadId(true) + .setNotificationId(notificationId) + .setDownloadGuid(downloadGuid) .build(); sDownloadNotificationService.onDownloadCancelled(downloadInfo); } @@ -179,10 +185,12 @@ public class DownloadController { /** * Notifies the download delegate about progress of a download. Downloads that use Chrome * network stack use custom notification to display the progress of downloads. + * TODO(qinmin): Generate the notificationId in the java side, the native downloadId is going + * to be deprecated. */ @CalledByNative - private void onDownloadUpdated(String url, String mimeType, String filename, - String path, long contentLength, int downloadId, int percentCompleted, + private void onDownloadUpdated(String url, String mimeType, String filename, String path, + long contentLength, int notificationId, String downloadGuid, int percentCompleted, long timeRemainingInMs, boolean hasUserGesture, boolean isPaused, boolean isResumable) { if (sDownloadNotificationService == null) return; DownloadInfo downloadInfo = new DownloadInfo.Builder() @@ -192,8 +200,8 @@ public class DownloadController { .setFilePath(path) .setContentLength(contentLength) .setDescription(filename) - .setDownloadId(downloadId) - .setHasDownloadId(true) + .setNotificationId(notificationId) + .setDownloadGuid(downloadGuid) .setPercentCompleted(percentCompleted) .setTimeRemainingInMillis(timeRemainingInMs) .setHasUserGesture(hasUserGesture) @@ -207,11 +215,10 @@ public class DownloadController { * Notifies the download delegate that a dangerous download started. */ @CalledByNative - private void onDangerousDownload(ContentViewCore view, String filename, - int downloadId) { + private void onDangerousDownload(ContentViewCore view, String filename, String downloadGuid) { ContentViewDownloadDelegate downloadDelegate = downloadDelegateFromView(view); if (downloadDelegate != null) { - downloadDelegate.onDangerousDownload(filename, downloadId); + downloadDelegate.onDangerousDownload(filename, downloadGuid); } } diff --git a/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java b/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java index 39da754..f6297be 100644 --- a/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java +++ b/content/public/android/java/src/org/chromium/content/browser/DownloadInfo.java @@ -18,8 +18,8 @@ public final class DownloadInfo { private final String mReferer; private final String mOriginalUrl; private final long mContentLength; - private final boolean mHasDownloadId; - private final int mDownloadId; + private final int mNotificationId; + private final String mDownloadGuid; private final boolean mHasUserGesture; private final String mContentDisposition; private final boolean mIsGETRequest; @@ -39,8 +39,8 @@ public final class DownloadInfo { mReferer = builder.mReferer; mOriginalUrl = builder.mOriginalUrl; mContentLength = builder.mContentLength; - mHasDownloadId = builder.mHasDownloadId; - mDownloadId = builder.mDownloadId; + mNotificationId = builder.mNotificationId; + mDownloadGuid = builder.mDownloadGuid; mHasUserGesture = builder.mHasUserGesture; mIsGETRequest = builder.mIsGETRequest; mContentDisposition = builder.mContentDisposition; @@ -94,12 +94,12 @@ public final class DownloadInfo { return mIsGETRequest; } - public boolean hasDownloadId() { - return mHasDownloadId; + public int getNotificationId() { + return mNotificationId; } - public int getDownloadId() { - return mDownloadId; + public String getDownloadGuid() { + return mDownloadGuid; } public boolean hasUserGesture() { @@ -144,8 +144,8 @@ public final class DownloadInfo { private String mOriginalUrl; private long mContentLength; private boolean mIsGETRequest; - private boolean mHasDownloadId; - private int mDownloadId; + private int mNotificationId; + private String mDownloadGuid; private boolean mHasUserGesture; private String mContentDisposition; private int mPercentCompleted = -1; @@ -208,13 +208,13 @@ public final class DownloadInfo { return this; } - public Builder setHasDownloadId(boolean hasDownloadId) { - mHasDownloadId = hasDownloadId; + public Builder setNotificationId(int notificationId) { + mNotificationId = notificationId; return this; } - public Builder setDownloadId(int downloadId) { - mDownloadId = downloadId; + public Builder setDownloadGuid(String downloadGuid) { + mDownloadGuid = downloadGuid; return this; } @@ -270,8 +270,8 @@ public final class DownloadInfo { .setReferer(downloadInfo.getReferer()) .setOriginalUrl(downloadInfo.getOriginalUrl()) .setContentLength(downloadInfo.getContentLength()) - .setHasDownloadId(downloadInfo.hasDownloadId()) - .setDownloadId(downloadInfo.getDownloadId()) + .setNotificationId(downloadInfo.getNotificationId()) + .setDownloadGuid(downloadInfo.getDownloadGuid()) .setHasUserGesture(downloadInfo.hasUserGesture()) .setContentDisposition(downloadInfo.getContentDisposition()) .setIsGETRequest(downloadInfo.isGETRequest()) |