| 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 // Use the <code>chrome.fileSystem</code> API to create, read, navigate, | 5 // Use the <code>chrome.fileSystem</code> API to create, read, navigate, |
| 6 // and write to a sandboxed section of the user's local file system. With this | 6 // and write to a sandboxed section of the user's local file system. With this |
| 7 // API, packaged apps can read and write to a user-selected location. For | 7 // API, packaged apps can read and write to a user-selected location. For |
| 8 // example, a text editor app can use the API to read and write local documents. | 8 // example, a text editor app can use the API to read and write local documents. |
| 9 namespace fileSystem { | 9 namespace fileSystem { |
| 10 dictionary AcceptOption { | 10 dictionary AcceptOption { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 openFile, | 31 openFile, |
| 32 | 32 |
| 33 // Prompts the user to open an existing file and returns a writable | 33 // Prompts the user to open an existing file and returns a writable |
| 34 // FileEntry on success. Calls using this type will fail unless the | 34 // FileEntry on success. Calls using this type will fail unless the |
| 35 // application has the 'write' permission under 'fileSystem'. | 35 // application has the 'write' permission under 'fileSystem'. |
| 36 openWritableFile, | 36 openWritableFile, |
| 37 | 37 |
| 38 // Prompts the user to open an existing file or a new file and returns a | 38 // Prompts the user to open an existing file or a new file and returns a |
| 39 // writable FileEntry on success. Calls using this type will fail unless the | 39 // writable FileEntry on success. Calls using this type will fail unless the |
| 40 // application has the 'write' permission under 'fileSystem'. | 40 // application has the 'write' permission under 'fileSystem'. |
| 41 saveFile | 41 saveFile, |
| 42 |
| 43 // Prompts the user to open a directory and returns a DirectoryEntry on |
| 44 // success. Calls using this type will fail unless the application has the |
| 45 // 'directory' permission under 'fileSystem'. If the application has the |
| 46 // 'write' permission under 'fileSystem', the returned DirectoryEntry will |
| 47 // be writable; otherwise it will be read-only. New in Chrome 31. |
| 48 openDirectory |
| 42 }; | 49 }; |
| 43 | 50 |
| 44 dictionary ChooseEntryOptions { | 51 dictionary ChooseEntryOptions { |
| 45 // Type of the prompt to show. The default is 'openFile'. From Chrome 31 | 52 // Type of the prompt to show. The default is 'openFile'. From Chrome 31 |
| 46 // onwards, 'openWritableFile' is deprecated and 'openFile' will return a | 53 // onwards, 'openWritableFile' is deprecated and 'openFile' will return a |
| 47 // writable file entry for apps with the 'write' permission under | 54 // writable file entry for apps with the 'write' permission under |
| 48 // 'fileSystem'. | 55 // 'fileSystem'. |
| 49 ChooseEntryType? type; | 56 ChooseEntryType? type; |
| 50 | 57 |
| 51 // The suggested file name that will be presented to the user as the | 58 // The suggested file name that will be presented to the user as the |
| 52 // default name to read or write. This is optional. | 59 // default name to read or write. This is optional. |
| 53 DOMString? suggestedName; | 60 DOMString? suggestedName; |
| 54 | 61 |
| 55 // The optional list of accept options for this file opener. Each option | 62 // The optional list of accept options for this file opener. Each option |
| 56 // will be presented as a unique group to the end-user. | 63 // will be presented as a unique group to the end-user. |
| 57 AcceptOption[]? accepts; | 64 AcceptOption[]? accepts; |
| 58 | 65 |
| 59 // Whether to accept all file types, in addition to the options specified | 66 // Whether to accept all file types, in addition to the options specified |
| 60 // in the accepts argument. The default is true. If the accepts field is | 67 // in the accepts argument. The default is true. If the accepts field is |
| 61 // unset or contains no valid entries, this will always be reset to true. | 68 // unset or contains no valid entries, this will always be reset to true. |
| 62 boolean? acceptsAllTypes; | 69 boolean? acceptsAllTypes; |
| 63 | 70 |
| 64 // Whether to accept multiple files. This is only supported for openFile and | 71 // Whether to accept multiple files. This is only supported for openFile and |
| 65 // openWritableFile. The callback to chooseEntry will be called with a list | 72 // openWritableFile. The callback to chooseEntry will be called with a list |
| 66 // of entries if this is set to true. Otherwise it will be called with a | 73 // of entries if this is set to true. Otherwise it will be called with a |
| 67 // single Entry. | 74 // single Entry. |
| 68 boolean? acceptsMultiple; | 75 boolean? acceptsMultiple; |
| 69 }; | 76 }; |
| 70 callback GetDisplayPathCallback = void (DOMString displayPath); | 77 callback GetDisplayPathCallback = void (DOMString displayPath); |
| 71 callback FileEntryCallback = void ([instanceOf=FileEntry] object fileEntry); | 78 callback EntryCallback = void ([instanceOf=Entry] object entry); |
| 72 callback FileEntriesCallback = void ( | 79 callback EntriesCallback = void ( |
| 73 [instanceOf=FileEntry] optional object fileEntry, | 80 [instanceOf=Entry] optional object entry, |
| 74 [instanceOf=FileEntry] optional object[] fileEntries); | 81 [instanceOf=FileEntry] optional object[] fileEntries); |
| 75 callback IsWritableCallback = void (boolean isWritable); | 82 callback IsWritableCallback = void (boolean isWritable); |
| 76 callback IsRestorableCallback = void (boolean isRestorable); | 83 callback IsRestorableCallback = void (boolean isRestorable); |
| 77 | 84 |
| 78 interface Functions { | 85 interface Functions { |
| 79 // Get the display path of a FileEntry object. The display path is based on | 86 // Get the display path of an Entry object. The display path is based on |
| 80 // the full path of the file on the local file system, but may be made more | 87 // the full path of the file or directory on the local file system, but may |
| 81 // readable for display purposes. | 88 // be made more readable for display purposes. |
| 82 static void getDisplayPath([instanceOf=FileEntry] object fileEntry, | 89 static void getDisplayPath([instanceOf=Entry] object entry, |
| 83 GetDisplayPathCallback callback); | 90 GetDisplayPathCallback callback); |
| 84 | 91 |
| 85 // Get a writable FileEntry from another FileEntry. This call will fail if | 92 // Get a writable Entry from another Entry. This call will fail if the |
| 86 // the application does not have the 'write' permission under 'fileSystem'. | 93 // application does not have the 'write' permission under 'fileSystem'. If |
| 87 static void getWritableEntry([instanceOf=FileEntry] object fileEntry, | 94 // entry is a DirectoryEntry, this call will fail if the application does |
| 88 FileEntryCallback callback); | 95 // not have the 'directory' permission under 'fileSystem'. |
| 96 static void getWritableEntry([instanceOf=Entry] object entry, |
| 97 EntryCallback callback); |
| 89 | 98 |
| 90 // Gets whether this FileEntry is writable or not. | 99 // Gets whether this Entry is writable or not. |
| 91 static void isWritableEntry([instanceOf=FileEntry] object fileEntry, | 100 static void isWritableEntry([instanceOf=Entry] object entry, |
| 92 IsWritableCallback callback); | 101 IsWritableCallback callback); |
| 93 | 102 |
| 94 // Ask the user to choose a file. | 103 // Ask the user to choose a file or directory. |
| 95 static void chooseEntry(optional ChooseEntryOptions options, | 104 static void chooseEntry(optional ChooseEntryOptions options, |
| 96 FileEntriesCallback callback); | 105 EntriesCallback callback); |
| 97 | 106 |
| 98 // Returns the file entry with the given id if it can be restored. This call | 107 // Returns the file entry with the given id if it can be restored. This call |
| 99 // will fail otherwise. This method is new in Chrome 30. | 108 // will fail otherwise. This method is new in Chrome 30. |
| 100 static void restoreEntry(DOMString id, FileEntryCallback callback); | 109 static void restoreEntry(DOMString id, EntryCallback callback); |
| 101 | 110 |
| 102 // Returns whether a file entry for the given id can be restored, i.e. | 111 // Returns whether a file entry for the given id can be restored, i.e. |
| 103 // whether restoreEntry would succeed with this id now. This method is new | 112 // whether restoreEntry would succeed with this id now. This method is new |
| 104 // in Chrome 30. | 113 // in Chrome 30. |
| 105 static void isRestorable(DOMString id, IsRestorableCallback callback); | 114 static void isRestorable(DOMString id, IsRestorableCallback callback); |
| 106 | 115 |
| 107 // Returns an id that can be passed to restoreEntry to regain access to a | 116 // Returns an id that can be passed to restoreEntry to regain access to a |
| 108 // given file entry. Only the 500 most recently used entries are retained, | 117 // given file entry. Only the 500 most recently used entries are retained, |
| 109 // where calls to retainEntry and restoreEntry count as use. If the app has | 118 // where calls to retainEntry and restoreEntry count as use. If the app has |
| 110 // the 'retainEntries' permission under 'fileSystem' (currently restricted | 119 // the 'retainEntries' permission under 'fileSystem' (currently restricted |
| 111 // to dev channel), entries are retained indefinitely. Otherwise, entries | 120 // to dev channel), entries are retained indefinitely. Otherwise, entries |
| 112 // are retained only while the app is running and across restarts. This | 121 // are retained only while the app is running and across restarts. This |
| 113 // method is new in Chrome 30. | 122 // method is new in Chrome 30. |
| 114 static DOMString retainEntry([instanceOf=FileEntry] object fileEntry); | 123 static DOMString retainEntry([instanceOf=Entry] object entry); |
| 115 }; | 124 }; |
| 116 }; | 125 }; |
| OLD | NEW |