Commit 06ad2160 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

[FS] Fix dcheck when no accepted file types are provided.

The file_type_index passed to SelectFileDialog::SelectFile can't be 1
(the first accepted type) if no explicitly accepted types are provided.

Bug: 1112122
Change-Id: If72b971be087c3b9b7142b6754f887e70f122fd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333036
Commit-Queue: Victor Costan <pwnall@chromium.org>
Auto-Submit: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794872}
parent 5a00dc01
......@@ -133,7 +133,8 @@ FileSystemChooser::Options::Options(
std::vector<blink::mojom::ChooseFileSystemEntryAcceptsOptionPtr> accepts,
bool include_accepts_all)
: type_(type),
file_types_(ConvertAcceptsToFileTypeInfo(accepts, include_accepts_all)) {}
file_types_(ConvertAcceptsToFileTypeInfo(accepts, include_accepts_all)),
default_file_type_index_(file_types_.extensions.empty() ? 0 : 1) {}
// static
void FileSystemChooser::CreateAndShow(
......@@ -178,7 +179,7 @@ void FileSystemChooser::CreateAndShow(
listener->dialog_->SelectFile(
dialog_type, /*title=*/base::string16(),
/*default_path=*/base::FilePath(), &options.file_type_info(),
/*file_type_index=*/1,
options.default_file_type_index(),
/*default_extension=*/base::FilePath::StringType(),
web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr,
/*params=*/nullptr);
......
......@@ -42,10 +42,12 @@ class CONTENT_EXPORT FileSystemChooser : public ui::SelectFileDialog::Listener {
const ui::SelectFileDialog::FileTypeInfo& file_type_info() const {
return file_types_;
}
int default_file_type_index() const { return default_file_type_index_; }
private:
blink::mojom::ChooseFileSystemEntryType type_;
ui::SelectFileDialog::FileTypeInfo file_types_;
int default_file_type_index_ = 0;
};
static void CreateAndShow(WebContents* web_contents,
......
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