Commit 01eb2a62 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Support duplicate download infobar for touchless devices

This patch disables the location selection dialog and always shows
the duplicate download infobar.

Bug: 958473
Change-Id: Id1ace68e1636728097e7865e270f08a57fb8ab3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1618009Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661015}
parent 1e7bfdb2
...@@ -23,6 +23,8 @@ import org.chromium.chrome.R; ...@@ -23,6 +23,8 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadManagerService; import org.chromium.chrome.browser.download.DownloadManagerService;
import org.chromium.chrome.browser.download.DownloadMetrics; import org.chromium.chrome.browser.download.DownloadMetrics;
import org.chromium.chrome.browser.download.DownloadUtils; import org.chromium.chrome.browser.download.DownloadUtils;
import org.chromium.ui.modaldialog.ModalDialogProperties;
import org.chromium.ui.modelutil.PropertyModel;
import java.io.File; import java.io.File;
...@@ -163,4 +165,21 @@ public class DuplicateDownloadInfoBar extends ConfirmInfoBar { ...@@ -163,4 +165,21 @@ public class DuplicateDownloadInfoBar extends ConfirmInfoBar {
layout.setMessage(getDownloadMessageText(context, template)); layout.setMessage(getDownloadMessageText(context, template));
} }
} }
@Override
public boolean supportsTouchlessMode() {
return true;
}
@Override
public PropertyModel createModel() {
PropertyModel model = super.createModel();
String template = getContext().getString(R.string.duplicate_download_request_infobar_text);
model.set(ModalDialogProperties.TITLE,
getDownloadMessageText(getContext(), template).toString());
return model;
}
} }
...@@ -146,7 +146,8 @@ public abstract class InfoBar implements InfoBarView { ...@@ -146,7 +146,8 @@ public abstract class InfoBar implements InfoBarView {
.with(TouchlessDialogProperties.CANCEL_ACTION, .with(TouchlessDialogProperties.CANCEL_ACTION,
view -> onCloseButtonClicked()) view -> onCloseButtonClicked())
.with(TouchlessDialogProperties.ALT_ACTION, null) .with(TouchlessDialogProperties.ALT_ACTION, null)
.with(ModalDialogProperties.TITLE, mMessage.toString()) .with(ModalDialogProperties.TITLE,
mMessage != null ? mMessage.toString() : "")
.with(ModalDialogProperties.TITLE_ICON, icon) .with(ModalDialogProperties.TITLE_ICON, icon)
.with(ModalDialogProperties.CONTROLLER, .with(ModalDialogProperties.CONTROLLER,
new ModalDialogProperties.Controller() { new ModalDialogProperties.Controller() {
......
...@@ -699,6 +699,7 @@ public class FeatureUtilities { ...@@ -699,6 +699,7 @@ public class FeatureUtilities {
/** /**
* @return Whether no-touch-mode is enabled. * @return Whether no-touch-mode is enabled.
*/ */
@CalledByNative
public static boolean isNoTouchModeEnabled() { public static boolean isNoTouchModeEnabled() {
return TouchlessDelegate.TOUCHLESS_MODE_ENABLED; return TouchlessDelegate.TOUCHLESS_MODE_ENABLED;
} }
......
...@@ -37,6 +37,11 @@ bool IsDownloadAutoResumptionEnabledInNative() { ...@@ -37,6 +37,11 @@ bool IsDownloadAutoResumptionEnabledInNative() {
return Java_FeatureUtilities_isDownloadAutoResumptionEnabledInNative(env); return Java_FeatureUtilities_isDownloadAutoResumptionEnabledInNative(env);
} }
bool IsNoTouchModeEnabled() {
JNIEnv* env = base::android::AttachCurrentThread();
return Java_FeatureUtilities_isNoTouchModeEnabled(env);
}
} // namespace android } // namespace android
} // namespace chrome } // namespace chrome
......
...@@ -22,6 +22,8 @@ bool GetIsInMultiWindowModeValue(); ...@@ -22,6 +22,8 @@ bool GetIsInMultiWindowModeValue();
bool IsDownloadAutoResumptionEnabledInNative(); bool IsDownloadAutoResumptionEnabledInNative();
bool IsNoTouchModeEnabled();
} // namespace android } // namespace android
} // namespace chrome } // namespace chrome
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
#include "chrome/browser/android/download/download_location_dialog_bridge_impl.h" #include "chrome/browser/android/download/download_location_dialog_bridge_impl.h"
#include "chrome/browser/android/download/download_manager_service.h" #include "chrome/browser/android/download/download_manager_service.h"
#include "chrome/browser/android/download/download_utils.h" #include "chrome/browser/android/download/download_utils.h"
#include "chrome/browser/android/feature_utilities.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#endif #endif
...@@ -848,7 +849,8 @@ void ChromeDownloadManagerDelegate::RequestConfirmation( ...@@ -848,7 +849,8 @@ void ChromeDownloadManagerDelegate::RequestConfirmation(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
content::WebContents* web_contents = content::WebContents* web_contents =
content::DownloadItemUtils::GetWebContents(download); content::DownloadItemUtils::GetWebContents(download);
if (base::FeatureList::IsEnabled(features::kDownloadsLocationChange)) { if (!chrome::android::IsNoTouchModeEnabled() &&
base::FeatureList::IsEnabled(features::kDownloadsLocationChange)) {
if (reason == DownloadConfirmationReason::SAVE_AS) { if (reason == DownloadConfirmationReason::SAVE_AS) {
// If this is a 'Save As' download, just run without confirmation. // If this is a 'Save As' download, just run without confirmation.
callback.Run(DownloadConfirmationResult::CONTINUE_WITHOUT_CONFIRMATION, callback.Run(DownloadConfirmationResult::CONTINUE_WITHOUT_CONFIRMATION,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment