Commit f4f37ad4 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

[NativeFS] Allow single accepted extension without wrapping in array.

This implements the change from https://github.com/WICG/native-file-system/pull/207

Change-Id: Ib496775f1c7e1a2c7b4be4f56232739acfc0d020
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311054Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Auto-Submit: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791255}
parent 735eccaa
...@@ -487,14 +487,15 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, AcceptsOptions) { ...@@ -487,14 +487,15 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, AcceptsOptions) {
EvalJs(shell(), EvalJs(shell(),
"self.showOpenFilePicker({types: [" "self.showOpenFilePicker({types: ["
" {description: 'foo', accept: {'text/custom': ['txt', 'Js']}}," " {description: 'foo', accept: {'text/custom': ['txt', 'Js']}},"
" {accept: {'image/jpeg': []}}" " {accept: {'image/jpeg': []}},"
" {accept: {'image/svg+xml': 'svg'}},"
"]})"); "]})");
EXPECT_TRUE(result.error.find("aborted") != std::string::npos) EXPECT_TRUE(result.error.find("aborted") != std::string::npos)
<< result.error; << result.error;
ASSERT_TRUE(dialog_params.file_types); ASSERT_TRUE(dialog_params.file_types);
EXPECT_TRUE(dialog_params.file_types->include_all_files); EXPECT_TRUE(dialog_params.file_types->include_all_files);
ASSERT_EQ(2u, dialog_params.file_types->extensions.size()); ASSERT_EQ(3u, dialog_params.file_types->extensions.size());
ASSERT_EQ(2u, dialog_params.file_types->extensions[0].size()); ASSERT_EQ(2u, dialog_params.file_types->extensions[0].size());
EXPECT_EQ(FILE_PATH_LITERAL("txt"), EXPECT_EQ(FILE_PATH_LITERAL("txt"),
dialog_params.file_types->extensions[0][0]); dialog_params.file_types->extensions[0][0]);
...@@ -504,8 +505,10 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, AcceptsOptions) { ...@@ -504,8 +505,10 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, AcceptsOptions) {
FILE_PATH_LITERAL("jpg"))); FILE_PATH_LITERAL("jpg")));
EXPECT_TRUE(base::Contains(dialog_params.file_types->extensions[1], EXPECT_TRUE(base::Contains(dialog_params.file_types->extensions[1],
FILE_PATH_LITERAL("jpeg"))); FILE_PATH_LITERAL("jpeg")));
EXPECT_TRUE(base::Contains(dialog_params.file_types->extensions[2],
FILE_PATH_LITERAL("svg")));
ASSERT_EQ(2u, ASSERT_EQ(3u,
dialog_params.file_types->extension_description_overrides.size()); dialog_params.file_types->extension_description_overrides.size());
EXPECT_EQ(base::ASCIIToUTF16("foo"), EXPECT_EQ(base::ASCIIToUTF16("foo"),
dialog_params.file_types->extension_description_overrides[0]); dialog_params.file_types->extension_description_overrides[0]);
......
...@@ -111,6 +111,8 @@ bindings_modules_generated_union_type_files = [ ...@@ -111,6 +111,8 @@ bindings_modules_generated_union_type_files = [
"$bindings_modules_v8_output_dir/unsigned_long_enforce_range_sequence_or_gpu_origin_3d_dict.h", "$bindings_modules_v8_output_dir/unsigned_long_enforce_range_sequence_or_gpu_origin_3d_dict.h",
"$bindings_modules_v8_output_dir/usv_string_or_uint32_array.cc", "$bindings_modules_v8_output_dir/usv_string_or_uint32_array.cc",
"$bindings_modules_v8_output_dir/usv_string_or_uint32_array.h", "$bindings_modules_v8_output_dir/usv_string_or_uint32_array.h",
"$bindings_modules_v8_output_dir/usv_string_or_usv_string_sequence.cc",
"$bindings_modules_v8_output_dir/usv_string_or_usv_string_sequence.h",
"$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.cc", "$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.cc",
"$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.h", "$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.h",
"$bindings_modules_v8_output_dir/worklet_animation_effect_or_worklet_group_effect.cc", "$bindings_modules_v8_output_dir/worklet_animation_effect_or_worklet_group_effect.cc",
......
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
// https://wicg.github.io/native-file-system/#dictdef-filepickeraccepttype // https://wicg.github.io/native-file-system/#dictdef-filepickeraccepttype
dictionary FilePickerAcceptType { dictionary FilePickerAcceptType {
USVString description; USVString description;
record<USVString, sequence<USVString>> accept; record<USVString, (USVString or sequence<USVString>)> accept;
}; };
...@@ -102,7 +102,10 @@ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> ConvertAccepts( ...@@ -102,7 +102,10 @@ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> ConvertAccepts(
} }
mimeTypes.push_back(type); mimeTypes.push_back(type);
extensions.AppendVector(a.second); if (a.second.IsUSVString())
extensions.push_back(a.second.GetAsUSVString());
else
extensions.AppendVector(a.second.GetAsUSVStringSequence());
} }
result.emplace_back( result.emplace_back(
blink::mojom::blink::ChooseFileSystemEntryAcceptsOption::New( blink::mojom::blink::ChooseFileSystemEntryAcceptsOption::New(
......
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