1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75

content / browser / file_system_access / file_system_access.proto [blame]

// 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;
  }
}