| 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 7058cbb9dd87cf41eaf6ea05b857f96f82909907..c21191561ddba8b48a4b9369a30243112cd6b798 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
|
| @@ -111,7 +111,8 @@ public class ChromeDownloadDelegate {
|
| if (fileExists) {
|
| launchDownloadInfoBar(newInfo, fullDirPath);
|
| } else {
|
| - enqueueDownloadManagerRequest(newInfo);
|
| + DownloadController.enqueueDownloadManagerRequest(newInfo);
|
| + DownloadController.closeTabIfBlank(mTab);
|
| }
|
| }
|
| }.execute();
|
| @@ -177,11 +178,11 @@ public class ChromeDownloadDelegate {
|
|
|
| @Override
|
| public void onPostExecute(Void args) {
|
| - enqueueDownloadManagerRequest(downloadInfo);
|
| + DownloadController.enqueueDownloadManagerRequest(downloadInfo);
|
| }
|
| }.execute();
|
| } else {
|
| - enqueueDownloadManagerRequest(downloadInfo);
|
| + DownloadController.enqueueDownloadManagerRequest(downloadInfo);
|
| }
|
| return DownloadController.closeTabIfBlank(mTab);
|
| }
|
| @@ -192,17 +193,6 @@ public class ChromeDownloadDelegate {
|
| new File(fullDirPath, info.getFileName()).toString(), mTab.isIncognito());
|
| }
|
|
|
| - /**
|
| - * Enqueue a request to download a file using Android DownloadManager.
|
| - *
|
| - * @param info Download information about the download.
|
| - */
|
| - private void enqueueDownloadManagerRequest(final DownloadInfo info) {
|
| - DownloadManagerService.getDownloadManagerService().enqueueDownloadManagerRequest(
|
| - new DownloadItem(true, info), true);
|
| - DownloadController.closeTabIfBlank(mTab);
|
| - }
|
| -
|
| /**
|
| * Check the external storage and notify user on error.
|
| *
|
| @@ -243,30 +233,6 @@ public class ChromeDownloadDelegate {
|
| DownloadManagerService.getDownloadManagerService().onDownloadFailed(fileName, reason);
|
| }
|
|
|
| - /**
|
| - * Enqueue a request to download a file using Android DownloadManager.
|
| - * @param url Url to download.
|
| - * @param userAgent User agent to use.
|
| - * @param contentDisposition Content disposition of the request.
|
| - * @param mimeType MIME type.
|
| - * @param cookie Cookie to use.
|
| - * @param referrer Referrer to use.
|
| - */
|
| - @CalledByNative
|
| - private void enqueueAndroidDownloadManagerRequest(String url, String userAgent,
|
| - String fileName, String mimeType, String cookie, String referrer) {
|
| - DownloadInfo downloadInfo = new DownloadInfo.Builder()
|
| - .setUrl(url)
|
| - .setUserAgent(userAgent)
|
| - .setFileName(fileName)
|
| - .setMimeType(mimeType)
|
| - .setCookie(cookie)
|
| - .setReferrer(referrer)
|
| - .setIsGETRequest(true)
|
| - .build();
|
| - enqueueDownloadManagerRequest(downloadInfo);
|
| - }
|
| -
|
| /**
|
| * If the given MIME type is null, or one of the "generic" types (text/plain
|
| * or application/octet-stream) map it to a type that Android can deal with.
|
| @@ -320,25 +286,6 @@ public class ChromeDownloadDelegate {
|
| return MimeTypeMap.getFileExtensionFromUrl(url);
|
| }
|
|
|
| - /**
|
| - * Discards a downloaded file.
|
| - *
|
| - * @param filepath File to be discarded.
|
| - */
|
| - private static void discardFile(final String filepath) {
|
| - new AsyncTask<Void, Void, Void>() {
|
| - @Override
|
| - public Void doInBackground(Void... params) {
|
| - Log.d(TAG, "Discarding download: " + filepath);
|
| - File file = new File(filepath);
|
| - if (file.exists() && !file.delete()) {
|
| - Log.e(TAG, "Error discarding file: " + filepath);
|
| - }
|
| - return null;
|
| - }
|
| - }.execute();
|
| - }
|
| -
|
| /**
|
| * For certain download types(OMA for example), android DownloadManager should
|
| * handle them. Call this function to intercept those downloads.
|
|
|