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 // fileBrowserPrivate API.
6 // This is a private API used by the file browser of ChromeOS.
7 [platforms=("chromeos"),
8 implemented_in="chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_functions.h"]
9 namespace fileBrowserPrivate {
10 // Type of the mounted volume.
11 enum VolumeType { drive, downloads, removable, archive, cloud_device };
13 // Device type. Available if this is removable volume.
14 enum DeviceType { usb, sd, optical, mobile, unknown };
16 // Additional data about mount, for example, that the filesystem is not
18 enum MountCondition { unknown, unsupported };
20 // Is the event raised for mounting or unmounting.
21 enum MountCompletedEventType { mount, unmount };
23 // Event type that tells listeners if mount was successful or an error
24 // occurred. It also specifies the error.
25 enum MountCompletedStatus {
29 error_invalid_argument,
31 error_path_already_mounted,
32 error_path_not_mounted,
33 error_directory_creation_failed,
34 error_invalid_mount_options,
35 error_invalid_unmount_options,
36 error_insufficient_permissions,
37 error_mount_program_not_found,
38 error_mount_program_failed,
39 error_invalid_device_path,
40 error_unknown_filesystem,
41 error_unsuported_filesystem,
42 error_invalid_archive,
47 // File transfer progress state.
48 enum TransferState { started, in_progress, completed, failed };
50 // Defines file transfer direction.
51 enum TransferType { upload, download };
53 // The type of the progress event.
54 enum CopyProgressStatusType {
55 // "begin_copy_entry" is fired for each entry (file or directory) before
56 // starting the copy operation.
59 // "end_copy_entry" is fired for each entry (file or directory) after ending
60 // the copy operation.
63 // "progress" is fired periodically to report progress of a file copy (not
67 // "success" is fired after all entries are copied.
70 // "error" is fired when an error occurs.
74 // Specifies type of event that is raised.
75 enum FileWatchEventType { changed, error };
77 // The type of entry that is needed. Default to ALL.
78 enum SearchType { EXCLUDE_DIRECTORIES, SHARED_WITH_ME, OFFLINE, ALL };
81 enum ZoomOperationType { in, out, reset };
84 enum DeviceEventType {
87 // If the device is disabled by preference, the disabled event is published
88 // instead of the added event.
90 // Device is added, but scan for the device is canceled. The event is
91 // published after the added event.
103 // Drive sync error type.
104 // Keep it synced with DriveSyncErrorType in operation_observer.h.
105 enum DriveSyncErrorType {
106 // Request to delete a file without permission.
107 delete_without_permission,
108 // Google Drive is temporarily unavailable.
110 // Miscellaneous errors other than listed above.
114 // A file task represents an action that the file manager can perform over the
115 // currently selected files. See
116 // chrome/browser/chromeos/extensions/file_manager/file_tasks.h for details
117 // about how file tasks are handled.
118 dictionary FileTask {
119 // The unique identifier of the task.
122 // Task title (ex. App name).
125 // Task icon url (from chrome://extension-icon/...)
128 // True if this task is a default task for the selected files.
132 // Drive file properties.
133 dictionary DriveEntryProperties {
134 // URL to the Drive thumbnail image for this file.
135 DOMString? thumbnailUrl;
137 // Width, if the entry is an image.
140 // Height, if the entry is an image.
143 // Rotation in clockwise degrees, if the entry is an image.
146 // True if the file is pinned in Drive cache.
149 // True if the file is present in Drive cache.
152 // True if the file is hosted on a Drive server instead of local.
155 // URL to the custom icon for this file.
156 DOMString? customIconUrl;
158 // Drive MIME type for this file.
159 DOMString? contentMimeType;
161 // True if the entry is labeled as shared-with-me.
162 boolean? sharedWithMe;
164 // True if the entry is labeled as shared (either from me to others or to me
169 // Information about total and remaining size on the mount point.
170 dictionary MountPointSizeStats {
171 // Approximate total available size on the mount point.
174 // Approximate remaining available size on the mount point.
175 double remainingSize;
178 // Information about a profile.
179 dictionary ProfileInfo {
180 // Profile ID. This is currently e-mail address of the profile.
183 // The name of the profile for display purpose.
184 DOMString displayName;
186 // True if the profile is the one running the current file manager instance.
187 // TODO(hirono): Remove the property because of the design change of
188 // multi-profile suuport.
189 boolean isCurrentProfile;
191 // Data URI of profile image;
195 // Mounted disk volume metadata.
196 dictionary VolumeMetadata {
197 // ID of the disk volume.
200 // Description of the profile where the volume belongs.
201 // TODO(hirono): Remove the property because of the design change of
202 // multi-profile suuport.
205 // Disk volume mount point path.
208 // The path to the mounted device, archive file or network resource.
209 DOMString? sourcePath;
211 // Type of the mounted volume.
212 VolumeType volumeType;
214 // Device type. Available if this is removable volume.
215 DeviceType? deviceType;
217 // Path to identify the device. This is consistent with DeviceEvent's
219 DOMString? devicePath;
221 // Label of the device.
222 DOMString? deviceLabel;
224 // Whether the device is parent or not (i.e. sdb rather than sdb1).
225 boolean? isParentDevice;
227 // Flag that specifies if volume is mounted in read-only mode.
230 // Additional data about mount, for example, that the filesystem is not
232 MountCondition? mountCondition;
235 // Payload data for mount event.
236 dictionary MountCompletedEvent {
237 // Is the event raised for mounting or unmounting.
238 MountCompletedEventType eventType;
240 // Event type that tells listeners if mount was successful or an error
241 // occurred. It also specifies the error.
242 MountCompletedStatus status;
244 // Metadata of the mounted volume.
245 VolumeMetadata volumeMetadata;
247 // Whether it is remount or not.
248 boolean isRemounting;
251 // Payload data for file transfer status updates.
252 dictionary FileTransferStatus {
253 // URL of file that is being transfered.
256 // File transfer progress state.
257 TransferState transferState;
259 // Defines file transfer direction.
260 TransferType transferType;
262 // Approximated completed portion of the transfer operation.
265 // Approximated total size of transfer operation.
269 // Error during the drive sync.
270 dictionary DriveSyncErrorEvent {
272 DriveSyncErrorType type;
274 // File URL of the entry that the error happens to.
278 // Payload data for copy status progress updates.
279 dictionary CopyProgressStatus {
280 // The type of the progress event.
281 CopyProgressStatusType type;
283 // URL for the entry currently being copied. This field is particularly useful
284 // when a directory copy is initiated with startCopy(). The field tells what
285 // file/directory in that directory is now being copied.
286 DOMString? sourceUrl;
288 // URL for the entry currently being created. This field is particularly
289 // useful when a directory copy is initiated with startCopy(). The field tells
290 // what file/directory in that directory is being created. Available only for
291 // end_copy_entry and success.
292 DOMString? destinationUrl;
294 // Number of processed bytes for the file currently being copied. Available
295 // only for "progress" event. To show the progress bar, a caller needs to
296 // pre-compute the size of files being copied for the file (not directory).
299 // FileError's code of the error. Available only for ERROR event.
303 // Payload data for file transfer cancel response.
304 dictionary FileTransferCancelStatus {
305 // URL of file that is being transfered.
308 // True if ongoing transfer operation was found and canceled.
312 // Directory change notification details.
313 dictionary FileWatchEvent {
314 // Specifies type of event that is raised.
315 FileWatchEventType eventType;
317 // An Entry object which represents a changed directory. The conversion into a
318 // kind of FileEntry object is done in
319 // file_browser_handler_custom_bindings.cc. For filesystem API's Entry
321 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
323 [instanceOf=Entry] object entry;
326 dictionary Preferences {
327 boolean driveEnabled;
328 boolean cellularDisabled;
329 boolean hostedFilesDisabled;
330 boolean use24hourClock;
331 boolean allowRedeemOffers;
334 dictionary PreferencesChange {
335 boolean? cellularDisabled;
336 boolean? hostedFilesDisabled;
339 dictionary SearchParams {
343 // ID of the search feed that should be fetched next. Value passed here should
344 // be gotten from previous searchDrive call. It can be empty for the initial
349 dictionary SearchMetadataParams {
350 // Search query. It can be empty. Any filename matches to an empty query.
353 // The type of entry that is needed. Default to ALL.
356 // Maximum number of results.
360 // Entry and Drive-related properties representing a search result.
361 dictionary SearchResult {
362 // A dictionary object which represents a Drive file. This will be converted
363 // into a kind of FileEntry object. See
364 // file_browser_handler_custom_bindings.cc for details. For filesystem API's
365 // Entry interface, see <a
366 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
368 [instanceOf=Entry] object entry;
370 // The base name of a Drive file that matched the search query. The matched
371 // sub strings are highlighted with <b> element. Meta characters are escaped
373 DOMString highlightedBaseName;
376 dictionary DriveConnectionState {
379 // Reasons of offline.
383 // Device event dispatched to listeners of onDeviceChaged. See also
384 // DeviceEventType to know when the event dispatched.
385 dictionary DeviceEvent {
386 // Event type of the device event.
387 DeviceEventType type;
388 // Device path to identify the device.
389 DOMString devicePath;
392 // Callback that does not take arguments.
393 callback SimpleCallback = void();
395 // |success| True of task execution was successfully initiated.
396 callback ExecuteTaskCallback = void(optional boolean success);
398 // |tasks| The list of matched file URL patterns for this task.
399 callback GetFileTasksCallback = void(FileTask[] tasks);
401 // |result| Hash containing the string assets.
402 callback GetStringsCallback = void(object result);
404 // |success| True when file watch is successfully added.
405 callback AddFileWatchCallback = void(optional boolean success);
407 // |success| True when file watch is successfully removed.
408 callback RemoveFileWatchCallback = void(optional boolean success);
410 // |fileSystem| A DOMFileSystem instance for local file system access. null if
411 // |the caller has no appropriate permissions.
412 callback RequestFileSystemCallback = void(optional object fileSystem);
414 // |fileProperties| A dictionary containing properties of the requested entry.
415 callback GetDriveEntryPropertiesCallback =
416 void(DriveEntryProperties fileProperties);
418 // |localFilePaths| An array of the local file paths for the requested files,
419 // one entry for each file in fileUrls.
420 callback GetDriveFilesCallback = void(DOMString[] localFilePaths);
422 // |sourcePath| Source path of the mount.
423 callback AddMountCallback = void(DOMString sourcePath);
425 // |volumeMetadataList| The list of VolumeMetadata representing mounted volumes.
426 callback GetVolumeMetadataListCallback =
427 void(VolumeMetadata[] volumeMetadataList);
429 // |fileTransferCancelStatuses| The list of FileTransferCancelStatus.
430 callback CancelFileTransfersCallback =
431 void(FileTransferCancelStatus[] fileTransferCancelStatuses);
433 // |copyId| ID of the copy task. Can be used to identify the progress, and to
435 callback StartCopyCallback = void(long copyId);
437 // |sizeStats| Name/value pairs of size stats. Will be undefined if stats could
438 // not be determined.
439 callback GetSizeStatsCallback = void(optional MountPointSizeStats sizeStats);
441 callback GetPreferencesCallback = void(Preferences result);
444 // |nextFeed| ID of the feed that contains next chunk of the search result.
445 // Should be sent to the next searchDrive request to perform
446 // incremental search.
447 callback SearchDriveCallback =
448 void([instanceOf=Entry] object[] entries, DOMString nextFeed);
450 callback SearchDriveMetadataCallback = void(SearchResult[] results);
452 callback ZipSelectionCallback = void(optional boolean success);
454 callback GetDriveConnectionStateCallback = void(DriveConnectionState result);
456 // |result| true if the length is in the valid range, false otherwise.
457 callback ValidatePathNameLengthCallback = void(boolean result);
459 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
460 callback RequestAccessTokenCallback = void(DOMString accessToken);
462 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
463 callback RequestWebStoreAccessTokenCallback = void(DOMString accessToken);
465 // |shareUrl| Share Url for the sharing dialog.
466 callback GetShareUrlCallback = void(DOMString shareUrl);
468 // |profiles| List of profile information.
469 // |runningProfile| ID of the profile that runs the application instance.
470 // |showingProfile| ID of the profile that shows the application window.
471 callback GetProfilesCallback = void(ProfileInfo[] profiles,
472 DOMString runningProfile,
473 DOMString displayProfile);
475 interface Functions {
476 // Logout the current user for navigating to the re-authentication screen for
477 // the Google account.
478 static void logoutUserForReauthentication();
480 // Cancels file selection.
481 static void cancelDialog();
483 // Executes file browser task over selected files.
484 // |taskId| The unique identifier of task to execute.
485 // |fileUrls| Array of file URLs
487 static void executeTask(DOMString taskId,
488 DOMString[] fileUrls,
489 optional ExecuteTaskCallback callback);
491 // Sets the default task for the supplied MIME types and suffixes of the
492 // supplied file URLs. Lists of MIME types and URLs may contain duplicates.
493 // |taskId| The unique identifier of task to mark as default.
494 // |fileUrls| Array of selected file URLs to extract suffixes from.
495 // |mimeTypes| Array of selected file MIME types.
497 static void setDefaultTask(DOMString taskId,
498 DOMString[] fileUrls,
499 optional DOMString[] mimeTypes,
500 optional SimpleCallback callback);
502 // Gets the list of tasks that can be performed over selected files.
503 // |fileUrls| Array of selected file URLs
504 // |mimeTypes| Array of selected file MIME types
506 static void getFileTasks(DOMString[] fileUrls,
507 DOMString[] mimeTypes,
508 GetFileTasksCallback callback);
510 // Gets localized strings and initialization data.
512 static void getStrings(GetStringsCallback callback);
515 // |fileUrl| URL of file to watch
517 static void addFileWatch(DOMString fileUrl, AddFileWatchCallback callback);
519 // Removes file watch.
520 // |fileUrl| URL of watched file to remove
522 static void removeFileWatch(DOMString fileUrl,
523 RemoveFileWatchCallback callback);
525 // Requests access to a file system volume.
526 // |volumeId| The ID of the file system volume to request. The volume ID is
527 // delivered to JavaScript as part of VolumeMetadata. By specifying
528 // "compatible", this function behaves in the compatible mode, where the
529 // returned FileSystem object gives access to all file system volumes such
530 // as Downloads folder and removal media like SD cards (i.e. all volumes
531 // are provided inside the single FileSystem object). In the new
532 // "per-volume FileSystem object model" crbug.com/322305, a separate
533 // FileSystem object is created for each volume. "compatible" parameter
534 // will be removed once Files.app is switched to the per-volume FileSystem
537 static void requestFileSystem(DOMString volumeId,
538 RequestFileSystemCallback callback);
540 // Selects multiple files.
541 // |selectedPaths| Array of selected paths
542 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
544 static void selectFiles(DOMString[] selectedPaths,
545 boolean shouldReturnLocalPath,
546 SimpleCallback callback);
549 // |selectedPath| A selected path
550 // |index| Index of Filter
551 // |forOpening| true if paths are selected for opening. false if for saving.
552 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
554 static void selectFile(DOMString selectedPath,
557 boolean shouldReturnLocalPath,
558 SimpleCallback callback);
560 // Requests Drive file properties for a file.
561 // |fileUrl| URL of a file
563 static void getDriveEntryProperties(DOMString fileUrl,
564 GetDriveEntryPropertiesCallback callback);
566 // Pins/unpins a Drive file in the cache.
567 // |fileUrl| URL of a file to pin/unpin.
568 // |pin| Pass true to pin the file.
569 // |callback| Completion callback. $ref:runtime.lastError will be set if there
571 static void pinDriveFile(DOMString fileUrl,
573 optional SimpleCallback callback);
576 // |fileUrls| Array of Drive file URLs to get.
578 static void getDriveFiles(DOMString[] fileUrls,
579 GetDriveFilesCallback callback);
581 // Mount a resource or a file.
582 // |source| Mount point source. For compressed files it is relative file path
583 // within external file system
585 static void addMount(DOMString source, AddMountCallback callback);
587 // Unmounts a mounted resource.
588 // |mountPath| A path of the mount.
589 static void removeMount(DOMString mountPath);
591 // Get the list of mounted volumes.
593 static void getVolumeMetadataList(GetVolumeMetadataListCallback callback);
595 // Cancels ongoing file transfers for selected files.
596 // |fileUrls| Array of files for which ongoing transfer should be canceled.
598 static void cancelFileTransfers(DOMString[] fileUrls,
599 CancelFileTransfersCallback callback);
601 // Starts to copy an entry. If the source is a directory, the copy is done
603 // |sourceUrl| URL of the source entry to be copied.
604 // |parent| URL of the destination directory.
605 // |newName| Name of the new entry. It shouldn't contain '/'.
606 // |callback| Completion callback.
607 static void startCopy(DOMString sourceUrl,
610 StartCopyCallback callback);
612 // Cancels the running copy task.
613 // |copyId| ID of the copy task to be cancelled.
614 // |callback| Completion callback of the cancel.
615 static void cancelCopy(long copyId, optional SimpleCallback callback);
617 // Retrieves total and remaining size of a mount point.
618 // |mountPath| Mount point path.
620 static void getSizeStats(DOMString mountPath, GetSizeStatsCallback callback);
622 // Formats a mounted volume.
623 // |volumeId| ID of the volume to be formatted.
624 static void formatVolume(DOMString volumeId);
626 // Retrieves file manager preferences.
628 static void getPreferences(GetPreferencesCallback callback);
630 // Sets file manager preferences.
632 static void setPreferences(PreferencesChange changeInfo);
634 // Performs drive content search.
637 static void searchDrive(SearchParams searchParams,
638 SearchDriveCallback callback);
640 // Performs drive metadata search.
643 static void searchDriveMetadata(SearchMetadataParams searchParams,
644 SearchDriveMetadataCallback callback);
646 // Create a zip file for the selected files.
647 // |dirURL| URL of the directory containing the selected files.
648 // |selectionUrls| URLs of the selected files. The files must be under the
649 // directory specified by dirURL.
650 // |destName| Name of the destination zip file. The zip file will be created
651 // under the directory specified by dirURL.
653 static void zipSelection(DOMString dirURL,
654 DOMString[] selectionUrls,
656 optional ZipSelectionCallback callback);
658 // Retrieves the state of the current drive connection.
660 static void getDriveConnectionState(GetDriveConnectionStateCallback callback);
662 // Checks whether the path name length fits in the limit of the filesystem.
663 // |parent_directory_url| The URL of the parent directory entry.
664 // |name| The name of the file.
665 // |callback| Called back when the check is finished.
666 static void validatePathNameLength(DOMString parent_directory_url,
668 ValidatePathNameLengthCallback callback);
670 // Changes the zoom factor of the Files.app.
671 // |operation| Zooming mode.
672 static void zoom(ZoomOperationType operation);
674 // Requests a Drive API OAuth2 access token.
675 // |refresh| Whether the token should be refetched instead of using the cached
678 static void requestAccessToken(boolean refresh,
679 RequestAccessTokenCallback callback);
681 // Requests a Webstore API OAuth2 access token.
683 static void requestWebStoreAccessToken(
684 RequestWebStoreAccessTokenCallback callback);
686 // Requests a share dialog url for the specified file.
687 // |url| Url for the file.
689 static void getShareUrl(DOMString url, GetShareUrlCallback callback);
691 // Requests to install a webstore item.
692 // |item_id| The id of the item to install.
694 static void installWebstoreItem(DOMString item_id,
695 SimpleCallback callback);
697 // Obtains a list of profiles that are logged-in.
698 static void getProfiles(GetProfilesCallback callback);
700 // Moves the window to other user's desktop.
701 static void visitDesktop(DOMString profileId,
702 SimpleCallback callback);
706 static void onMountCompleted(MountCompletedEvent event);
708 static void onFileTransfersUpdated(FileTransferStatus[] event);
710 static void onCopyProgress(long copyId, CopyProgressStatus status);
712 static void onDirectoryChanged(FileWatchEvent event);
714 static void onPreferencesChanged();
716 static void onDriveConnectionStatusChanged();
718 static void onDeviceChanged(DeviceEvent event);
720 static void onDriveSyncError(DriveSyncErrorEvent event);