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.
171 // True if this task is from generic file handler. Generic file handler is a
172 // file handler which handles any type of files (e.g. extensions: ["*"],
173 // types: ["*/*"]). Partial wild card (e.g. types: ["image/*"]) is not
174 // generic file handler.
175 boolean isGenericFileHandler
;
178 // Additional entry properties.
179 dictionary EntryProperties
{
180 // Size of this file.
183 // Timestamp of entry update time, in milliseconds past the epoch.
184 double? lastModifiedTime
;
186 // URL to the Drive thumbnail image for this file.
187 DOMString? thumbnailUrl
;
189 // Width, if the entry is an image.
192 // Height, if the entry is an image.
195 // Rotation in clockwise degrees, if the entry is an image.
198 // True if the file is pinned in cache.
201 // True if the file is present in cache.
204 // True if the file is hosted on a server instead of local.
207 // True if the file is available offline.
208 boolean? isAvailableOffline
;
210 // True if the file is available on metered connection.
211 boolean? isAvailableWhenMetered
;
213 // URL to the custom icon for this file.
214 DOMString? customIconUrl
;
216 // Drive MIME type for this file.
217 DOMString? contentMimeType
;
219 // True if the entry is labeled as shared-with-me.
220 boolean? sharedWithMe
;
222 // True if the entry is labeled as shared (either from me to others or to me
226 // External file URL to open the file in browser.
227 DOMString? externalFileUrl
;
230 // Information about total and remaining size on the mount point.
231 dictionary MountPointSizeStats
{
232 // Approximate total available size on the mount point.
235 // Approximate remaining available size on the mount point.
236 double remainingSize
;
239 // Information about a profile.
240 dictionary ProfileInfo
{
241 // Profile ID. This is currently e-mail address of the profile.
244 // The name of the profile for display purpose.
245 DOMString displayName
;
247 // True if the profile is the one running the current file manager instance.
248 // TODO(hirono): Remove the property because of the design change of
249 // multi-profile suuport.
250 boolean isCurrentProfile
;
253 // Mounted disk volume metadata.
254 dictionary VolumeMetadata
{
255 // ID of the disk volume.
258 // Id the provided file system (for proviided file systems).
259 DOMString? fileSystemId
;
261 // Extension providing this volume (for provided file systems).
262 DOMString? extensionId
;
264 // Label of the volume (if available).
265 DOMString? volumeLabel
;
267 // Description of the profile where the volume belongs.
268 // TODO(hirono): Remove the property because of the design change of
269 // multi-profile support.
272 // The path to the mounted device, archive file or network resource.
273 DOMString? sourcePath
;
275 // Type of the mounted volume.
276 VolumeType volumeType
;
278 // Device type. Available if this is removable volume.
279 DeviceType? deviceType
;
281 // Path to identify the device. This is consistent with DeviceEvent's
283 DOMString? devicePath
;
285 // Whether the device is parent or not (i.e. sdb rather than sdb1).
286 boolean? isParentDevice
;
288 // Flag that specifies if volume is mounted in read-only mode.
291 // Flag that specifies whether the volume contains media.
294 // Additional data about mount, for example, that the filesystem is not
296 MountCondition? mountCondition
;
299 // Payload data for mount event.
300 dictionary MountCompletedEvent
{
301 // Is the event raised for mounting or unmounting.
302 MountCompletedEventType eventType
;
304 // Event type that tells listeners if mount was successful or an error
305 // occurred. It also specifies the error.
306 MountCompletedStatus status
;
308 // Metadata of the mounted volume.
309 VolumeMetadata volumeMetadata
;
311 // Whether the volume event should be notified or not.
312 boolean shouldNotify
;
315 // Payload data for file transfer status updates.
316 dictionary FileTransferStatus
{
317 // URL of file that is being transfered.
320 // File transfer progress state.
321 TransferState transferState
;
323 // Defines file transfer direction.
324 TransferType transferType
;
326 // Approximated completed portion of the transfer operation.
329 // Approximated total size of transfer operation.
332 // Total number of jobs.
336 // Error during the drive sync.
337 dictionary DriveSyncErrorEvent
{
339 DriveSyncErrorType type
;
341 // File URL of the entry that the error happens to.
345 // Payload data for copy status progress updates.
346 dictionary CopyProgressStatus
{
347 // The type of the progress event.
348 CopyProgressStatusType type
;
350 // URL for the entry currently being copied. This field is particularly useful
351 // when a directory copy is initiated with startCopy(). The field tells what
352 // file/directory in that directory is now being copied.
353 DOMString? sourceUrl
;
355 // URL for the entry currently being created. This field is particularly
356 // useful when a directory copy is initiated with startCopy(). The field tells
357 // what file/directory in that directory is being created. Available only for
358 // end_copy_entry and success.
359 DOMString? destinationUrl
;
361 // Number of processed bytes for the file currently being copied. Available
362 // only for "progress" event. To show the progress bar, a caller needs to
363 // pre-compute the size of files being copied for the file (not directory).
366 // DOMError's name. Available only for ERROR event.
370 // Payload data for file transfer cancel response.
371 dictionary FileTransferCancelStatus
{
372 // URL of file that is being transfered.
375 // True if ongoing transfer operation was found and canceled.
379 // Detailed information of change.
380 dictionary FileChange
{
381 // URL of changed file (or directory).
384 // Type of change, which may be multiple.
385 ChangeType
[] changes
;
388 // Directory change notification details.
389 dictionary FileWatchEvent
{
390 // Specifies type of event that is raised.
391 FileWatchEventType eventType
;
393 // An Entry object which represents a changed directory. The conversion into a
394 // kind of FileEntry object is done in
395 // file_browser_handler_custom_bindings.cc. For filesystem API's Entry
397 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
399 [instanceOf
=Entry] object entry;
401 // Detailed change information of change. It would be null if the detailed
402 // information is not available.
403 FileChange
[]? changedFiles
;
406 dictionary Preferences
{
407 boolean driveEnabled
;
408 boolean cellularDisabled
;
409 boolean hostedFilesDisabled
;
410 boolean use24hourClock
;
411 boolean allowRedeemOffers
;
414 dictionary PreferencesChange
{
415 boolean? cellularDisabled
;
416 boolean? hostedFilesDisabled
;
419 dictionary SearchParams
{
423 // ID of the search feed that should be fetched next. Value passed here should
424 // be gotten from previous searchDrive call. It can be empty for the initial
429 dictionary SearchMetadataParams
{
430 // Search query. It can be empty. Any filename matches to an empty query.
433 // The type of entry that is needed. Default to ALL.
436 // Maximum number of results.
440 // Entry and Drive-related properties representing a search result.
441 dictionary SearchResult
{
442 // A dictionary object which represents a Drive file. This will be converted
443 // into a kind of FileEntry object. See
444 // file_browser_handler_custom_bindings.cc for details. For filesystem API's
445 // Entry interface, see <a
446 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
448 [instanceOf
=Entry] object entry;
450 // The base name of a Drive file that matched the search query. The matched
451 // sub strings are highlighted with <b> element. Meta characters are escaped
453 DOMString highlightedBaseName
;
456 dictionary DriveConnectionState
{
459 // Reasons of offline.
462 // Whether the device has a cellular network access or not. i.e. the |type|
463 // can be 'metered' or not.
464 boolean hasCellularNetworkAccess
;
467 // Device event dispatched to listeners of onDeviceChaged. See also
468 // DeviceEventType to know when the event dispatched.
469 dictionary DeviceEvent
{
470 // Event type of the device event.
471 DeviceEventType type
;
472 // Device path to identify the device.
473 DOMString devicePath
;
476 // Callback that does not take arguments.
477 callback SimpleCallback
= void();
479 // |result| Result of the task execution.
480 callback ExecuteTaskCallback
= void(TaskResult result
);
482 // |tasks| The list of matched file URL patterns for this task.
483 callback GetFileTasksCallback
= void(FileTask
[] tasks
);
485 // |result| Hash containing the string assets.
486 callback GetStringsCallback
= void(object result
);
488 // |success| True when file watch is successfully added.
489 callback AddFileWatchCallback
= void(optional boolean success
);
491 // |success| True when file watch is successfully removed.
492 callback RemoveFileWatchCallback
= void(optional boolean success
);
494 // |fileSystem| A DOMFileSystem instance for local file system access. null if
495 // the caller has no appropriate permissions.
496 callback RequestFileSystemCallback
= void(optional object fileSystem
);
498 // |entryProperties| A dictionary containing properties of the requested
500 callback GetEntryPropertiesCallback
=
501 void(EntryProperties
[] entryProperties
);
503 // |sourcePath| Source path of the mount.
504 callback AddMountCallback
= void(DOMString sourcePath
);
506 // |volumeMetadataList| The list of VolumeMetadata representing mounted volumes.
507 callback GetVolumeMetadataListCallback
=
508 void(VolumeMetadata
[] volumeMetadataList
);
510 // |fileTransferCancelStatuses| The list of FileTransferCancelStatus.
511 callback CancelFileTransfersCallback
=
512 void(FileTransferCancelStatus
[] fileTransferCancelStatuses
);
514 // |copyId| ID of the copy task. Can be used to identify the progress, and to
516 callback StartCopyCallback
= void(long copyId
);
518 // |sizeStats| Name/value pairs of size stats. Will be undefined if stats could
519 // not be determined.
520 callback GetSizeStatsCallback
= void(optional MountPointSizeStats sizeStats
);
522 callback GetPreferencesCallback
= void(Preferences result
);
525 // |nextFeed| ID of the feed that contains next chunk of the search result.
526 // Should be sent to the next searchDrive request to perform
527 // incremental search.
528 callback SearchDriveCallback
=
529 void([instanceOf
=Entry] object[] entries
, DOMString nextFeed
);
531 callback SearchDriveMetadataCallback
= void(SearchResult
[] results
);
533 callback ZipSelectionCallback
= void(optional boolean success
);
535 callback GetDriveConnectionStateCallback
= void(DriveConnectionState result
);
537 // |result| true if the length is in the valid range, false otherwise.
538 callback ValidatePathNameLengthCallback
= void(boolean result
);
540 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
541 callback RequestAccessTokenCallback
= void(DOMString accessToken
);
543 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
544 callback RequestWebStoreAccessTokenCallback
= void(DOMString accessToken
);
547 callback GetUrlCallback
= void(DOMString url
);
549 // |profiles| List of profile information.
550 // |runningProfile| ID of the profile that runs the application instance.
551 // |showingProfile| ID of the profile that shows the application window.
552 callback GetProfilesCallback
= void(ProfileInfo
[] profiles
,
553 DOMString runningProfile
,
554 DOMString displayProfile
);
556 // |entryUrl| URL of an entry in a normal file system.
557 callback ResolveEntriesCallback
=
558 void([instanceOf
=FileEntry
] object[] entries
);
560 interface Functions
{
561 // Logout the current user for navigating to the re-authentication screen for
562 // the Google account.
563 static
void logoutUserForReauthentication
();
565 // Cancels file selection.
566 static
void cancelDialog
();
568 // Executes file browser task over selected files.
569 // |taskId| The unique identifier of task to execute.
570 // |fileUrls| Array of file URLs
572 static
void executeTask
(DOMString taskId
,
573 DOMString
[] fileUrls
,
574 optional ExecuteTaskCallback
callback);
576 // Sets the default task for the supplied MIME types and suffixes of the
577 // supplied file URLs. Lists of MIME types and URLs may contain duplicates.
578 // |taskId| The unique identifier of task to mark as default.
579 // |fileUrls| Array of selected file URLs to extract suffixes from.
580 // |mimeTypes| Array of selected file MIME types.
582 static
void setDefaultTask
(DOMString taskId
,
583 DOMString
[] fileUrls
,
584 optional DOMString
[] mimeTypes
,
585 optional SimpleCallback
callback);
587 // Gets the list of tasks that can be performed over selected files.
588 // |fileUrls| Array of selected file URLs
590 static
void getFileTasks
(DOMString
[] fileUrls
,
591 GetFileTasksCallback
callback);
593 // Gets localized strings and initialization data.
595 static
void getStrings
(GetStringsCallback
callback);
598 // |fileUrl| URL of file to watch
600 static
void addFileWatch
(DOMString fileUrl
, AddFileWatchCallback
callback);
602 // Removes file watch.
603 // |fileUrl| URL of watched file to remove
605 static
void removeFileWatch
(DOMString fileUrl
,
606 RemoveFileWatchCallback
callback);
608 // Requests access to a file system volume.
609 // |volumeId| The ID of the file system volume to request. The volume ID is
610 // delivered to JavaScript as part of VolumeMetadata. By specifying
611 // "compatible", this function behaves in the compatible mode, where the
612 // returned FileSystem object gives access to all file system volumes such
613 // as Downloads folder and removal media like SD cards (i.e. all volumes
614 // are provided inside the single FileSystem object). In the new
615 // "per-volume FileSystem object model" crbug.com/322305, a separate
616 // FileSystem object is created for each volume. "compatible" parameter
617 // will be removed once Files.app is switched to the per-volume FileSystem
620 static
void requestFileSystem
(DOMString volumeId
,
621 RequestFileSystemCallback
callback);
623 // Selects multiple files.
624 // |selectedPaths| Array of selected paths
625 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
627 static
void selectFiles
(DOMString
[] selectedPaths
,
628 boolean shouldReturnLocalPath
,
629 SimpleCallback
callback);
632 // |selectedPath| A selected path
633 // |index| Index of Filter
634 // |forOpening| true if paths are selected for opening. false if for saving.
635 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
637 static
void selectFile
(DOMString selectedPath
,
640 boolean shouldReturnLocalPath
,
641 SimpleCallback
callback);
643 // Requests additional properties for files.
644 // |fileUrls| list of URLs of files
646 static
void getEntryProperties
(
647 DOMString
[] fileUrls
,
648 GetEntryPropertiesCallback
callback);
650 // Pins/unpins a Drive file in the cache.
651 // |fileUrl| URL of a file to pin/unpin.
652 // |pin| Pass true to pin the file.
653 // |callback| Completion callback. $(ref:runtime.lastError) will be set if
654 // there was an error.
655 static
void pinDriveFile
(DOMString fileUrl
,
657 optional SimpleCallback
callback);
659 // Resolves file entries in the isolated file system and returns corresponding
660 // entries in the external file system mounted to Chrome OS file manager
661 // backend. If resolving entry fails, the entry will be just ignored and the
662 // corresponding entry does not appear in the result.
664 static
void resolveIsolatedEntries
(
665 [instanceOf
=FileEntry
] object[] entries
,
666 ResolveEntriesCallback
callback);
668 // Mount a resource or a file.
669 // |source| Mount point source. For compressed files it is relative file path
670 // within external file system
672 static
void addMount
(DOMString
source, AddMountCallback
callback);
674 // Unmounts a mounted resource.
675 // |volumeId| An ID of the volume.
676 static
void removeMount
(DOMString volumeId
);
678 // Get the list of mounted volumes.
680 static
void getVolumeMetadataList
(GetVolumeMetadataListCallback
callback);
682 // Cancels ongoing file transfers for selected files.
683 // |fileUrls| Array of files for which ongoing transfer should be canceled.
684 // If this is absent, all jobs are canceled.
685 // |callback| Completion callback of the cancel.
686 static
void cancelFileTransfers
(
687 optional DOMString
[] fileUrls
,
688 optional CancelFileTransfersCallback
callback);
690 // Starts to copy an entry. If the source is a directory, the copy is done
692 // |sourceUrl| URL of the source entry to be copied.
693 // |parent| URL of the destination directory.
694 // |newName| Name of the new entry. It shouldn't contain '/'.
695 // |callback| Completion callback.
696 static
void startCopy
(DOMString sourceUrl
,
699 StartCopyCallback
callback);
701 // Cancels the running copy task.
702 // |copyId| ID of the copy task to be cancelled.
703 // |callback| Completion callback of the cancel.
704 static
void cancelCopy
(long copyId
, optional SimpleCallback
callback);
706 // Retrieves total and remaining size of a mount point.
707 // |volumeId| ID of the volume to be checked.
709 static
void getSizeStats
(DOMString volumeId
, GetSizeStatsCallback
callback);
711 // Formats a mounted volume.
712 // |volumeId| ID of the volume to be formatted.
713 static
void formatVolume
(DOMString volumeId
);
715 // Retrieves file manager preferences.
717 static
void getPreferences
(GetPreferencesCallback
callback);
719 // Sets file manager preferences.
721 static
void setPreferences
(PreferencesChange changeInfo
);
723 // Performs drive content search.
726 static
void searchDrive
(SearchParams searchParams
,
727 SearchDriveCallback
callback);
729 // Performs drive metadata search.
732 static
void searchDriveMetadata
(SearchMetadataParams searchParams
,
733 SearchDriveMetadataCallback
callback);
735 // Create a zip file for the selected files.
736 // |dirURL| URL of the directory containing the selected files.
737 // |selectionUrls| URLs of the selected files. The files must be under the
738 // directory specified by dirURL.
739 // |destName| Name of the destination zip file. The zip file will be created
740 // under the directory specified by dirURL.
742 static
void zipSelection
(DOMString dirURL
,
743 DOMString
[] selectionUrls
,
745 optional ZipSelectionCallback
callback);
747 // Retrieves the state of the current drive connection.
749 static
void getDriveConnectionState
(GetDriveConnectionStateCallback
callback);
751 // Checks whether the path name length fits in the limit of the filesystem.
752 // |parent_directory_url| The URL of the parent directory entry.
753 // |name| The name of the file.
754 // |callback| Called back when the check is finished.
755 static
void validatePathNameLength
(DOMString parent_directory_url
,
757 ValidatePathNameLengthCallback
callback);
759 // Changes the zoom factor of the Files.app.
760 // |operation| Zooming mode.
761 static
void zoom
(ZoomOperationType operation
);
763 // Requests a Drive API OAuth2 access token.
764 // |refresh| Whether the token should be refetched instead of using the cached
767 static
void requestAccessToken
(boolean refresh
,
768 RequestAccessTokenCallback
callback);
770 // Requests a Webstore API OAuth2 access token.
772 static
void requestWebStoreAccessToken
(
773 RequestWebStoreAccessTokenCallback
callback);
775 // Requests a share dialog url for the specified file.
776 // |url| Url for the file.
778 static
void getShareUrl
(DOMString url
, GetUrlCallback
callback);
780 // Requests a download url to download the file contents.
781 // |url| Url for the file.
783 static
void getDownloadUrl
(DOMString url
, GetUrlCallback
callback);
785 // Requests to share drive files.
786 // |url| URL of a file to be shared.
787 // |shareType| Type of access that is getting granted.
788 static
void requestDriveShare
(DOMString url
,
789 DriveShareType shareType
,
790 SimpleCallback
callback);
792 // Requests to install a webstore item.
793 // |item_id| The id of the item to install.
794 // |silentInstallation| False to show installation prompt. True not to show.
796 static
void installWebstoreItem
(DOMString itemId
,
797 boolean silentInstallation
,
798 SimpleCallback
callback);
800 // Obtains a list of profiles that are logged-in.
801 static
void getProfiles
(GetProfilesCallback
callback);
803 // Moves the window to other user's desktop.
804 static
void visitDesktop
(DOMString profileId
,
805 optional SimpleCallback
callback);
807 // Opens inspector window.
808 // |type| InspectionType which specifies how to open inspector.
809 static
void openInspector
(InspectionType type
);
813 static
void onMountCompleted
(MountCompletedEvent event
);
815 static
void onFileTransfersUpdated
(FileTransferStatus event
);
817 static
void onCopyProgress
(long copyId
, CopyProgressStatus status
);
819 static
void onDirectoryChanged
(FileWatchEvent event
);
821 static
void onPreferencesChanged
();
823 static
void onDriveConnectionStatusChanged
();
825 static
void onDeviceChanged
(DeviceEvent event
);
827 static
void onDriveSyncError
(DriveSyncErrorEvent event
);