files_app_state.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright 2021 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. import {AllowedPaths} from './allowed_paths.js';
  5. import {DialogType} from './dialog_type.js';
  6. // TODO(b/199452030): Fix duplication with files_app_state.js
  7. /**
  8. * FilesAppState is used in 2 ways:
  9. *
  10. * 1. Persist in the localStorage the some state, like current directory,
  11. * sorting column options, etc.
  12. *
  13. * 2. To open a new window:
  14. * 2.1, Requests to open a new window set part of these options to configure the
  15. * how the new window should behave.
  16. * 2.2 When the Files app extension is restarted, the background page retrieves
  17. * the last state from localStorage for each opened window and re-spawn the
  18. * windows with their state.
  19. *
  20. * @record
  21. */
  22. export class FilesAppState {
  23. constructor() {
  24. /**
  25. * The desired target directory when opening a new window.
  26. * @public {string|null|undefined}
  27. */
  28. this.currentDirectoryURL;
  29. /**
  30. * The URL for a file or directory to be selected once a new window is
  31. * spawned.
  32. * @public {string|undefined}
  33. */
  34. this.selectionURL;
  35. /**
  36. * For SaveAs dialog it prefills the <input> for the file name with this
  37. * value.
  38. * For FilePicker it pre-selects the file in the file list.
  39. * @public {string|undefined}
  40. */
  41. this.targetName;
  42. /**
  43. * Search term to initialize the Files app directly in a search results.
  44. * @public {string|undefined}
  45. */
  46. this.searchQuery;
  47. /**
  48. * The type of the window being opened, when it's undefined it defaults to
  49. * the normal Files app window (non-dialog version).
  50. * @public {!DialogType|undefined}
  51. */
  52. this.type;
  53. /**
  54. * List of file extensions (.txt, .zip, etc) that will be used by
  55. * AndroidAppListModel, when displaying Files app as FilePicker for ARC++.
  56. * Files app displays Android apps that can handle such extensions in the
  57. * DirectoryTree.
  58. * TODO(lucmult): Add type for the Object below:
  59. * @public {!Array<!Object>|undefined}
  60. */
  61. this.typeList;
  62. /**
  63. * For FilePicker indicates that the "All files" should be displayed in the
  64. * file type dropdown in the footer.
  65. * @public {boolean|undefined}
  66. */
  67. this.includeAllFiles;
  68. /**
  69. * Defines what volumes are available in the Files app, when NATIVE_PATH is
  70. * used, any virtual volume (FSPs) is hidden.
  71. *
  72. * Defaults to `ANY_PATH_OR_URL` when undefined.
  73. * @public {!AllowedPaths|undefined}
  74. */
  75. this.allowedPaths;
  76. /**
  77. * If the Android apps should be shown in the DirectoryTree for FilePicker.
  78. * @public {boolean|undefined}
  79. */
  80. this.showAndroidPickerApps;
  81. /**
  82. * Array of Files app mode dependent volume filter names. Defaults to an
  83. * empty Array when undefined, and is the normal case (no filters).
  84. *
  85. * See filtered_volume_manager.js for details about the available volume
  86. * filter names and their volume filter effects.
  87. *
  88. * @public {!Array<string>|undefined}
  89. */
  90. this.volumeFilter;
  91. }
  92. }