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 // fileManagerPrivate 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_manager_private_api_functions.h"]
9 namespace fileManagerPrivate
{
10 // Type of the mounted volume.
11 enum VolumeType
{ drive
, downloads
, removable
, archive
, cloud_device
, provided
,
14 // Device type. Available if this is removable volume.
15 enum DeviceType
{ usb
, sd
, optical
, mobile
, unknown
};
17 // Additional data about mount, for example, that the filesystem is not
19 enum MountCondition
{ unknown
, unsupported
};
21 // Is the event raised for mounting or unmounting.
22 enum MountCompletedEventType
{ mount
, unmount
};
24 // Event type that tells listeners if mount was successful or an error
25 // occurred. It also specifies the error.
26 enum MountCompletedStatus
{
30 error_invalid_argument
,
32 error_path_already_mounted
,
33 error_path_not_mounted
,
34 error_directory_creation_failed
,
35 error_invalid_mount_options
,
36 error_invalid_unmount_options
,
37 error_insufficient_permissions
,
38 error_mount_program_not_found
,
39 error_mount_program_failed
,
40 error_invalid_device_path
,
41 error_unknown_filesystem
,
42 error_unsupported_filesystem
,
43 error_invalid_archive
,
48 // File transfer progress state.
49 enum TransferState
{ added
, started
, in_progress
, completed
, failed
};
51 // Defines file transfer direction.
52 enum TransferType
{ upload
, download
};
54 // The type of the progress event.
55 enum CopyProgressStatusType
{
56 // "begin_copy_entry" is fired for each entry (file or directory) before
57 // starting the copy operation.
60 // "end_copy_entry" is fired for each entry (file or directory) after ending
61 // the copy operation.
64 // "progress" is fired periodically to report progress of a file copy (not
68 // "success" is fired after all entries are copied.
71 // "error" is fired when an error occurs.
75 // Specifies type of event that is raised.
76 enum FileWatchEventType
{ changed
, error
};
78 // Specifies type of change in file watch event.
79 enum ChangeType
{ add_or_update
, delete
};
81 // The type of entry that is needed. Default to ALL.
82 enum SearchType
{ EXCLUDE_DIRECTORIES
, SHARED_WITH_ME
, OFFLINE
, ALL
};
85 enum ZoomOperationType
{ in, out, reset
};
87 // Specifies how to open inspector.
89 // Open inspector for foreground page.
91 // Open inspector for foreground page and bring focus to the console.
93 // Open inspector for foreground page in inspect element mode.
95 // Open inspector for background page.
100 enum DeviceEventType
{
101 // If the device is disabled by preference.
103 // Device is removed.
105 // Device is hard unplugged.
115 // Drive sync error type.
116 // Keep it synced with DriveSyncErrorType in operation_observer.h.
117 enum DriveSyncErrorType
{
118 // Request to delete a file without permission.
119 delete_without_permission
,
120 // Google Drive is temporarily unavailable.
122 // Miscellaneous errors other than listed above.
126 // Result of task execution.
128 // The task execution succeeded and a new window/tab was opened.
130 // The task execution succeeded and the message was sent to the proper
133 // The task execution failed.
135 // No URL is specified.
140 enum DriveShareType
{
146 // ImageSet that represents multi-scale images.
147 dictionary ImageSet
{
149 DOMString scale1xUrl
;
151 DOMString scale2xUrl
;
154 // A file task represents an action that the file manager can perform over the
155 // currently selected files. See
156 // chrome/browser/chromeos/extensions/file_manager/file_tasks.h for details
157 // about how file tasks are handled.
158 dictionary FileTask
{
159 // The unique identifier of the task.
162 // Task title (ex. App name).
165 // Task icon url (from chrome://extension-icon/...)
168 // True if this task is a default task for the selected files.
172 // Additional entry properties.
173 dictionary EntryProperties
{
174 // Size of this file.
177 // Timestamp of entry update time, in milliseconds past the epoch.
178 double? lastModifiedTime
;
180 // URL to the Drive thumbnail image for this file.
181 DOMString? thumbnailUrl
;
183 // Width, if the entry is an image.
186 // Height, if the entry is an image.
189 // Rotation in clockwise degrees, if the entry is an image.
192 // True if the file is pinned in cache.
195 // True if the file is present in cache.
198 // True if the file is hosted on a server instead of local.
201 // True if the file is available offline.
202 boolean? isAvailableOffline
;
204 // True if the file is available on metered connection.
205 boolean? isAvailableWhenMetered
;
207 // URL to the custom icon for this file.
208 DOMString? customIconUrl
;
210 // Drive MIME type for this file.
211 DOMString? contentMimeType
;
213 // True if the entry is labeled as shared-with-me.
214 boolean? sharedWithMe
;
216 // True if the entry is labeled as shared (either from me to others or to me
221 // Information about total and remaining size on the mount point.
222 dictionary MountPointSizeStats
{
223 // Approximate total available size on the mount point.
226 // Approximate remaining available size on the mount point.
227 double remainingSize
;
230 // Information about a profile.
231 dictionary ProfileInfo
{
232 // Profile ID. This is currently e-mail address of the profile.
235 // The name of the profile for display purpose.
236 DOMString displayName
;
238 // True if the profile is the one running the current file manager instance.
239 // TODO(hirono): Remove the property because of the design change of
240 // multi-profile suuport.
241 boolean isCurrentProfile
;
244 // Mounted disk volume metadata.
245 dictionary VolumeMetadata
{
246 // ID of the disk volume.
249 // Id the provided file system (for proviided file systems).
250 DOMString? fileSystemId
;
252 // Extension providing this volume (for provided file systems).
253 DOMString? extensionId
;
255 // Label of the volume (if available).
256 DOMString? volumeLabel
;
258 // Description of the profile where the volume belongs.
259 // TODO(hirono): Remove the property because of the design change of
260 // multi-profile support.
263 // The path to the mounted device, archive file or network resource.
264 DOMString? sourcePath
;
266 // Type of the mounted volume.
267 VolumeType volumeType
;
269 // Device type. Available if this is removable volume.
270 DeviceType? deviceType
;
272 // Path to identify the device. This is consistent with DeviceEvent's
274 DOMString? devicePath
;
276 // Whether the device is parent or not (i.e. sdb rather than sdb1).
277 boolean? isParentDevice
;
279 // Flag that specifies if volume is mounted in read-only mode.
282 // Additional data about mount, for example, that the filesystem is not
284 MountCondition? mountCondition
;
287 // Payload data for mount event.
288 dictionary MountCompletedEvent
{
289 // Is the event raised for mounting or unmounting.
290 MountCompletedEventType eventType
;
292 // Event type that tells listeners if mount was successful or an error
293 // occurred. It also specifies the error.
294 MountCompletedStatus status
;
296 // Metadata of the mounted volume.
297 VolumeMetadata volumeMetadata
;
299 // Whether the volume event should be notified or not.
300 boolean shouldNotify
;
303 // Payload data for file transfer status updates.
304 dictionary FileTransferStatus
{
305 // URL of file that is being transfered.
308 // File transfer progress state.
309 TransferState transferState
;
311 // Defines file transfer direction.
312 TransferType transferType
;
314 // Approximated completed portion of the transfer operation.
317 // Approximated total size of transfer operation.
320 // Total number of jobs.
324 // Error during the drive sync.
325 dictionary DriveSyncErrorEvent
{
327 DriveSyncErrorType type
;
329 // File URL of the entry that the error happens to.
333 // Payload data for copy status progress updates.
334 dictionary CopyProgressStatus
{
335 // The type of the progress event.
336 CopyProgressStatusType type
;
338 // URL for the entry currently being copied. This field is particularly useful
339 // when a directory copy is initiated with startCopy(). The field tells what
340 // file/directory in that directory is now being copied.
341 DOMString? sourceUrl
;
343 // URL for the entry currently being created. This field is particularly
344 // useful when a directory copy is initiated with startCopy(). The field tells
345 // what file/directory in that directory is being created. Available only for
346 // end_copy_entry and success.
347 DOMString? destinationUrl
;
349 // Number of processed bytes for the file currently being copied. Available
350 // only for "progress" event. To show the progress bar, a caller needs to
351 // pre-compute the size of files being copied for the file (not directory).
354 // DOMError's name. Available only for ERROR event.
358 // Payload data for file transfer cancel response.
359 dictionary FileTransferCancelStatus
{
360 // URL of file that is being transfered.
363 // True if ongoing transfer operation was found and canceled.
367 // Detailed information of change.
368 dictionary FileChange
{
369 // URL of changed file (or directory).
372 // Type of change, which may be multiple.
373 ChangeType
[] changes
;
376 // Directory change notification details.
377 dictionary FileWatchEvent
{
378 // Specifies type of event that is raised.
379 FileWatchEventType eventType
;
381 // An Entry object which represents a changed directory. The conversion into a
382 // kind of FileEntry object is done in
383 // file_browser_handler_custom_bindings.cc. For filesystem API's Entry
385 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
387 [instanceOf
=Entry] object entry;
389 // Detailed change information of change. It would be null if the detailed
390 // information is not available.
391 FileChange
[]? changedFiles
;
394 dictionary Preferences
{
395 boolean driveEnabled
;
396 boolean cellularDisabled
;
397 boolean hostedFilesDisabled
;
398 boolean use24hourClock
;
399 boolean allowRedeemOffers
;
402 dictionary PreferencesChange
{
403 boolean? cellularDisabled
;
404 boolean? hostedFilesDisabled
;
407 dictionary SearchParams
{
411 // ID of the search feed that should be fetched next. Value passed here should
412 // be gotten from previous searchDrive call. It can be empty for the initial
417 dictionary SearchMetadataParams
{
418 // Search query. It can be empty. Any filename matches to an empty query.
421 // The type of entry that is needed. Default to ALL.
424 // Maximum number of results.
428 // Entry and Drive-related properties representing a search result.
429 dictionary SearchResult
{
430 // A dictionary object which represents a Drive file. This will be converted
431 // into a kind of FileEntry object. See
432 // file_browser_handler_custom_bindings.cc for details. For filesystem API's
433 // Entry interface, see <a
434 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
436 [instanceOf
=Entry] object entry;
438 // The base name of a Drive file that matched the search query. The matched
439 // sub strings are highlighted with <b> element. Meta characters are escaped
441 DOMString highlightedBaseName
;
444 dictionary DriveConnectionState
{
447 // Reasons of offline.
451 // Device event dispatched to listeners of onDeviceChaged. See also
452 // DeviceEventType to know when the event dispatched.
453 dictionary DeviceEvent
{
454 // Event type of the device event.
455 DeviceEventType type
;
456 // Device path to identify the device.
457 DOMString devicePath
;
460 // Callback that does not take arguments.
461 callback SimpleCallback
= void();
463 // |result| Result of the task execution.
464 callback ExecuteTaskCallback
= void(TaskResult result
);
466 // |tasks| The list of matched file URL patterns for this task.
467 callback GetFileTasksCallback
= void(FileTask
[] tasks
);
469 // |result| Hash containing the string assets.
470 callback GetStringsCallback
= void(object result
);
472 // |success| True when file watch is successfully added.
473 callback AddFileWatchCallback
= void(optional boolean success
);
475 // |success| True when file watch is successfully removed.
476 callback RemoveFileWatchCallback
= void(optional boolean success
);
478 // |fileSystem| A DOMFileSystem instance for local file system access. null if
479 // the caller has no appropriate permissions.
480 callback RequestFileSystemCallback
= void(optional object fileSystem
);
482 // |entryProperties| A dictionary containing properties of the requested
484 callback GetEntryPropertiesCallback
=
485 void(EntryProperties
[] entryProperties
);
487 // |sourcePath| Source path of the mount.
488 callback AddMountCallback
= void(DOMString sourcePath
);
490 // |volumeMetadataList| The list of VolumeMetadata representing mounted volumes.
491 callback GetVolumeMetadataListCallback
=
492 void(VolumeMetadata
[] volumeMetadataList
);
494 // |fileTransferCancelStatuses| The list of FileTransferCancelStatus.
495 callback CancelFileTransfersCallback
=
496 void(FileTransferCancelStatus
[] fileTransferCancelStatuses
);
498 // |copyId| ID of the copy task. Can be used to identify the progress, and to
500 callback StartCopyCallback
= void(long copyId
);
502 // |sizeStats| Name/value pairs of size stats. Will be undefined if stats could
503 // not be determined.
504 callback GetSizeStatsCallback
= void(optional MountPointSizeStats sizeStats
);
506 callback GetPreferencesCallback
= void(Preferences result
);
509 // |nextFeed| ID of the feed that contains next chunk of the search result.
510 // Should be sent to the next searchDrive request to perform
511 // incremental search.
512 callback SearchDriveCallback
=
513 void([instanceOf
=Entry] object[] entries
, DOMString nextFeed
);
515 callback SearchDriveMetadataCallback
= void(SearchResult
[] results
);
517 callback ZipSelectionCallback
= void(optional boolean success
);
519 callback GetDriveConnectionStateCallback
= void(DriveConnectionState result
);
521 // |result| true if the length is in the valid range, false otherwise.
522 callback ValidatePathNameLengthCallback
= void(boolean result
);
524 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
525 callback RequestAccessTokenCallback
= void(DOMString accessToken
);
527 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
528 callback RequestWebStoreAccessTokenCallback
= void(DOMString accessToken
);
531 callback GetUrlCallback
= void(DOMString url
);
533 // |profiles| List of profile information.
534 // |runningProfile| ID of the profile that runs the application instance.
535 // |showingProfile| ID of the profile that shows the application window.
536 callback GetProfilesCallback
= void(ProfileInfo
[] profiles
,
537 DOMString runningProfile
,
538 DOMString displayProfile
);
540 // |entryUrl| URL of an entry in a normal file system.
541 callback ResolveEntriesCallback
=
542 void([instanceOf
=FileEntry
] object[] entries
);
544 interface Functions
{
545 // Logout the current user for navigating to the re-authentication screen for
546 // the Google account.
547 static
void logoutUserForReauthentication
();
549 // Cancels file selection.
550 static
void cancelDialog
();
552 // Executes file browser task over selected files.
553 // |taskId| The unique identifier of task to execute.
554 // |fileUrls| Array of file URLs
556 static
void executeTask
(DOMString taskId
,
557 DOMString
[] fileUrls
,
558 optional ExecuteTaskCallback
callback);
560 // Sets the default task for the supplied MIME types and suffixes of the
561 // supplied file URLs. Lists of MIME types and URLs may contain duplicates.
562 // |taskId| The unique identifier of task to mark as default.
563 // |fileUrls| Array of selected file URLs to extract suffixes from.
564 // |mimeTypes| Array of selected file MIME types.
566 static
void setDefaultTask
(DOMString taskId
,
567 DOMString
[] fileUrls
,
568 optional DOMString
[] mimeTypes
,
569 optional SimpleCallback
callback);
571 // Gets the list of tasks that can be performed over selected files.
572 // |fileUrls| Array of selected file URLs
574 static
void getFileTasks
(DOMString
[] fileUrls
,
575 GetFileTasksCallback
callback);
577 // Gets localized strings and initialization data.
579 static
void getStrings
(GetStringsCallback
callback);
582 // |fileUrl| URL of file to watch
584 static
void addFileWatch
(DOMString fileUrl
, AddFileWatchCallback
callback);
586 // Removes file watch.
587 // |fileUrl| URL of watched file to remove
589 static
void removeFileWatch
(DOMString fileUrl
,
590 RemoveFileWatchCallback
callback);
592 // Requests access to a file system volume.
593 // |volumeId| The ID of the file system volume to request. The volume ID is
594 // delivered to JavaScript as part of VolumeMetadata. By specifying
595 // "compatible", this function behaves in the compatible mode, where the
596 // returned FileSystem object gives access to all file system volumes such
597 // as Downloads folder and removal media like SD cards (i.e. all volumes
598 // are provided inside the single FileSystem object). In the new
599 // "per-volume FileSystem object model" crbug.com/322305, a separate
600 // FileSystem object is created for each volume. "compatible" parameter
601 // will be removed once Files.app is switched to the per-volume FileSystem
604 static
void requestFileSystem
(DOMString volumeId
,
605 RequestFileSystemCallback
callback);
607 // Selects multiple files.
608 // |selectedPaths| Array of selected paths
609 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
611 static
void selectFiles
(DOMString
[] selectedPaths
,
612 boolean shouldReturnLocalPath
,
613 SimpleCallback
callback);
616 // |selectedPath| A selected path
617 // |index| Index of Filter
618 // |forOpening| true if paths are selected for opening. false if for saving.
619 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
621 static
void selectFile
(DOMString selectedPath
,
624 boolean shouldReturnLocalPath
,
625 SimpleCallback
callback);
627 // Requests additional properties for files.
628 // |fileUrls| list of URLs of files
630 static
void getEntryProperties
(
631 DOMString
[] fileUrls
,
632 GetEntryPropertiesCallback
callback);
634 // Pins/unpins a Drive file in the cache.
635 // |fileUrl| URL of a file to pin/unpin.
636 // |pin| Pass true to pin the file.
637 // |callback| Completion callback. $(ref:runtime.lastError) will be set if
638 // there was an error.
639 static
void pinDriveFile
(DOMString fileUrl
,
641 optional SimpleCallback
callback);
643 // Resolves file entries in the isolated file system and returns corresponding
644 // entries in the external file system mounted to Chrome OS file manager
645 // backend. If resolving entry fails, the entry will be just ignored and the
646 // corresponding entry does not appear in the result.
648 static
void resolveIsolatedEntries
(
649 [instanceOf
=FileEntry
] object[] entries
,
650 ResolveEntriesCallback
callback);
652 // Mount a resource or a file.
653 // |source| Mount point source. For compressed files it is relative file path
654 // within external file system
656 static
void addMount
(DOMString
source, AddMountCallback
callback);
658 // Unmounts a mounted resource.
659 // |volumeId| An ID of the volume.
660 static
void removeMount
(DOMString volumeId
);
662 // Get the list of mounted volumes.
664 static
void getVolumeMetadataList
(GetVolumeMetadataListCallback
callback);
666 // Cancels ongoing file transfers for selected files.
667 // |fileUrls| Array of files for which ongoing transfer should be canceled.
668 // If this is absent, all jobs are canceled.
670 static
void cancelFileTransfers
(optional DOMString
[] fileUrls
,
671 CancelFileTransfersCallback
callback);
673 // Starts to copy an entry. If the source is a directory, the copy is done
675 // |sourceUrl| URL of the source entry to be copied.
676 // |parent| URL of the destination directory.
677 // |newName| Name of the new entry. It shouldn't contain '/'.
678 // |callback| Completion callback.
679 static
void startCopy
(DOMString sourceUrl
,
682 StartCopyCallback
callback);
684 // Cancels the running copy task.
685 // |copyId| ID of the copy task to be cancelled.
686 // |callback| Completion callback of the cancel.
687 static
void cancelCopy
(long copyId
, optional SimpleCallback
callback);
689 // Retrieves total and remaining size of a mount point.
690 // |volumeId| ID of the volume to be checked.
692 static
void getSizeStats
(DOMString volumeId
, GetSizeStatsCallback
callback);
694 // Formats a mounted volume.
695 // |volumeId| ID of the volume to be formatted.
696 static
void formatVolume
(DOMString volumeId
);
698 // Retrieves file manager preferences.
700 static
void getPreferences
(GetPreferencesCallback
callback);
702 // Sets file manager preferences.
704 static
void setPreferences
(PreferencesChange changeInfo
);
706 // Performs drive content search.
709 static
void searchDrive
(SearchParams searchParams
,
710 SearchDriveCallback
callback);
712 // Performs drive metadata search.
715 static
void searchDriveMetadata
(SearchMetadataParams searchParams
,
716 SearchDriveMetadataCallback
callback);
718 // Create a zip file for the selected files.
719 // |dirURL| URL of the directory containing the selected files.
720 // |selectionUrls| URLs of the selected files. The files must be under the
721 // directory specified by dirURL.
722 // |destName| Name of the destination zip file. The zip file will be created
723 // under the directory specified by dirURL.
725 static
void zipSelection
(DOMString dirURL
,
726 DOMString
[] selectionUrls
,
728 optional ZipSelectionCallback
callback);
730 // Retrieves the state of the current drive connection.
732 static
void getDriveConnectionState
(GetDriveConnectionStateCallback
callback);
734 // Checks whether the path name length fits in the limit of the filesystem.
735 // |parent_directory_url| The URL of the parent directory entry.
736 // |name| The name of the file.
737 // |callback| Called back when the check is finished.
738 static
void validatePathNameLength
(DOMString parent_directory_url
,
740 ValidatePathNameLengthCallback
callback);
742 // Changes the zoom factor of the Files.app.
743 // |operation| Zooming mode.
744 static
void zoom
(ZoomOperationType operation
);
746 // Requests a Drive API OAuth2 access token.
747 // |refresh| Whether the token should be refetched instead of using the cached
750 static
void requestAccessToken
(boolean refresh
,
751 RequestAccessTokenCallback
callback);
753 // Requests a Webstore API OAuth2 access token.
755 static
void requestWebStoreAccessToken
(
756 RequestWebStoreAccessTokenCallback
callback);
758 // Requests a share dialog url for the specified file.
759 // |url| Url for the file.
761 static
void getShareUrl
(DOMString url
, GetUrlCallback
callback);
763 // Requests a download url to download the file contents.
764 // |url| Url for the file.
766 static
void getDownloadUrl
(DOMString url
, GetUrlCallback
callback);
768 // Requests to share drive files.
769 // |url| URL of a file to be shared.
770 // |shareType| Type of access that is getting granted.
771 static
void requestDriveShare
(DOMString url
,
772 DriveShareType shareType
,
773 SimpleCallback
callback);
775 // Requests to install a webstore item.
776 // |item_id| The id of the item to install.
777 // |silentInstallation| False to show installation prompt. True not to show.
779 static
void installWebstoreItem
(DOMString itemId
,
780 boolean silentInstallation
,
781 SimpleCallback
callback);
783 // Obtains a list of profiles that are logged-in.
784 static
void getProfiles
(GetProfilesCallback
callback);
786 // Moves the window to other user's desktop.
787 static
void visitDesktop
(DOMString profileId
,
788 optional SimpleCallback
callback);
790 // Opens inspector window.
791 // |type| InspectionType which specifies how to open inspector.
792 static
void openInspector
(InspectionType type
);
796 static
void onMountCompleted
(MountCompletedEvent event
);
798 static
void onFileTransfersUpdated
(FileTransferStatus event
);
800 static
void onCopyProgress
(long copyId
, CopyProgressStatus status
);
802 static
void onDirectoryChanged
(FileWatchEvent event
);
804 static
void onPreferencesChanged
();
806 static
void onDriveConnectionStatusChanged
();
808 static
void onDeviceChanged
(DeviceEvent event
);
810 static
void onDriveSyncError
(DriveSyncErrorEvent event
);