| 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 7a6ac101c328fd9f8b456ee4b9887592078a7143..3f3c59135c70ebca8c2333deaff87bd9f250b16d 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
|
| @@ -18,11 +18,11 @@ import android.widget.Toast;
|
| import org.chromium.base.VisibleForTesting;
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.chrome.R;
|
| -import org.chromium.chrome.browser.infobar.ConfirmInfoBar;
|
| -import org.chromium.chrome.browser.infobar.InfoBar;
|
| -import org.chromium.chrome.browser.infobar.InfoBarListeners;
|
| -import org.chromium.chrome.browser.tab.Tab;
|
| -import org.chromium.chrome.browser.tabmodel.TabModelSelector;
|
| +//import org.chromium.chrome.browser.infobar.ConfirmInfoBar;
|
| +//import org.chromium.chrome.browser.infobar.InfoBar;
|
| +//import org.chromium.chrome.browser.infobar.InfoBarListeners;
|
| +//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.DownloadInfo;
|
| import org.chromium.content_public.browser.WebContents;
|
| @@ -39,7 +39,7 @@ import java.io.File;
|
| * Prompts the user when a dangerous file is downloaded. Auto-opens PDFs after downloading.
|
| */
|
| public class ChromeDownloadDelegate
|
| - implements ContentViewDownloadDelegate, InfoBarListeners.Confirm {
|
| + implements ContentViewDownloadDelegate {
|
| // The application context.
|
| private final Context mContext;
|
| private final Tab mTab;
|
| @@ -49,47 +49,47 @@ public class ChromeDownloadDelegate
|
| // Pending download request for a dangerous file.
|
| private DownloadInfo mPendingRequest;
|
|
|
| - @Override
|
| - public void onConfirmInfoBarButtonClicked(ConfirmInfoBar infoBar, boolean confirm) {
|
| - if (mPendingRequest.hasDownloadId()) {
|
| - nativeDangerousDownloadValidated(mTab, mPendingRequest.getDownloadId(), confirm);
|
| - if (confirm) {
|
| - showDownloadStartNotification();
|
| - }
|
| - closeBlankTab();
|
| - } else if (confirm) {
|
| - // User confirmed the download.
|
| - if (mPendingRequest.isGETRequest()) {
|
| - enqueueDownloadManagerRequest(mPendingRequest);
|
| - } else {
|
| - DownloadInfo newDownloadInfo = DownloadInfo.Builder.fromDownloadInfo(
|
| - mPendingRequest).setIsSuccessful(true).build();
|
| - DownloadManagerService.getDownloadManagerService(mContext).onDownloadCompleted(
|
| - newDownloadInfo);
|
| - }
|
| - } else {
|
| - // User did not accept the download, discard the file if it is a POST download.
|
| - if (!mPendingRequest.isGETRequest()) {
|
| - discardFile(mPendingRequest.getFilePath());
|
| - }
|
| - }
|
| - mPendingRequest = null;
|
| - infoBar.dismissJavaOnlyInfoBar();
|
| - }
|
| -
|
| - @Override
|
| - public void onInfoBarDismissed(InfoBar infoBar) {
|
| - if (mPendingRequest != null) {
|
| - if (mPendingRequest.hasDownloadId()) {
|
| - nativeDangerousDownloadValidated(mTab, mPendingRequest.getDownloadId(), false);
|
| - } else if (!mPendingRequest.isGETRequest()) {
|
| - // Infobar was dismissed, discard the file if a POST download is pending.
|
| - discardFile(mPendingRequest.getFilePath());
|
| - }
|
| - }
|
| - // Forget the pending request.
|
| - mPendingRequest = null;
|
| - }
|
| +// @Override
|
| +// public void onConfirmInfoBarButtonClicked(ConfirmInfoBar infoBar, boolean confirm) {
|
| +// if (mPendingRequest.hasDownloadId()) {
|
| +// nativeDangerousDownloadValidated(mTab, mPendingRequest.getDownloadId(), confirm);
|
| +// if (confirm) {
|
| +// showDownloadStartNotification();
|
| +// }
|
| +// closeBlankTab();
|
| +// } else if (confirm) {
|
| +// // User confirmed the download.
|
| +// if (mPendingRequest.isGETRequest()) {
|
| +// enqueueDownloadManagerRequest(mPendingRequest);
|
| +// } else {
|
| +// DownloadInfo newDownloadInfo = DownloadInfo.Builder.fromDownloadInfo(
|
| +// mPendingRequest).setIsSuccessful(true).build();
|
| +// DownloadManagerService.getDownloadManagerService(mContext).onDownloadCompleted(
|
| +// newDownloadInfo);
|
| +// }
|
| +// } else {
|
| +// // User did not accept the download, discard the file if it is a POST download.
|
| +// if (!mPendingRequest.isGETRequest()) {
|
| +// discardFile(mPendingRequest.getFilePath());
|
| +// }
|
| +// }
|
| +// mPendingRequest = null;
|
| +// infoBar.dismissJavaOnlyInfoBar();
|
| +// }
|
| +
|
| +// @Override
|
| +// public void onInfoBarDismissed(InfoBar infoBar) {
|
| +// if (mPendingRequest != null) {
|
| +// if (mPendingRequest.hasDownloadId()) {
|
| +// nativeDangerousDownloadValidated(mTab, mPendingRequest.getDownloadId(), false);
|
| +// } else if (!mPendingRequest.isGETRequest()) {
|
| +// // Infobar was dismissed, discard the file if a POST download is pending.
|
| +// discardFile(mPendingRequest.getFilePath());
|
| +// }
|
| +// }
|
| +// // Forget the pending request.
|
| +// mPendingRequest = null;
|
| +// }
|
|
|
| /**
|
| * Creates ChromeDownloadDelegate.
|
| @@ -97,13 +97,13 @@ public class ChromeDownloadDelegate
|
| * @param tabModelSelector The TabModelSelector responsible for {@code mTab}.
|
| * @param tab The corresponding tab instance.
|
| */
|
| - public ChromeDownloadDelegate(
|
| - Context context, TabModelSelector tabModelSelector, Tab tab) {
|
| - mContext = context;
|
| - mTab = tab;
|
| - mTabModelSelector = tabModelSelector;
|
| - mPendingRequest = null;
|
| - }
|
| +// public ChromeDownloadDelegate(
|
| +// Context context, TabModelSelector tabModelSelector, Tab tab) {
|
| +// mContext = context;
|
| +// mTab = tab;
|
| +// mTabModelSelector = tabModelSelector;
|
| +// mPendingRequest = null;
|
| +// }
|
|
|
| /**
|
| * Return the download path of a file.
|
| @@ -268,29 +268,29 @@ public class ChromeDownloadDelegate
|
| confirmDangerousDownload(downloadInfo);
|
| }
|
|
|
| - /**
|
| - * Launch an info bar if the file name already exists for the download.
|
| - * @param info The information of the file we are about to download.
|
| - * @return Whether an info bar has been launched or not.
|
| - */
|
| - private boolean launchInfoBarIfFileExists(final DownloadInfo info) {
|
| - // Checks if file exists.
|
| - final String fileName = info.getFileName();
|
| - File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
| - if (!dir.mkdir() && !dir.isDirectory()) return false;
|
| - String dirName = dir.getName();
|
| - final File file = new File(dir, info.getFileName());
|
| - String fullDirPath = file.getParent();
|
| - if (!file.exists()) return false;
|
| - if (TextUtils.isEmpty(fileName) || TextUtils.isEmpty(dirName)
|
| - || TextUtils.isEmpty(fullDirPath)) {
|
| - return false;
|
| - }
|
| -
|
| - nativeLaunchDownloadOverwriteInfoBar(
|
| - this, mTab, info, info.getFileName(), dirName, fullDirPath);
|
| - return true;
|
| - }
|
| +// /**
|
| +// * Launch an info bar if the file name already exists for the download.
|
| +// * @param info The information of the file we are about to download.
|
| +// * @return Whether an info bar has been launched or not.
|
| +// */
|
| +// private boolean launchInfoBarIfFileExists(final DownloadInfo info) {
|
| +// // Checks if file exists.
|
| +// final String fileName = info.getFileName();
|
| +// File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
| +// if (!dir.mkdir() && !dir.isDirectory()) return false;
|
| +// String dirName = dir.getName();
|
| +// final File file = new File(dir, info.getFileName());
|
| +// String fullDirPath = file.getParent();
|
| +// if (!file.exists()) return false;
|
| +// if (TextUtils.isEmpty(fileName) || TextUtils.isEmpty(dirName)
|
| +// || TextUtils.isEmpty(fullDirPath)) {
|
| +// return false;
|
| +// }
|
| +//
|
| +// nativeLaunchDownloadOverwriteInfoBar(
|
| +// this, mTab, info, info.getFileName(), dirName, fullDirPath);
|
| +// return true;
|
| +// }
|
|
|
| /**
|
| * Sends the download request to Android download manager.
|
|
|