1// Copyright 2019 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5module blink.mojom; 6 7import "mojo/public/mojom/base/string16.mojom"; 8import "third_party/blink/public/mojom/native_file_system/native_file_system_directory_handle.mojom"; 9import "third_party/blink/public/mojom/native_file_system/native_file_system_file_handle.mojom"; 10import "third_party/blink/public/mojom/native_file_system/native_file_system_error.mojom"; 11import "third_party/blink/public/mojom/native_file_system/native_file_system_transfer_token.mojom"; 12 13enum ChooseFileSystemEntryType { 14 kOpenFile, 15 kOpenMultipleFiles, 16 kSaveFile, 17 kOpenDirectory 18}; 19 20// Struct to represent individual options for types of files that are accepted 21// by calls to ChooseEntry. Each type has an optional description, and any 22// number of mime types and/or extensions. 23// Options with no extensions and no known mime types will be ignored. 24struct ChooseFileSystemEntryAcceptsOption { 25 mojo_base.mojom.String16 description; 26 array<string> mime_types; 27 array<string> extensions; 28}; 29 30// Interface provided by the browser to the renderer as main entry point to the 31// Native File System API. The renderer can request this interface for a 32// specific worker or document, so the browser process will always be able to 33// tell what operations are being done by which document or worker. 34interface NativeFileSystemManager { 35 // Opens the sandboxed filesystem for the origin of the current document or worker. 36 GetSandboxedFileSystem() => 37 (NativeFileSystemError result, 38 pending_remote<NativeFileSystemDirectoryHandle>? directory); 39 40 // Prompts the user to select a file from the native filesystem. Returns an 41 // error code if something failed, or a list of the selected entries on 42 // success. 43 // If |include_accepts_all| is true, a "all files" option is included in the 44 // dialog displayed to the user. If no valid options are present in |accepts| 45 // |include_accepts_all| is treated as if it was true. 46 ChooseEntries(ChooseFileSystemEntryType type, 47 array<ChooseFileSystemEntryAcceptsOption> accepts, 48 bool include_accepts_all) => 49 (NativeFileSystemError result, 50 array<NativeFileSystemEntry> entries); 51 52 // Used to redeem tokens received by a postMessage() target. Clones 53 // FileSystemFileHandles. Token redemption should never fail. The 54 // postMessage() target should perform an origin check before 55 // redeeming tokens. Origin check failures must dispatch a messageerror 56 // event instead of cloning the objects. NativeFileSystemManager will also 57 // validate the redeemed token, including the token's origin, before binding the 58 // FileSystemHandle. 59 GetFileHandleFromToken( 60 pending_remote<NativeFileSystemTransferToken> token, 61 pending_receiver<NativeFileSystemFileHandle> file_handle); 62 63 // Same as GetFileHandleFromToken(), but for FileSystemDirectoryHandles. 64 // See GetFileHandleFromToken() comment above for details. 65 GetDirectoryHandleFromToken( 66 pending_remote<NativeFileSystemTransferToken> token, 67 pending_receiver<NativeFileSystemDirectoryHandle> directory_handle); 68}; 69