| Index: chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
|
| 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 7921771a81372d8c25470dd2dacad21928ac22b3..29e6ae6d52e471c6737a41d5165ea232e3bb885a 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
|
| @@ -32,9 +32,8 @@ import org.chromium.chrome.browser.infobar.SimpleConfirmInfoBarBuilder;
|
| import org.chromium.chrome.browser.tab.EmptyTabObserver;
|
| import org.chromium.chrome.browser.tab.Tab;
|
| import org.chromium.chrome.browser.tabmodel.TabModelSelector;
|
| -import org.chromium.content.browser.ContentViewDownloadDelegate;
|
| import org.chromium.content.browser.DownloadController;
|
| -import org.chromium.content.browser.DownloadInfo;
|
| +import org.chromium.content_public.browser.DownloadInfo;
|
| import org.chromium.content_public.browser.WebContents;
|
| import org.chromium.ui.base.WindowAndroid;
|
| import org.chromium.ui.base.WindowAndroid.PermissionCallback;
|
| @@ -51,7 +50,7 @@ import java.io.File;
|
| *
|
| * Prompts the user when a dangerous file is downloaded. Auto-opens PDFs after downloading.
|
| */
|
| -public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| +public class ChromeDownloadDelegate {
|
| private static final String TAG = "Download";
|
|
|
| private class DangerousDownloadListener implements SimpleConfirmInfoBarBuilder.Listener {
|
| @@ -125,17 +124,17 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| private final DangerousDownloadListener mDangerousDownloadListener;
|
|
|
| // The application context.
|
| - private final Context mContext;
|
| + private Context mContext;
|
| private Tab mTab;
|
|
|
| // Pending download request for a dangerous file.
|
| private DownloadInfo mPendingRequest;
|
|
|
| /**
|
| - * Creates ChromeDownloadDelegate.
|
| - * @param context The application context.
|
| - * @param tab The corresponding tab instance.
|
| - */
|
| + * Creates ChromeDownloadDelegate.
|
| + * @param context The application context.
|
| + * @param tab The corresponding tab instance.
|
| + */
|
| public ChromeDownloadDelegate(Context context, Tab tab) {
|
| mContext = context;
|
| mTab = tab;
|
| @@ -150,14 +149,17 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| mDangerousDownloadListener = new DangerousDownloadListener();
|
| }
|
|
|
| - @Override
|
| - public void requestHttpGetDownload(DownloadInfo downloadInfo, boolean mustDownload) {
|
| + @CalledByNative
|
| + public void requestHttpGetDownload(String url, String userAgent, String contentDisposition,
|
| + String mimeType, String cookie, String referer, boolean hasUserGesture,
|
| + String filename, long contentLength, boolean mustDownload) {
|
| + Log.e(TAG, "requestHttpGetDownload2:" + url);
|
| // If we're dealing with A/V content that's not explicitly marked for download, check if it
|
| // is streamable.
|
| if (!mustDownload) {
|
| // Query the package manager to see if there's a registered handler that matches.
|
| Intent intent = new Intent(Intent.ACTION_VIEW);
|
| - intent.setDataAndType(Uri.parse(downloadInfo.getUrl()), downloadInfo.getMimeType());
|
| + intent.setDataAndType(Uri.parse(url), mimeType);
|
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
| // If the intent is resolved to ourselves, we don't want to attempt to load the url
|
| // only to try and download it again.
|
| @@ -165,6 +167,18 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| return;
|
| }
|
| }
|
| + DownloadInfo downloadInfo = new DownloadInfo.Builder()
|
| + .setUrl(url)
|
| + .setUserAgent(userAgent)
|
| + .setContentDisposition(contentDisposition)
|
| + .setMimeType(mimeType)
|
| + .setCookie(cookie)
|
| + .setReferer(referer)
|
| + .setHasUserGesture(hasUserGesture)
|
| + .setFileName(filename)
|
| + .setContentLength(contentLength)
|
| + .setIsGETRequest(true)
|
| + .build();
|
| onDownloadStartNoStream(downloadInfo);
|
| }
|
|
|
| @@ -268,7 +282,7 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| * @param filename File name of the download item.
|
| * @param downloadGuid GUID of the download.
|
| */
|
| - @Override
|
| + @CalledByNative
|
| public void onDangerousDownload(String filename, String downloadGuid) {
|
| DownloadInfo downloadInfo = new DownloadInfo.Builder()
|
| .setFileName(filename)
|
| @@ -277,7 +291,7 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| confirmDangerousDownload(downloadInfo);
|
| }
|
|
|
| - @Override
|
| + @CalledByNative
|
| public void requestFileAccess(final long callbackId) {
|
| if (mTab == null) {
|
| // TODO(tedchoc): Show toast (only when activity is alive).
|
| @@ -464,8 +478,8 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| * @param filename Name of the file.
|
| * @param mimeType MIME type of the content.
|
| */
|
| - @Override
|
| - public void onDownloadStarted(String filename, String mimeType) {
|
| + @CalledByNative
|
| + private void onDownloadStarted(String filename, String mimeType) {
|
| if (!isDangerousFile(filename, mimeType)) {
|
| showDownloadStartNotification();
|
| closeBlankTab();
|
| @@ -626,7 +640,6 @@ public class ChromeDownloadDelegate implements ContentViewDownloadDelegate {
|
| protected Context getContext() {
|
| return mContext;
|
| }
|
| -
|
| private static native String nativeGetDownloadWarningText(String filename);
|
| private static native boolean nativeIsDownloadDangerous(String filename);
|
| private static native void nativeDangerousDownloadValidated(
|
|
|