Properly attach InfoBarContainer when it is swapped to a new WebContents
[chromium-blink-merge.git] / chrome / common / extensions / api / file_system_provider.idl
blob0772f2c337a78cf5053da65f4d79d8a846b489e4
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 // Source of the file system data.
45 enum FileSystemSource {
46 // The file system is handling a file, eg. an archive file obtained via the
47 // <code>onLaunched</code> event and the <code>file_handlers</code> manifest
48 // entry.
49 FILE,
51 // The file system contents are fetched from an external device, such as a
52 // USB device, but not via <code>file_handlers</code>.
53 DEVICE,
55 // The file system is network based. The contents are obtained from another
56 // server or local network. Eg. cloud services.
57 NETWORK
60 // Represents metadata of a file or a directory.
61 dictionary EntryMetadata {
62 // True if it is a directory.
63 boolean isDirectory;
65 // Name of this entry (not full path name). Must not contain '/'. For root
66 // it must be empty.
67 DOMString name;
69 // File size in bytes.
70 double size;
72 // The last modified time of this entry.
73 [instanceOf=Date] object modificationTime;
75 // Mime type for the entry.
76 DOMString? mimeType;
78 // Thumbnail image as a data URI in either PNG, JPEG or WEBP format, at most
79 // 32 KB in size. Optional, but can be provided only when explicitly
80 // requested by the <code>onGetMetadataRequested</code> event.
81 DOMString? thumbnail;
84 // Represents a watcher.
85 dictionary Watcher {
86 // The path of the entry being observed.
87 DOMString entryPath;
89 // Whether watching should include all child entries recursively. It can be
90 // true for directories only.
91 boolean recursive;
93 // Tag used by the last notification for the watcher.
94 DOMString? lastTag;
97 // Represents an opened file.
98 dictionary OpenedFile {
99 // A request ID to be be used by consecutive read/write and close requests.
100 long openRequestId;
102 // The path of the opened file.
103 DOMString filePath;
105 // Whether the file was opened for reading or writing.
106 OpenFileMode mode;
109 // Represents a mounted file system.
110 dictionary FileSystemInfo {
111 // The identifier of the file system.
112 DOMString fileSystemId;
114 // A human-readable name for the file system.
115 DOMString displayName;
117 // Whether the file system supports operations which may change contents
118 // of the file system (such as creating, deleting or writing to files).
119 boolean writable;
121 // The maximum number of files that can be opened at once. If 0, then not
122 // limited.
123 long openedFilesLimit;
125 // List of currently opened files.
126 OpenedFile[] openedFiles;
128 // Source of the file system data.
129 FileSystemSource? source;
131 // Whether the file system supports the <code>tag</code> field for observing
132 // directories.
133 [nodoc] boolean? supportsNotifyTag;
135 // List of watchers.
136 [nodoc] Watcher[] watchers;
139 // Options for the <code>mount()</code> method.
140 dictionary MountOptions {
141 // The string indentifier of the file system. Must be unique per each
142 // extension.
143 DOMString fileSystemId;
145 // A human-readable name for the file system.
146 DOMString displayName;
148 // Whether the file system supports operations which may change contents
149 // of the file system (such as creating, deleting or writing to files).
150 boolean? writable;
152 // The maximum number of files that can be opened at once. If not specified,
153 // or 0, then not limited.
154 long? openedFilesLimit;
156 // Source of the file system data.
157 FileSystemSource? source;
159 // Whether the file system supports the <code>tag</code> field for observed
160 // directories. Required in order to enable the internal cache.
161 [nodoc] boolean? supportsNotifyTag;
164 // Options for the <code>unmount()</code> method.
165 dictionary UnmountOptions {
166 // The identifier of the file system to be unmounted.
167 DOMString fileSystemId;
170 // Options for the <code>onUnmountRequested()</code> event.
171 dictionary UnmountRequestedOptions {
172 // The identifier of the file system to be unmounted.
173 DOMString fileSystemId;
175 // The unique identifier of this request.
176 long requestId;
179 // Options for the <code>onGetMetadataRequested()</code> event.
180 dictionary GetMetadataRequestedOptions {
181 // The identifier of the file system related to this operation.
182 DOMString fileSystemId;
184 // The unique identifier of this request.
185 long requestId;
187 // The path of the entry to fetch metadata about.
188 DOMString entryPath;
190 // Set to <code>true</code> if the thumbnail is requested.
191 boolean thumbnail;
194 // Options for the <code>onReadDirectoryRequested()</code> event.
195 dictionary ReadDirectoryRequestedOptions {
196 // The identifier of the file system related to this operation.
197 DOMString fileSystemId;
199 // The unique identifier of this request.
200 long requestId;
202 // The path of the directory which contents are requested.
203 DOMString directoryPath;
206 // Options for the <code>onOpenFileRequested()</code> event.
207 dictionary OpenFileRequestedOptions {
208 // The identifier of the file system related to this operation.
209 DOMString fileSystemId;
211 // A request ID which will be used by consecutive read/write and close
212 // requests.
213 long requestId;
215 // The path of the file to be opened.
216 DOMString filePath;
218 // Whether the file will be used for reading or writing.
219 OpenFileMode mode;
222 // Options for the <code>onCloseFileRequested()</code> event.
223 dictionary CloseFileRequestedOptions {
224 // The identifier of the file system related to this operation.
225 DOMString fileSystemId;
227 // The unique identifier of this request.
228 long requestId;
230 // A request ID used to open the file.
231 long openRequestId;
234 // Options for the <code>onReadFileRequested()</code> event.
235 dictionary ReadFileRequestedOptions {
236 // The identifier of the file system related to this operation.
237 DOMString fileSystemId;
239 // The unique identifier of this request.
240 long requestId;
242 // A request ID used to open the file.
243 long openRequestId;
245 // Position in the file (in bytes) to start reading from.
246 double offset;
248 // Number of bytes to be returned.
249 double length;
252 // Options for the <code>onCreateDirectoryRequested()</code> event.
253 dictionary CreateDirectoryRequestedOptions {
254 // The identifier of the file system related to this operation.
255 DOMString fileSystemId;
257 // The unique identifier of this request.
258 long requestId;
260 // The path of the directory to be created.
261 DOMString directoryPath;
263 // Whether the operation is recursive (for directories only).
264 boolean recursive;
267 // Options for the <code>onDeleteEntryRequested()</code> event.
268 dictionary DeleteEntryRequestedOptions {
269 // The identifier of the file system related to this operation.
270 DOMString fileSystemId;
272 // The unique identifier of this request.
273 long requestId;
275 // The path of the entry to be deleted.
276 DOMString entryPath;
278 // Whether the operation is recursive (for directories only).
279 boolean recursive;
282 // Options for the <code>onCreateFileRequested()</code> event.
283 dictionary CreateFileRequestedOptions {
284 // The identifier of the file system related to this operation.
285 DOMString fileSystemId;
287 // The unique identifier of this request.
288 long requestId;
290 // The path of the file to be created.
291 DOMString filePath;
294 // Options for the <code>onCopyEntryRequested()</code> event.
295 dictionary CopyEntryRequestedOptions {
296 // The identifier of the file system related to this operation.
297 DOMString fileSystemId;
299 // The unique identifier of this request.
300 long requestId;
302 // The source path of the entry to be copied.
303 DOMString sourcePath;
305 // The destination path for the copy operation.
306 DOMString targetPath;
309 // Options for the <code>onMoveEntryRequested()</code> event.
310 dictionary MoveEntryRequestedOptions {
311 // The identifier of the file system related to this operation.
312 DOMString fileSystemId;
314 // The unique identifier of this request.
315 long requestId;
317 // The source path of the entry to be moved into a new place.
318 DOMString sourcePath;
320 // The destination path for the copy operation.
321 DOMString targetPath;
324 // Options for the <code>onTruncateRequested()</code> event.
325 dictionary TruncateRequestedOptions {
326 // The identifier of the file system related to this operation.
327 DOMString fileSystemId;
329 // The unique identifier of this request.
330 long requestId;
332 // The path of the file to be truncated.
333 DOMString filePath;
335 // Number of bytes to be retained after the operation completes.
336 double length;
339 // Options for the <code>onWriteFileRequested()</code> event.
340 dictionary WriteFileRequestedOptions {
341 // The identifier of the file system related to this operation.
342 DOMString fileSystemId;
344 // The unique identifier of this request.
345 long requestId;
347 // A request ID used to open the file.
348 long openRequestId;
350 // Position in the file (in bytes) to start writing the bytes from.
351 double offset;
353 // Buffer of bytes to be written to the file.
354 ArrayBuffer data;
357 // Options for the <code>onAbortRequested()</code> event.
358 dictionary AbortRequestedOptions {
359 // The identifier of the file system related to this operation.
360 DOMString fileSystemId;
362 // The unique identifier of this request.
363 long requestId;
365 // An ID of the request to be aborted.
366 long operationRequestId;
369 // Options for the <code>onAddWatcherRequested()</code> event.
370 dictionary AddWatcherRequestedOptions {
371 // The identifier of the file system related to this operation.
372 DOMString fileSystemId;
374 // The unique identifier of this request.
375 long requestId;
377 // The path of the entry to be observed.
378 DOMString entryPath;
380 // Whether observing should include all child entries recursively. It can be
381 // true for directories only.
382 boolean recursive;
385 // Options for the <code>onRemoveWatcherRequested()</code> event.
386 dictionary RemoveWatcherRequestedOptions {
387 // The identifier of the file system related to this operation.
388 DOMString fileSystemId;
390 // The unique identifier of this request.
391 long requestId;
393 // The path of the watched entry.
394 DOMString entryPath;
396 // Mode of the watcher.
397 boolean recursive;
400 // Information about a change happened to an entry within the observed
401 // directory (including the entry itself).
402 dictionary Change {
403 // The path of the changed entry.
404 DOMString entryPath;
406 // The type of the change which happened to the entry.
407 ChangeType changeType;
410 // Options for the <code>Notify()</code> method.
411 dictionary NotifyOptions {
412 // The identifier of the file system related to this change.
413 DOMString fileSystemId;
415 // The path of the observed entry.
416 DOMString observedPath;
418 // Mode of the observed entry.
419 boolean recursive;
421 // The type of the change which happened to the observed entry. If it is
422 // DELETED, then the observed entry will be automatically removed from the
423 // list of observed entries.
424 ChangeType changeType;
426 // List of changes to entries within the observed directory (including the
427 // entry itself)
428 Change[]? changes;
430 // Tag for the notification. Required if the file system was mounted with
431 // the <code>supportsNotifyTag</code> option. Note, that this flag is
432 // necessary to provide notifications about changes which changed even
433 // when the system was shutdown.
434 DOMString? tag;
437 // Options for the <code>onConfigureRequested()</code> event.
438 [nodoc] dictionary ConfigureRequestedOptions {
439 // The identifier of the file system to be configured.
440 DOMString fileSystemId;
442 // The unique identifier of this request.
443 long requestId;
446 // Callback to receive the result of getAll() function.
447 callback GetAllCallback = void(FileSystemInfo[] fileSystems);
449 // Callback to receive the result of get() function.
450 callback GetCallback = void(FileSystemInfo fileSystem);
452 // Callback to be called by the providing extension in case of a success.
453 [nocompile] callback ProviderSuccessCallback = void();
455 // Callback to be called by the providing extension in case of an error.
456 [nocompile] callback ProviderErrorCallback = void(ProviderError error);
458 // Success callback for the <code>onGetMetadataRequested</code> event.
459 [nocompile] callback MetadataCallback = void(
460 EntryMetadata metadata);
462 // Success callback for the <code>onReadDirectoryRequested</code> event. If
463 // more entries will be returned, then <code>hasMore</code> must be true, and
464 // it has to be called again with additional entries. If no more entries are
465 // available, then <code>hasMore</code> must be set to false.
466 [nocompile] callback EntriesCallback = void(
467 EntryMetadata[] entries, boolean hasMore);
469 // Success callback for the <code>onReadFileRequested</code> event. If more
470 // data will be returned, then <code>hasMore</code> must be true, and it
471 // has to be called again with additional entries. If no more data is
472 // available, then <code>hasMore</code> must be set to false.
473 [nocompile] callback FileDataCallback = void(
474 ArrayBuffer data, boolean hasMore);
476 // A generic result callback to indicate success or failure.
477 callback ResultCallback = void();
479 interface Functions {
480 // Mounts a file system with the given <code>fileSystemId</code> and <code>
481 // displayName</code>. <code>displayName</code> will be shown in the left
482 // panel of Files.app. <code>displayName</code> can contain any characters
483 // including '/', but cannot be an empty string. <code>displayName</code>
484 // must be descriptive but doesn't have to be unique. The <code>fileSystemId
485 // </code> must not be an empty string.
487 // Depending on the type of the file system being mounted, the <code>source
488 // </code> option must be set appropriately.
490 // In case of an error, <code>chrome.runtime.lastError</code> will be set
491 // will a corresponding error code.
492 static void mount(MountOptions options,
493 optional ResultCallback callback);
495 // Unmounts a file system with the given <code>fileSystemId</code>. It
496 // must be called after <code>onUnmountRequested</code> is invoked. Also,
497 // the providing extension can decide to perform unmounting if not requested
498 // (eg. in case of lost connection, or a file error).
500 // In case of an error, <code>chrome.runtime.lastError</code> will be set
501 // will a corresponding error code.
502 static void unmount(UnmountOptions options,
503 optional ResultCallback callback);
505 // Returns all file systems mounted by the extension.
506 static void getAll(GetAllCallback callback);
508 // Returns information about a file system with the passed <code>
509 // fileSystemId</code>.
510 static void get(DOMString fileSystemId, GetCallback callback);
512 // Notifies about changes in the watched directory at <code>
513 // observedPath</code> in <code>recursive</code mode. If the file system is
514 // mounted with <code>supportsNofityTag</code>, then <code>tag</code> must
515 // be provided, and all changes since the last notification always reported,
516 // even if the system was shutdown. The last tag can be obtained with <code>
517 // getAll()</code>. Note, that <code>tag</code> is required in order to
518 // enable the internal cache.
520 // Value of <code>tag</code> can be any string which is unique per call,
521 // so it's possible to identify the last registered notification. Eg. if
522 // the providing extension starts after a reboot, and the last registered
523 // notification's tag is equal to "123", then it should call notify() for
524 // all changes which happened since the change tagged as "123". It cannot
525 // be an empty string.
527 // Not all providers are able to provide a tag, but if the file system has
528 // a changelog, then the tag can be eg. a change number, or a revision
529 // number.
531 // Note that if a parent directory is removed, then all descendant entries
532 // are also removed, and if they are watched, then the API must be notified
533 // about the fact. Also, if a directory is renamed, then all descendant
534 // entries are in fact removed, as there is no entry under their original
535 // paths anymore.
537 // In case of an error, <code>chrome.runtime.lastError</code> will be set
538 // will a corresponding error code.
539 [nodoc] static void notify(NotifyOptions options,
540 optional ResultCallback callback);
543 interface Events {
544 // Raised when unmounting for the file system with the <code>fileSystemId
545 // </code> identifier is requested. In the response, the <code>unmount
546 // </code> API method must be called together with <code>successCallback
547 // </code>. If unmounting is not possible (eg. due to a pending operation),
548 // then <code>errorCallback</code> must be called.
549 [maxListeners=1] static void onUnmountRequested(
550 UnmountRequestedOptions options,
551 ProviderSuccessCallback successCallback,
552 ProviderErrorCallback errorCallback);
554 // Raised when metadata of a file or a directory at <code>entryPath</code>
555 // is requested. The metadata must be returned with the <code>
556 // successCallback</code> call. In case of an error, <code>errorCallback
557 // </code> must be called.
558 [maxListeners=1] static void onGetMetadataRequested(
559 GetMetadataRequestedOptions options,
560 MetadataCallback successCallback,
561 ProviderErrorCallback errorCallback);
563 // Raised when contents of a directory at <code>directoryPath</code> are
564 // requested. The results must be returned in chunks by calling the <code>
565 // successCallback</code> several times. In case of an error, <code>
566 // errorCallback</code> must be called.
567 [maxListeners=1] static void onReadDirectoryRequested(
568 ReadDirectoryRequestedOptions options,
569 EntriesCallback successCallback,
570 ProviderErrorCallback errorCallback);
572 // Raised when opening a file at <code>filePath</code> is requested. If the
573 // file does not exist, then the operation must fail. Maximum number of
574 // files opened at once can be specified with <code>MountOptions</code>.
575 [maxListeners=1] static void onOpenFileRequested(
576 OpenFileRequestedOptions options,
577 ProviderSuccessCallback successCallback,
578 ProviderErrorCallback errorCallback);
580 // Raised when opening a file previously opened with <code>openRequestId
581 // </code> is requested to be closed.
582 [maxListeners=1] static void onCloseFileRequested(
583 CloseFileRequestedOptions options,
584 ProviderSuccessCallback successCallback,
585 ProviderErrorCallback errorCallback);
587 // Raised when reading contents of a file opened previously with <code>
588 // openRequestId</code> is requested. The results must be returned in
589 // chunks by calling <code>successCallback</code> several times. In case of
590 // an error, <code>errorCallback</code> must be called.
591 [maxListeners=1] static void onReadFileRequested(
592 ReadFileRequestedOptions options,
593 FileDataCallback successCallback,
594 ProviderErrorCallback errorCallback);
596 // Raised when creating a directory is requested. The operation must fail
597 // with the EXISTS error if the target directory already exists.
598 // If <code>recursive</code> is true, then all of the missing directories
599 // on the directory path must be created.
600 [maxListeners=1] static void onCreateDirectoryRequested(
601 CreateDirectoryRequestedOptions options,
602 ProviderSuccessCallback successCallback,
603 ProviderErrorCallback errorCallback);
605 // Raised when deleting an entry is requested. If <code>recursive</code> is
606 // true, and the entry is a directory, then all of the entries inside
607 // must be recursively deleted as well.
608 [maxListeners=1] static void onDeleteEntryRequested(
609 DeleteEntryRequestedOptions options,
610 ProviderSuccessCallback successCallback,
611 ProviderErrorCallback errorCallback);
613 // Raised when creating a file is requested. If the file already exists,
614 // then <code>errorCallback</code> must be called with the <code>EXISTS
615 // </code> error code.
616 [maxListeners=1] static void onCreateFileRequested(
617 CreateFileRequestedOptions options,
618 ProviderSuccessCallback successCallback,
619 ProviderErrorCallback errorCallback);
621 // Raised when copying an entry (recursively if a directory) is requested.
622 // If an error occurs, then <code>errorCallback</code> must be called.
623 [maxListeners=1] static void onCopyEntryRequested(
624 CopyEntryRequestedOptions options,
625 ProviderSuccessCallback successCallback,
626 ProviderErrorCallback errorCallback);
628 // Raised when moving an entry (recursively if a directory) is requested.
629 // If an error occurs, then <code>errorCallback</code> must be called.
630 [maxListeners=1] static void onMoveEntryRequested(
631 MoveEntryRequestedOptions options,
632 ProviderSuccessCallback successCallback,
633 ProviderErrorCallback errorCallback);
635 // Raised when truncating a file to a desired length is requested.
636 // If an error occurs, then <code>errorCallback</code> must be called.
637 [maxListeners=1] static void onTruncateRequested(
638 TruncateRequestedOptions options,
639 ProviderSuccessCallback successCallback,
640 ProviderErrorCallback errorCallback);
642 // Raised when writing contents to a file opened previously with <code>
643 // openRequestId</code> is requested.
644 [maxListeners=1] static void onWriteFileRequested(
645 WriteFileRequestedOptions options,
646 ProviderSuccessCallback successCallback,
647 ProviderErrorCallback errorCallback);
649 // Raised when aborting an operation with <code>operationRequestId</code>
650 // is requested. The operation executed with <code>operationRequestId</code>
651 // must be immediately stopped and <code>successCallback</code> of this
652 // abort request executed. If aborting fails, then <code>errorCallback
653 // </code> must be called. Note, that callbacks of the aborted operation
654 // must not be called, as they will be ignored. Despite calling <code>
655 // errorCallback</code>, the request may be forcibly aborted.
656 [maxListeners=1] static void onAbortRequested(
657 AbortRequestedOptions options,
658 ProviderSuccessCallback successCallback,
659 ProviderErrorCallback errorCallback);
661 // Raised when showing a configuration dialog for <code>fileSystemId</code>
662 // is requested. If it's not supported, then this event must not be handled.
663 [maxListeners=1, nodoc] static void onConfigureRequested(
664 ConfigureRequestedOptions options,
665 ProviderSuccessCallback successCallback,
666 ProviderErrorCallback errorCallback);
668 // Raised when showing a dialog for mounting a new file system is requested.
669 // If the extension/app is a file handler, then this event shouldn't be
670 // handled. Instead <code>onLaunched</code> should be handled in order to
671 // mount new file systems when a file is opened.
672 [maxListeners=1, nodoc] static void onMountRequested(
673 ProviderSuccessCallback successCallback,
674 ProviderErrorCallback errorCallback);
676 // Raised when setting a new directory watcher is requested. If an error
677 // occurs, then <code>errorCallback</code> must be called.
678 [maxListeners=1, nodoc] static void onAddWatcherRequested(
679 AddWatcherRequestedOptions options,
680 ProviderSuccessCallback successCallback,
681 ProviderErrorCallback errorCallback);
683 // Raised when the watcher should be removed. If an error occurs, then
684 // <code>errorCallback</code> must be called.
685 [maxListeners=1, nodoc] static void onRemoveWatcherRequested(
686 RemoveWatcherRequestedOptions options,
687 ProviderSuccessCallback successCallback,
688 ProviderErrorCallback errorCallback);