Bug 1831502 [wpt PR 39860] - HTML: sync html5lib-tests, a=testonly
[gecko.git] / widget / nsIFilePicker.idl
blob5ce2af3c3d0fa474630c9b5f79e7e4d9a6340b73
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsISupports.idl"
9 interface nsIFile;
10 interface nsIURI;
11 interface mozIDOMWindowProxy;
12 interface nsISimpleEnumerator;
14 // Declared in this file, below.
15 interface nsIFilePickerShownCallback;
17 [scriptable, uuid(9285b984-02d3-46b4-9514-7da8c471a747)]
18 interface nsIFilePicker : nsISupports
20 cenum Mode: 16 {
21 modeOpen = 0, // Load a file or directory
22 modeSave = 1, // Save a file or directory
23 modeGetFolder = 2, // Select a folder/directory
24 modeOpenMultiple = 3, // Load multiple files
27 cenum ResultCode: 16 {
28 returnOK = 0, // User hit Ok, process selection
29 returnCancel = 1, // User hit cancel, ignore selection
30 returnReplace = 2, // User acknowledged file already exists so ok to replace, process selection
33 const long filterAll = 0x001; // *.*
34 const long filterHTML = 0x002; // *.html; *.htm
35 const long filterText = 0x004; // *.txt
36 const long filterImages = 0x008; // *.jpe; *.jpg; *.jpeg; *.gif;
37 // *.png; *.bmp; *.ico; *.svg;
38 // *.svgz; *.tif; *.tiff; *.ai;
39 // *.drw; *.pct; *.psp; *.xcf;
40 // *.psd; *.raw; *.webp
41 const long filterXML = 0x010; // *.xml
42 const long filterXUL = 0x020; // *.xul
43 const long filterApps = 0x040; // Applications (per-platform implementation)
44 const long filterAllowURLs = 0x080; // Allow URLs
45 const long filterAudio = 0x100; // *.aac; *.aif; *.flac; *.iff;
46 // *.m4a; *.m4b; *.mid; *.midi;
47 // *.mp3; *.mpa; *.mpc; *.oga;
48 // *.ogg; *.ra; *.ram; *.snd;
49 // *.wav; *.wma
50 const long filterVideo = 0x200; // *.avi; *.divx; *.flv; *.m4v;
51 // *.mkv; *.mov; *.mp4; *.mpeg;
52 // *.mpg; *.ogm; *.ogv; *.ogx;
53 // *.rm; *.rmvb; *.smil; *.webm;
54 // *.wmv; *.xvid
56 cenum CaptureTarget: 8 {
57 captureNone = 0, // No capture target specified.
58 captureDefault = 1, // Missing/invalid value default.
59 captureUser = 2, // "user" capture target specified.
60 captureEnv = 3, // "environment" capture target specified.
63 /**
64 * Initialize the file picker widget. The file picker is not valid until this
65 * method is called.
67 * @param parent mozIDOMWindow parent. This dialog will be dependent
68 * on this parent. parent must be non-null.
69 * @param title The title for the file widget
70 * @param mode load, save, or get folder
73 void init(in mozIDOMWindowProxy parent, in AString title, in nsIFilePicker_Mode mode);
75 /**
76 * Append to the filter list with things from the predefined list
78 * @param filters mask of filters i.e. (filterAll | filterHTML)
81 void appendFilters(in long filterMask);
83 /**
84 * Add a filter
86 * @param title name of the filter
87 * @param filter extensions to filter -- semicolon and space separated
90 void appendFilter(in AString title,
91 in AString filter);
93 /**
94 * Add a raw filter (eg, add a MIME type without transforming it to a list of
95 * extensions).
97 * @param filter a filter taken directly from the accept attribute
98 * without processing
101 void appendRawFilter(in AString filter);
104 * The filename that should be suggested to the user as a default. This should
105 * include the extension.
107 * @throws NS_ERROR_FAILURE on attempts to get
109 attribute AString defaultString;
112 * The extension that should be associated with files of the type we
113 * want to work with. On some platforms, this extension will be
114 * automatically appended to filenames the user enters, if needed.
116 attribute AString defaultExtension;
119 * The filter which is currently selected in the File Picker dialog
121 * @return Returns the index (0 based) of the selected filter in the filter list.
123 attribute long filterIndex;
126 * Set the directory that the file open/save dialog initially displays
127 * Note that, if displaySpecialDirectory has been already set, this value will
128 * be ignored.
130 * @param displayDirectory the name of the directory
133 attribute nsIFile displayDirectory;
136 * Set the directory that the file open/save dialog initially displays using
137 * one of the special name as such as 'Desk', 'TmpD', and so on.
138 * Note that, if displayDirectory has been already set, this value will be
139 * ignored.
141 * @param displaySpecialDirectory the name of the special directory
144 attribute AString displaySpecialDirectory;
148 * Get the nsIFile for the file or directory.
150 * @return Returns the file currently selected
152 readonly attribute nsIFile file;
155 * Get the nsIURI for the file or directory.
157 * @return Returns the file currently selected
159 readonly attribute nsIURI fileURL;
162 * Get the enumerator for the selected files
163 * only works in the modeOpenMultiple mode
165 * @return Returns the files currently selected
167 readonly attribute nsISimpleEnumerator files;
170 * Get the DOM File or the DOM Directory
172 * @return Returns the file or directory currently selected DOM object.
174 readonly attribute nsISupports domFileOrDirectory;
177 * Get the enumerator for the selected files or directories
178 * only works in the modeOpenMultiple mode
180 * @return Returns the files/directories currently selected as DOM object.
182 readonly attribute nsISimpleEnumerator domFileOrDirectoryEnumerator;
185 * Controls whether the chosen file(s) should be added to the system's recent
186 * documents list. This attribute will be ignored if the system has no "Recent
187 * Docs" concept, or if the application is in private browsing mode (in which
188 * case the file will not be added). Defaults to true.
190 attribute boolean addToRecentDocs;
193 * Opens the file dialog asynchrounously.
194 * The passed in object's done method will be called upon completion.
196 void open(in nsIFilePickerShownCallback aFilePickerShownCallback);
199 * The picker's mode, as set by the 'mode' argument passed to init()
200 * (one of the modeOpen et. al. constants specified above).
202 readonly attribute nsIFilePicker_Mode mode;
205 * If set to non-empty string, the nsIFilePicker implementation
206 * may use okButtonLabel as the label for the button the user uses to accept
207 * file selection.
209 attribute AString okButtonLabel;
212 * Implementation of HTMLInputElement's `capture` property.
214 * Not used by Firefox Desktop.
216 attribute nsIFilePicker_CaptureTarget capture;
219 [scriptable, function, uuid(0d79adad-b244-49A5-9997-2a8cad93fc44)]
220 interface nsIFilePickerShownCallback : nsISupports
223 * Callback which is called when a filepicker is shown and a result
224 * is returned.
226 * @param aResult One of returnOK, returnCancel, or returnReplace
228 void done(in nsIFilePicker_ResultCode aResult);