| 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 the user's local file system. With this API, Chrome Apps can | 6 // and write to the user's local file system. With this API, Chrome Apps can |
| 7 // read and write to a user-selected location. For example, a text editor app | 7 // read and write to a user-selected location. For example, a text editor app |
| 8 // can use the API to read and write local documents. All failures are notified | 8 // can use the API to read and write local documents. All failures are notified |
| 9 // via chrome.runtime.lastError. | 9 // via chrome.runtime.lastError. |
| 10 namespace fileSystem { | 10 namespace fileSystem { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 // Represents a mounted volume, which can be accessed via <code>chrome. | 95 // Represents a mounted volume, which can be accessed via <code>chrome. |
| 96 // fileSystem.requestFileSystem</code>. | 96 // fileSystem.requestFileSystem</code>. |
| 97 dictionary Volume { | 97 dictionary Volume { |
| 98 DOMString volumeId; | 98 DOMString volumeId; |
| 99 boolean writable; | 99 boolean writable; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 // Change to an entry within a tracked directory. | 102 // Change to an entry within a tracked directory. |
| 103 [nodoc] dictionary ChildChange { | 103 [nodoc] dictionary ChildChange { |
| 104 [instanceOf=Entry] object entry; | 104 [instanceOf=FileSystemEntry] object entry; |
| 105 ChildChangeType type; | 105 ChildChangeType type; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 // Event notifying about an inserted or a removed volume from the system. | 108 // Event notifying about an inserted or a removed volume from the system. |
| 109 dictionary VolumeListChangedEvent { | 109 dictionary VolumeListChangedEvent { |
| 110 Volume[] volumes; | 110 Volume[] volumes; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 // Event notifying about a change in a file or a directory, including its | 113 // Event notifying about a change in a file or a directory, including its |
| 114 // contents. | 114 // contents. |
| 115 [nodoc] dictionary EntryChangedEvent { | 115 [nodoc] dictionary EntryChangedEvent { |
| 116 // Tracked entry. | 116 // Tracked entry. |
| 117 [instanceOf=Entry] object target; | 117 [instanceOf=FileSystemEntry] object target; |
| 118 | 118 |
| 119 // List of changed entries within the tracked directory in order they | 119 // List of changed entries within the tracked directory in order they |
| 120 // happened. May not be available for some types of file systems. | 120 // happened. May not be available for some types of file systems. |
| 121 ChildChange[]? childChanges; | 121 ChildChange[]? childChanges; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 // Event notifying about a tracked file or a directory being removed. | 124 // Event notifying about a tracked file or a directory being removed. |
| 125 [nodoc] dictionary EntryRemovedEvent { | 125 [nodoc] dictionary EntryRemovedEvent { |
| 126 [instanceOf=Entry] object target; | 126 [instanceOf=FileSystemEntry] object target; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 callback GetDisplayPathCallback = void (DOMString displayPath); | 129 callback GetDisplayPathCallback = void (DOMString displayPath); |
| 130 callback EntryCallback = void ([instanceOf=Entry] object entry); | 130 callback EntryCallback = void ([instanceOf=FileSystemEntry] object entry); |
| 131 callback EntriesCallback = void ( | 131 callback EntriesCallback = void ( |
| 132 [instanceOf=Entry] optional object entry, | 132 [instanceOf=FileSystemEntry] optional object entry, |
| 133 [instanceOf=FileEntry] optional object[] fileEntries); | 133 [instanceOf=FileSystemFileEntry] optional object[] fileEntries); |
| 134 callback IsWritableCallback = void (boolean isWritable); | 134 callback IsWritableCallback = void (boolean isWritable); |
| 135 callback IsRestorableCallback = void (boolean isRestorable); | 135 callback IsRestorableCallback = void (boolean isRestorable); |
| 136 [nodoc] callback GetObservedEntriesCallback = void ( | 136 [nodoc] callback GetObservedEntriesCallback = void ( |
| 137 [instanceOf=Entry] object[] entries); | 137 [instanceOf=FileSystemEntry] object[] entries); |
| 138 callback RequestFileSystemCallback = void( | 138 callback RequestFileSystemCallback = void( |
| 139 [instanceOf=FileSystem] optional object fileSystem); | 139 [instanceOf=FileSystem] optional object fileSystem); |
| 140 callback GetVolumeListCallback = void(optional Volume[] volumes); | 140 callback GetVolumeListCallback = void(optional Volume[] volumes); |
| 141 | 141 |
| 142 interface Functions { | 142 interface Functions { |
| 143 // Get the display path of an Entry object. The display path is based on | 143 // Get the display path of an Entry object. The display path is based on |
| 144 // the full path of the file or directory on the local file system, but may | 144 // the full path of the file or directory on the local file system, but may |
| 145 // be made more readable for display purposes. | 145 // be made more readable for display purposes. |
| 146 static void getDisplayPath([instanceOf=Entry] object entry, | 146 static void getDisplayPath([instanceOf=FileSystemEntry] object entry, |
| 147 GetDisplayPathCallback callback); | 147 GetDisplayPathCallback callback); |
| 148 | 148 |
| 149 // Get a writable Entry from another Entry. This call will fail with a | 149 // Get a writable Entry from another Entry. This call will fail with a |
| 150 // runtime error if the application does not have the 'write' permission | 150 // runtime error if the application does not have the 'write' permission |
| 151 // under 'fileSystem'. If entry is a DirectoryEntry, this call will fail if | 151 // under 'fileSystem'. If entry is a DirectoryEntry, this call will fail if |
| 152 // the application does not have the 'directory' permission under | 152 // the application does not have the 'directory' permission under |
| 153 // 'fileSystem'. | 153 // 'fileSystem'. |
| 154 static void getWritableEntry([instanceOf=Entry] object entry, | 154 static void getWritableEntry([instanceOf=FileSystemEntry] object entry, |
| 155 EntryCallback callback); | 155 EntryCallback callback); |
| 156 | 156 |
| 157 // Gets whether this Entry is writable or not. | 157 // Gets whether this Entry is writable or not. |
| 158 static void isWritableEntry([instanceOf=Entry] object entry, | 158 static void isWritableEntry([instanceOf=FileSystemEntry] object entry, |
| 159 IsWritableCallback callback); | 159 IsWritableCallback callback); |
| 160 | 160 |
| 161 // Ask the user to choose a file or directory. | 161 // Ask the user to choose a file or directory. |
| 162 static void chooseEntry(optional ChooseEntryOptions options, | 162 static void chooseEntry(optional ChooseEntryOptions options, |
| 163 EntriesCallback callback); | 163 EntriesCallback callback); |
| 164 | 164 |
| 165 // Returns the file entry with the given id if it can be restored. This call | 165 // Returns the file entry with the given id if it can be restored. This call |
| 166 // will fail with a runtime error otherwise. | 166 // will fail with a runtime error otherwise. |
| 167 static void restoreEntry(DOMString id, EntryCallback callback); | 167 static void restoreEntry(DOMString id, EntryCallback callback); |
| 168 | 168 |
| 169 // Returns whether the app has permission to restore the entry with the | 169 // Returns whether the app has permission to restore the entry with the |
| 170 // given id. | 170 // given id. |
| 171 static void isRestorable(DOMString id, IsRestorableCallback callback); | 171 static void isRestorable(DOMString id, IsRestorableCallback callback); |
| 172 | 172 |
| 173 // Returns an id that can be passed to restoreEntry to regain access to a | 173 // Returns an id that can be passed to restoreEntry to regain access to a |
| 174 // given file entry. Only the 500 most recently used entries are retained, | 174 // given file entry. Only the 500 most recently used entries are retained, |
| 175 // where calls to retainEntry and restoreEntry count as use. If the app has | 175 // where calls to retainEntry and restoreEntry count as use. If the app has |
| 176 // the 'retainEntries' permission under 'fileSystem', entries are retained | 176 // the 'retainEntries' permission under 'fileSystem', entries are retained |
| 177 // indefinitely. Otherwise, entries are retained only while the app is | 177 // indefinitely. Otherwise, entries are retained only while the app is |
| 178 // running and across restarts. | 178 // running and across restarts. |
| 179 static DOMString retainEntry([instanceOf=Entry] object entry); | 179 static DOMString retainEntry([instanceOf=FileSystemEntry] object entry); |
| 180 | 180 |
| 181 // Requests access to a file system for a volume represented by <code> | 181 // Requests access to a file system for a volume represented by <code> |
| 182 // options.volumeId</code>. If <code>options.writable</code> is set to true, | 182 // options.volumeId</code>. If <code>options.writable</code> is set to true, |
| 183 // then the file system will be writable. Otherwise, it will be read-only. | 183 // then the file system will be writable. Otherwise, it will be read-only. |
| 184 // The <code>writable</code> option requires the <code> | 184 // The <code>writable</code> option requires the <code> |
| 185 // "fileSystem": {"write"}</code> permission in the manifest. Available to | 185 // "fileSystem": {"write"}</code> permission in the manifest. Available to |
| 186 // kiosk apps running in kiosk session only. For manual-launch kiosk mode, a | 186 // kiosk apps running in kiosk session only. For manual-launch kiosk mode, a |
| 187 // confirmation dialog will be shown on top of the active app window. | 187 // confirmation dialog will be shown on top of the active app window. |
| 188 // In case of an error, <code>fileSystem</code> will be undefined, and | 188 // In case of an error, <code>fileSystem</code> will be undefined, and |
| 189 // <code>chrome.runtime.lastError</code> will be set. | 189 // <code>chrome.runtime.lastError</code> will be set. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 204 // is closed or suspended, unless <code>entry</code> is retained using | 204 // is closed or suspended, unless <code>entry</code> is retained using |
| 205 // <code>chrome.fileSystem.retainEntry</code>. | 205 // <code>chrome.fileSystem.retainEntry</code>. |
| 206 // | 206 // |
| 207 // In such case of retained entries, the observer stays active across | 207 // In such case of retained entries, the observer stays active across |
| 208 // restarts until <code>unobserveEntry</code> is explicitly called. Note, | 208 // restarts until <code>unobserveEntry</code> is explicitly called. Note, |
| 209 // that once the <code>entry</code> is not retained anymore, the observer | 209 // that once the <code>entry</code> is not retained anymore, the observer |
| 210 // will be removed automatically. Observed entries are also automatically | 210 // will be removed automatically. Observed entries are also automatically |
| 211 // restored when either <code>getObservers</code> is called, or an observing | 211 // restored when either <code>getObservers</code> is called, or an observing |
| 212 // event for it is invoked. | 212 // event for it is invoked. |
| 213 [nodoc] static void observeDirectory( | 213 [nodoc] static void observeDirectory( |
| 214 [instanceOf=DirectoryEntry] object entry, | 214 [instanceOf=FileSystemDirectoryEntry] object entry, |
| 215 optional boolean recursive); | 215 optional boolean recursive); |
| 216 | 216 |
| 217 // Unobserves a previously observed either a file or a directory. | 217 // Unobserves a previously observed either a file or a directory. |
| 218 [nodoc] static void unobserveEntry([instanceOf=Entry] object entry); | 218 [nodoc] static void unobserveEntry([instanceOf=FileSystemEntry] object entry
); |
| 219 | 219 |
| 220 // Lists all observed entries. | 220 // Lists all observed entries. |
| 221 [nodoc] static void getObservedEntries(GetObservedEntriesCallback callback); | 221 [nodoc] static void getObservedEntries(GetObservedEntriesCallback callback); |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 interface Events { | 224 interface Events { |
| 225 // Called when a list of available volumes is changed. | 225 // Called when a list of available volumes is changed. |
| 226 static void onVolumeListChanged(VolumeListChangedEvent event); | 226 static void onVolumeListChanged(VolumeListChangedEvent event); |
| 227 | 227 |
| 228 // Called when an observed entry is changed. | 228 // Called when an observed entry is changed. |
| 229 [nodoc] static void onEntryChanged(EntryChangedEvent event); | 229 [nodoc] static void onEntryChanged(EntryChangedEvent event); |
| 230 | 230 |
| 231 // Called when an observed entry is removed. | 231 // Called when an observed entry is removed. |
| 232 [nodoc] static void onEntryRemoved(EntryRemovedEvent event); | 232 [nodoc] static void onEntryRemoved(EntryRemovedEvent event); |
| 233 }; | 233 }; |
| 234 }; | 234 }; |
| OLD | NEW |