blob: 71b6702b1515f62916a9de124bc07bc782066e5f [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// fileBrowserPrivate API.
// This is a private API used by the file browser of ChromeOS.
[platforms=("chromeos"),
implemented_in="chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_functions.h"]
namespace fileBrowserPrivate {
// Type of the mounted volume.
enum VolumeType { drive, downloads, removable, archive };
// Device type. Available if this is removable volume.
enum DeviceType { usb, sd, optical, mobile, unknown };
// Additional data about mount, for example, that the filesystem is not
// supported.
enum MountCondition { unknown, unsupported };
// Is the event raised for mounting or unmounting.
enum MountCompletedEventType { mount, unmount };
// Event type that tells listeners if mount was successful or an error
// occurred. It also specifies the error.
enum MountCompletedStatus {
success,
error_unknown,
error_internal,
error_invalid_argument,
error_invalid_path,
error_path_already_mounted,
error_path_not_mounted,
error_directory_creation_failed,
error_invalid_mount_options,
error_invalid_unmount_options,
error_insufficient_permissions,
error_mount_program_not_found,
error_mount_program_failed,
error_invalid_device_path,
error_unknown_filesystem,
error_unsuported_filesystem,
error_invalid_archive,
error_authentication,
error_path_unmounted
};
// File transfer progress state.
enum TransferState { started, in_progress, completed, failed };
// Defines file transfer direction.
enum TransferType { upload, download };
// The type of the progress event.
enum CopyProgressStatusType {
// "begin_copy_entry" is fired for each entry (file or directory) before
// starting the copy operation.
begin_copy_entry,
// "end_copy_entry" is fired for each entry (file or directory) after ending
// the copy operation.
end_copy_entry,
// "progress" is fired periodically to report progress of a file copy (not
// directory).
progress,
// "success" is fired after all entries are copied.
success,
// "error" is fired when an error occurs.
error
};
// Specifies type of event that is raised.
enum FileWatchEventType { changed, error };
// The type of entry that is needed. Default to ALL.
enum SearchType { EXCLUDE_DIRECTORIES, SHARED_WITH_ME, OFFLINE, ALL };
// Zooming mode.
enum ZoomOperationType { in, out, reset };
// A file task represents an action that the file manager can perform over the
// currently selected files. See
// chrome/browser/chromeos/extensions/file_manager/file_tasks.h for details
// about how file tasks are handled.
dictionary FileTask {
// The unique identifier of the task.
DOMString taskId;
// Task title (ex. App name).
DOMString title;
// Task icon url (from chrome://extension-icon/...)
DOMString iconUrl;
// True if this task is a default task for the selected files.
boolean isDefault;
};
// Drive file properties.
dictionary DriveEntryProperties {
// URL to the Drive thumbnail image for this file.
DOMString? thumbnailUrl;
// Width, if the entry is an image.
long? imageWidth;
// Height, if the entry is an image.
long? imageHeight;
// Rotation in clockwise degrees, if the entry is an image.
long? imageRotation;
// True if the file is pinned in Drive cache.
boolean? isPinned;
// True if the file is present in Drive cache.
boolean? isPresent;
// True if the file is hosted on a Drive server instead of local.
boolean? isHosted;
// URL to the custom icon for this file.
DOMString? customIconUrl;
// Drive MIME type for this file.
DOMString? contentMimeType;
// True if the entry is labeled as shared-with-me.
boolean? sharedWithMe;
// True if the entry is labeled as shared (either from me to others or to me
// by others.)
boolean? shared;
};
// Information about total and remaining size on the mount point.
dictionary MountPointSizeStats {
// Approximate total available size on the mount point.
double totalSize;
// Approximate remaining available size on the mount point.
double remainingSize;
};
// Information about a profile.
dictionary ProfileInfo {
// The name of the profile for display purpose.
DOMString displayName;
// True if the profile is the one running the current file manager instance.
boolean isCurrentProfile;
};
// Mounted disk volume metadata.
dictionary VolumeMetadata {
// ID of the disk volume.
DOMString volumeId;
// Description of the profile where the volume belongs.
ProfileInfo profile;
// Disk volume mount point path.
DOMString mountPath;
// The path to the mounted device, archive file or network resource.
DOMString? sourcePath;
// Type of the mounted volume.
VolumeType volumeType;
// Device type. Available if this is removable volume.
DeviceType? deviceType;
// Flag that specifies if volume is mounted in read-only mode.
boolean isReadOnly;
// Additional data about mount, for example, that the filesystem is not
// supported.
MountCondition? mountCondition;
};
// Payload data for mount event.
dictionary MountCompletedEvent {
// Is the event raised for mounting or unmounting.
MountCompletedEventType eventType;
// Event type that tells listeners if mount was successful or an error
// occurred. It also specifies the error.
MountCompletedStatus status;
// Metadata of the mounted volume.
VolumeMetadata volumeMetadata;
};
// Payload data for file transfer status updates.
dictionary FileTransferStatus {
// URL of file that is being transfered.
DOMString fileUrl;
// File transfer progress state.
TransferState transferState;
// Defines file transfer direction.
TransferType transferType;
// Approximated completed portion of the transfer operation.
double? processed;
// Approximated total size of transfer operation.
double? total;
};
// Payload data for copy status progress updates.
dictionary CopyProgressStatus {
// The type of the progress event.
CopyProgressStatusType type;
// URL for the entry currently being copied. This field is particularly useful
// when a directory copy is initiated with startCopy(). The field tells what
// file/directory in that directory is now being copied.
DOMString? sourceUrl;
// URL for the entry currently being created. This field is particularly
// useful when a directory copy is initiated with startCopy(). The field tells
// what file/directory in that directory is being created. Available only for
// end_copy_entry and success.
DOMString? destinationUrl;
// Number of processed bytes for the file currently being copied. Available
// only for "progress" event. To show the progress bar, a caller needs to
// pre-compute the size of files being copied for the file (not directory).
double? size;
// FileError's code of the error. Available only for ERROR event.
long? error;
};
// Payload data for file transfer cancel response.
dictionary FileTransferCancelStatus {
// URL of file that is being transfered.
DOMString fileUrl;
// True if ongoing transfer operation was found and canceled.
boolean canceled;
};
// Directory change notification details.
dictionary FileWatchEvent {
// Specifies type of event that is raised.
FileWatchEventType eventType;
// An Entry object which represents a changed directory. The conversion into a
// kind of FileEntry object is done in
// file_browser_handler_custom_bindings.cc. For filesystem API's Entry
// interface, see <a
// href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
// interface</a>.
[instanceOf=Entry] object entry;
};
dictionary Preferences {
boolean driveEnabled;
boolean cellularDisabled;
boolean hostedFilesDisabled;
boolean use24hourClock;
boolean allowRedeemOffers;
};
dictionary PreferencesChange {
boolean? cellularDisabled;
boolean? hostedFilesDisabled;
};
dictionary SearchParams {
// Search query.
DOMString query;
// ID of the search feed that should be fetched next. Value passed here should
// be gotten from previous searchDrive call. It can be empty for the initial
// search request.
DOMString nextFeed;
};
dictionary SearchMetadataParams {
// Search query. It can be empty. Any filename matches to an empty query.
DOMString query;
// The type of entry that is needed. Default to ALL.
SearchType types;
// Maximum number of results.
long maxResults;
};
// Entry and Drive-related properties representing a search result.
dictionary SearchResult {
// A dictionary object which represents a Drive file. This will be converted
// into a kind of FileEntry object. See
// file_browser_handler_custom_bindings.cc for details. For filesystem API's
// Entry interface, see <a
// href='http://www.w3.org/TR/file-system-api/#the-entry-interface'>The Entry
// interface</a>.
[instanceOf=Entry] object entry;
// The base name of a Drive file that matched the search query. The matched
// sub strings are highlighted with <b> element. Meta characters are escaped
// like &lt;.
DOMString highlightedBaseName;
};
dictionary DriveConnectionState {
DOMString type;
// Reasons of offline.
DOMString? reason;
};
// |success| True of task execution was successfully initiated.
callback ExecuteTaskCallback = void(optional boolean success);
callback SetDefaultTaskCallback = void();
// |tasks| The list of matched file URL patterns for this task.
callback GetFileTasksCallback = void(FileTask[] tasks);
// |result| Hash containing the string assets.
callback GetStringsCallback = void(object result);
// |success| True when file watch is successfully added.
callback AddFileWatchCallback = void(optional boolean success);
// |success| True when file watch is successfully removed.
callback RemoveFileWatchCallback = void(optional boolean success);
// |fileSystem| A DOMFileSystem instance for local file system access. null if
// |the caller has no appropriate permissions.
callback RequestFileSystemCallback = void(optional object fileSystem);
callback SelectFilesCallback = void();
callback SelectFileCallback = void();
// |fileProperties| A dictionary containing properties of the requested entry.
callback GetDriveEntryPropertiesCallback =
void(DriveEntryProperties fileProperties);
callback PinDriveFileCallback = void();
// |localFilePaths| An array of the local file paths for the requested files,
// one entry for each file in fileUrls.
callback GetDriveFilesCallback = void(DOMString[] localFilePaths);
// |sourcePath| Source path of the mount.
callback AddMountCallback = void(DOMString sourcePath);
// |volumeMetadataList| The list of VolumeMetadata representing mounted volumes.
callback GetVolumeMetadataListCallback =
void(VolumeMetadata[] volumeMetadataList);
// |fileTransferCancelStatuses| The list of FileTransferCancelStatus.
callback CancelFileTransfersCallback =
void(FileTransferCancelStatus[] fileTransferCancelStatuses);
// |copyId| ID of the copy task. Can be used to identify the progress, and to
// cancel the task.
callback StartCopyCallback = void(long copyId);
callback CancelCopyCallback = void();
// |sizeStats| Name/value pairs of size stats. Will be undefined if stats could
// not be determined.
callback GetSizeStatsCallback = void(optional MountPointSizeStats sizeStats);
callback GetPreferencesCallback = void(Preferences result);
// |entries|
// |nextFeed| ID of the feed that contains next chunk of the search result.
// Should be sent to the next searchDrive request to perform
// incremental search.
callback SearchDriveCallback =
void([instanceOf=Entry] object[] entries, DOMString nextFeed);
callback SearchDriveMetadataCallback = void(SearchResult[] results);
callback ZipSelectionCallback = void(optional boolean success);
callback GetDriveConnectionStateCallback = void(DriveConnectionState result);
// |result| true if the length is in the valid range, false otherwise.
callback ValidatePathNameLengthCallback = void(boolean result);
// |accessToken| OAuth2 access token, or an empty string if failed to fetch.
callback RequestAccessTokenCallback = void(DOMString accessToken);
// |accessToken| OAuth2 access token, or an empty string if failed to fetch.
callback RequestWebStoreAccessTokenCallback = void(DOMString accessToken);
// |shareUrl| Share Url for the sharing dialog.
callback GetShareUrlCallback = void(DOMString shareUrl);
callback InstallWebstoreItemCallback = void();
interface Functions {
// Logout the current user for navigating to the re-authentication screen for
// the Google account.
static void logoutUserForReauthentication();
// Cancels file selection.
static void cancelDialog();
// Executes file browser task over selected files.
// |taskId| The unique identifier of task to execute.
// |fileUrls| Array of file URLs
// |callback|
static void executeTask(DOMString taskId,
DOMString[] fileUrls,
optional ExecuteTaskCallback callback);
// Sets the default task for the supplied MIME types and suffixes of the
// supplied file URLs. Lists of MIME types and URLs may contain duplicates.
// |taskId| The unique identifier of task to mark as default.
// |fileUrls| Array of selected file URLs to extract suffixes from.
// |mimeTypes| Array of selected file MIME types.
// |callback|
static void setDefaultTask(DOMString taskId,
DOMString[] fileUrls,
optional DOMString[] mimeTypes,
optional SetDefaultTaskCallback callback);
// Gets the list of tasks that can be performed over selected files.
// |fileUrls| Array of selected file URLs
// |mimeTypes| Array of selected file MIME types
// |callback|
static void getFileTasks(DOMString[] fileUrls,
DOMString[] mimeTypes,
GetFileTasksCallback callback);
// Gets localized strings and initialization data.
// |callback|
static void getStrings(GetStringsCallback callback);
// Adds file watch.
// |fileUrl| URL of file to watch
// |callback|
static void addFileWatch(DOMString fileUrl, AddFileWatchCallback callback);
// Removes file watch.
// |fileUrl| URL of watched file to remove
// |callback|
static void removeFileWatch(DOMString fileUrl,
RemoveFileWatchCallback callback);
// Requests access to a file system volume.
// |volumeId| The ID of the file system volume to request. The volume ID is
// delivered to JavaScript as part of VolumeMetadata. By specifying
// "compatible", this function behaves in the compatible mode, where the
// returned FileSystem object gives access to all file system volumes such
// as Downloads folder and removal media like SD cards (i.e. all volumes
// are provided inside the single FileSystem object). In the new
// "per-volume FileSystem object model" crbug.com/322305, a separate
// FileSystem object is created for each volume. "compatible" parameter
// will be removed once Files.app is switched to the per-volume FileSystem
// object model.
// |callback|
static void requestFileSystem(DOMString volumeId,
RequestFileSystemCallback callback);
// Selects multiple files.
// |selectedPaths| Array of selected paths
// |shouldReturnLocalPath| true if paths need to be resolved to local paths.
// |callback|
static void selectFiles(DOMString[] selectedPaths,
boolean shouldReturnLocalPath,
SelectFilesCallback callback);
// Selects a file.
// |selectedPath| A selected path
// |index| Index of Filter
// |forOpening| true if paths are selected for opening. false if for saving.
// |shouldReturnLocalPath| true if paths need to be resolved to local paths.
// |callback|
static void selectFile(DOMString selectedPath,
long index,
boolean forOpening,
boolean shouldReturnLocalPath,
SelectFileCallback callback);
// Requests Drive file properties for a file.
// |fileUrl| URL of a file
// |callback|
static void getDriveEntryProperties(DOMString fileUrl,
GetDriveEntryPropertiesCallback callback);
// Pins/unpins a Drive file in the cache.
// |fileUrl| URL of a file to pin/unpin.
// |pin| Pass true to pin the file.
// |callback| Completion callback. $ref:runtime.lastError will be set if there
// was an error.
static void pinDriveFile(DOMString fileUrl,
boolean pin,
optional PinDriveFileCallback callback);
// Get Drive files.
// |fileUrls| Array of Drive file URLs to get.
// |callback|
static void getDriveFiles(DOMString[] fileUrls,
GetDriveFilesCallback callback);
// Mount a resource or a file.
// |source| Mount point source. For compressed files it is relative file path
// within external file system
// |callback|
static void addMount(DOMString source, AddMountCallback callback);
// Unmounts a mounted resource.
// |mountPath| A path of the mount.
static void removeMount(DOMString mountPath);
// Get the list of mounted volumes.
// |callback|
static void getVolumeMetadataList(GetVolumeMetadataListCallback callback);
// Cancels ongoing file transfers for selected files.
// |fileUrls| Array of files for which ongoing transfer should be canceled.
// |callback|
static void cancelFileTransfers(DOMString[] fileUrls,
CancelFileTransfersCallback callback);
// Starts to copy an entry. If the source is a directory, the copy is done
// recursively.
// |sourceUrl| URL of the source entry to be copied.
// |parent| URL of the destination directory.
// |newName| Name of the new entry. It shouldn't contain '/'.
// |callback| Completion callback.
static void startCopy(DOMString sourceUrl,
DOMString parent,
DOMString newName,
StartCopyCallback callback);
// Cancels the running copy task.
// |copyId| ID of the copy task to be cancelled.
// |callback| Completion callback of the cancel.
static void cancelCopy(long copyId, optional CancelCopyCallback callback);
// Retrieves total and remaining size of a mount point.
// |mountPath| Mount point path.
// |callback|
static void getSizeStats(DOMString mountPath, GetSizeStatsCallback callback);
// Formats a mounted volume.
// |volumeId| ID of the volume to be formatted.
static void formatVolume(DOMString volumeId);
// Retrieves file manager preferences.
// |callback|
static void getPreferences(GetPreferencesCallback callback);
// Sets file manager preferences.
// |changeInfo|
static void setPreferences(PreferencesChange changeInfo);
// Performs drive content search.
// |searchParams|
// |callback|
static void searchDrive(SearchParams searchParams,
SearchDriveCallback callback);
// Performs drive metadata search.
// |searchParams|
// |callback|
static void searchDriveMetadata(SearchMetadataParams searchParams,
SearchDriveMetadataCallback callback);
// Create a zip file for the selected files.
// |dirURL| URL of the directory containing the selected files.
// |selectionUrls| URLs of the selected files. The files must be under the
// directory specified by dirURL.
// |destName| Name of the destination zip file. The zip file will be created
// under the directory specified by dirURL.
// |callback|
static void zipSelection(DOMString dirURL,
DOMString[] selectionUrls,
DOMString destName,
optional ZipSelectionCallback callback);
// Retrieves the state of the current drive connection.
// |callback|
static void getDriveConnectionState(GetDriveConnectionStateCallback callback);
// Checks whether the path name length fits in the limit of the filesystem.
// |parent_directory_url| The URL of the parent directory entry.
// |name| The name of the file.
// |callback| Called back when the check is finished.
static void validatePathNameLength(DOMString parent_directory_url,
DOMString name,
ValidatePathNameLengthCallback callback);
// Changes the zoom factor of the Files.app.
// |operation| Zooming mode.
static void zoom(ZoomOperationType operation);
// Requests a Drive API OAuth2 access token.
// |refresh| Whether the token should be refetched instead of using the cached
// one.
// |callback|
static void requestAccessToken(boolean refresh,
RequestAccessTokenCallback callback);
// Requests a Webstore API OAuth2 access token.
// |callback|
static void requestWebStoreAccessToken(
RequestWebStoreAccessTokenCallback callback);
// Requests a share dialog url for the specified file.
// |url| Url for the file.
// |callback|
static void getShareUrl(DOMString url, GetShareUrlCallback callback);
// Requests to install a webstore item.
// |item_id| The id of the item to install.
// |callback|
static void installWebstoreItem(DOMString item_id,
InstallWebstoreItemCallback callback);
};
interface Events {
static void onMountCompleted(MountCompletedEvent event);
static void onFileTransfersUpdated(FileTransferStatus[] event);
static void onCopyProgress(long copyId, CopyProgressStatus status);
static void onDirectoryChanged(FileWatchEvent event);
static void onPreferencesChanged();
static void onDriveConnectionStatusChanged();
};
};