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
, 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_unsuported_filesystem
,
43 error_invalid_archive
,
48 // File transfer progress state.
49 enum TransferState
{ 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 // The type of entry that is needed. Default to ALL.
79 enum SearchType
{ EXCLUDE_DIRECTORIES
, SHARED_WITH_ME
, OFFLINE
, ALL
};
82 enum ZoomOperationType
{ in, out, reset
};
85 enum DeviceEventType
{
88 // If the device is disabled by preference, the disabled event is published
89 // instead of the added event.
91 // Device is added, but scan for the device is canceled. The event is
92 // published after the added event.
104 // Drive sync error type.
105 // Keep it synced with DriveSyncErrorType in operation_observer.h.
106 enum DriveSyncErrorType
{
107 // Request to delete a file without permission.
108 delete_without_permission
,
109 // Google Drive is temporarily unavailable.
111 // Miscellaneous errors other than listed above.
115 // Result of task execution.
117 // The task execution succeeded and a new window/tab was opened.
119 // The task execution succeeded and the message was sent to the proper
122 // The task execution failed.
124 // No URL is specified.
129 enum DriveShareType
{
135 // ImageSet that represents multi-scale images.
136 dictionary ImageSet
{
138 DOMString scale1xUrl
;
140 DOMString scale2xUrl
;
143 // A file task represents an action that the file manager can perform over the
144 // currently selected files. See
145 // chrome/browser/chromeos/extensions/file_manager/file_tasks.h for details
146 // about how file tasks are handled.
147 dictionary FileTask
{
148 // The unique identifier of the task.
151 // Task title (ex. App name).
154 // Task icon url (from chrome://extension-icon/...)
157 // True if this task is a default task for the selected files.
161 // Drive file properties.
162 dictionary DriveEntryProperties
{
163 // URL to the Drive thumbnail image for this file.
164 DOMString? thumbnailUrl
;
166 // Width, if the entry is an image.
169 // Height, if the entry is an image.
172 // Rotation in clockwise degrees, if the entry is an image.
175 // True if the file is pinned in Drive cache.
178 // True if the file is present in Drive cache.
181 // True if the file is hosted on a Drive server instead of local.
184 // URL to the custom icon for this file.
185 DOMString? customIconUrl
;
187 // Drive MIME type for this file.
188 DOMString? contentMimeType
;
190 // True if the entry is labeled as shared-with-me.
191 boolean? sharedWithMe
;
193 // True if the entry is labeled as shared (either from me to others or to me
198 // Information about total and remaining size on the mount point.
199 dictionary MountPointSizeStats
{
200 // Approximate total available size on the mount point.
203 // Approximate remaining available size on the mount point.
204 double remainingSize
;
207 // Information about a profile.
208 dictionary ProfileInfo
{
209 // Profile ID. This is currently e-mail address of the profile.
212 // The name of the profile for display purpose.
213 DOMString displayName
;
215 // True if the profile is the one running the current file manager instance.
216 // TODO(hirono): Remove the property because of the design change of
217 // multi-profile suuport.
218 boolean isCurrentProfile
;
220 // Image set of profile image.
221 ImageSet? profileImage
;
224 // Mounted disk volume metadata.
225 dictionary VolumeMetadata
{
226 // ID of the disk volume.
229 // Description of the profile where the volume belongs.
230 // TODO(hirono): Remove the property because of the design change of
231 // multi-profile support.
234 // The path to the mounted device, archive file or network resource.
235 DOMString? sourcePath
;
237 // Type of the mounted volume.
238 VolumeType volumeType
;
240 // Device type. Available if this is removable volume.
241 DeviceType? deviceType
;
243 // Path to identify the device. This is consistent with DeviceEvent's
245 DOMString? devicePath
;
247 // Label of the device.
248 DOMString? deviceLabel
;
250 // Whether the device is parent or not (i.e. sdb rather than sdb1).
251 boolean? isParentDevice
;
253 // Flag that specifies if volume is mounted in read-only mode.
256 // Additional data about mount, for example, that the filesystem is not
258 MountCondition? mountCondition
;
261 // Payload data for mount event.
262 dictionary MountCompletedEvent
{
263 // Is the event raised for mounting or unmounting.
264 MountCompletedEventType eventType
;
266 // Event type that tells listeners if mount was successful or an error
267 // occurred. It also specifies the error.
268 MountCompletedStatus status
;
270 // Metadata of the mounted volume.
271 VolumeMetadata volumeMetadata
;
273 // Whether it is remount or not.
274 boolean isRemounting
;
277 // Payload data for file transfer status updates.
278 dictionary FileTransferStatus
{
279 // URL of file that is being transfered.
282 // File transfer progress state.
283 TransferState transferState
;
285 // Defines file transfer direction.
286 TransferType transferType
;
288 // Approximated completed portion of the transfer operation.
291 // Approximated total size of transfer operation.
295 // Error during the drive sync.
296 dictionary DriveSyncErrorEvent
{
298 DriveSyncErrorType type
;
300 // File URL of the entry that the error happens to.
304 // Payload data for copy status progress updates.
305 dictionary CopyProgressStatus
{
306 // The type of the progress event.
307 CopyProgressStatusType type
;
309 // URL for the entry currently being copied. This field is particularly useful
310 // when a directory copy is initiated with startCopy(). The field tells what
311 // file/directory in that directory is now being copied.
312 DOMString? sourceUrl
;
314 // URL for the entry currently being created. This field is particularly
315 // useful when a directory copy is initiated with startCopy(). The field tells
316 // what file/directory in that directory is being created. Available only for
317 // end_copy_entry and success.
318 DOMString? destinationUrl
;
320 // Number of processed bytes for the file currently being copied. Available
321 // only for "progress" event. To show the progress bar, a caller needs to
322 // pre-compute the size of files being copied for the file (not directory).
325 // DOMError's name. Available only for ERROR event.
329 // Payload data for file transfer cancel response.
330 dictionary FileTransferCancelStatus
{
331 // URL of file that is being transfered.
334 // True if ongoing transfer operation was found and canceled.
338 // Directory change notification details.
339 dictionary FileWatchEvent
{
340 // Specifies type of event that is raised.
341 FileWatchEventType eventType
;
343 // An Entry object which represents a changed directory. The conversion into a
344 // kind of FileEntry object is done in
345 // file_browser_handler_custom_bindings.cc. For filesystem API's Entry
347 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
349 [instanceOf
=Entry] object entry;
352 dictionary Preferences
{
353 boolean driveEnabled
;
354 boolean cellularDisabled
;
355 boolean hostedFilesDisabled
;
356 boolean use24hourClock
;
357 boolean allowRedeemOffers
;
360 dictionary PreferencesChange
{
361 boolean? cellularDisabled
;
362 boolean? hostedFilesDisabled
;
365 dictionary SearchParams
{
369 // ID of the search feed that should be fetched next. Value passed here should
370 // be gotten from previous searchDrive call. It can be empty for the initial
375 dictionary SearchMetadataParams
{
376 // Search query. It can be empty. Any filename matches to an empty query.
379 // The type of entry that is needed. Default to ALL.
382 // Maximum number of results.
386 // Entry and Drive-related properties representing a search result.
387 dictionary SearchResult
{
388 // A dictionary object which represents a Drive file. This will be converted
389 // into a kind of FileEntry object. See
390 // file_browser_handler_custom_bindings.cc for details. For filesystem API's
391 // Entry interface, see <a
392 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
394 [instanceOf
=Entry] object entry;
396 // The base name of a Drive file that matched the search query. The matched
397 // sub strings are highlighted with <b> element. Meta characters are escaped
399 DOMString highlightedBaseName
;
402 dictionary DriveConnectionState
{
405 // Reasons of offline.
409 // Device event dispatched to listeners of onDeviceChaged. See also
410 // DeviceEventType to know when the event dispatched.
411 dictionary DeviceEvent
{
412 // Event type of the device event.
413 DeviceEventType type
;
414 // Device path to identify the device.
415 DOMString devicePath
;
418 // Callback that does not take arguments.
419 callback SimpleCallback
= void();
421 // |result| Result of the task execution.
422 callback ExecuteTaskCallback
= void(TaskResult result
);
424 // |tasks| The list of matched file URL patterns for this task.
425 callback GetFileTasksCallback
= void(FileTask
[] tasks
);
427 // |result| Hash containing the string assets.
428 callback GetStringsCallback
= void(object result
);
430 // |success| True when file watch is successfully added.
431 callback AddFileWatchCallback
= void(optional boolean success
);
433 // |success| True when file watch is successfully removed.
434 callback RemoveFileWatchCallback
= void(optional boolean success
);
436 // |fileSystem| A DOMFileSystem instance for local file system access. null if
437 // |the caller has no appropriate permissions.
438 callback RequestFileSystemCallback
= void(optional object fileSystem
);
440 // |fileProperties| A dictionary containing properties of the requested entries.
441 callback GetDriveEntryPropertiesCallback
=
442 void(DriveEntryProperties
[] entryProperties
);
444 // |localFilePaths| An array of the local file paths for the requested files,
445 // one entry for each file in fileUrls.
446 callback GetDriveFilesCallback
= void(DOMString
[] localFilePaths
);
448 // |sourcePath| Source path of the mount.
449 callback AddMountCallback
= void(DOMString sourcePath
);
451 // |volumeMetadataList| The list of VolumeMetadata representing mounted volumes.
452 callback GetVolumeMetadataListCallback
=
453 void(VolumeMetadata
[] volumeMetadataList
);
455 // |fileTransferCancelStatuses| The list of FileTransferCancelStatus.
456 callback CancelFileTransfersCallback
=
457 void(FileTransferCancelStatus
[] fileTransferCancelStatuses
);
459 // |copyId| ID of the copy task. Can be used to identify the progress, and to
461 callback StartCopyCallback
= void(long copyId
);
463 // |sizeStats| Name/value pairs of size stats. Will be undefined if stats could
464 // not be determined.
465 callback GetSizeStatsCallback
= void(optional MountPointSizeStats sizeStats
);
467 callback GetPreferencesCallback
= void(Preferences result
);
470 // |nextFeed| ID of the feed that contains next chunk of the search result.
471 // Should be sent to the next searchDrive request to perform
472 // incremental search.
473 callback SearchDriveCallback
=
474 void([instanceOf
=Entry] object[] entries
, DOMString nextFeed
);
476 callback SearchDriveMetadataCallback
= void(SearchResult
[] results
);
478 callback ZipSelectionCallback
= void(optional boolean success
);
480 callback GetDriveConnectionStateCallback
= void(DriveConnectionState result
);
482 // |result| true if the length is in the valid range, false otherwise.
483 callback ValidatePathNameLengthCallback
= void(boolean result
);
485 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
486 callback RequestAccessTokenCallback
= void(DOMString accessToken
);
488 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
489 callback RequestWebStoreAccessTokenCallback
= void(DOMString accessToken
);
491 // |shareUrl| Share Url for the sharing dialog.
492 callback GetShareUrlCallback
= void(DOMString shareUrl
);
494 // |profiles| List of profile information.
495 // |runningProfile| ID of the profile that runs the application instance.
496 // |showingProfile| ID of the profile that shows the application window.
497 callback GetProfilesCallback
= void(ProfileInfo
[] profiles
,
498 DOMString runningProfile
,
499 DOMString displayProfile
);
501 interface Functions
{
502 // Logout the current user for navigating to the re-authentication screen for
503 // the Google account.
504 static
void logoutUserForReauthentication
();
506 // Cancels file selection.
507 static
void cancelDialog
();
509 // Executes file browser task over selected files.
510 // |taskId| The unique identifier of task to execute.
511 // |fileUrls| Array of file URLs
513 static
void executeTask
(DOMString taskId
,
514 DOMString
[] fileUrls
,
515 optional ExecuteTaskCallback
callback);
517 // Sets the default task for the supplied MIME types and suffixes of the
518 // supplied file URLs. Lists of MIME types and URLs may contain duplicates.
519 // |taskId| The unique identifier of task to mark as default.
520 // |fileUrls| Array of selected file URLs to extract suffixes from.
521 // |mimeTypes| Array of selected file MIME types.
523 static
void setDefaultTask
(DOMString taskId
,
524 DOMString
[] fileUrls
,
525 optional DOMString
[] mimeTypes
,
526 optional SimpleCallback
callback);
528 // Gets the list of tasks that can be performed over selected files.
529 // |fileUrls| Array of selected file URLs
530 // |mimeTypes| Array of selected file MIME types
532 static
void getFileTasks
(DOMString
[] fileUrls
,
533 DOMString
[] mimeTypes
,
534 GetFileTasksCallback
callback);
536 // Gets localized strings and initialization data.
538 static
void getStrings
(GetStringsCallback
callback);
541 // |fileUrl| URL of file to watch
543 static
void addFileWatch
(DOMString fileUrl
, AddFileWatchCallback
callback);
545 // Removes file watch.
546 // |fileUrl| URL of watched file to remove
548 static
void removeFileWatch
(DOMString fileUrl
,
549 RemoveFileWatchCallback
callback);
551 // Requests access to a file system volume.
552 // |volumeId| The ID of the file system volume to request. The volume ID is
553 // delivered to JavaScript as part of VolumeMetadata. By specifying
554 // "compatible", this function behaves in the compatible mode, where the
555 // returned FileSystem object gives access to all file system volumes such
556 // as Downloads folder and removal media like SD cards (i.e. all volumes
557 // are provided inside the single FileSystem object). In the new
558 // "per-volume FileSystem object model" crbug.com/322305, a separate
559 // FileSystem object is created for each volume. "compatible" parameter
560 // will be removed once Files.app is switched to the per-volume FileSystem
563 static
void requestFileSystem
(DOMString volumeId
,
564 RequestFileSystemCallback
callback);
566 // Selects multiple files.
567 // |selectedPaths| Array of selected paths
568 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
570 static
void selectFiles
(DOMString
[] selectedPaths
,
571 boolean shouldReturnLocalPath
,
572 SimpleCallback
callback);
575 // |selectedPath| A selected path
576 // |index| Index of Filter
577 // |forOpening| true if paths are selected for opening. false if for saving.
578 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
580 static
void selectFile
(DOMString selectedPath
,
583 boolean shouldReturnLocalPath
,
584 SimpleCallback
callback);
586 // Requests Drive file properties for files.
587 // |fileUrls| list of URLs of files
589 static
void getDriveEntryProperties
(
590 DOMString
[] fileUrls
,
591 GetDriveEntryPropertiesCallback
callback);
593 // Pins/unpins a Drive file in the cache.
594 // |fileUrl| URL of a file to pin/unpin.
595 // |pin| Pass true to pin the file.
596 // |callback| Completion callback. $(ref:runtime.lastError) will be set if there
598 static
void pinDriveFile
(DOMString fileUrl
,
600 optional SimpleCallback
callback);
603 // |fileUrls| Array of Drive file URLs to get.
605 static
void getDriveFiles
(DOMString
[] fileUrls
,
606 GetDriveFilesCallback
callback);
608 // Mount a resource or a file.
609 // |source| Mount point source. For compressed files it is relative file path
610 // within external file system
612 static
void addMount
(DOMString
source, AddMountCallback
callback);
614 // Unmounts a mounted resource.
615 // |volumeId| An ID of the volume.
616 static
void removeMount
(DOMString volumeId
);
618 // Get the list of mounted volumes.
620 static
void getVolumeMetadataList
(GetVolumeMetadataListCallback
callback);
622 // Cancels ongoing file transfers for selected files.
623 // |fileUrls| Array of files for which ongoing transfer should be canceled.
625 static
void cancelFileTransfers
(DOMString
[] fileUrls
,
626 CancelFileTransfersCallback
callback);
628 // Starts to copy an entry. If the source is a directory, the copy is done
630 // |sourceUrl| URL of the source entry to be copied.
631 // |parent| URL of the destination directory.
632 // |newName| Name of the new entry. It shouldn't contain '/'.
633 // |callback| Completion callback.
634 static
void startCopy
(DOMString sourceUrl
,
637 StartCopyCallback
callback);
639 // Cancels the running copy task.
640 // |copyId| ID of the copy task to be cancelled.
641 // |callback| Completion callback of the cancel.
642 static
void cancelCopy
(long copyId
, optional SimpleCallback
callback);
644 // Retrieves total and remaining size of a mount point.
645 // |volumeId| ID of the volume to be checked.
647 static
void getSizeStats
(DOMString volumeId
, GetSizeStatsCallback
callback);
649 // Formats a mounted volume.
650 // |volumeId| ID of the volume to be formatted.
651 static
void formatVolume
(DOMString volumeId
);
653 // Retrieves file manager preferences.
655 static
void getPreferences
(GetPreferencesCallback
callback);
657 // Sets file manager preferences.
659 static
void setPreferences
(PreferencesChange changeInfo
);
661 // Performs drive content search.
664 static
void searchDrive
(SearchParams searchParams
,
665 SearchDriveCallback
callback);
667 // Performs drive metadata search.
670 static
void searchDriveMetadata
(SearchMetadataParams searchParams
,
671 SearchDriveMetadataCallback
callback);
673 // Create a zip file for the selected files.
674 // |dirURL| URL of the directory containing the selected files.
675 // |selectionUrls| URLs of the selected files. The files must be under the
676 // directory specified by dirURL.
677 // |destName| Name of the destination zip file. The zip file will be created
678 // under the directory specified by dirURL.
680 static
void zipSelection
(DOMString dirURL
,
681 DOMString
[] selectionUrls
,
683 optional ZipSelectionCallback
callback);
685 // Retrieves the state of the current drive connection.
687 static
void getDriveConnectionState
(GetDriveConnectionStateCallback
callback);
689 // Checks whether the path name length fits in the limit of the filesystem.
690 // |parent_directory_url| The URL of the parent directory entry.
691 // |name| The name of the file.
692 // |callback| Called back when the check is finished.
693 static
void validatePathNameLength
(DOMString parent_directory_url
,
695 ValidatePathNameLengthCallback
callback);
697 // Changes the zoom factor of the Files.app.
698 // |operation| Zooming mode.
699 static
void zoom
(ZoomOperationType operation
);
701 // Requests a Drive API OAuth2 access token.
702 // |refresh| Whether the token should be refetched instead of using the cached
705 static
void requestAccessToken
(boolean refresh
,
706 RequestAccessTokenCallback
callback);
708 // Requests a Webstore API OAuth2 access token.
710 static
void requestWebStoreAccessToken
(
711 RequestWebStoreAccessTokenCallback
callback);
713 // Requests a share dialog url for the specified file.
714 // |url| Url for the file.
716 static
void getShareUrl
(DOMString url
, GetShareUrlCallback
callback);
718 // Requests to share drive files.
719 // |url| URL of a file to be shared.
720 // |shareType| Type of access that is getting granted.
721 static
void requestDriveShare
(DOMString url
,
722 DriveShareType shareType
,
723 SimpleCallback
callback);
725 // Requests to install a webstore item.
726 // |item_id| The id of the item to install.
728 static
void installWebstoreItem
(DOMString item_id
,
729 SimpleCallback
callback);
731 // Obtains a list of profiles that are logged-in.
732 static
void getProfiles
(GetProfilesCallback
callback);
734 // Moves the window to other user's desktop.
735 static
void visitDesktop
(DOMString profileId
,
736 optional SimpleCallback
callback);
740 static
void onMountCompleted
(MountCompletedEvent event
);
742 static
void onFileTransfersUpdated
(FileTransferStatus
[] event
);
744 static
void onCopyProgress
(long copyId
, CopyProgressStatus status
);
746 static
void onDirectoryChanged
(FileWatchEvent event
);
748 static
void onPreferencesChanged
();
750 static
void onDriveConnectionStatusChanged
();
752 static
void onDeviceChanged
(DeviceEvent event
);
754 static
void onDriveSyncError
(DriveSyncErrorEvent event
);
756 // Dispatched when a profile is added.
757 static
void onProfileAdded
();
759 // Dispatched when any window moves another desktop.
760 // TODO(hirono): Add information which window is moved.
761 static
void onDesktopChanged
();