Enable Enterprise enrollment on desktop builds.
[chromium-blink-merge.git] / chrome / common / extensions / api / file_browser_private.idl
blobdc3bca43a9aaa13d11e513806753604d30585c46
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,
12 mtp, testing };
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
18 // supported.
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 {
27 success,
28 error_unknown,
29 error_internal,
30 error_invalid_argument,
31 error_invalid_path,
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,
44 error_authentication,
45 error_path_unmounted
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.
58 begin_copy_entry,
60 // "end_copy_entry" is fired for each entry (file or directory) after ending
61 // the copy operation.
62 end_copy_entry,
64 // "progress" is fired periodically to report progress of a file copy (not
65 // directory).
66 progress,
68 // "success" is fired after all entries are copied.
69 success,
71 // "error" is fired when an error occurs.
72 error
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 };
81 // Zooming mode.
82 enum ZoomOperationType { in, out, reset };
84 // Device event type.
85 enum DeviceEventType {
86 // Device is added.
87 added,
88 // If the device is disabled by preference, the disabled event is published
89 // instead of the added event.
90 disabled,
91 // Device is added, but scan for the device is canceled. The event is
92 // published after the added event.
93 scan_canceled,
94 // Device is removed.
95 removed,
96 // Device is hard unplugged.
97 hard_unplugged,
98 // Format started.
99 format_start,
100 // Format succeeded.
101 format_success,
102 // Format failed.
103 format_fail
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.
112 service_unavailable,
113 // Miscellaneous errors other than listed above.
114 misc
117 // Result of task execution.
118 enum TaskResult {
119 // The task execution succeeded and a new window/tab was opened.
120 opened,
121 // The task execution succeeded and the message was sent to the proper
122 // extension.
123 message_sent,
124 // The task execution failed.
125 failed,
126 // No URL is specified.
127 empty
130 // Drive share type.
131 enum DriveShareType {
132 can_edit,
133 can_comment,
134 can_view
137 // ImageSet that represents multi-scale images.
138 dictionary ImageSet {
139 // 1x scale URL.
140 DOMString scale1xUrl;
141 // 2x scale URL.
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.
151 DOMString taskId;
153 // Task title (ex. App name).
154 DOMString title;
156 // Task icon url (from chrome://extension-icon/...)
157 DOMString iconUrl;
159 // True if this task is a default task for the selected files.
160 boolean isDefault;
163 // Drive file properties.
164 dictionary DriveEntryProperties {
165 // Size of this file.
166 double? fileSize;
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.
175 long? imageWidth;
177 // Height, if the entry is an image.
178 long? imageHeight;
180 // Rotation in clockwise degrees, if the entry is an image.
181 long? imageRotation;
183 // True if the file is pinned in Drive cache.
184 boolean? isPinned;
186 // True if the file is present in Drive cache.
187 boolean? isPresent;
189 // True if the file is hosted on a Drive server instead of local.
190 boolean? isHosted;
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
202 // by others.)
203 boolean? shared;
206 // Information about total and remaining size on the mount point.
207 dictionary MountPointSizeStats {
208 // Approximate total available size on the mount point.
209 double totalSize;
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.
218 DOMString profileId;
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.
235 DOMString volumeId;
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.
240 ProfileInfo profile;
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
252 // devicePath.
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.
262 boolean isReadOnly;
264 // Additional data about mount, for example, that the filesystem is not
265 // supported.
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.
288 DOMString fileUrl;
290 // File transfer progress state.
291 TransferState transferState;
293 // Defines file transfer direction.
294 TransferType transferType;
296 // Approximated completed portion of the transfer operation.
297 double? processed;
299 // Approximated total size of transfer operation.
300 double? total;
303 // Error during the drive sync.
304 dictionary DriveSyncErrorEvent {
305 // Error type.
306 DriveSyncErrorType type;
308 // File URL of the entry that the error happens to.
309 DOMString fileUrl;
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).
331 double? size;
333 // DOMError's name. Available only for ERROR event.
334 DOMString? error;
337 // Payload data for file transfer cancel response.
338 dictionary FileTransferCancelStatus {
339 // URL of file that is being transfered.
340 DOMString fileUrl;
342 // True if ongoing transfer operation was found and canceled.
343 boolean 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
354 // interface, see <a
355 // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
356 // interface</a>.
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 {
374 // Search query.
375 DOMString query;
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
379 // search request.
380 DOMString nextFeed;
383 dictionary SearchMetadataParams {
384 // Search query. It can be empty. Any filename matches to an empty query.
385 DOMString query;
387 // The type of entry that is needed. Default to ALL.
388 SearchType types;
390 // Maximum number of results.
391 long maxResults;
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
401 // interface</a>.
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
406 // like &lt;.
407 DOMString highlightedBaseName;
410 dictionary DriveConnectionState {
411 DOMString type;
413 // Reasons of offline.
414 DOMString? reason;
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
468 // cancel the task.
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);
477 // |entries|
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
520 // |callback|
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.
530 // |callback|
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
539 // |callback|
540 static void getFileTasks(DOMString[] fileUrls,
541 DOMString[] mimeTypes,
542 GetFileTasksCallback callback);
544 // Gets localized strings and initialization data.
545 // |callback|
546 static void getStrings(GetStringsCallback callback);
548 // Adds file watch.
549 // |fileUrl| URL of file to watch
550 // |callback|
551 static void addFileWatch(DOMString fileUrl, AddFileWatchCallback callback);
553 // Removes file watch.
554 // |fileUrl| URL of watched file to remove
555 // |callback|
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
569 // object model.
570 // |callback|
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.
577 // |callback|
578 static void selectFiles(DOMString[] selectedPaths,
579 boolean shouldReturnLocalPath,
580 SimpleCallback callback);
582 // Selects a file.
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.
587 // |callback|
588 static void selectFile(DOMString selectedPath,
589 long index,
590 boolean forOpening,
591 boolean shouldReturnLocalPath,
592 SimpleCallback callback);
594 // Requests Drive file properties for files.
595 // |fileUrls| list of URLs of files
596 // |callback|
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
605 // was an error.
606 static void pinDriveFile(DOMString fileUrl,
607 boolean pin,
608 optional SimpleCallback callback);
610 // Get Drive files.
611 // |fileUrls| Array of Drive file URLs to get.
612 // |callback|
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
619 // |callback|
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.
627 // |callback|
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.
632 // |callback|
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
637 // recursively.
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,
643 DOMString parent,
644 DOMString newName,
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.
654 // |callback|
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.
662 // |callback|
663 static void getPreferences(GetPreferencesCallback callback);
665 // Sets file manager preferences.
666 // |changeInfo|
667 static void setPreferences(PreferencesChange changeInfo);
669 // Performs drive content search.
670 // |searchParams|
671 // |callback|
672 static void searchDrive(SearchParams searchParams,
673 SearchDriveCallback callback);
675 // Performs drive metadata search.
676 // |searchParams|
677 // |callback|
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.
687 // |callback|
688 static void zipSelection(DOMString dirURL,
689 DOMString[] selectionUrls,
690 DOMString destName,
691 optional ZipSelectionCallback callback);
693 // Retrieves the state of the current drive connection.
694 // |callback|
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,
702 DOMString name,
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
711 // one.
712 // |callback|
713 static void requestAccessToken(boolean refresh,
714 RequestAccessTokenCallback callback);
716 // Requests a Webstore API OAuth2 access token.
717 // |callback|
718 static void requestWebStoreAccessToken(
719 RequestWebStoreAccessTokenCallback callback);
721 // Requests a share dialog url for the specified file.
722 // |url| Url for the file.
723 // |callback|
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.
735 // |callback|
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);
747 interface Events {
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();