e8b42564ad1ebd90c102d68513b78b78b0bade38
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / api / file_browser_private.idl
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.
4
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 };
12
13 // Device type. Available if this is removable volume.
14 enum DeviceType { usb, sd, optical, mobile, unknown };
15
16 // Additional data about mount, for example, that the filesystem is not
17 // supported.
18 enum MountCondition { unknown, unsupported };
19
20 // Is the event raised for mounting or unmounting.
21 enum MountCompletedEventType { mount, unmount };
22
23 // Event type that tells listeners if mount was successful or an error
24 // occurred. It also specifies the error.
25 enum MountCompletedStatus {
26   success,
27   error_unknown,
28   error_internal,
29   error_invalid_argument,
30   error_invalid_path,
31   error_path_already_mounted,
32   error_path_not_mounted,
33   error_directory_creation_failed,
34   error_invalid_mount_options,
35   error_invalid_unmount_options,
36   error_insufficient_permissions,
37   error_mount_program_not_found,
38   error_mount_program_failed,
39   error_invalid_device_path,
40   error_unknown_filesystem,
41   error_unsuported_filesystem,
42   error_invalid_archive,
43   error_authentication,
44   error_path_unmounted
45 };
46
47 // File transfer progress state.
48 enum TransferState { started, in_progress, completed, failed };
49
50 // Defines file transfer direction.
51 enum TransferType { upload, download };
52
53 // The type of the progress event.
54 enum CopyProgressStatusType {
55   // "begin_copy_entry" is fired for each entry (file or directory) before
56   // starting the copy operation.
57   begin_copy_entry,
58
59   // "end_copy_entry" is fired for each entry (file or directory) after ending
60   // the copy operation.
61   end_copy_entry,
62
63   // "progress" is fired periodically to report progress of a file copy (not
64   // directory).
65   progress,
66
67   // "success" is fired after all entries are copied.
68   success,
69
70   // "error" is fired when an error occurs.
71   error
72 };
73
74 // Specifies type of event that is raised.
75 enum FileWatchEventType { changed, error };
76
77 // The type of entry that is needed. Default to ALL.
78 enum SearchType { EXCLUDE_DIRECTORIES, SHARED_WITH_ME, OFFLINE, ALL };
79
80 // Zooming mode.
81 enum ZoomOperationType { in, out, reset };
82
83 // Device event type.
84 enum DeviceEventType {
85   // Device is added.
86   added,
87   // If the device is disabled by preference, the disabled event is published
88   // instead of the added event.
89   disabled,
90   // Device is added, but scan for the device is canceled. The event is
91   // published after the added event.
92   scan_canceled,
93   // Device is removed.
94   removed,
95   // Format started.
96   format_start,
97   // Format succeeded.
98   format_success,
99   // Format failed.
100   format_fail
101 };
102
103 // Drive sync error type.
104 // Keep it synced with DriveSyncErrorType in operation_observer.h.
105 enum DriveSyncErrorType {
106   // Request to delete a file without permission.
107   delete_without_permission,
108   // Google Drive is temporarily unavailable.
109   service_unavailable,
110   // Miscellaneous errors other than listed above.
111   misc
112 };
113
114 // A file task represents an action that the file manager can perform over the
115 // currently selected files. See
116 // chrome/browser/chromeos/extensions/file_manager/file_tasks.h for details
117 // about how file tasks are handled.
118 dictionary FileTask {
119   // The unique identifier of the task.
120   DOMString taskId;
121
122   // Task title (ex. App name).
123   DOMString title;
124
125   // Task icon url (from chrome://extension-icon/...)
126   DOMString iconUrl;
127
128   // True if this task is a default task for the selected files.
129   boolean isDefault;
130 };
131
132 // Drive file properties.
133 dictionary DriveEntryProperties {
134   // URL to the Drive thumbnail image for this file.
135   DOMString? thumbnailUrl;
136
137   // Width, if the entry is an image.
138   long? imageWidth;
139
140   // Height, if the entry is an image.
141   long? imageHeight;
142
143   // Rotation in clockwise degrees, if the entry is an image.
144   long? imageRotation;
145
146   // True if the file is pinned in Drive cache.
147   boolean? isPinned;
148
149   // True if the file is present in Drive cache.
150   boolean? isPresent;
151
152   // True if the file is hosted on a Drive server instead of local.
153   boolean? isHosted;
154
155   // URL to the custom icon for this file.
156   DOMString? customIconUrl;
157
158   // Drive MIME type for this file.
159   DOMString? contentMimeType;
160
161   // True if the entry is labeled as shared-with-me.
162   boolean? sharedWithMe;
163
164   // True if the entry is labeled as shared (either from me to others or to me
165   // by others.)
166   boolean? shared;
167 };
168
169 // Information about total and remaining size on the mount point.
170 dictionary MountPointSizeStats {
171   // Approximate total available size on the mount point.
172   double totalSize;
173
174   // Approximate remaining available size on the mount point.
175   double remainingSize;
176 };
177
178 // Information about a profile.
179 dictionary ProfileInfo {
180   // Profile ID. This is currently e-mail address of the profile.
181   DOMString profileId;
182
183   // The name of the profile for display purpose.
184   DOMString displayName;
185
186   // True if the profile is the one running the current file manager instance.
187   // TODO(hirono): Remove the property because of the design change of
188   // multi-profile suuport.
189   boolean isCurrentProfile;
190
191   // Data URI of profile image;
192   DOMString? imageUri;
193 };
194
195 // Mounted disk volume metadata.
196 dictionary VolumeMetadata {
197   // ID of the disk volume.
198   DOMString volumeId;
199
200   // Description of the profile where the volume belongs.
201   // TODO(hirono): Remove the property because of the design change of
202   // multi-profile suuport.
203   ProfileInfo profile;
204
205   // Disk volume mount point path.
206   DOMString mountPath;
207
208   // The path to the mounted device, archive file or network resource.
209   DOMString? sourcePath;
210
211   // Type of the mounted volume.
212   VolumeType volumeType;
213
214   // Device type. Available if this is removable volume.
215   DeviceType? deviceType;
216
217   // Path to identify the device. This is consistent with DeviceEvent's
218   // devicePath.
219   DOMString? devicePath;
220
221   // Label of the device.
222   DOMString? deviceLabel;
223
224   // Whether the device is parent or not (i.e. sdb rather than sdb1).
225   boolean? isParentDevice;
226
227   // Flag that specifies if volume is mounted in read-only mode.
228   boolean isReadOnly;
229
230   // Additional data about mount, for example, that the filesystem is not
231   // supported.
232   MountCondition? mountCondition;
233 };
234
235 // Payload data for mount event.
236 dictionary MountCompletedEvent {
237   // Is the event raised for mounting or unmounting.
238   MountCompletedEventType eventType;
239
240   // Event type that tells listeners if mount was successful or an error
241   // occurred. It also specifies the error.
242   MountCompletedStatus status;
243
244   // Metadata of the mounted volume.
245   VolumeMetadata volumeMetadata;
246
247   // Whether it is remount or not.
248   boolean isRemounting;
249 };
250
251 // Payload data for file transfer status updates.
252 dictionary FileTransferStatus {
253   // URL of file that is being transfered.
254   DOMString fileUrl;
255
256   // File transfer progress state.
257   TransferState transferState;
258
259   // Defines file transfer direction.
260   TransferType transferType;
261
262   // Approximated completed portion of the transfer operation.
263   double? processed;
264
265   // Approximated total size of transfer operation.
266   double? total;
267 };
268
269 // Error during the drive sync.
270 dictionary DriveSyncErrorEvent {
271   // Error type.
272   DriveSyncErrorType type;
273
274   // File URL of the entry that the error happens to.
275   DOMString fileUrl;
276 };
277
278 // Payload data for copy status progress updates.
279 dictionary CopyProgressStatus {
280   // The type of the progress event.
281   CopyProgressStatusType type;
282
283   // URL for the entry currently being copied. This field is particularly useful
284   // when a directory copy is initiated with startCopy(). The field tells what
285   // file/directory in that directory is now being copied.
286   DOMString? sourceUrl;
287
288   // URL for the entry currently being created. This field is particularly
289   // useful when a directory copy is initiated with startCopy(). The field tells
290   // what file/directory in that directory is being created. Available only for
291   // end_copy_entry and success.
292   DOMString? destinationUrl;
293
294   // Number of processed bytes for the file currently being copied. Available
295   // only for "progress" event. To show the progress bar, a caller needs to
296   // pre-compute the size of files being copied for the file (not directory).
297   double? size;
298
299   // FileError's code of the error. Available only for ERROR event.
300   long? error;
301 };
302
303 // Payload data for file transfer cancel response.
304 dictionary FileTransferCancelStatus {
305   // URL of file that is being transfered.
306   DOMString fileUrl;
307
308   // True if ongoing transfer operation was found and canceled.
309   boolean canceled;
310 };
311
312 // Directory change notification details.
313 dictionary FileWatchEvent {
314   // Specifies type of event that is raised.
315   FileWatchEventType eventType;
316
317   // An Entry object which represents a changed directory. The conversion into a
318   // kind of FileEntry object is done in
319   // file_browser_handler_custom_bindings.cc. For filesystem API's Entry
320   // interface, see <a
321   // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
322   // interface</a>.
323   [instanceOf=Entry] object entry;
324 };
325
326 dictionary Preferences {
327   boolean driveEnabled;
328   boolean cellularDisabled;
329   boolean hostedFilesDisabled;
330   boolean use24hourClock;
331   boolean allowRedeemOffers;
332 };
333
334 dictionary PreferencesChange {
335   boolean? cellularDisabled;
336   boolean? hostedFilesDisabled;
337 };
338
339 dictionary SearchParams {
340   // Search query.
341   DOMString query;
342
343   // ID of the search feed that should be fetched next. Value passed here should
344   // be gotten from previous searchDrive call. It can be empty for the initial
345   // search request.
346   DOMString nextFeed;
347 };
348
349 dictionary SearchMetadataParams {
350   // Search query. It can be empty. Any filename matches to an empty query.
351   DOMString query;
352
353   // The type of entry that is needed. Default to ALL.
354   SearchType types;
355
356   // Maximum number of results.
357   long maxResults;
358 };
359
360 // Entry and Drive-related properties representing a search result.
361 dictionary SearchResult {
362   // A dictionary object which represents a Drive file. This will be converted
363   // into a kind of FileEntry object. See
364   // file_browser_handler_custom_bindings.cc for details. For filesystem API's
365   // Entry interface, see <a
366   // href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
367   // interface</a>.
368   [instanceOf=Entry] object entry;
369
370   // The base name of a Drive file that matched the search query. The matched
371   // sub strings are highlighted with <b> element. Meta characters are escaped
372   // like &lt;.
373   DOMString highlightedBaseName;
374 };
375
376 dictionary DriveConnectionState {
377   DOMString type;
378
379   // Reasons of offline.
380   DOMString? reason;
381 };
382
383 // Device event dispatched to listeners of onDeviceChaged.  See also
384 // DeviceEventType to know when the event dispatched.
385 dictionary DeviceEvent {
386   // Event type of the device event.
387   DeviceEventType type;
388   // Device path to identify the device.
389   DOMString devicePath;
390 };
391
392 // Callback that does not take arguments.
393 callback SimpleCallback = void();
394
395 // |success| True of task execution was successfully initiated.
396 callback ExecuteTaskCallback = void(optional boolean success);
397
398 // |tasks| The list of matched file URL patterns for this task.
399 callback GetFileTasksCallback = void(FileTask[] tasks);
400
401 // |result| Hash containing the string assets.
402 callback GetStringsCallback = void(object result);
403
404 // |success| True when file watch is successfully added.
405 callback AddFileWatchCallback = void(optional boolean success);
406
407 // |success| True when file watch is successfully removed.
408 callback RemoveFileWatchCallback = void(optional boolean success);
409
410 // |fileSystem| A DOMFileSystem instance for local file system access. null if
411 // |the caller has no appropriate permissions.
412 callback RequestFileSystemCallback = void(optional object fileSystem);
413
414 // |fileProperties| A dictionary containing properties of the requested entry.
415 callback GetDriveEntryPropertiesCallback =
416     void(DriveEntryProperties fileProperties);
417
418 // |localFilePaths| An array of the local file paths for the requested files,
419 // one entry for each file in fileUrls.
420 callback GetDriveFilesCallback = void(DOMString[] localFilePaths);
421
422 // |sourcePath| Source path of the mount.
423 callback AddMountCallback = void(DOMString sourcePath);
424
425 // |volumeMetadataList| The list of VolumeMetadata representing mounted volumes.
426 callback GetVolumeMetadataListCallback =
427     void(VolumeMetadata[] volumeMetadataList);
428
429 // |fileTransferCancelStatuses| The list of FileTransferCancelStatus.
430 callback CancelFileTransfersCallback =
431     void(FileTransferCancelStatus[] fileTransferCancelStatuses);
432
433 // |copyId| ID of the copy task. Can be used to identify the progress, and to
434 // cancel the task.
435 callback StartCopyCallback = void(long copyId);
436
437 // |sizeStats| Name/value pairs of size stats. Will be undefined if stats could
438 // not be determined.
439 callback GetSizeStatsCallback = void(optional MountPointSizeStats sizeStats);
440
441 callback GetPreferencesCallback = void(Preferences result);
442
443 // |entries|
444 // |nextFeed| ID of the feed that contains next chunk of the search result.
445 //     Should be sent to the next searchDrive request to perform
446 //     incremental search.
447 callback SearchDriveCallback =
448     void([instanceOf=Entry] object[] entries, DOMString nextFeed);
449
450 callback SearchDriveMetadataCallback = void(SearchResult[] results);
451
452 callback ZipSelectionCallback = void(optional boolean success);
453
454 callback GetDriveConnectionStateCallback = void(DriveConnectionState result);
455
456 // |result| true if the length is in the valid range, false otherwise.
457 callback ValidatePathNameLengthCallback = void(boolean result);
458
459 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
460 callback RequestAccessTokenCallback = void(DOMString accessToken);
461
462 // |accessToken| OAuth2 access token, or an empty string if failed to fetch.
463 callback RequestWebStoreAccessTokenCallback = void(DOMString accessToken);
464
465 // |shareUrl| Share Url for the sharing dialog.
466 callback GetShareUrlCallback = void(DOMString shareUrl);
467
468 // |profiles| List of profile information.
469 // |runningProfile| ID of the profile that runs the application instance.
470 // |showingProfile| ID of the profile that shows the application window.
471 callback GetProfilesCallback = void(ProfileInfo[] profiles,
472                                     DOMString runningProfile,
473                                     DOMString displayProfile);
474
475 interface Functions {
476   // Logout the current user for navigating to the re-authentication screen for
477   // the Google account.
478   static void logoutUserForReauthentication();
479
480   // Cancels file selection.
481   static void cancelDialog();
482
483   // Executes file browser task over selected files.
484   // |taskId| The unique identifier of task to execute.
485   // |fileUrls| Array of file URLs
486   // |callback|
487   static void executeTask(DOMString taskId,
488                           DOMString[] fileUrls,
489                           optional ExecuteTaskCallback callback);
490
491   // Sets the default task for the supplied MIME types and suffixes of the
492   // supplied file URLs. Lists of MIME types and URLs may contain duplicates.
493   // |taskId| The unique identifier of task to mark as default.
494   // |fileUrls| Array of selected file URLs to extract suffixes from.
495   // |mimeTypes| Array of selected file MIME types.
496   // |callback|
497   static void setDefaultTask(DOMString taskId,
498                              DOMString[] fileUrls,
499                              optional DOMString[] mimeTypes,
500                              optional SimpleCallback callback);
501
502   // Gets the list of tasks that can be performed over selected files.
503   // |fileUrls| Array of selected file URLs
504   // |mimeTypes| Array of selected file MIME types
505   // |callback|
506   static void getFileTasks(DOMString[] fileUrls,
507                            DOMString[] mimeTypes,
508                            GetFileTasksCallback callback);
509
510   // Gets localized strings and initialization data.
511   // |callback|
512   static void getStrings(GetStringsCallback callback);
513
514   // Adds file watch.
515   // |fileUrl| URL of file to watch
516   // |callback|
517   static void addFileWatch(DOMString fileUrl, AddFileWatchCallback callback);
518
519   // Removes file watch.
520   // |fileUrl| URL of watched file to remove
521   // |callback|
522   static void removeFileWatch(DOMString fileUrl,
523                               RemoveFileWatchCallback callback);
524
525   // Requests access to a file system volume.
526   // |volumeId| The ID of the file system volume to request. The volume ID is
527   //     delivered to JavaScript as part of VolumeMetadata. By specifying
528   //     "compatible", this function behaves in the compatible mode, where the
529   //     returned FileSystem object gives access to all file system volumes such
530   //     as Downloads folder and removal media like SD cards (i.e. all volumes
531   //     are provided inside the single FileSystem object). In the new
532   //     "per-volume FileSystem object model" crbug.com/322305, a separate
533   //     FileSystem object is created for each volume. "compatible" parameter
534   //     will be removed once Files.app is switched to the per-volume FileSystem
535   //     object model.
536   // |callback|
537   static void requestFileSystem(DOMString volumeId,
538                                 RequestFileSystemCallback callback);
539
540   // Selects multiple files.
541   // |selectedPaths| Array of selected paths
542   // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
543   // |callback|
544   static void selectFiles(DOMString[] selectedPaths,
545                           boolean shouldReturnLocalPath,
546                           SimpleCallback callback);
547
548   // Selects a file.
549   // |selectedPath| A selected path
550   // |index| Index of Filter
551   // |forOpening| true if paths are selected for opening. false if for saving.
552   // |shouldReturnLocalPath| true if paths need to be resolved to local paths.
553   // |callback|
554   static void selectFile(DOMString selectedPath,
555                          long index,
556                          boolean forOpening,
557                          boolean shouldReturnLocalPath,
558                          SimpleCallback callback);
559
560   // Requests Drive file properties for a file.
561   // |fileUrl| URL of a file
562   // |callback|
563   static void getDriveEntryProperties(DOMString fileUrl,
564                                       GetDriveEntryPropertiesCallback callback);
565
566   // Pins/unpins a Drive file in the cache.
567   // |fileUrl| URL of a file to pin/unpin.
568   // |pin| Pass true to pin the file.
569   // |callback| Completion callback. $ref:runtime.lastError will be set if there
570   //     was an error.
571   static void pinDriveFile(DOMString fileUrl,
572                            boolean pin,
573                            optional SimpleCallback callback);
574
575   // Get Drive files.
576   // |fileUrls| Array of Drive file URLs to get.
577   // |callback|
578   static void getDriveFiles(DOMString[] fileUrls,
579                             GetDriveFilesCallback callback);
580
581   // Mount a resource or a file.
582   // |source| Mount point source. For compressed files it is relative file path
583   //     within external file system
584   // |callback|
585   static void addMount(DOMString source, AddMountCallback callback);
586
587   // Unmounts a mounted resource.
588   // |mountPath| A path of the mount.
589   static void removeMount(DOMString mountPath);
590
591   // Get the list of mounted volumes.
592   // |callback|
593   static void getVolumeMetadataList(GetVolumeMetadataListCallback callback);
594
595   // Cancels ongoing file transfers for selected files.
596   // |fileUrls| Array of files for which ongoing transfer should be canceled.
597   // |callback|
598   static void cancelFileTransfers(DOMString[] fileUrls,
599                                   CancelFileTransfersCallback callback);
600
601   // Starts to copy an entry. If the source is a directory, the copy is done
602   // recursively.
603   // |sourceUrl| URL of the source entry to be copied.
604   // |parent| URL of the destination directory.
605   // |newName| Name of the new entry. It shouldn't contain '/'.
606   // |callback| Completion callback.
607   static void startCopy(DOMString sourceUrl,
608                         DOMString parent,
609                         DOMString newName,
610                         StartCopyCallback callback);
611
612   // Cancels the running copy task.
613   // |copyId| ID of the copy task to be cancelled.
614   // |callback| Completion callback of the cancel.
615   static void cancelCopy(long copyId, optional SimpleCallback callback);
616
617   // Retrieves total and remaining size of a mount point.
618   // |mountPath| Mount point path.
619   // |callback|
620   static void getSizeStats(DOMString mountPath, GetSizeStatsCallback callback);
621
622   // Formats a mounted volume.
623   // |volumeId| ID of the volume to be formatted.
624   static void formatVolume(DOMString volumeId);
625
626   // Retrieves file manager preferences.
627   // |callback|
628   static void getPreferences(GetPreferencesCallback callback);
629
630   // Sets file manager preferences.
631   // |changeInfo|
632   static void setPreferences(PreferencesChange changeInfo);
633
634   // Performs drive content search.
635   // |searchParams|
636   // |callback|
637   static void searchDrive(SearchParams searchParams,
638                           SearchDriveCallback callback);
639
640   // Performs drive metadata search.
641   // |searchParams|
642   // |callback|
643   static void searchDriveMetadata(SearchMetadataParams searchParams,
644                                   SearchDriveMetadataCallback callback);
645
646   // Create a zip file for the selected files.
647   // |dirURL| URL of the directory containing the selected files.
648   // |selectionUrls| URLs of the selected files. The files must be under the
649   //     directory specified by dirURL.
650   // |destName| Name of the destination zip file. The zip file will be created
651   //     under the directory specified by dirURL.
652   // |callback|
653   static void zipSelection(DOMString dirURL,
654                            DOMString[] selectionUrls,
655                            DOMString destName,
656                            optional ZipSelectionCallback callback);
657
658   // Retrieves the state of the current drive connection.
659   // |callback|
660   static void getDriveConnectionState(GetDriveConnectionStateCallback callback);
661
662   // Checks whether the path name length fits in the limit of the filesystem.
663   // |parent_directory_url| The URL of the parent directory entry.
664   // |name| The name of the file.
665   // |callback| Called back when the check is finished.
666   static void validatePathNameLength(DOMString parent_directory_url,
667                                      DOMString name,
668                                      ValidatePathNameLengthCallback callback);
669
670   // Changes the zoom factor of the Files.app.
671   // |operation| Zooming mode.
672   static void zoom(ZoomOperationType operation);
673
674   // Requests a Drive API OAuth2 access token.
675   // |refresh| Whether the token should be refetched instead of using the cached
676   //     one.
677   // |callback|
678   static void requestAccessToken(boolean refresh,
679                                  RequestAccessTokenCallback callback);
680
681   // Requests a Webstore API OAuth2 access token.
682   // |callback|
683   static void requestWebStoreAccessToken(
684       RequestWebStoreAccessTokenCallback callback);
685
686   // Requests a share dialog url for the specified file.
687   // |url| Url for the file.
688   // |callback|
689   static void getShareUrl(DOMString url, GetShareUrlCallback callback);
690
691   // Requests to install a webstore item.
692   // |item_id| The id of the item to install.
693   // |callback|
694   static void installWebstoreItem(DOMString item_id,
695                                   SimpleCallback callback);
696
697   // Obtains a list of profiles that are logged-in.
698   static void getProfiles(GetProfilesCallback callback);
699
700   // Moves the window to other user's desktop.
701   static void visitDesktop(DOMString profileId,
702                            SimpleCallback callback);
703 };
704
705 interface Events {
706   static void onMountCompleted(MountCompletedEvent event);
707
708   static void onFileTransfersUpdated(FileTransferStatus[] event);
709
710   static void onCopyProgress(long copyId, CopyProgressStatus status);
711
712   static void onDirectoryChanged(FileWatchEvent event);
713
714   static void onPreferencesChanged();
715
716   static void onDriveConnectionStatusChanged();
717
718   static void onDeviceChanged(DeviceEvent event);
719
720   static void onDriveSyncError(DriveSyncErrorEvent event);
721 };
722 };