summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/native_file_system
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/native_file_system')
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/BUILD.gn8
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/README.md16
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/directory_picker_options.idl7
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/file_picker_accept_type.idl9
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/file_picker_options.idl9
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/file_system_directory_handle.idl2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/file_system_file_handle.idl2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/file_system_writable_file_stream.idl2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/file_system_writer.idl16
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.cc379
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.h56
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system_test.cc (renamed from chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system_test.cc)10
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/idls.gni11
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.cc2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.h2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.cc2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.h2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.cc37
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h4
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.cc2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.h2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.cc13
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.h2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.cc2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.h2
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.cc243
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.h64
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/open_file_picker_options.idl8
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/save_file_picker_options.idl7
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.cc170
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.h32
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.idl20
-rw-r--r--chromium/third_party/blink/renderer/modules/native_file_system/worker_global_scope_native_file_system.idl13
33 files changed, 550 insertions, 606 deletions
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/BUILD.gn b/chromium/third_party/blink/renderer/modules/native_file_system/BUILD.gn
index c248e70eba5..77de97c110f 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/BUILD.gn
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/BUILD.gn
@@ -6,6 +6,8 @@ import("//third_party/blink/renderer/modules/modules.gni")
blink_modules_sources("native_file_system") {
sources = [
+ "global_native_file_system.cc",
+ "global_native_file_system.h",
"native_file_system_directory_handle.cc",
"native_file_system_directory_handle.h",
"native_file_system_directory_iterator.cc",
@@ -20,10 +22,6 @@ blink_modules_sources("native_file_system") {
"native_file_system_underlying_sink.h",
"native_file_system_writable_file_stream.cc",
"native_file_system_writable_file_stream.h",
- "native_file_system_writer.cc",
- "native_file_system_writer.h",
- "window_native_file_system.cc",
- "window_native_file_system.h",
]
deps = [ "//third_party/blink/renderer/platform" ]
@@ -31,7 +29,7 @@ blink_modules_sources("native_file_system") {
jumbo_source_set("unit_tests") {
testonly = true
- sources = [ "window_native_file_system_test.cc" ]
+ sources = [ "global_native_file_system_test.cc" ]
configs += [
"//third_party/blink/renderer:config",
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/README.md b/chromium/third_party/blink/renderer/modules/native_file_system/README.md
index 8be6bc87056..4787d052cd1 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/README.md
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/README.md
@@ -13,7 +13,7 @@ contains the mojom interfaces for these APIs.
## APIs In this directory
This directory contains the implementation of the new and still under
-development [Native File System API](https://github.com/WICG/native-file-system/blob/master/EXPLAINER.md).
+development [Native File System API](https://wicg.github.io/native-file-system/).
It consists of the following parts:
@@ -21,17 +21,15 @@ It consists of the following parts:
these interfaces mimic the old `Entry` interfaces, but expose a more modern
promisified API.
- * `getSystemDirectory`: An entry point (exposed via `FileSystemDirectoryHandle`)
- that today only gives access to the same sandboxed filesystem as what was
- available through the old API. In the future this could get extended to add
- support for other directories as well.
+ * ` getOriginPrivateDirectory`: An entry point that gives access to the same
+ sandboxed filesystem as what is available through the old API.
- * `FileSystemWriter`: a more modern API with similar functionality to the
+ * `FileSystemWritableFileStream`: a more modern API with similar functionality to the
old `FileWriter` API. The implementation of this actually does make use of
a different mojom interface than the old API. But since the functionality is
mostly the same, hopefully we will be able to migrate the old implementation
to the new mojom API as well.
- * `chooseFileSystemEntries`: An entry point, currently on `window`, that lets
- a website pop-up a file picker, prompting the user to select one or more
- files or directories, to which the website than gets access.
+ * `showOpenFilePicker`, `showSaveFilePicker` and `showDirectorPicker`: Entry points
+ on `window`, that let a website pop-up a file or directory picker, prompting the
+ user to select one or more files or directories, to which the website than gets access.
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/directory_picker_options.idl b/chromium/third_party/blink/renderer/modules/native_file_system/directory_picker_options.idl
new file mode 100644
index 00000000000..3ebc626cee2
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/directory_picker_options.idl
@@ -0,0 +1,7 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://wicg.github.io/native-file-system/#dictdef-directorypickeroptions
+dictionary DirectoryPickerOptions {
+};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/file_picker_accept_type.idl b/chromium/third_party/blink/renderer/modules/native_file_system/file_picker_accept_type.idl
new file mode 100644
index 00000000000..661a17d1811
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/file_picker_accept_type.idl
@@ -0,0 +1,9 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://wicg.github.io/native-file-system/#dictdef-filepickeraccepttype
+dictionary FilePickerAcceptType {
+ USVString description;
+ record<USVString, sequence<USVString>> accept;
+};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/file_picker_options.idl b/chromium/third_party/blink/renderer/modules/native_file_system/file_picker_options.idl
new file mode 100644
index 00000000000..7bb6d45d657
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/file_picker_options.idl
@@ -0,0 +1,9 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://wicg.github.io/native-file-system/#dictdef-filepickeroptions
+dictionary FilePickerOptions {
+ sequence<FilePickerAcceptType> types;
+ boolean excludeAcceptAllOption = false;
+};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_directory_handle.idl b/chromium/third_party/blink/renderer/modules/native_file_system/file_system_directory_handle.idl
index bf4d4deda7b..9ce1f889755 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_directory_handle.idl
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/file_system_directory_handle.idl
@@ -18,6 +18,6 @@
[CallWith=ScriptState, Measure] Promise<sequence<USVString>?> resolve(FileSystemHandle possibleChild);
- [CallWith=ScriptState, Measure, RaisesException]
+ [CallWith=ScriptState, Measure, RaisesException, RuntimeEnabled=LegacyNativeFileSystem]
static Promise<FileSystemDirectoryHandle> getSystemDirectory(GetSystemDirectoryOptions options);
};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_file_handle.idl b/chromium/third_party/blink/renderer/modules/native_file_system/file_system_file_handle.idl
index c725cb9ae72..b24362e53ef 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_file_handle.idl
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/file_system_file_handle.idl
@@ -10,6 +10,6 @@
RuntimeEnabled=NativeFileSystem,
ImplementedAs=NativeFileSystemFileHandle
] interface FileSystemFileHandle : FileSystemHandle {
- [CallWith=ScriptState, RuntimeEnabled=WritableFileStream, RaisesException] Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWriterOptions options = {});
+ [CallWith=ScriptState, RaisesException] Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWriterOptions options = {});
[CallWith=ScriptState, RaisesException] Promise<File> getFile();
};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_writable_file_stream.idl b/chromium/third_party/blink/renderer/modules/native_file_system/file_system_writable_file_stream.idl
index 8fd21015f1e..e09e63d9cfa 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_writable_file_stream.idl
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/file_system_writable_file_stream.idl
@@ -7,7 +7,7 @@
Exposed=(Window,Worker),
SecureContext,
ImplementedAs=NativeFileSystemWritableFileStream,
- RuntimeEnabled=WritableFileStream
+ RuntimeEnabled=NativeFileSystem
] interface FileSystemWritableFileStream : WritableStream {
[CallWith=ScriptState, RaisesException] Promise<void> write((BufferSource or Blob or USVString or WriteParams) data);
[CallWith=ScriptState, RaisesException] Promise<void> truncate(unsigned long long size);
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_writer.idl b/chromium/third_party/blink/renderer/modules/native_file_system/file_system_writer.idl
deleted file mode 100644
index 5f8787b38ce..00000000000
--- a/chromium/third_party/blink/renderer/modules/native_file_system/file_system_writer.idl
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// https://wicg.github.io/native-file-system/#filesystemwriter
-[
- Exposed=(Window,Worker),
- SecureContext,
- ImplementedAs=NativeFileSystemWriter,
- RuntimeEnabled=NativeFileSystem
-] interface FileSystemWriter {
- [CallWith=ScriptState, RaisesException] Promise<void> write(unsigned long long position, (BufferSource or Blob or USVString) data);
- [CallWith=ScriptState, RaisesException] Promise<void> truncate(unsigned long long size);
-
- [CallWith=ScriptState, RaisesException] Promise<void> close();
-};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.cc b/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.cc
new file mode 100644
index 00000000000..3ee55ea558c
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.cc
@@ -0,0 +1,379 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/modules/native_file_system/global_native_file_system.h"
+
+#include <utility>
+
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/remote.h"
+#include "services/network/public/mojom/web_sandbox_flags.mojom-blink.h"
+#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
+#include "third_party/blink/public/mojom/native_file_system/native_file_system_manager.mojom-blink.h"
+#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_choose_file_system_entries_options.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_choose_file_system_entries_options_accepts.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_file_picker_accept_type.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_open_file_picker_options.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_save_file_picker_options.h"
+#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/dom/dom_exception.h"
+#include "third_party/blink/renderer/core/execution_context/security_context.h"
+#include "third_party/blink/renderer/core/fileapi/file_error.h"
+#include "third_party/blink/renderer/core/frame/local_dom_window.h"
+#include "third_party/blink/renderer/core/frame/local_frame.h"
+#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
+#include "third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.h"
+#include "third_party/blink/renderer/modules/native_file_system/native_file_system_error.h"
+#include "third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h"
+#include "third_party/blink/renderer/platform/bindings/exception_state.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
+#include "third_party/blink/renderer/platform/network/http_parsers.h"
+#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
+#include "third_party/blink/renderer/platform/wtf/functional.h"
+
+namespace blink {
+
+namespace {
+// The name to use for the root directory of a sandboxed file system.
+constexpr const char kSandboxRootDirectoryName[] = "";
+
+mojom::blink::ChooseFileSystemEntryType ConvertChooserType(const String& input,
+ bool multiple) {
+ if (input == "open-file" || input == "openFile") {
+ return multiple
+ ? mojom::blink::ChooseFileSystemEntryType::kOpenMultipleFiles
+ : mojom::blink::ChooseFileSystemEntryType::kOpenFile;
+ }
+ if (input == "save-file" || input == "saveFile")
+ return mojom::blink::ChooseFileSystemEntryType::kSaveFile;
+ if (input == "open-directory" || input == "openDirectory")
+ return mojom::blink::ChooseFileSystemEntryType::kOpenDirectory;
+ NOTREACHED();
+ return mojom::blink::ChooseFileSystemEntryType::kOpenFile;
+}
+
+Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> ConvertAccepts(
+ const HeapVector<Member<ChooseFileSystemEntriesOptionsAccepts>>& accepts) {
+ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> result;
+ result.ReserveInitialCapacity(accepts.size());
+ for (const auto& a : accepts) {
+ result.emplace_back(
+ blink::mojom::blink::ChooseFileSystemEntryAcceptsOption::New(
+ a->hasDescription() ? a->description() : g_empty_string,
+ a->hasMimeTypes() ? a->mimeTypes() : Vector<String>(),
+ a->hasExtensions() ? a->extensions() : Vector<String>()));
+ }
+ return result;
+}
+
+constexpr bool IsHTTPWhitespace(UChar chr) {
+ return chr == ' ' || chr == '\n' || chr == '\t' || chr == '\r';
+}
+
+Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> ConvertAccepts(
+ const HeapVector<Member<FilePickerAcceptType>>& types,
+ ExceptionState& exception_state) {
+ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> result;
+ result.ReserveInitialCapacity(types.size());
+ for (const auto& t : types) {
+ Vector<String> mimeTypes;
+ mimeTypes.ReserveInitialCapacity(t->accept().size());
+ Vector<String> extensions;
+ for (const auto& a : t->accept()) {
+ String type = a.first.StripWhiteSpace(IsHTTPWhitespace);
+ if (type.IsEmpty()) {
+ exception_state.ThrowTypeError("Invalid type: " + a.first);
+ return {};
+ }
+ Vector<String> parsed_type;
+ type.Split('/', true, parsed_type);
+ if (parsed_type.size() != 2) {
+ exception_state.ThrowTypeError("Invalid type: " + a.first);
+ return {};
+ }
+ if (!IsValidHTTPToken(parsed_type[0])) {
+ exception_state.ThrowTypeError("Invalid type: " + a.first);
+ return {};
+ }
+ if (!IsValidHTTPToken(parsed_type[1])) {
+ exception_state.ThrowTypeError("Invalid type: " + a.first);
+ return {};
+ }
+
+ mimeTypes.push_back(type);
+ extensions.AppendVector(a.second);
+ }
+ result.emplace_back(
+ blink::mojom::blink::ChooseFileSystemEntryAcceptsOption::New(
+ t->hasDescription() ? t->description() : g_empty_string,
+ std::move(mimeTypes), std::move(extensions)));
+ }
+ return result;
+}
+
+ScriptPromise GetOriginPrivateDirectoryImpl(ScriptState* script_state,
+ ExceptionState& exception_state) {
+ ExecutionContext* context = ExecutionContext::From(script_state);
+ if (!context->GetSecurityOrigin()->CanAccessNativeFileSystem()) {
+ if (context->GetSecurityContext().IsSandboxed(
+ network::mojom::blink::WebSandboxFlags::kOrigin)) {
+ exception_state.ThrowSecurityError(
+ "System directory access is denied because the context is "
+ "sandboxed and lacks the 'allow-same-origin' flag.");
+ return ScriptPromise();
+ } else {
+ exception_state.ThrowSecurityError("System directory access is denied.");
+ return ScriptPromise();
+ }
+ }
+
+ auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
+ ScriptPromise result = resolver->Promise();
+
+ mojo::Remote<mojom::blink::NativeFileSystemManager> manager;
+ context->GetBrowserInterfaceBroker().GetInterface(
+ manager.BindNewPipeAndPassReceiver());
+
+ auto* raw_manager = manager.get();
+ raw_manager->GetSandboxedFileSystem(WTF::Bind(
+ [](ScriptPromiseResolver* resolver,
+ mojo::Remote<mojom::blink::NativeFileSystemManager>,
+ mojom::blink::NativeFileSystemErrorPtr result,
+ mojo::PendingRemote<mojom::blink::NativeFileSystemDirectoryHandle>
+ handle) {
+ ExecutionContext* context = resolver->GetExecutionContext();
+ if (!context)
+ return;
+ if (result->status != mojom::blink::NativeFileSystemStatus::kOk) {
+ native_file_system_error::Reject(resolver, *result);
+ return;
+ }
+ resolver->Resolve(MakeGarbageCollected<NativeFileSystemDirectoryHandle>(
+ context, kSandboxRootDirectoryName, std::move(handle)));
+ },
+ WrapPersistent(resolver), std::move(manager)));
+
+ return result;
+}
+
+void VerifyIsAllowedToShowFilePicker(const LocalDOMWindow& window,
+ ExceptionState& exception_state) {
+ if (!window.IsCurrentlyDisplayedInFrame()) {
+ exception_state.ThrowDOMException(DOMExceptionCode::kAbortError, "");
+ return;
+ }
+
+ Document* document = window.document();
+ if (!document) {
+ exception_state.ThrowDOMException(DOMExceptionCode::kAbortError, "");
+ return;
+ }
+
+ if (!document->GetSecurityOrigin()->CanAccessNativeFileSystem()) {
+ if (document->IsSandboxed(
+ network::mojom::blink::WebSandboxFlags::kOrigin)) {
+ exception_state.ThrowSecurityError(
+ "Sandboxed documents aren't allowed to show a file picker.");
+ return;
+ } else {
+ exception_state.ThrowSecurityError(
+ "This document isn't allowed to show a file picker.");
+ return;
+ }
+ }
+
+ LocalFrame* local_frame = window.GetFrame();
+ if (!local_frame || local_frame->IsCrossOriginToMainFrame()) {
+ exception_state.ThrowSecurityError(
+ "Cross origin sub frames aren't allowed to show a file picker.");
+ return;
+ }
+
+ if (!LocalFrame::HasTransientUserActivation(local_frame)) {
+ exception_state.ThrowSecurityError(
+ "Must be handling a user gesture to show a file picker.");
+ return;
+ }
+}
+
+ScriptPromise ShowFilePickerImpl(
+ ScriptState* script_state,
+ LocalDOMWindow& window,
+ mojom::blink::ChooseFileSystemEntryType chooser_type,
+ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> accepts,
+ bool accept_all,
+ bool return_as_sequence) {
+ auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
+ ScriptPromise resolver_result = resolver->Promise();
+
+ // TODO(mek): Cache mojo::Remote<mojom::blink::NativeFileSystemManager>
+ // associated with an ExecutionContext, so we don't have to request a new one
+ // for each operation, and can avoid code duplication between here and other
+ // uses.
+ mojo::Remote<mojom::blink::NativeFileSystemManager> manager;
+ window.GetBrowserInterfaceBroker().GetInterface(
+ manager.BindNewPipeAndPassReceiver());
+
+ auto* raw_manager = manager.get();
+ raw_manager->ChooseEntries(
+ chooser_type, std::move(accepts), accept_all,
+ WTF::Bind(
+ [](ScriptPromiseResolver* resolver,
+ mojo::Remote<mojom::blink::NativeFileSystemManager>,
+ bool return_as_sequence, LocalFrame* local_frame,
+ mojom::blink::NativeFileSystemErrorPtr file_operation_result,
+ Vector<mojom::blink::NativeFileSystemEntryPtr> entries) {
+ ExecutionContext* context = resolver->GetExecutionContext();
+ if (!context)
+ return;
+ if (file_operation_result->status !=
+ mojom::blink::NativeFileSystemStatus::kOk) {
+ native_file_system_error::Reject(resolver,
+ *file_operation_result);
+ return;
+ }
+
+ // While it would be better to not trust the renderer process,
+ // we're doing this here to avoid potential mojo message pipe
+ // ordering problems, where the frame activation state
+ // reconciliation messages would compete with concurrent Native File
+ // System messages to the browser.
+ // TODO(https://crbug.com/1017270): Remove this after spec change,
+ // or when activation moves to browser.
+ LocalFrame::NotifyUserActivation(local_frame);
+
+ if (return_as_sequence) {
+ HeapVector<Member<NativeFileSystemHandle>> results;
+ results.ReserveInitialCapacity(entries.size());
+ for (auto& entry : entries) {
+ results.push_back(NativeFileSystemHandle::CreateFromMojoEntry(
+ std::move(entry), context));
+ }
+ resolver->Resolve(results);
+ } else {
+ DCHECK_EQ(1u, entries.size());
+ resolver->Resolve(NativeFileSystemHandle::CreateFromMojoEntry(
+ std::move(entries[0]), context));
+ }
+ },
+ WrapPersistent(resolver), std::move(manager), return_as_sequence,
+ WrapPersistent(window.GetFrame())));
+ return resolver_result;
+}
+
+} // namespace
+
+// static
+ScriptPromise GlobalNativeFileSystem::chooseFileSystemEntries(
+ ScriptState* script_state,
+ LocalDOMWindow& window,
+ const ChooseFileSystemEntriesOptions* options,
+ ExceptionState& exception_state) {
+ VerifyIsAllowedToShowFilePicker(window, exception_state);
+ if (exception_state.HadException())
+ return ScriptPromise();
+
+ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> accepts;
+ if (options->hasAccepts())
+ accepts = ConvertAccepts(options->accepts());
+
+ return ShowFilePickerImpl(
+ script_state, window,
+ ConvertChooserType(options->type(), options->multiple()),
+ std::move(accepts), !options->excludeAcceptAllOption(),
+ options->multiple());
+}
+
+// static
+ScriptPromise GlobalNativeFileSystem::showOpenFilePicker(
+ ScriptState* script_state,
+ LocalDOMWindow& window,
+ const OpenFilePickerOptions* options,
+ ExceptionState& exception_state) {
+ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> accepts;
+ if (options->hasTypes())
+ accepts = ConvertAccepts(options->types(), exception_state);
+ if (exception_state.HadException())
+ return ScriptPromise();
+
+ if (accepts.IsEmpty() && options->excludeAcceptAllOption()) {
+ exception_state.ThrowTypeError("Need at least one accepted type");
+ return ScriptPromise();
+ }
+
+ VerifyIsAllowedToShowFilePicker(window, exception_state);
+ if (exception_state.HadException())
+ return ScriptPromise();
+
+ return ShowFilePickerImpl(
+ script_state, window,
+ options->multiple()
+ ? mojom::blink::ChooseFileSystemEntryType::kOpenMultipleFiles
+ : mojom::blink::ChooseFileSystemEntryType::kOpenFile,
+ std::move(accepts), !options->excludeAcceptAllOption(),
+ /*return_as_sequence=*/true);
+}
+
+// static
+ScriptPromise GlobalNativeFileSystem::showSaveFilePicker(
+ ScriptState* script_state,
+ LocalDOMWindow& window,
+ const SaveFilePickerOptions* options,
+ ExceptionState& exception_state) {
+ Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> accepts;
+ if (options->hasTypes())
+ accepts = ConvertAccepts(options->types(), exception_state);
+ if (exception_state.HadException())
+ return ScriptPromise();
+
+ if (accepts.IsEmpty() && options->excludeAcceptAllOption()) {
+ exception_state.ThrowTypeError("Need at least one accepted type");
+ return ScriptPromise();
+ }
+
+ VerifyIsAllowedToShowFilePicker(window, exception_state);
+ if (exception_state.HadException())
+ return ScriptPromise();
+
+ return ShowFilePickerImpl(
+ script_state, window, mojom::blink::ChooseFileSystemEntryType::kSaveFile,
+ std::move(accepts), !options->excludeAcceptAllOption(),
+ /*return_as_sequence=*/false);
+}
+
+// static
+ScriptPromise GlobalNativeFileSystem::showDirectoryPicker(
+ ScriptState* script_state,
+ LocalDOMWindow& window,
+ const DirectoryPickerOptions* options,
+ ExceptionState& exception_state) {
+ VerifyIsAllowedToShowFilePicker(window, exception_state);
+ if (exception_state.HadException())
+ return ScriptPromise();
+
+ return ShowFilePickerImpl(
+ script_state, window,
+ mojom::blink::ChooseFileSystemEntryType::kOpenDirectory, {},
+ /*accept_all=*/true,
+ /*return_as_sequence=*/false);
+}
+
+// static
+ScriptPromise GlobalNativeFileSystem::getOriginPrivateDirectory(
+ ScriptState* script_state,
+ const LocalDOMWindow& window,
+ ExceptionState& exception_state) {
+ return GetOriginPrivateDirectoryImpl(script_state, exception_state);
+}
+
+// static
+ScriptPromise GlobalNativeFileSystem::getOriginPrivateDirectory(
+ ScriptState* script_state,
+ const WorkerGlobalScope& workerGlobalScope,
+ ExceptionState& exception_state) {
+ return GetOriginPrivateDirectoryImpl(script_state, exception_state);
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.h b/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.h
new file mode 100644
index 00000000000..7f1037e3d7f
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system.h
@@ -0,0 +1,56 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_GLOBAL_NATIVE_FILE_SYSTEM_H_
+#define THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_GLOBAL_NATIVE_FILE_SYSTEM_H_
+
+#include "third_party/blink/renderer/platform/heap/handle.h"
+#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
+
+namespace blink {
+
+class ChooseFileSystemEntriesOptions;
+class OpenFilePickerOptions;
+class SaveFilePickerOptions;
+class DirectoryPickerOptions;
+class ExceptionState;
+class LocalDOMWindow;
+class ScriptPromise;
+class ScriptState;
+class WorkerGlobalScope;
+
+class GlobalNativeFileSystem {
+ STATIC_ONLY(GlobalNativeFileSystem);
+
+ public:
+ static ScriptPromise chooseFileSystemEntries(
+ ScriptState*,
+ LocalDOMWindow&,
+ const ChooseFileSystemEntriesOptions*,
+ ExceptionState&);
+
+ static ScriptPromise showOpenFilePicker(ScriptState*,
+ LocalDOMWindow&,
+ const OpenFilePickerOptions*,
+ ExceptionState&);
+ static ScriptPromise showSaveFilePicker(ScriptState*,
+ LocalDOMWindow&,
+ const SaveFilePickerOptions*,
+ ExceptionState&);
+ static ScriptPromise showDirectoryPicker(ScriptState*,
+ LocalDOMWindow&,
+ const DirectoryPickerOptions*,
+ ExceptionState&);
+
+ static ScriptPromise getOriginPrivateDirectory(ScriptState*,
+ const LocalDOMWindow&,
+ ExceptionState&);
+ static ScriptPromise getOriginPrivateDirectory(ScriptState*,
+ const WorkerGlobalScope&,
+ ExceptionState&);
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_GLOBAL_NATIVE_FILE_SYSTEM_H_
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system_test.cc b/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system_test.cc
index 476b6549e17..aedf47decc9 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system_test.cc
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/global_native_file_system_test.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "third_party/blink/renderer/modules/native_file_system/window_native_file_system.h"
+#include "third_party/blink/renderer/modules/native_file_system/global_native_file_system.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
@@ -97,7 +97,7 @@ class MockNativeFileSystemManager
BrowserInterfaceBrokerProxy& broker_;
};
-class WindowNativeFileSystemTest : public PageTestBase {
+class GlobalNativeFileSystemTest : public PageTestBase {
public:
void SetUp() override {
PageTestBase::SetUp();
@@ -116,7 +116,7 @@ class WindowNativeFileSystemTest : public PageTestBase {
}
};
-TEST_F(WindowNativeFileSystemTest, UserActivationRequiredOtherwiseDenied) {
+TEST_F(GlobalNativeFileSystemTest, UserActivationRequiredOtherwiseDenied) {
LocalFrame* frame = &GetFrame();
EXPECT_FALSE(frame->HasStickyUserActivation());
@@ -131,7 +131,7 @@ TEST_F(WindowNativeFileSystemTest, UserActivationRequiredOtherwiseDenied) {
EXPECT_FALSE(frame->HasStickyUserActivation());
}
-TEST_F(WindowNativeFileSystemTest, UserActivationChooseEntriesSuccessful) {
+TEST_F(GlobalNativeFileSystemTest, UserActivationChooseEntriesSuccessful) {
LocalFrame* frame = &GetFrame();
EXPECT_FALSE(frame->HasStickyUserActivation());
@@ -174,7 +174,7 @@ TEST_F(WindowNativeFileSystemTest, UserActivationChooseEntriesSuccessful) {
EXPECT_TRUE(frame->HasStickyUserActivation());
}
-TEST_F(WindowNativeFileSystemTest, UserActivationChooseEntriesErrors) {
+TEST_F(GlobalNativeFileSystemTest, UserActivationChooseEntriesErrors) {
LocalFrame* frame = &GetFrame();
EXPECT_FALSE(frame->HasStickyUserActivation());
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/idls.gni b/chromium/third_party/blink/renderer/modules/native_file_system/idls.gni
index 490d4ad43aa..6e11fe1cebc 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/idls.gni
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/idls.gni
@@ -8,20 +8,27 @@ modules_idl_files = [
"file_system_file_handle.idl",
"file_system_handle.idl",
"file_system_writable_file_stream.idl",
- "file_system_writer.idl",
]
modules_dictionary_idl_files = [
"choose_file_system_entries_options.idl",
"choose_file_system_entries_options_accepts.idl",
+ "directory_picker_options.idl",
+ "file_picker_accept_type.idl",
+ "file_picker_options.idl",
"file_system_create_writer_options.idl",
"file_system_get_directory_options.idl",
"file_system_get_file_options.idl",
"file_system_handle_permission_descriptor.idl",
"file_system_remove_options.idl",
"get_system_directory_options.idl",
+ "open_file_picker_options.idl",
"native_file_system_directory_iterator_entry.idl",
+ "save_file_picker_options.idl",
"write_params.idl",
]
-modules_dependency_idl_files = [ "window_native_file_system.idl" ]
+modules_dependency_idl_files = [
+ "window_native_file_system.idl",
+ "worker_global_scope_native_file_system.idl",
+]
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.cc b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.cc
index 8894b4005bc..27403aaac53 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.cc
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.cc
@@ -250,7 +250,7 @@ NativeFileSystemDirectoryHandle::Transfer() {
return result;
}
-void NativeFileSystemDirectoryHandle::Trace(Visitor* visitor) {
+void NativeFileSystemDirectoryHandle::Trace(Visitor* visitor) const {
visitor->Trace(mojo_ptr_);
NativeFileSystemHandle::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.h b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.h
index 9997033c91b..0474d916291 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.h
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.h
@@ -51,7 +51,7 @@ class NativeFileSystemDirectoryHandle final : public NativeFileSystemHandle {
return mojo_ptr_.get();
}
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
private:
void QueryPermissionImpl(
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.cc b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.cc
index b25417e3ac2..b665fa8ed46 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.cc
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.cc
@@ -53,7 +53,7 @@ ScriptPromise NativeFileSystemDirectoryIterator::next(
return ScriptPromise::Cast(script_state, ToV8(result, script_state));
}
-void NativeFileSystemDirectoryIterator::Trace(Visitor* visitor) {
+void NativeFileSystemDirectoryIterator::Trace(Visitor* visitor) const {
ScriptWrappable::Trace(visitor);
ExecutionContextClient::Trace(visitor);
visitor->Trace(receiver_);
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.h b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.h
index 4480443ac9e..b265f53746e 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.h
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_directory_iterator.h
@@ -33,7 +33,7 @@ class NativeFileSystemDirectoryIterator final
ScriptPromise next(ScriptState*);
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
private:
void DidReadDirectory(mojom::blink::NativeFileSystemErrorPtr result,
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.cc b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.cc
index 39f4929462f..9419f3b555b 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.cc
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.cc
@@ -14,7 +14,6 @@
#include "third_party/blink/renderer/core/fileapi/file_error.h"
#include "third_party/blink/renderer/modules/native_file_system/native_file_system_error.h"
#include "third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.h"
-#include "third_party/blink/renderer/modules/native_file_system/native_file_system_writer.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/file_metadata.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
@@ -33,40 +32,6 @@ NativeFileSystemFileHandle::NativeFileSystemFileHandle(
DCHECK(mojo_ptr_.is_bound());
}
-ScriptPromise NativeFileSystemFileHandle::createWriter(
- ScriptState* script_state,
- const FileSystemCreateWriterOptions* options) {
- auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
- ScriptPromise result = resolver->Promise();
-
- if (!mojo_ptr_.is_bound()) {
- resolver->Reject(MakeGarbageCollected<DOMException>(
- DOMExceptionCode::kInvalidStateError));
- return result;
- }
-
- mojo_ptr_->CreateFileWriter(
- options->keepExistingData(),
- WTF::Bind(
- [](ScriptPromiseResolver* resolver,
- mojom::blink::NativeFileSystemErrorPtr result,
- mojo::PendingRemote<mojom::blink::NativeFileSystemFileWriter>
- writer) {
- ExecutionContext* context = resolver->GetExecutionContext();
- if (!context)
- return;
- if (result->status != mojom::blink::NativeFileSystemStatus::kOk) {
- native_file_system_error::Reject(resolver, *result);
- return;
- }
- resolver->Resolve(MakeGarbageCollected<NativeFileSystemWriter>(
- context, std::move(writer)));
- },
- WrapPersistent(resolver)));
-
- return result;
-}
-
ScriptPromise NativeFileSystemFileHandle::createWritable(
ScriptState* script_state,
const FileSystemCreateWriterOptions* options,
@@ -137,7 +102,7 @@ NativeFileSystemFileHandle::Transfer() {
return result;
}
-void NativeFileSystemFileHandle::Trace(Visitor* visitor) {
+void NativeFileSystemFileHandle::Trace(Visitor* visitor) const {
visitor->Trace(mojo_ptr_);
NativeFileSystemHandle::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h
index e0fc8d3df89..47fbd767254 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h
@@ -24,8 +24,6 @@ class NativeFileSystemFileHandle final : public NativeFileSystemHandle {
bool isFile() const override { return true; }
- ScriptPromise createWriter(ScriptState*,
- const FileSystemCreateWriterOptions* options);
ScriptPromise createWritable(ScriptState*,
const FileSystemCreateWriterOptions* options,
ExceptionState&);
@@ -38,7 +36,7 @@ class NativeFileSystemFileHandle final : public NativeFileSystemHandle {
return mojo_ptr_.get();
}
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
private:
void QueryPermissionImpl(
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.cc b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.cc
index ed7e9edc502..c759bf521bc 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.cc
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.cc
@@ -112,7 +112,7 @@ ScriptPromise NativeFileSystemHandle::isSameEntry(
return result;
}
-void NativeFileSystemHandle::Trace(Visitor* visitor) {
+void NativeFileSystemHandle::Trace(Visitor* visitor) const {
ScriptWrappable::Trace(visitor);
ExecutionContextClient::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.h b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.h
index cc2804f245d..8bb5147ef57 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.h
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_handle.h
@@ -49,7 +49,7 @@ class NativeFileSystemHandle : public ScriptWrappable,
virtual mojo::PendingRemote<mojom::blink::NativeFileSystemTransferToken>
Transfer() = 0;
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
private:
virtual void QueryPermissionImpl(
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.cc b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.cc
index 7ff83a0f659..49ae32fef81 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.cc
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.cc
@@ -104,27 +104,28 @@ ScriptPromise NativeFileSystemUnderlyingSink::HandleParams(
const WriteParams& params,
ExceptionState& exception_state) {
if (params.type() == "truncate") {
- if (!params.hasSize()) {
+ if (!params.hasSizeNonNull()) {
exception_state.ThrowDOMException(
DOMExceptionCode::kSyntaxError,
"Invalid params passed. truncate requires a size argument");
return ScriptPromise();
}
- return Truncate(script_state, params.size(), exception_state);
+ return Truncate(script_state, params.sizeNonNull(), exception_state);
}
if (params.type() == "seek") {
- if (!params.hasPosition()) {
+ if (!params.hasPositionNonNull()) {
exception_state.ThrowDOMException(
DOMExceptionCode::kSyntaxError,
"Invalid params passed. seek requires a position argument");
return ScriptPromise();
}
- return Seek(script_state, params.position(), exception_state);
+ return Seek(script_state, params.positionNonNull(), exception_state);
}
if (params.type() == "write") {
- uint64_t position = params.hasPosition() ? params.position() : offset_;
+ uint64_t position =
+ params.hasPositionNonNull() ? params.positionNonNull() : offset_;
if (!params.hasData()) {
exception_state.ThrowDOMException(
DOMExceptionCode::kSyntaxError,
@@ -261,7 +262,7 @@ void NativeFileSystemUnderlyingSink::CloseComplete(
writer_remote_.reset();
}
-void NativeFileSystemUnderlyingSink::Trace(Visitor* visitor) {
+void NativeFileSystemUnderlyingSink::Trace(Visitor* visitor) const {
ScriptWrappable::Trace(visitor);
UnderlyingSinkBase::Trace(visitor);
visitor->Trace(writer_remote_);
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.h b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.h
index e4b1b89ed70..cac18d80062 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.h
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_underlying_sink.h
@@ -37,7 +37,7 @@ class NativeFileSystemUnderlyingSink final : public UnderlyingSinkBase {
ScriptValue reason,
ExceptionState&) override;
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
private:
ScriptPromise HandleParams(ScriptState*, const WriteParams&, ExceptionState&);
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.cc b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.cc
index 9eb16481ea4..56d5db3f1bf 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.cc
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.cc
@@ -123,7 +123,7 @@ ScriptPromise NativeFileSystemWritableFileStream::seek(
return promise;
}
-void NativeFileSystemWritableFileStream::Trace(Visitor* visitor) {
+void NativeFileSystemWritableFileStream::Trace(Visitor* visitor) const {
WritableStream::Trace(visitor);
visitor->Trace(underlying_sink_);
}
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.h b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.h
index 3eb79e89f89..3a037f3e34f 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.h
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writable_file_stream.h
@@ -27,7 +27,7 @@ class NativeFileSystemWritableFileStream final : public WritableStream {
ScriptState*,
mojo::PendingRemote<mojom::blink::NativeFileSystemFileWriter>);
- void Trace(Visitor* visitor) override;
+ void Trace(Visitor* visitor) const override;
// IDL defined functions specific to NativeFileSystemWritableFileStream.
ScriptPromise write(
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.cc b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.cc
deleted file mode 100644
index 7ec053fac3f..00000000000
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.cc
+++ /dev/null
@@ -1,243 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "third_party/blink/renderer/modules/native_file_system/native_file_system_writer.h"
-
-#include <memory>
-#include <utility>
-
-#include "third_party/blink/public/mojom/native_file_system/native_file_system_error.mojom-blink.h"
-#include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view_or_blob_or_usv_string.h"
-#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
-#include "third_party/blink/renderer/bindings/core/v8/v8_blob.h"
-#include "third_party/blink/renderer/bindings/core/v8/v8_readable_stream.h"
-#include "third_party/blink/renderer/core/dom/dom_exception.h"
-#include "third_party/blink/renderer/core/fetch/fetch_data_loader.h"
-#include "third_party/blink/renderer/core/fetch/readable_stream_bytes_consumer.h"
-#include "third_party/blink/renderer/core/fileapi/blob.h"
-#include "third_party/blink/renderer/core/fileapi/file_error.h"
-#include "third_party/blink/renderer/core/streams/readable_stream.h"
-#include "third_party/blink/renderer/modules/native_file_system/native_file_system_error.h"
-#include "third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h"
-#include "third_party/blink/renderer/platform/blob/blob_data.h"
-#include "third_party/blink/renderer/platform/heap/heap.h"
-#include "third_party/blink/renderer/platform/wtf/functional.h"
-
-namespace blink {
-
-NativeFileSystemWriter::NativeFileSystemWriter(
- ExecutionContext* context,
- mojo::PendingRemote<mojom::blink::NativeFileSystemFileWriter>
- writer_pending_remote)
- : writer_remote_(context) {
- writer_remote_.Bind(std::move(writer_pending_remote),
- context->GetTaskRunner(TaskType::kMiscPlatformAPI));
- DCHECK(writer_remote_.is_bound());
-}
-
-ScriptPromise NativeFileSystemWriter::write(
- ScriptState* script_state,
- uint64_t position,
- const ArrayBufferOrArrayBufferViewOrBlobOrUSVString& data,
- ExceptionState& exception_state) {
- DCHECK(!data.IsNull());
-
- auto blob_data = std::make_unique<BlobData>();
- Blob* blob = nullptr;
- if (data.IsArrayBuffer()) {
- DOMArrayBuffer* array_buffer = data.GetAsArrayBuffer();
- blob_data->AppendBytes(array_buffer->Data(),
- array_buffer->ByteLengthAsSizeT());
- } else if (data.IsArrayBufferView()) {
- DOMArrayBufferView* array_buffer_view = data.GetAsArrayBufferView().View();
- blob_data->AppendBytes(array_buffer_view->BaseAddress(),
- array_buffer_view->byteLengthAsSizeT());
- } else if (data.IsBlob()) {
- blob = data.GetAsBlob();
- } else if (data.IsUSVString()) {
- // Let the developer be explicit about line endings.
- blob_data->AppendText(data.GetAsUSVString(),
- /*normalize_line_endings_to_native=*/false);
- }
-
- if (!blob) {
- uint64_t size = blob_data->length();
- blob = MakeGarbageCollected<Blob>(
- BlobDataHandle::Create(std::move(blob_data), size));
- }
-
- return WriteBlob(script_state, position, blob, exception_state);
-}
-
-ScriptPromise NativeFileSystemWriter::WriteBlob(
- ScriptState* script_state,
- uint64_t position,
- Blob* blob,
- ExceptionState& exception_state) {
- if (!writer_remote_.is_bound() || pending_operation_) {
- exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError, "");
- return ScriptPromise();
- }
- pending_operation_ =
- MakeGarbageCollected<ScriptPromiseResolver>(script_state);
- ScriptPromise result = pending_operation_->Promise();
- writer_remote_->Write(
- position, blob->AsMojoBlob(),
- WTF::Bind(&NativeFileSystemWriter::WriteComplete, WrapPersistent(this)));
- return result;
-}
-
-class NativeFileSystemWriter::StreamWriterClient
- : public GarbageCollected<StreamWriterClient>,
- public FetchDataLoader::Client {
- USING_GARBAGE_COLLECTED_MIXIN(StreamWriterClient);
-
- public:
- explicit StreamWriterClient(NativeFileSystemWriter* writer)
- : writer_(writer) {}
-
- void DidFetchDataStartedDataPipe(
- mojo::ScopedDataPipeConsumerHandle data_pipe) override {
- data_pipe_ = std::move(data_pipe);
- }
-
- mojo::ScopedDataPipeConsumerHandle TakeDataPipe() {
- DCHECK(data_pipe_);
- return std::move(data_pipe_);
- }
-
- void DidFetchDataLoadedDataPipe() override {
- // WriteComplete could have been called with an error before we reach this
- // point, in that case just return.
- if (did_complete_)
- return;
- DCHECK(!did_finish_writing_to_pipe_);
- DCHECK(writer_->pending_operation_);
- did_finish_writing_to_pipe_ = true;
- }
-
- void DidFetchDataLoadFailed() override {
- // WriteComplete could have been called with an error before we reach this
- // point, in that case just return.
- if (did_complete_)
- return;
- DCHECK(writer_->pending_operation_);
- did_complete_ = true;
- writer_->pending_operation_->Reject(
- file_error::CreateDOMException(base::File::FILE_ERROR_FAILED));
- Reset();
- }
-
- void Abort() override {
- // WriteComplete could have been called with an error before we reach this
- // point, in that case just return.
- if (did_complete_)
- return;
- DCHECK(writer_->pending_operation_);
- did_complete_ = true;
- writer_->pending_operation_->Reject(
- file_error::CreateDOMException(base::File::FILE_ERROR_ABORT));
- Reset();
- }
-
- void WriteComplete(mojom::blink::NativeFileSystemErrorPtr result,
- uint64_t bytes_written) {
- // Early return if we already completed (with an error) before.
- if (did_complete_)
- return;
- DCHECK(writer_->pending_operation_);
- did_complete_ = true;
- if (result->status != mojom::blink::NativeFileSystemStatus::kOk) {
- native_file_system_error::Reject(writer_->pending_operation_, *result);
- } else {
- DCHECK(did_finish_writing_to_pipe_);
- writer_->pending_operation_->Resolve();
- }
- Reset();
- }
-
- void Trace(Visitor* visitor) override {
- Client::Trace(visitor);
- visitor->Trace(writer_);
- }
-
- private:
- void Reset() {
- writer_->pending_operation_ = nullptr;
- writer_->stream_loader_ = nullptr;
- }
-
- Member<NativeFileSystemWriter> writer_;
- mojo::ScopedDataPipeConsumerHandle data_pipe_;
- bool did_finish_writing_to_pipe_ = false;
- bool did_complete_ = false;
-};
-
-ScriptPromise NativeFileSystemWriter::truncate(
- ScriptState* script_state,
- uint64_t size,
- ExceptionState& exception_state) {
- if (!writer_remote_.is_bound() || pending_operation_) {
- exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError, "");
- return ScriptPromise();
- }
- pending_operation_ =
- MakeGarbageCollected<ScriptPromiseResolver>(script_state);
- ScriptPromise result = pending_operation_->Promise();
- writer_remote_->Truncate(size,
- WTF::Bind(&NativeFileSystemWriter::TruncateComplete,
- WrapPersistent(this)));
- return result;
-}
-
-ScriptPromise NativeFileSystemWriter::close(ScriptState* script_state,
- ExceptionState& exception_state) {
- if (!writer_remote_.is_bound() || pending_operation_) {
- exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError, "");
- return ScriptPromise();
- }
- pending_operation_ =
- MakeGarbageCollected<ScriptPromiseResolver>(script_state);
- ScriptPromise result = pending_operation_->Promise();
- writer_remote_->Close(
- WTF::Bind(&NativeFileSystemWriter::CloseComplete, WrapPersistent(this)));
-
- return result;
-}
-
-void NativeFileSystemWriter::Trace(Visitor* visitor) {
- ScriptWrappable::Trace(visitor);
- visitor->Trace(writer_remote_);
- visitor->Trace(file_);
- visitor->Trace(pending_operation_);
- visitor->Trace(stream_loader_);
-}
-
-void NativeFileSystemWriter::WriteComplete(
- mojom::blink::NativeFileSystemErrorPtr result,
- uint64_t bytes_written) {
- DCHECK(pending_operation_);
- native_file_system_error::ResolveOrReject(pending_operation_, *result);
- pending_operation_ = nullptr;
-}
-
-void NativeFileSystemWriter::TruncateComplete(
- mojom::blink::NativeFileSystemErrorPtr result) {
- DCHECK(pending_operation_);
- native_file_system_error::ResolveOrReject(pending_operation_, *result);
- pending_operation_ = nullptr;
-}
-
-void NativeFileSystemWriter::CloseComplete(
- mojom::blink::NativeFileSystemErrorPtr result) {
- DCHECK(pending_operation_);
- native_file_system_error::ResolveOrReject(pending_operation_, *result);
- file_ = nullptr;
- pending_operation_ = nullptr;
- // We close the mojo pipe because we intend this writer to be discarded after
- // close. Subsequent operations will fail.
- writer_remote_.reset();
-}
-
-} // namespace blink
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.h b/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.h
deleted file mode 100644
index f5936ff6c53..00000000000
--- a/chromium/third_party/blink/renderer/modules/native_file_system/native_file_system_writer.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_WRITER_H_
-#define THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_WRITER_H_
-
-#include "third_party/blink/public/mojom/native_file_system/native_file_system_error.mojom-blink-forward.h"
-#include "third_party/blink/public/mojom/native_file_system/native_file_system_file_writer.mojom-blink.h"
-#include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view_or_blob_or_usv_string.h"
-#include "third_party/blink/renderer/core/execution_context/execution_context.h"
-#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
-#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
-
-namespace blink {
-
-class Blob;
-class ExceptionState;
-class FetchDataLoader;
-class ScriptPromise;
-class ScriptPromiseResolver;
-class ScriptState;
-class NativeFileSystemFileHandle;
-
-class NativeFileSystemWriter final : public ScriptWrappable {
- DEFINE_WRAPPERTYPEINFO();
-
- public:
- NativeFileSystemWriter(
- ExecutionContext* context,
- mojo::PendingRemote<mojom::blink::NativeFileSystemFileWriter>);
-
- ScriptPromise write(ScriptState*,
- uint64_t position,
- const ArrayBufferOrArrayBufferViewOrBlobOrUSVString& data,
- ExceptionState&);
- ScriptPromise truncate(ScriptState*, uint64_t size, ExceptionState&);
- ScriptPromise close(ScriptState*, ExceptionState&);
-
- void Trace(Visitor*) override;
-
- private:
- class StreamWriterClient;
-
- ScriptPromise WriteBlob(ScriptState*,
- uint64_t position,
- Blob*,
- ExceptionState&);
-
- void WriteComplete(mojom::blink::NativeFileSystemErrorPtr result,
- uint64_t bytes_written);
- void TruncateComplete(mojom::blink::NativeFileSystemErrorPtr result);
- void CloseComplete(mojom::blink::NativeFileSystemErrorPtr result);
-
- HeapMojoRemote<mojom::blink::NativeFileSystemFileWriter> writer_remote_;
- Member<NativeFileSystemFileHandle> file_;
-
- Member<ScriptPromiseResolver> pending_operation_;
- Member<FetchDataLoader> stream_loader_;
-};
-
-} // namespace blink
-
-#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_NATIVE_FILE_SYSTEM_WRITER_H_
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/open_file_picker_options.idl b/chromium/third_party/blink/renderer/modules/native_file_system/open_file_picker_options.idl
new file mode 100644
index 00000000000..96456f757a8
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/open_file_picker_options.idl
@@ -0,0 +1,8 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://wicg.github.io/native-file-system/#dictdef-openfilepickeroptions
+dictionary OpenFilePickerOptions : FilePickerOptions {
+ boolean multiple = false;
+};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/save_file_picker_options.idl b/chromium/third_party/blink/renderer/modules/native_file_system/save_file_picker_options.idl
new file mode 100644
index 00000000000..d18f9d01f73
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/save_file_picker_options.idl
@@ -0,0 +1,7 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://wicg.github.io/native-file-system/#dictdef-savefilepickeroptions
+dictionary SaveFilePickerOptions : FilePickerOptions {
+};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.cc b/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.cc
deleted file mode 100644
index 664309feae0..00000000000
--- a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.cc
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "third_party/blink/renderer/modules/native_file_system/window_native_file_system.h"
-
-#include <utility>
-
-#include "mojo/public/cpp/bindings/remote.h"
-#include "services/network/public/mojom/web_sandbox_flags.mojom-blink.h"
-#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
-#include "third_party/blink/public/mojom/native_file_system/native_file_system_manager.mojom-blink.h"
-#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
-#include "third_party/blink/renderer/bindings/modules/v8/v8_choose_file_system_entries_options.h"
-#include "third_party/blink/renderer/bindings/modules/v8/v8_choose_file_system_entries_options_accepts.h"
-#include "third_party/blink/renderer/core/dom/document.h"
-#include "third_party/blink/renderer/core/dom/dom_exception.h"
-#include "third_party/blink/renderer/core/fileapi/file_error.h"
-#include "third_party/blink/renderer/core/frame/local_dom_window.h"
-#include "third_party/blink/renderer/core/frame/local_frame.h"
-#include "third_party/blink/renderer/modules/native_file_system/native_file_system_directory_handle.h"
-#include "third_party/blink/renderer/modules/native_file_system/native_file_system_error.h"
-#include "third_party/blink/renderer/modules/native_file_system/native_file_system_file_handle.h"
-#include "third_party/blink/renderer/platform/bindings/exception_state.h"
-#include "third_party/blink/renderer/platform/heap/heap.h"
-#include "third_party/blink/renderer/platform/wtf/functional.h"
-
-namespace blink {
-
-namespace {
-
-mojom::blink::ChooseFileSystemEntryType ConvertChooserType(const String& input,
- bool multiple) {
- if (input == "open-file" || input == "openFile") {
- return multiple
- ? mojom::blink::ChooseFileSystemEntryType::kOpenMultipleFiles
- : mojom::blink::ChooseFileSystemEntryType::kOpenFile;
- }
- if (input == "save-file" || input == "saveFile")
- return mojom::blink::ChooseFileSystemEntryType::kSaveFile;
- if (input == "open-directory" || input == "openDirectory")
- return mojom::blink::ChooseFileSystemEntryType::kOpenDirectory;
- NOTREACHED();
- return mojom::blink::ChooseFileSystemEntryType::kOpenFile;
-}
-
-Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> ConvertAccepts(
- const HeapVector<Member<ChooseFileSystemEntriesOptionsAccepts>>& accepts) {
- Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> result;
- result.ReserveInitialCapacity(accepts.size());
- for (const auto& a : accepts) {
- result.emplace_back(
- blink::mojom::blink::ChooseFileSystemEntryAcceptsOption::New(
- a->hasDescription() ? a->description() : g_empty_string,
- a->hasMimeTypes() ? a->mimeTypes() : Vector<String>(),
- a->hasExtensions() ? a->extensions() : Vector<String>()));
- }
- return result;
-}
-
-} // namespace
-
-// static
-ScriptPromise WindowNativeFileSystem::chooseFileSystemEntries(
- ScriptState* script_state,
- LocalDOMWindow& window,
- const ChooseFileSystemEntriesOptions* options,
- ExceptionState& exception_state) {
- if (!window.IsCurrentlyDisplayedInFrame()) {
- exception_state.ThrowDOMException(DOMExceptionCode::kAbortError, "");
- return ScriptPromise();
- }
-
- Document* document = window.document();
- if (!document) {
- exception_state.ThrowDOMException(DOMExceptionCode::kAbortError, "");
- return ScriptPromise();
- }
-
- if (!document->GetSecurityOrigin()->CanAccessNativeFileSystem()) {
- if (document->IsSandboxed(
- network::mojom::blink::WebSandboxFlags::kOrigin)) {
- exception_state.ThrowSecurityError(
- "Sandboxed documents aren't allowed to show a file picker.");
- return ScriptPromise();
- } else {
- exception_state.ThrowSecurityError(
- "This document isn't allowed to show a file picker.");
- return ScriptPromise();
- }
- }
-
- LocalFrame* local_frame = window.GetFrame();
- if (!local_frame || local_frame->IsCrossOriginToMainFrame()) {
- exception_state.ThrowSecurityError(
- "Cross origin sub frames aren't allowed to show a file picker.");
- return ScriptPromise();
- }
-
- if (!LocalFrame::HasTransientUserActivation(local_frame)) {
- exception_state.ThrowSecurityError(
- "Must be handling a user gesture to show a file picker.");
- return ScriptPromise();
- }
-
- Vector<mojom::blink::ChooseFileSystemEntryAcceptsOptionPtr> accepts;
- if (options->hasAccepts())
- accepts = ConvertAccepts(options->accepts());
-
- auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
- ScriptPromise resolver_result = resolver->Promise();
-
- // TODO(mek): Cache mojo::Remote<mojom::blink::NativeFileSystemManager>
- // associated with an ExecutionContext, so we don't have to request a new one
- // for each operation, and can avoid code duplication between here and other
- // uses.
- mojo::Remote<mojom::blink::NativeFileSystemManager> manager;
- document->GetBrowserInterfaceBroker().GetInterface(
- manager.BindNewPipeAndPassReceiver());
-
- auto* raw_manager = manager.get();
- raw_manager->ChooseEntries(
- ConvertChooserType(options->type(), options->multiple()),
- std::move(accepts), !options->excludeAcceptAllOption(),
- WTF::Bind(
- [](ScriptPromiseResolver* resolver,
- mojo::Remote<mojom::blink::NativeFileSystemManager>,
- const ChooseFileSystemEntriesOptions* options,
- LocalFrame* local_frame,
- mojom::blink::NativeFileSystemErrorPtr file_operation_result,
- Vector<mojom::blink::NativeFileSystemEntryPtr> entries) {
- ExecutionContext* context = resolver->GetExecutionContext();
- if (!context)
- return;
- if (file_operation_result->status !=
- mojom::blink::NativeFileSystemStatus::kOk) {
- native_file_system_error::Reject(resolver,
- *file_operation_result);
- return;
- }
-
- // While it would be better to not trust the renderer process,
- // we're doing this here to avoid potential mojo message pipe
- // ordering problems, where the frame activation state
- // reconciliation messages would compete with concurrent Native File
- // System messages to the browser.
- // TODO(https://crbug.com/1017270): Remove this after spec change,
- // or when activation moves to browser.
- LocalFrame::NotifyUserActivation(local_frame);
-
- if (options->multiple()) {
- HeapVector<Member<NativeFileSystemHandle>> results;
- results.ReserveInitialCapacity(entries.size());
- for (auto& entry : entries) {
- results.push_back(NativeFileSystemHandle::CreateFromMojoEntry(
- std::move(entry), context));
- }
- resolver->Resolve(results);
- } else {
- DCHECK_EQ(1u, entries.size());
- resolver->Resolve(NativeFileSystemHandle::CreateFromMojoEntry(
- std::move(entries[0]), context));
- }
- },
- WrapPersistent(resolver), std::move(manager), WrapPersistent(options),
- WrapPersistent(local_frame)));
- return resolver_result;
-}
-
-} // namespace blink
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.h b/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.h
deleted file mode 100644
index 8f4926ab0d6..00000000000
--- a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_WINDOW_NATIVE_FILE_SYSTEM_H_
-#define THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_WINDOW_NATIVE_FILE_SYSTEM_H_
-
-#include "third_party/blink/renderer/platform/heap/handle.h"
-#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
-
-namespace blink {
-
-class ChooseFileSystemEntriesOptions;
-class ExceptionState;
-class LocalDOMWindow;
-class ScriptPromise;
-class ScriptState;
-
-class WindowNativeFileSystem {
- STATIC_ONLY(WindowNativeFileSystem);
-
- public:
- static ScriptPromise chooseFileSystemEntries(
- ScriptState*,
- LocalDOMWindow&,
- const ChooseFileSystemEntriesOptions*,
- ExceptionState&);
-};
-
-} // namespace blink
-
-#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_NATIVE_FILE_SYSTEM_WINDOW_NATIVE_FILE_SYSTEM_H_
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.idl b/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.idl
index fae73c8984d..df7c4473a89 100644
--- a/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.idl
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/window_native_file_system.idl
@@ -2,13 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// https://wicg.github.io/native-file-system/#api-choosefilesystementries
+// https://wicg.github.io/native-file-system/#native-filesystem
+// https://wicg.github.io/native-file-system/#api-getoriginprivatefilesystem
[
SecureContext,
RuntimeEnabled=NativeFileSystem,
- ImplementedAs=WindowNativeFileSystem
+ ImplementedAs=GlobalNativeFileSystem
] partial interface Window {
- [CallWith=ScriptState, Measure, RaisesException]
+ [CallWith=ScriptState, Measure, RaisesException, RuntimeEnabled=LegacyNativeFileSystem]
Promise<(FileSystemHandle or sequence<FileSystemHandle>)>
chooseFileSystemEntries(optional ChooseFileSystemEntriesOptions options = {});
+
+ [CallWith=ScriptState, RaisesException]
+ Promise<sequence<FileSystemFileHandle>> showOpenFilePicker(
+ optional OpenFilePickerOptions options = {});
+ [CallWith=ScriptState, RaisesException]
+ Promise<FileSystemFileHandle> showSaveFilePicker(
+ optional SaveFilePickerOptions options = {});
+ [CallWith=ScriptState, RaisesException]
+ Promise<FileSystemDirectoryHandle> showDirectoryPicker(
+ optional DirectoryPickerOptions options = {});
+
+ [CallWith=ScriptState, RaisesException]
+ Promise<FileSystemDirectoryHandle> getOriginPrivateDirectory();
};
diff --git a/chromium/third_party/blink/renderer/modules/native_file_system/worker_global_scope_native_file_system.idl b/chromium/third_party/blink/renderer/modules/native_file_system/worker_global_scope_native_file_system.idl
new file mode 100644
index 00000000000..eaf542b453a
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/native_file_system/worker_global_scope_native_file_system.idl
@@ -0,0 +1,13 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://wicg.github.io/native-file-system/#api-getoriginprivatefilesystem
+[
+ SecureContext,
+ RuntimeEnabled=NativeFileSystem,
+ ImplementedAs=GlobalNativeFileSystem
+] partial interface WorkerGlobalScope {
+ [CallWith=ScriptState, RaisesException]
+ Promise<FileSystemDirectoryHandle> getOriginPrivateDirectory();
+};