summaryrefslogtreecommitdiffstats
path: root/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
diff options
context:
space:
mode:
authorqinmin <qinmin@chromium.org>2016-03-25 21:13:38 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-26 04:14:58 +0000
commit30ac0f57a0fcae1a13e6374c05927a04caf526e5 (patch)
treebb56349228c53a3ee588e25971e935af6996f5fb /chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
parent220c7edc3243b54970a13d91c690b2dffc15732d (diff)
downloadchromium_src-30ac0f57a0fcae1a13e6374c05927a04caf526e5.zip
chromium_src-30ac0f57a0fcae1a13e6374c05927a04caf526e5.tar.gz
chromium_src-30ac0f57a0fcae1a13e6374c05927a04caf526e5.tar.bz2
Switch to use download GUID to indentify download items
Download GUID is introduced by http://crrev.com/eef62b0282ec19ebc040785d0b7ac36de398cbc1 Unlike download Id, the GUID can live across browser sessions and will not be reused. This change switches the java class to also use the GUID. Chrome will temporarily use the old download Id as the notification Id. This is because the android notification requires an int to identify it, rather than a string. In the future, we will generate the notification Id from java side. The download Ids generated by the Android DownloadManager are not affected by this CL. However, they are only used in OMA downloads and when we call addCompletedDownload(). BUG=593020 Review URL: https://codereview.chromium.org/1809203006 Cr-Commit-Position: refs/heads/master@{#383443}
Diffstat (limited to 'chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java')
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
index 65aa770..79c4a63 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
@@ -58,8 +58,8 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
public void onInfoBarButtonClicked(boolean confirm) {
assert mTab != null;
if (mPendingRequest == null) return;
- if (mPendingRequest.hasDownloadId()) {
- nativeDangerousDownloadValidated(mTab, mPendingRequest.getDownloadId(), confirm);
+ if (mPendingRequest.getDownloadGuid() != null) {
+ nativeDangerousDownloadValidated(mTab, mPendingRequest.getDownloadGuid(), confirm);
if (confirm) {
showDownloadStartNotification();
}
@@ -107,9 +107,10 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
@Override
public void onInfoBarDismissed() {
if (mPendingRequest != null) {
- if (mPendingRequest.hasDownloadId()) {
+ if (mPendingRequest.getDownloadGuid() != null) {
assert mTab != null;
- nativeDangerousDownloadValidated(mTab, mPendingRequest.getDownloadId(), false);
+ nativeDangerousDownloadValidated(
+ mTab, mPendingRequest.getDownloadGuid(), false);
} else if (!mPendingRequest.isGETRequest()) {
// Infobar was dismissed, discard the file if a POST download is pending.
discardFile(mPendingRequest.getFilePath());
@@ -269,15 +270,14 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
* Called when a danagerous download is about to start.
*
* @param filename File name of the download item.
- * @param downloadId ID of the download.
+ * @param downloadGuid GUID of the download.
*/
@Override
- public void onDangerousDownload(String filename, int downloadId) {
+ public void onDangerousDownload(String filename, String downloadGuid) {
DownloadInfo downloadInfo = new DownloadInfo.Builder()
.setFileName(filename)
.setDescription(filename)
- .setHasDownloadId(true)
- .setDownloadId(downloadId).build();
+ .setDownloadGuid(downloadGuid).build();
confirmDangerousDownload(downloadInfo);
}
@@ -416,7 +416,8 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
*/
private void enqueueDownloadManagerRequest(final DownloadInfo info) {
DownloadManagerService.getDownloadManagerService(
- mContext.getApplicationContext()).enqueueDownloadManagerRequest(info, true);
+ mContext.getApplicationContext()).enqueueDownloadManagerRequest(
+ new DownloadItem(true, info), true);
closeBlankTab();
}
@@ -630,7 +631,7 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
private static native String nativeGetDownloadWarningText(String filename);
private static native boolean nativeIsDownloadDangerous(String filename);
private static native void nativeDangerousDownloadValidated(
- Object tab, int downloadId, boolean accept);
+ Object tab, String downloadGuid, boolean accept);
private static native void nativeLaunchDownloadOverwriteInfoBar(ChromeDownloadDelegate delegate,
Tab tab, DownloadInfo downloadInfo, String fileName, String dirName,
String dirFullPath);