Commit b8316388 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download location: Fix a crash in DownloadLocationDialog.

The download file name can be null in some cases when the file name is
set to empty by the users.
In these cases, AlertDialogEditText may return null when calling getText().

Since we lose the suggested file path, the download should be canceled.

Bug: 901783
Change-Id: I4989006b0a0b038fa51eacd070f7dfb542c1b2bd
Reviewed-on: https://chromium-review.googlesource.com/c/1318369Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605487}
parent 42a59d6a
......@@ -131,7 +131,7 @@ public class DownloadLocationDialog extends ModalDialogView
*/
@Nullable
String getFileName() {
if (mFileName == null) return null;
if (mFileName == null || mFileName.getText() == null) return null;
return mFileName.getText().toString();
}
......
......@@ -138,7 +138,7 @@ public class DownloadLocationDialogBridge implements ModalDialogView.Controller
private void handleResponses(
String fileName, DirectoryOption directoryOption, boolean dontShowAgain) {
// If there's no file location, treat as a cancellation.
if (directoryOption == null || directoryOption.location == null) {
if (directoryOption == null || directoryOption.location == null || fileName == null) {
cancel();
return;
}
......
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