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