| // Copyright 2020 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| syntax = "proto2"; |
| |
| option optimize_for = LITE_RUNTIME; |
| |
| package content; |
| |
| // Used to serialize a File System Access handle representing a file or |
| // directory. |
| // |
| // Paths are stored as a serialized base::FilePath. I.e. on platforms where |
| // base::FilePath uses 8 bit characters this directly contains those |
| // characters, and on platforms where base::FilePath uses 16 bit characters |
| // those characters are serialized using the current platform's endianness. |
| // This means paths can't necesarilly be read back on different platforms |
| // or computers from where they were written, but since the path references |
| // something on the local device that likely doesn't exist on a different |
| // computer anyway this should be no problem in practice. |
| message LocalFileData { |
| // The root path of a File System Access handle is the path that the user |
| // selected in a file or directory picker. All permissions related to the |
| // handle are based on this path. |
| required bytes root_path = 1; |
| |
| // If `relative_path` is empty, `root_path` is the full path to the file or |
| // directory this object represents. If non-empty this path should be appended |
| // to `root_path` to get the full path. This can happen for example if a |
| // website has access to a directory, but stores references to files or |
| // directories inside that picked directory to IndexedDB. In that case we |
| // still want permissions to be based on the originally picked path, but also |
| // need to know the path to the actual file or directory that was stored. |
| required bytes relative_path = 2; |
| |
| // The display name of the file. If `display_name` is empty, the basename |
| // of the file path is used. |
| optional bytes display_name = 3; |
| } |
| |
| // Used to serialize a File System Access handle representing a file or |
| // directory in the origin scoped sandboxed file system. |
| // |
| // The same comment as for the above LocalFileData messages applies here as |
| // well regarding serialization format of the paths themselves. |
| message SandboxedFileData { |
| // The path to the file or directory relative to the root of the origin's |
| // sandboxed file system. |
| required bytes virtual_path = 1; |
| // The storage bucket ID. Will be populated only if the non-default bucket |
| // is being used. |
| optional int64 bucket_id = 2; |
| } |
| |
| // Used to serialize any File System Access handle, for example when a handle is |
| // stored in IndexedDB. |
| message FileSystemAccessHandleData { |
| // Is this handle representing a file or a directory? |
| enum HandleType { |
| kFile = 0; |
| kDirectory = 1; |
| } |
| required HandleType handle_type = 1; |
| |
| // The actual data, depending on the type of file system this handle is backed |
| // by. |
| oneof data { |
| SandboxedFileData sandboxed = 2; |
| // Paths reference the devices local file system. |
| LocalFileData local = 3; |
| // Paths are virtual paths in an external file system. |
| LocalFileData external = 4; |
| } |
| } |