Fix broken path in extensions/common/PRESUBMIT.py
[chromium-blink-merge.git] / chrome / common / extensions / api / file_system_provider.idl
blobdea956abb9f8cfd20b29c3a824246acb9878a87e
1 // Copyright 2013 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.
5 // Use the <code>chrome.fileSystemProvider</code> API to create file systems,
6 // that can be accessible from the file manager on Chrome OS.
7 [implemented_in="chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h"]
8 namespace fileSystemProvider {
9 // Error codes used by providing extensions in response to requests as well
10 // as in case of errors when calling methods of the API. For success, <code>
11 // OK</code> must be used.
12 enum ProviderError {
13 OK,
14 FAILED,
15 IN_USE,
16 EXISTS,
17 NOT_FOUND,
18 ACCESS_DENIED,
19 TOO_MANY_OPENED,
20 NO_MEMORY,
21 NO_SPACE,
22 NOT_A_DIRECTORY,
23 INVALID_OPERATION,
24 SECURITY,
25 ABORT,
26 NOT_A_FILE,
27 NOT_EMPTY,
28 INVALID_URL,
32 // Mode of opening a file. Used by <code>onOpenFileRequested</code>.
33 enum OpenFileMode {
34 READ,
35 WRITE
38 // Type of a change detected on the observed directory.
39 enum ChangeType {
40 CHANGED,
41 DELETED
44 // Represents metadata of a file or a directory.
45 dictionary EntryMetadata {
46 // True if it is a directory.
47 boolean isDirectory;
49 // Name of this entry (not full path name). Must not contain '/'. For root
50 // it must be empty.
51 DOMString name;
53 // File size in bytes.
54 double size;
56 // The last modified time of this entry.
57 [instanceOf=Date] object modificationTime;
59 // Mime type for the entry.
60 DOMString? mimeType;
62 // Thumbnail image as a data URI in either PNG, JPEG or WEBP format, at most
63 // 32 KB in size. Optional, but can be provided only when explicitly
64 // requested by the <code>onGetMetadataRequested</code> event.
65 DOMString? thumbnail;
68 // Represents a watcher.
69 dictionary Watcher {
70 // The path of the entry being observed.
71 DOMString entryPath;
73 // Whether watching should include all child entries recursively. It can be
74 // true for directories only.
75 boolean recursive;
77 // Tag used by the last notification for the watcher.
78 DOMString? lastTag;
81 // Represents an opened file.
82 dictionary OpenedFile {
83 // A request ID to be be used by consecutive read/write and close requests.
84 long openRequestId;
86 // The path of the opened file.
87 DOMString filePath;
89 // Whether the file was opened for reading or writing.
90 OpenFileMode mode;
93 // Represents a mounted file system.
94 dictionary FileSystemInfo {
95 // The identifier of the file system.
96 DOMString fileSystemId;
98 // A human-readable name for the file system.
99 DOMString displayName;
101 // Whether the file system supports operations which may change contents
102 // of the file system (such as creating, deleting or writing to files).
103 boolean writable;
105 // The maximum number of files that can be opened at once. If 0, then not
106 // limited.
107 long openedFilesLimit;
109 // List of currently opened files.
110 OpenedFile[] openedFiles;
112 // Whether the file system supports the <code>tag</code> field for observing
113 // directories.
114 [nodoc] boolean? supportsNotifyTag;
116 // List of watchers.
117 [nodoc] Watcher[] watchers;
120 // Options for the <code>mount()</code> method.
121 dictionary MountOptions {
122 // The string indentifier of the file system. Must be unique per each
123 // extension.
124 DOMString fileSystemId;
126 // A human-readable name for the file system.
127 DOMString displayName;
129 // Whether the file system supports operations which may change contents
130 // of the file system (such as creating, deleting or writing to files).
131 boolean? writable;
133 // The maximum number of files that can be opened at once. If not specified,
134 // or 0, then not limited.
135 long? openedFilesLimit;
137 // Whether the file system supports the <code>tag</code> field for observed
138 // directories. Required in order to enable the internal cache.
139 [nodoc] boolean? supportsNotifyTag;
142 // Options for the <code>unmount()</code> method.
143 dictionary UnmountOptions {
144 // The identifier of the file system to be unmounted.
145 DOMString fileSystemId;
148 // Options for the <code>onUnmountRequested()</code> event.
149 dictionary UnmountRequestedOptions {
150 // The identifier of the file system to be unmounted.
151 DOMString fileSystemId;
153 // The unique identifier of this request.
154 long requestId;
157 // Options for the <code>onGetMetadataRequested()</code> event.
158 dictionary GetMetadataRequestedOptions {
159 // The identifier of the file system related to this operation.
160 DOMString fileSystemId;
162 // The unique identifier of this request.
163 long requestId;
165 // The path of the entry to fetch metadata about.
166 DOMString entryPath;
168 // Set to <code>true</code> if the thumbnail is requested.
169 boolean thumbnail;
172 // Options for the <code>onReadDirectoryRequested()</code> event.
173 dictionary ReadDirectoryRequestedOptions {
174 // The identifier of the file system related to this operation.
175 DOMString fileSystemId;
177 // The unique identifier of this request.
178 long requestId;
180 // The path of the directory which contents are requested.
181 DOMString directoryPath;
184 // Options for the <code>onOpenFileRequested()</code> event.
185 dictionary OpenFileRequestedOptions {
186 // The identifier of the file system related to this operation.
187 DOMString fileSystemId;
189 // A request ID which will be used by consecutive read/write and close
190 // requests.
191 long requestId;
193 // The path of the file to be opened.
194 DOMString filePath;
196 // Whether the file will be used for reading or writing.
197 OpenFileMode mode;
200 // Options for the <code>onCloseFileRequested()</code> event.
201 dictionary CloseFileRequestedOptions {
202 // The identifier of the file system related to this operation.
203 DOMString fileSystemId;
205 // The unique identifier of this request.
206 long requestId;
208 // A request ID used to open the file.
209 long openRequestId;
212 // Options for the <code>onReadFileRequested()</code> event.
213 dictionary ReadFileRequestedOptions {
214 // The identifier of the file system related to this operation.
215 DOMString fileSystemId;
217 // The unique identifier of this request.
218 long requestId;
220 // A request ID used to open the file.
221 long openRequestId;
223 // Position in the file (in bytes) to start reading from.
224 double offset;
226 // Number of bytes to be returned.
227 double length;
230 // Options for the <code>onCreateDirectoryRequested()</code> event.
231 dictionary CreateDirectoryRequestedOptions {
232 // The identifier of the file system related to this operation.
233 DOMString fileSystemId;
235 // The unique identifier of this request.
236 long requestId;
238 // The path of the directory to be created.
239 DOMString directoryPath;
241 // Whether the operation is recursive (for directories only).
242 boolean recursive;
245 // Options for the <code>onDeleteEntryRequested()</code> event.
246 dictionary DeleteEntryRequestedOptions {
247 // The identifier of the file system related to this operation.
248 DOMString fileSystemId;
250 // The unique identifier of this request.
251 long requestId;
253 // The path of the entry to be deleted.
254 DOMString entryPath;
256 // Whether the operation is recursive (for directories only).
257 boolean recursive;
260 // Options for the <code>onCreateFileRequested()</code> event.
261 dictionary CreateFileRequestedOptions {
262 // The identifier of the file system related to this operation.
263 DOMString fileSystemId;
265 // The unique identifier of this request.
266 long requestId;
268 // The path of the file to be created.
269 DOMString filePath;
272 // Options for the <code>onCopyEntryRequested()</code> event.
273 dictionary CopyEntryRequestedOptions {
274 // The identifier of the file system related to this operation.
275 DOMString fileSystemId;
277 // The unique identifier of this request.
278 long requestId;
280 // The source path of the entry to be copied.
281 DOMString sourcePath;
283 // The destination path for the copy operation.
284 DOMString targetPath;
287 // Options for the <code>onMoveEntryRequested()</code> event.
288 dictionary MoveEntryRequestedOptions {
289 // The identifier of the file system related to this operation.
290 DOMString fileSystemId;
292 // The unique identifier of this request.
293 long requestId;
295 // The source path of the entry to be moved into a new place.
296 DOMString sourcePath;
298 // The destination path for the copy operation.
299 DOMString targetPath;
302 // Options for the <code>onTruncateRequested()</code> event.
303 dictionary TruncateRequestedOptions {
304 // The identifier of the file system related to this operation.
305 DOMString fileSystemId;
307 // The unique identifier of this request.
308 long requestId;
310 // The path of the file to be truncated.
311 DOMString filePath;
313 // Number of bytes to be retained after the operation completes.
314 double length;
317 // Options for the <code>onWriteFileRequested()</code> event.
318 dictionary WriteFileRequestedOptions {
319 // The identifier of the file system related to this operation.
320 DOMString fileSystemId;
322 // The unique identifier of this request.
323 long requestId;
325 // A request ID used to open the file.
326 long openRequestId;
328 // Position in the file (in bytes) to start writing the bytes from.
329 double offset;
331 // Buffer of bytes to be written to the file.
332 ArrayBuffer data;
335 // Options for the <code>onAbortRequested()</code> event.
336 dictionary AbortRequestedOptions {
337 // The identifier of the file system related to this operation.
338 DOMString fileSystemId;
340 // The unique identifier of this request.
341 long requestId;
343 // An ID of the request to be aborted.
344 long operationRequestId;
347 // Options for the <code>onAddWatcherRequested()</code> event.
348 dictionary AddWatcherRequestedOptions {
349 // The identifier of the file system related to this operation.
350 DOMString fileSystemId;
352 // The unique identifier of this request.
353 long requestId;
355 // The path of the entry to be observed.
356 DOMString entryPath;
358 // Whether observing should include all child entries recursively. It can be
359 // true for directories only.
360 boolean recursive;
363 // Options for the <code>onRemoveWatcherRequested()</code> event.
364 dictionary RemoveWatcherRequestedOptions {
365 // The identifier of the file system related to this operation.
366 DOMString fileSystemId;
368 // The unique identifier of this request.
369 long requestId;
371 // The path of the watched entry.
372 DOMString entryPath;
374 // Mode of the watcher.
375 boolean recursive;
378 // Information about a change happened to an entry within the observed
379 // directory (including the entry itself).
380 dictionary Change {
381 // The path of the changed entry.
382 DOMString entryPath;
384 // The type of the change which happened to the entry.
385 ChangeType changeType;
388 // Options for the <code>Notify()</code> method.
389 dictionary NotifyOptions {
390 // The identifier of the file system related to this change.
391 DOMString fileSystemId;
393 // The path of the observed entry.
394 DOMString observedPath;
396 // Mode of the observed entry.
397 boolean recursive;
399 // The type of the change which happened to the observed entry. If it is
400 // DELETED, then the observed entry will be automatically removed from the
401 // list of observed entries.
402 ChangeType changeType;
404 // List of changes to entries within the observed directory (including the
405 // entry itself)
406 Change[]? changes;
408 // Tag for the notification. Required if the file system was mounted with
409 // the <code>supportsNotifyTag</code> option. Note, that this flag is
410 // necessary to provide notifications about changes which changed even
411 // when the system was shutdown.
412 DOMString? tag;
415 // Options for the <code>onConfigureRequested()</code> event.
416 [nodoc] dictionary ConfigureRequestedOptions {
417 // The identifier of the file system to be configured.
418 DOMString fileSystemId;
420 // The unique identifier of this request.
421 long requestId;
424 // Callback to receive the result of getAll() function.
425 callback GetAllCallback = void(FileSystemInfo[] fileSystems);
427 // Callback to receive the result of get() function.
428 callback GetCallback = void(FileSystemInfo fileSystem);
430 // Callback to be called by the providing extension in case of a success.
431 [nocompile] callback ProviderSuccessCallback = void();
433 // Callback to be called by the providing extension in case of an error.
434 [nocompile] callback ProviderErrorCallback = void(ProviderError error);
436 // Success callback for the <code>onGetMetadataRequested</code> event.
437 [nocompile] callback MetadataCallback = void(
438 EntryMetadata metadata);
440 // Success callback for the <code>onReadDirectoryRequested</code> event. If
441 // more entries will be returned, then <code>hasMore</code> must be true, and
442 // it has to be called again with additional entries. If no more entries are
443 // available, then <code>hasMore</code> must be set to false.
444 [nocompile] callback EntriesCallback = void(
445 EntryMetadata[] entries, boolean hasMore);
447 // Success callback for the <code>onReadFileRequested</code> event. If more
448 // data will be returned, then <code>hasMore</code> must be true, and it
449 // has to be called again with additional entries. If no more data is
450 // available, then <code>hasMore</code> must be set to false.
451 [nocompile] callback FileDataCallback = void(
452 ArrayBuffer data, boolean hasMore);
454 // A generic result callback to indicate success or failure.
455 callback ResultCallback = void();
457 interface Functions {
458 // Mounts a file system with the given <code>fileSystemId</code> and <code>
459 // displayName</code>. <code>displayName</code> will be shown in the left
460 // panel of Files.app. <code>displayName</code> can contain any characters
461 // including '/', but cannot be an empty string. <code>displayName</code>
462 // must be descriptive but doesn't have to be unique. The <code>fileSystemId
463 // </code> must not be an empty string.
465 // Depending on the type of the file system being mounted, the <code>source
466 // </code> option must be set appropriately.
468 // In case of an error, <code>chrome.runtime.lastError</code> will be set
469 // will a corresponding error code.
470 static void mount(MountOptions options,
471 optional ResultCallback callback);
473 // Unmounts a file system with the given <code>fileSystemId</code>. It
474 // must be called after <code>onUnmountRequested</code> is invoked. Also,
475 // the providing extension can decide to perform unmounting if not requested
476 // (eg. in case of lost connection, or a file error).
478 // In case of an error, <code>chrome.runtime.lastError</code> will be set
479 // will a corresponding error code.
480 static void unmount(UnmountOptions options,
481 optional ResultCallback callback);
483 // Returns all file systems mounted by the extension.
484 static void getAll(GetAllCallback callback);
486 // Returns information about a file system with the passed <code>
487 // fileSystemId</code>.
488 static void get(DOMString fileSystemId, GetCallback callback);
490 // Notifies about changes in the watched directory at <code>
491 // observedPath</code> in <code>recursive</code mode. If the file system is
492 // mounted with <code>supportsNofityTag</code>, then <code>tag</code> must
493 // be provided, and all changes since the last notification always reported,
494 // even if the system was shutdown. The last tag can be obtained with <code>
495 // getAll()</code>. Note, that <code>tag</code> is required in order to
496 // enable the internal cache.
498 // Value of <code>tag</code> can be any string which is unique per call,
499 // so it's possible to identify the last registered notification. Eg. if
500 // the providing extension starts after a reboot, and the last registered
501 // notification's tag is equal to "123", then it should call notify() for
502 // all changes which happened since the change tagged as "123". It cannot
503 // be an empty string.
505 // Not all providers are able to provide a tag, but if the file system has
506 // a changelog, then the tag can be eg. a change number, or a revision
507 // number.
509 // Note that if a parent directory is removed, then all descendant entries
510 // are also removed, and if they are watched, then the API must be notified
511 // about the fact. Also, if a directory is renamed, then all descendant
512 // entries are in fact removed, as there is no entry under their original
513 // paths anymore.
515 // In case of an error, <code>chrome.runtime.lastError</code> will be set
516 // will a corresponding error code.
517 [nodoc] static void notify(NotifyOptions options,
518 optional ResultCallback callback);
521 interface Events {
522 // Raised when unmounting for the file system with the <code>fileSystemId
523 // </code> identifier is requested. In the response, the <code>unmount
524 // </code> API method must be called together with <code>successCallback
525 // </code>. If unmounting is not possible (eg. due to a pending operation),
526 // then <code>errorCallback</code> must be called.
527 [maxListeners=1] static void onUnmountRequested(
528 UnmountRequestedOptions options,
529 ProviderSuccessCallback successCallback,
530 ProviderErrorCallback errorCallback);
532 // Raised when metadata of a file or a directory at <code>entryPath</code>
533 // is requested. The metadata must be returned with the <code>
534 // successCallback</code> call. In case of an error, <code>errorCallback
535 // </code> must be called.
536 [maxListeners=1] static void onGetMetadataRequested(
537 GetMetadataRequestedOptions options,
538 MetadataCallback successCallback,
539 ProviderErrorCallback errorCallback);
541 // Raised when contents of a directory at <code>directoryPath</code> are
542 // requested. The results must be returned in chunks by calling the <code>
543 // successCallback</code> several times. In case of an error, <code>
544 // errorCallback</code> must be called.
545 [maxListeners=1] static void onReadDirectoryRequested(
546 ReadDirectoryRequestedOptions options,
547 EntriesCallback successCallback,
548 ProviderErrorCallback errorCallback);
550 // Raised when opening a file at <code>filePath</code> is requested. If the
551 // file does not exist, then the operation must fail. Maximum number of
552 // files opened at once can be specified with <code>MountOptions</code>.
553 [maxListeners=1] static void onOpenFileRequested(
554 OpenFileRequestedOptions options,
555 ProviderSuccessCallback successCallback,
556 ProviderErrorCallback errorCallback);
558 // Raised when opening a file previously opened with <code>openRequestId
559 // </code> is requested to be closed.
560 [maxListeners=1] static void onCloseFileRequested(
561 CloseFileRequestedOptions options,
562 ProviderSuccessCallback successCallback,
563 ProviderErrorCallback errorCallback);
565 // Raised when reading contents of a file opened previously with <code>
566 // openRequestId</code> is requested. The results must be returned in
567 // chunks by calling <code>successCallback</code> several times. In case of
568 // an error, <code>errorCallback</code> must be called.
569 [maxListeners=1] static void onReadFileRequested(
570 ReadFileRequestedOptions options,
571 FileDataCallback successCallback,
572 ProviderErrorCallback errorCallback);
574 // Raised when creating a directory is requested. The operation must fail
575 // with the EXISTS error if the target directory already exists.
576 // If <code>recursive</code> is true, then all of the missing directories
577 // on the directory path must be created.
578 [maxListeners=1] static void onCreateDirectoryRequested(
579 CreateDirectoryRequestedOptions options,
580 ProviderSuccessCallback successCallback,
581 ProviderErrorCallback errorCallback);
583 // Raised when deleting an entry is requested. If <code>recursive</code> is
584 // true, and the entry is a directory, then all of the entries inside
585 // must be recursively deleted as well.
586 [maxListeners=1] static void onDeleteEntryRequested(
587 DeleteEntryRequestedOptions options,
588 ProviderSuccessCallback successCallback,
589 ProviderErrorCallback errorCallback);
591 // Raised when creating a file is requested. If the file already exists,
592 // then <code>errorCallback</code> must be called with the <code>EXISTS
593 // </code> error code.
594 [maxListeners=1] static void onCreateFileRequested(
595 CreateFileRequestedOptions options,
596 ProviderSuccessCallback successCallback,
597 ProviderErrorCallback errorCallback);
599 // Raised when copying an entry (recursively if a directory) is requested.
600 // If an error occurs, then <code>errorCallback</code> must be called.
601 [maxListeners=1] static void onCopyEntryRequested(
602 CopyEntryRequestedOptions options,
603 ProviderSuccessCallback successCallback,
604 ProviderErrorCallback errorCallback);
606 // Raised when moving an entry (recursively if a directory) is requested.
607 // If an error occurs, then <code>errorCallback</code> must be called.
608 [maxListeners=1] static void onMoveEntryRequested(
609 MoveEntryRequestedOptions options,
610 ProviderSuccessCallback successCallback,
611 ProviderErrorCallback errorCallback);
613 // Raised when truncating a file to a desired length is requested.
614 // If an error occurs, then <code>errorCallback</code> must be called.
615 [maxListeners=1] static void onTruncateRequested(
616 TruncateRequestedOptions options,
617 ProviderSuccessCallback successCallback,
618 ProviderErrorCallback errorCallback);
620 // Raised when writing contents to a file opened previously with <code>
621 // openRequestId</code> is requested.
622 [maxListeners=1] static void onWriteFileRequested(
623 WriteFileRequestedOptions options,
624 ProviderSuccessCallback successCallback,
625 ProviderErrorCallback errorCallback);
627 // Raised when aborting an operation with <code>operationRequestId</code>
628 // is requested. The operation executed with <code>operationRequestId</code>
629 // must be immediately stopped and <code>successCallback</code> of this
630 // abort request executed. If aborting fails, then <code>errorCallback
631 // </code> must be called. Note, that callbacks of the aborted operation
632 // must not be called, as they will be ignored. Despite calling <code>
633 // errorCallback</code>, the request may be forcibly aborted.
634 [maxListeners=1] static void onAbortRequested(
635 AbortRequestedOptions options,
636 ProviderSuccessCallback successCallback,
637 ProviderErrorCallback errorCallback);
639 // Raised when showing a configuration dialog for <code>fileSystemId</code>
640 // is requested. If it's not supported, then this event must not be handled.
641 [maxListeners=1, nodoc] static void onConfigureRequested(
642 ConfigureRequestedOptions options,
643 ProviderSuccessCallback successCallback,
644 ProviderErrorCallback errorCallback);
646 // Raised when showing a dialog for mounting a new file system is requested.
647 // If the extension/app is a file handler, then this event shouldn't be
648 // handled. Instead <code>onLaunched</code> should be handled in order to
649 // mount new file systems when a file is opened.
650 [maxListeners=1, nodoc] static void onMountRequested(
651 ProviderSuccessCallback successCallback,
652 ProviderErrorCallback errorCallback);
654 // Raised when setting a new directory watcher is requested. If an error
655 // occurs, then <code>errorCallback</code> must be called.
656 [maxListeners=1, nodoc] static void onAddWatcherRequested(
657 AddWatcherRequestedOptions options,
658 ProviderSuccessCallback successCallback,
659 ProviderErrorCallback errorCallback);
661 // Raised when the watcher should be removed. If an error occurs, then
662 // <code>errorCallback</code> must be called.
663 [maxListeners=1, nodoc] static void onRemoveWatcherRequested(
664 RemoveWatcherRequestedOptions options,
665 ProviderSuccessCallback successCallback,
666 ProviderErrorCallback errorCallback);