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.
96 // Device is hard unplugged.
106 // Drive sync error type.
107 // Keep it synced with DriveSyncErrorType in operation_observer.h.
108 enum DriveSyncErrorType
{
109 // Request to delete a file without permission.
110 delete_without_permission
,
111 // Google Drive is temporarily unavailable.
113 // Miscellaneous errors other than listed above.
117 // Result of task execution.
119 // The task execution succeeded and a new window/tab was opened.
121 // The task execution succeeded and the message was sent to the proper
124 // The task execution failed.
126 // No URL is specified.
131 enum DriveShareType
{
137 // ImageSet that represents multi-scale images.
138 dictionary ImageSet
{
140 DOMString scale1xUrl
;
142 DOMString scale2xUrl
;
145 // A file task represents an action that the file manager can perform over the
146 // currently selected files. See
147 // chrome/browser/chromeos/extensions/file_manager/file_tasks.h for details
148 // about how file tasks are handled.
149 dictionary FileTask
{
150 // The unique identifier of the task.
153 // Task title (ex. App name).
156 // Task icon url (from chrome://extension-icon/...)
159 // True if this task is a default task for the selected files.
163 // Drive file properties.
164 dictionary DriveEntryProperties
{
165 // Size of this file.
168 // Timestamp of entry update time, in milliseconds past the epoch.
169 double? lastModifiedTime
;
171 // URL to the Drive thumbnail image for this file.
172 DOMString? thumbnailUrl
;
174 // Width, if the entry is an image.
177 // Height, if the entry is an image.
180 // Rotation in clockwise degrees, if the entry is an image.
183 // True if the file is pinned in Drive cache.
186 // True if the file is present in Drive cache.
189 // True if the file is hosted on a Drive server instead of local.
192 // URL to the custom icon for this file.
193 DOMString? customIconUrl
;
195 // Drive MIME type for this file.
196 DOMString? contentMimeType
;
198 // True if the entry is labeled as shared-with-me.
199 boolean? sharedWithMe
;
201 // True if the entry is labeled as shared (either from me to others or to me
206 // Information about total and remaining size on the mount point.
207 dictionary MountPointSizeStats
{
208 // Approximate total available size on the mount point.
211 // Approximate remaining available size on the mount point.
212 double remainingSize
;
215 // Information about a profile.
216 dictionary ProfileInfo
{
217 // Profile ID. This is currently e-mail address of the profile.
220 // The name of the profile for display purpose.
221 DOMString displayName
;
223 // True if the profile is the one running the current file manager instance.
224 // TODO(hirono): Remove the property because of the design change of
225 // multi-profile suuport.
226 boolean isCurrentProfile
;
228 // Image set of profile image.
229 ImageSet? profileImage
;
232 // Mounted disk volume metadata.
233 dictionary VolumeMetadata
{
234 // ID of the disk volume.
237 // Description of the profile where the volume belongs.
238 // TODO(hirono): Remove the property because of the design change of
239 // multi-profile support.
242 // The path to the mounted device, archive file or network resource.
243 DOMString? sourcePath
;
245 // Type of the mounted volume.
246 VolumeType volumeType
;
248 // Device type. Available if this is removable volume.
249 DeviceType? deviceType
;
251 // Path to identify the device. This is consistent with DeviceEvent's
253 DOMString? devicePath
;
255 // Label of the device.
256 DOMString? deviceLabel
;
258 // Whether the device is parent or not (i.e. sdb rather than sdb1).
259 boolean? isParentDevice
;
261 // Flag that specifies if volume is mounted in read-only mode.
264 // Additional data about mount, for example, that the filesystem is not
266 MountCondition? mountCondition
;
269 // Payload data for mount event.
270 dictionary MountCompletedEvent
{
271 // Is the event raised for mounting or unmounting.
272 MountCompletedEventType eventType
;
274 // Event type that tells listeners if mount was successful or an error
275 // occurred. It also specifies the error.
276 MountCompletedStatus status
;
278 // Metadata of the mounted volume.
279 VolumeMetadata volumeMetadata
;
281 // Whether it is remount or not.
282 boolean isRemounting
;
285 // Payload data for file transfer status updates.
286 dictionary FileTransferStatus
{
287 // URL of file that is being transfered.
290 // File transfer progress state.
291 TransferState transferState
;
293 // Defines file transfer direction.
294 TransferType transferType
;
296 // Approximated completed portion of the transfer operation.
299 // Approximated total size of transfer operation.
303 // Error during the drive sync.
304 dictionary DriveSyncErrorEvent
{
306 DriveSyncErrorType type
;
308 // File URL of the entry that the error happens to.
312 // Payload data for copy status progress updates.
313 dictionary CopyProgressStatus
{
314 // The type of the progress event.
315 CopyProgressStatusType type
;
317 // URL for the entry currently being copied. This field is particularly useful
318 // when a directory copy is initiated with startCopy(). The field tells what
319 // file/directory in that directory is now being copied.
320 DOMString? sourceUrl
;
322 // URL for the entry currently being created. This field is particularly
323 // useful when a directory copy is initiated with startCopy(). The field tells
324 // what file/directory in that directory is being created. Available only for
325 // end_copy_entry and success.
326 DOMString? destinationUrl
;
328 // Number of processed bytes for the file currently being copied. Available
329 // only for "progress" event. To show the progress bar, a caller needs to
330 // pre-compute the size of files being copied for the file (not directory).
333 // DOMError's name. Available only for ERROR event.
337 // Payload data for file transfer cancel response.
338 dictionary FileTransferCancelStatus
{
339 // URL of file that is being transfered.
342 // True if ongoing transfer operation was found and canceled.
346 // Directory change notification details.
347 dictionary FileWatchEvent
{
348 // Specifies type of event that is raised.
349 FileWatchEventType eventType
;
351 // An Entry object which represents a changed directory. The conversion into a
352 // kind of FileEntry object is done in
353 // file_browser_handler_custom_bindings.cc. For filesystem API's Entry
355 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
357 [instanceOf
=Entry] object entry;
360 dictionary Preferences
{
361 boolean driveEnabled
;
362 boolean cellularDisabled
;
363 boolean hostedFilesDisabled
;
364 boolean use24hourClock
;
365 boolean allowRedeemOffers
;
368 dictionary PreferencesChange
{
369 boolean? cellularDisabled
;
370 boolean? hostedFilesDisabled
;
373 dictionary SearchParams
{
377 // ID of the search feed that should be fetched next. Value passed here should
378 // be gotten from previous searchDrive call. It can be empty for the initial
383 dictionary SearchMetadataParams
{
384 // Search query. It can be empty. Any filename matches to an empty query.
387 // The type of entry that is needed. Default to ALL.
390 // Maximum number of results.
394 // Entry and Drive-related properties representing a search result.
395 dictionary SearchResult
{
396 // A dictionary object which represents a Drive file. This will be converted
397 // into a kind of FileEntry object. See
398 // file_browser_handler_custom_bindings.cc for details. For filesystem API's
399 // Entry interface, see <a
400 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
402 [instanceOf
=Entry] object entry;
404 // The base name of a Drive file that matched the search query. The matched
405 // sub strings are highlighted with <b> element. Meta characters are escaped
407 DOMString highlightedBaseName
;
410 dictionary DriveConnectionState
{
413 // Reasons of offline.
417 // Device event dispatched to listeners of onDeviceChaged. See also
418 // DeviceEventType to know when the event dispatched.
419 dictionary DeviceEvent
{
420 // Event type of the device event.
421 DeviceEventType type
;
422 // Device path to identify the device.
423 DOMString devicePath
;
426 // Callback that does not take arguments.
427 callback SimpleCallback
= void();
429 // |result| Result of the task execution.
430 callback ExecuteTaskCallback
= void(TaskResult result
);
432 // |tasks| The list of matched file URL patterns for this task.
433 callback GetFileTasksCallback
= void(FileTask
[] tasks
);
435 // |result| Hash containing the string assets.
436 callback GetStringsCallback
= void(object result
);
438 // |success| True when file watch is successfully added.
439 callback AddFileWatchCallback
= void(optional boolean success
);
441 // |success| True when file watch is successfully removed.
442 callback RemoveFileWatchCallback
= void(optional boolean success
);
444 // |fileSystem| A DOMFileSystem instance for local file system access. null if
445 // |the caller has no appropriate permissions.
446 callback RequestFileSystemCallback
= void(optional object fileSystem
);
448 // |fileProperties| A dictionary containing properties of the requested entries.
449 callback GetDriveEntryPropertiesCallback
=
450 void(DriveEntryProperties
[] entryProperties
);
452 // |localFilePaths| An array of the local file paths for the requested files,
453 // one entry for each file in fileUrls.
454 callback GetDriveFilesCallback
= void(DOMString
[] localFilePaths
);
456 // |sourcePath| Source path of the mount.
457 callback AddMountCallback
= void(DOMString sourcePath
);
459 // |volumeMetadataList| The list of VolumeMetadata representing mounted volumes.
460 callback GetVolumeMetadataListCallback
=
461 void(VolumeMetadata
[] volumeMetadataList
);
463 // |fileTransferCancelStatuses| The list of FileTransferCancelStatus.
464 callback CancelFileTransfersCallback
=
465 void(FileTransferCancelStatus
[] fileTransferCancelStatuses
);
467 // |copyId| ID of the copy task. Can be used to identify the progress, and to
469 callback StartCopyCallback
= void(long copyId
);
471 // |sizeStats| Name/value pairs of size stats. Will be undefined if stats could
472 // not be determined.
473 callback GetSizeStatsCallback
= void(optional MountPointSizeStats sizeStats
);
475 callback GetPreferencesCallback
= void(Preferences result
);
478 // |nextFeed| ID of the feed that contains next chunk of the search result.
479 // Should be sent to the next searchDrive request to perform
480 // incremental search.
481 callback SearchDriveCallback
=
482 void([instanceOf
=Entry] object[] entries
, DOMString nextFeed
);
484 callback SearchDriveMetadataCallback
= void(SearchResult
[] results
);
486 callback ZipSelectionCallback
= void(optional boolean success
);
488 callback GetDriveConnectionStateCallback
= void(DriveConnectionState result
);
490 // |result| true if the length is in the valid range, false otherwise.
491 callback ValidatePathNameLengthCallback
= void(boolean result
);
493 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
494 callback RequestAccessTokenCallback
= void(DOMString accessToken
);
496 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
497 callback RequestWebStoreAccessTokenCallback
= void(DOMString accessToken
);
499 // |shareUrl| Share Url for the sharing dialog.
500 callback GetShareUrlCallback
= void(DOMString shareUrl
);
502 // |profiles| List of profile information.
503 // |runningProfile| ID of the profile that runs the application instance.
504 // |showingProfile| ID of the profile that shows the application window.
505 callback GetProfilesCallback
= void(ProfileInfo
[] profiles
,
506 DOMString runningProfile
,
507 DOMString displayProfile
);
509 interface Functions
{
510 // Logout the current user for navigating to the re-authentication screen for
511 // the Google account.
512 static
void logoutUserForReauthentication
();
514 // Cancels file selection.
515 static
void cancelDialog
();
517 // Executes file browser task over selected files.
518 // |taskId| The unique identifier of task to execute.
519 // |fileUrls| Array of file URLs
521 static
void executeTask
(DOMString taskId
,
522 DOMString
[] fileUrls
,
523 optional ExecuteTaskCallback
callback);
525 // Sets the default task for the supplied MIME types and suffixes of the
526 // supplied file URLs. Lists of MIME types and URLs may contain duplicates.
527 // |taskId| The unique identifier of task to mark as default.
528 // |fileUrls| Array of selected file URLs to extract suffixes from.
529 // |mimeTypes| Array of selected file MIME types.
531 static
void setDefaultTask
(DOMString taskId
,
532 DOMString
[] fileUrls
,
533 optional DOMString
[] mimeTypes
,
534 optional SimpleCallback
callback);
536 // Gets the list of tasks that can be performed over selected files.
537 // |fileUrls| Array of selected file URLs
538 // |mimeTypes| Array of selected file MIME types
540 static
void getFileTasks
(DOMString
[] fileUrls
,
541 DOMString
[] mimeTypes
,
542 GetFileTasksCallback
callback);
544 // Gets localized strings and initialization data.
546 static
void getStrings
(GetStringsCallback
callback);
549 // |fileUrl| URL of file to watch
551 static
void addFileWatch
(DOMString fileUrl
, AddFileWatchCallback
callback);
553 // Removes file watch.
554 // |fileUrl| URL of watched file to remove
556 static
void removeFileWatch
(DOMString fileUrl
,
557 RemoveFileWatchCallback
callback);
559 // Requests access to a file system volume.
560 // |volumeId| The ID of the file system volume to request. The volume ID is
561 // delivered to JavaScript as part of VolumeMetadata. By specifying
562 // "compatible", this function behaves in the compatible mode, where the
563 // returned FileSystem object gives access to all file system volumes such
564 // as Downloads folder and removal media like SD cards (i.e. all volumes
565 // are provided inside the single FileSystem object). In the new
566 // "per-volume FileSystem object model" crbug.com/322305, a separate
567 // FileSystem object is created for each volume. "compatible" parameter
568 // will be removed once Files.app is switched to the per-volume FileSystem
571 static
void requestFileSystem
(DOMString volumeId
,
572 RequestFileSystemCallback
callback);
574 // Selects multiple files.
575 // |selectedPaths| Array of selected paths
576 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
578 static
void selectFiles
(DOMString
[] selectedPaths
,
579 boolean shouldReturnLocalPath
,
580 SimpleCallback
callback);
583 // |selectedPath| A selected path
584 // |index| Index of Filter
585 // |forOpening| true if paths are selected for opening. false if for saving.
586 // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
588 static
void selectFile
(DOMString selectedPath
,
591 boolean shouldReturnLocalPath
,
592 SimpleCallback
callback);
594 // Requests Drive file properties for files.
595 // |fileUrls| list of URLs of files
597 static
void getDriveEntryProperties
(
598 DOMString
[] fileUrls
,
599 GetDriveEntryPropertiesCallback
callback);
601 // Pins/unpins a Drive file in the cache.
602 // |fileUrl| URL of a file to pin/unpin.
603 // |pin| Pass true to pin the file.
604 // |callback| Completion callback. $(ref:runtime.lastError) will be set if there
606 static
void pinDriveFile
(DOMString fileUrl
,
608 optional SimpleCallback
callback);
611 // |fileUrls| Array of Drive file URLs to get.
613 static
void getDriveFiles
(DOMString
[] fileUrls
,
614 GetDriveFilesCallback
callback);
616 // Mount a resource or a file.
617 // |source| Mount point source. For compressed files it is relative file path
618 // within external file system
620 static
void addMount
(DOMString
source, AddMountCallback
callback);
622 // Unmounts a mounted resource.
623 // |volumeId| An ID of the volume.
624 static
void removeMount
(DOMString volumeId
);
626 // Get the list of mounted volumes.
628 static
void getVolumeMetadataList
(GetVolumeMetadataListCallback
callback);
630 // Cancels ongoing file transfers for selected files.
631 // |fileUrls| Array of files for which ongoing transfer should be canceled.
633 static
void cancelFileTransfers
(DOMString
[] fileUrls
,
634 CancelFileTransfersCallback
callback);
636 // Starts to copy an entry. If the source is a directory, the copy is done
638 // |sourceUrl| URL of the source entry to be copied.
639 // |parent| URL of the destination directory.
640 // |newName| Name of the new entry. It shouldn't contain '/'.
641 // |callback| Completion callback.
642 static
void startCopy
(DOMString sourceUrl
,
645 StartCopyCallback
callback);
647 // Cancels the running copy task.
648 // |copyId| ID of the copy task to be cancelled.
649 // |callback| Completion callback of the cancel.
650 static
void cancelCopy
(long copyId
, optional SimpleCallback
callback);
652 // Retrieves total and remaining size of a mount point.
653 // |volumeId| ID of the volume to be checked.
655 static
void getSizeStats
(DOMString volumeId
, GetSizeStatsCallback
callback);
657 // Formats a mounted volume.
658 // |volumeId| ID of the volume to be formatted.
659 static
void formatVolume
(DOMString volumeId
);
661 // Retrieves file manager preferences.
663 static
void getPreferences
(GetPreferencesCallback
callback);
665 // Sets file manager preferences.
667 static
void setPreferences
(PreferencesChange changeInfo
);
669 // Performs drive content search.
672 static
void searchDrive
(SearchParams searchParams
,
673 SearchDriveCallback
callback);
675 // Performs drive metadata search.
678 static
void searchDriveMetadata
(SearchMetadataParams searchParams
,
679 SearchDriveMetadataCallback
callback);
681 // Create a zip file for the selected files.
682 // |dirURL| URL of the directory containing the selected files.
683 // |selectionUrls| URLs of the selected files. The files must be under the
684 // directory specified by dirURL.
685 // |destName| Name of the destination zip file. The zip file will be created
686 // under the directory specified by dirURL.
688 static
void zipSelection
(DOMString dirURL
,
689 DOMString
[] selectionUrls
,
691 optional ZipSelectionCallback
callback);
693 // Retrieves the state of the current drive connection.
695 static
void getDriveConnectionState
(GetDriveConnectionStateCallback
callback);
697 // Checks whether the path name length fits in the limit of the filesystem.
698 // |parent_directory_url| The URL of the parent directory entry.
699 // |name| The name of the file.
700 // |callback| Called back when the check is finished.
701 static
void validatePathNameLength
(DOMString parent_directory_url
,
703 ValidatePathNameLengthCallback
callback);
705 // Changes the zoom factor of the Files.app.
706 // |operation| Zooming mode.
707 static
void zoom
(ZoomOperationType operation
);
709 // Requests a Drive API OAuth2 access token.
710 // |refresh| Whether the token should be refetched instead of using the cached
713 static
void requestAccessToken
(boolean refresh
,
714 RequestAccessTokenCallback
callback);
716 // Requests a Webstore API OAuth2 access token.
718 static
void requestWebStoreAccessToken
(
719 RequestWebStoreAccessTokenCallback
callback);
721 // Requests a share dialog url for the specified file.
722 // |url| Url for the file.
724 static
void getShareUrl
(DOMString url
, GetShareUrlCallback
callback);
726 // Requests to share drive files.
727 // |url| URL of a file to be shared.
728 // |shareType| Type of access that is getting granted.
729 static
void requestDriveShare
(DOMString url
,
730 DriveShareType shareType
,
731 SimpleCallback
callback);
733 // Requests to install a webstore item.
734 // |item_id| The id of the item to install.
736 static
void installWebstoreItem
(DOMString item_id
,
737 SimpleCallback
callback);
739 // Obtains a list of profiles that are logged-in.
740 static
void getProfiles
(GetProfilesCallback
callback);
742 // Moves the window to other user's desktop.
743 static
void visitDesktop
(DOMString profileId
,
744 optional SimpleCallback
callback);
748 static
void onMountCompleted
(MountCompletedEvent event
);
750 static
void onFileTransfersUpdated
(FileTransferStatus
[] event
);
752 static
void onCopyProgress
(long copyId
, CopyProgressStatus status
);
754 static
void onDirectoryChanged
(FileWatchEvent event
);
756 static
void onPreferencesChanged
();
758 static
void onDriveConnectionStatusChanged
();
760 static
void onDeviceChanged
(DeviceEvent event
);
762 static
void onDriveSyncError
(DriveSyncErrorEvent event
);
764 // Dispatched when a profile is added.
765 static
void onProfileAdded
();
767 // Dispatched when any window moves another desktop.
768 // TODO(hirono): Add information which window is moved.
769 static
void onDesktopChanged
();