OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // File-level comment to appease parser. Eventually this will not be necessary. | 5 // File-level comment to appease parser. Eventually this will not be necessary. |
6 | 6 |
7 namespace fileSystem { | 7 namespace fileSystem { |
| 8 dictionary AcceptOption { |
| 9 // This is the optional text description for this option. If not present, |
| 10 // a description will be automatically generated; typically containing an |
| 11 // expanded list of valid extensions (e.g. "text/html" may expand to |
| 12 // "*.html, *.htm"). |
| 13 DOMString? description; |
| 14 |
| 15 // Mime-types to accept, e.g. "image/jpeg" or "audio/*". One of mimeTypes or |
| 16 // extensions must contain at least one valid element. |
| 17 DOMString[]? mimeTypes; |
| 18 |
| 19 // Extensions to accept, e.g. "jpg", "gif", "crx". |
| 20 DOMString[]? extensions; |
| 21 }; |
| 22 |
8 dictionary ChooseFileOptions { | 23 dictionary ChooseFileOptions { |
9 // Type of the prompt to show. Valid types are 'openFile', | 24 // Type of the prompt to show. Valid types are 'openFile', |
10 // 'openWritableFile' or 'saveFile'. | 25 // 'openWritableFile' or 'saveFile'. |
11 // | 26 // |
12 // Both 'openFile' and 'openWritableFile' will prompt the user to open an | 27 // Both 'openFile' and 'openWritableFile' will prompt the user to open an |
13 // existing file, with 'openFile' returning a read-only FileEntry on | 28 // existing file, with 'openFile' returning a read-only FileEntry on |
14 // success. 'saveFile' will prompt the user to choose an existing file or | 29 // success. 'saveFile' will prompt the user to choose an existing file or |
15 // a new file, and will return a writable FileEntry. | 30 // a new file, and will return a writable FileEntry. |
16 // Calls to chooseFile with either 'openWritableFile' or 'saveFile' will | 31 // Calls to chooseFile with either 'openWritableFile' or 'saveFile' will |
17 // fail unless the application has the fileSystemWrite permission. | 32 // fail unless the application has the fileSystemWrite permission. |
18 // | 33 // |
19 // The default is 'openFile'. | 34 // The default is 'openFile'. |
20 DOMString? type; | 35 DOMString? type; |
21 | 36 |
22 // The suggested file name that will be presented to the user as the | 37 // The suggested file name that will be presented to the user as the |
23 // default name to read or write. This is optional. | 38 // default name to read or write. This is optional. |
24 DOMString? suggestedName; | 39 DOMString? suggestedName; |
| 40 |
| 41 // The optional list of accept options for this file opener. Each option |
| 42 // will be presented as a unique group to the end-user. |
| 43 AcceptOption[]? accepts; |
| 44 |
| 45 // Whether to accept all file types, in addition to the options specified |
| 46 // in the accepts argument. The default is true. If the accepts field is |
| 47 // unset or contains no valid entries, this will always be reset to true. |
| 48 boolean? acceptsAllTypes; |
25 }; | 49 }; |
26 callback GetDisplayPathCallback = void (DOMString displayPath); | 50 callback GetDisplayPathCallback = void (DOMString displayPath); |
27 callback FileEntryCallback = void ([instanceOf=FileEntry] object fileEntry); | 51 callback FileEntryCallback = void ([instanceOf=FileEntry] object fileEntry); |
28 callback IsWritableCallback = void (boolean isWritable); | 52 callback IsWritableCallback = void (boolean isWritable); |
29 | 53 |
30 interface Functions { | 54 interface Functions { |
31 // Get the display path of a FileEntry object. The display path is based on | 55 // Get the display path of a FileEntry object. The display path is based on |
32 // the full path of the file on the local file system, but may be made more | 56 // the full path of the file on the local file system, but may be made more |
33 // readable for display purposes. | 57 // readable for display purposes. |
34 static void getDisplayPath([instanceOf=FileEntry] object fileEntry, | 58 static void getDisplayPath([instanceOf=FileEntry] object fileEntry, |
35 GetDisplayPathCallback callback); | 59 GetDisplayPathCallback callback); |
36 | 60 |
37 // Get a writable FileEntry from another FileEntry. This call will fail | 61 // Get a writable FileEntry from another FileEntry. This call will fail |
38 // if the application does not have the fileSystemWrite permission. | 62 // if the application does not have the fileSystemWrite permission. |
39 static void getWritableFileEntry([instanceOf=FileEntry] object fileEntry, | 63 static void getWritableFileEntry([instanceOf=FileEntry] object fileEntry, |
40 FileEntryCallback callback); | 64 FileEntryCallback callback); |
41 | 65 |
42 // Gets whether this FileEntry is writable or not. | 66 // Gets whether this FileEntry is writable or not. |
43 static void isWritableFileEntry([instanceOf=FileEntry] object fileEntry, | 67 static void isWritableFileEntry([instanceOf=FileEntry] object fileEntry, |
44 IsWritableCallback callback); | 68 IsWritableCallback callback); |
45 | 69 |
46 // Ask the user to choose a file. | 70 // Ask the user to choose a file. |
47 static void chooseFile(optional ChooseFileOptions options, | 71 static void chooseFile(optional ChooseFileOptions options, |
48 FileEntryCallback callback); | 72 FileEntryCallback callback); |
49 }; | 73 }; |
50 }; | 74 }; |
OLD | NEW |