| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/DownloadOverwriteInfoBar.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/DownloadOverwriteInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/DownloadOverwriteInfoBar.java
|
| index 08fa74b27bbeb718cad669f64751e17166638619..288d50c92e999abc8247b934013e9570ea19a999 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/DownloadOverwriteInfoBar.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/DownloadOverwriteInfoBar.java
|
| @@ -19,6 +19,7 @@ import android.view.View;
|
|
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.chrome.R;
|
| +import org.chromium.chrome.browser.download.DownloadUtils;
|
|
|
| import java.util.List;
|
|
|
| @@ -41,7 +42,8 @@ public class DownloadOverwriteInfoBar extends InfoBar {
|
| * Constructs DownloadOverwriteInfoBar.
|
| * @param fileName The file name. ex) example.jpg
|
| * @param dirName The dir name. ex) Downloads
|
| - * @param dirFullPath The full dir path. ex) sdcards/Downloads
|
| + * @param dirFullPath The full dir path. ex) sdcards/Downloads. If empty, the Download Manager
|
| + * will be opened.
|
| */
|
| private DownloadOverwriteInfoBar(String fileName, String dirName, String dirFullPath) {
|
| super(R.drawable.infobar_downloading, null, null);
|
| @@ -57,9 +59,18 @@ public class DownloadOverwriteInfoBar extends InfoBar {
|
| onButtonClicked(action);
|
| }
|
|
|
| + private boolean opensDownloadManager() {
|
| + return mDirFullPath == null || mDirFullPath.isEmpty();
|
| + }
|
| +
|
| private CharSequence getMessageText(Context context) {
|
| String template = context.getString(R.string.download_overwrite_infobar_text);
|
| - Intent intent = getIntentForDirectoryLaunch(mDirFullPath);
|
| + Intent intent = null;
|
| +
|
| + // If the full path is left empty, we assume that the file is in the Chrome Download
|
| + // Manager. So then in formatInfoBarMessage, if the intent remains null then we are going
|
| + // to open the download manager when the directory name is clicked.
|
| + if (!opensDownloadManager()) intent = getIntentForDirectoryLaunch(mDirFullPath);
|
| return formatInfoBarMessage(context, template, mFileName, mDirName, intent);
|
| }
|
|
|
| @@ -97,7 +108,7 @@ public class DownloadOverwriteInfoBar extends InfoBar {
|
| * @param dirNameIntent The intent to be launched when user touches the directory name link.
|
| * @return CharSequence formatted message for InfoBar.
|
| */
|
| - private static CharSequence formatInfoBarMessage(final Context context, String template,
|
| + private CharSequence formatInfoBarMessage(final Context context, String template,
|
| String fileName, String dirName, final Intent dirNameIntent) {
|
| SpannableString formattedFileName = new SpannableString(fileName);
|
| formattedFileName.setSpan(new StyleSpan(Typeface.BOLD), 0, fileName.length(),
|
| @@ -111,6 +122,13 @@ public class DownloadOverwriteInfoBar extends InfoBar {
|
| context.startActivity(dirNameIntent);
|
| }
|
| }, 0, dirName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
| + } else if (opensDownloadManager()) {
|
| + formattedDirName.setSpan(new ClickableSpan() {
|
| + @Override
|
| + public void onClick(View view) {
|
| + DownloadUtils.showDownloadManager(null, null);
|
| + }
|
| + }, 0, dirName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
| }
|
|
|
| return TextUtils.expandTemplate(template, formattedFileName, formattedDirName);
|
|
|