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 // Use the <code>chrome.fileSystemProvider</code> API to create file systems,
6 // that can be accessible from the file manager on Chrome OS.
7 [platforms
=("chromeos"),
8 implemented_in
="chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.h"]
9 namespace fileSystemProvider
{
10 // Error codes used by providing extensions in response to requests. For
11 // success, <code>OK</code> should be used.
32 // Represents metadata of a file or a directory.
33 dictionary EntryMetadata
{
34 // True if it is a directory.
37 // Name of this entry (not full path name).
40 // File size in bytes.
43 // The last modified time of this entry.
44 [instanceOf
=Date
] object modificationTime
;
47 // Callback to receive the result of mount() function.
48 // <code>fileSystemID</code> will be a unique ID for the file system just
49 // mounted. The ID is used to distinguish multiple file systems mounted
50 // from a single File System Provider.
51 callback MountCallback
= void(long fileSystemId
,
52 [nodoc
, instanceOf
=DOMError
] object error
);
55 // Callback to receive the result of unmount() function with the <code>
56 // fileSystemId</code> identifier.
57 callback UnmountCallback
= void(long fileSystemId
,
58 [nodoc
, instanceOf
=DOMError
] object error
);
60 // Callback to be called by the providing extension in case of a success.
61 callback ProviderSuccessCallback
= void();
63 // Callback to be called by the providing extension in case of an error.
64 callback ProviderErrorCallback
= void(ProviderError error
);
66 // Callback to handle an error raised from the browser.
67 [nocompile
] callback ErrorCallback
= void([instanceOf
=DOMError
] object error
);
69 // Success callback for the <code>onGetMetadataRequested</code> event.
70 callback MetadataCallback
= void(EntryMetadata metadata
);
73 // Mounts a file system with the given <code>displayName</code>.
74 // <code>displayName</code> will be shown in the left panel of
75 // Files.app. <code>displayName</code> can contain any characters
76 // including '/', but cannot be an empty string. <code>displayName</code>
77 // should be descriptive but doesn't have to be unique. Duplicate display
78 // names are uniquified by adding suffix like "(1)" in the Files.app UI.
79 static
void mount
(DOMString displayName
,
80 MountCallback successCallback
,
81 [nocompile
] ErrorCallback errorCallback
);
83 // Unmounts a file system with the given <code>fileSystemId</code>. It
84 // should be called after <code>onUnmountRequested</code> is invoked. Also,
85 // the providing extension can decide to perform unmounting if not requested
86 // (eg. in case of lost connection, or a file error). If there is no file
87 // system with the requested id, or unmounting fails, then the
88 // <code>errorCallback</code> will be called.
89 static
void unmount
(long fileSystemId
,
90 UnmountCallback successCallback
,
91 [nocompile
] ErrorCallback errorCallback
);
95 // Raised when unmounting for the file system with the <code>fileSystemId
96 // </code> identifier is requested. In response, the <code>unmount</code>
97 // API method should be called together with <code>successCallback</code>.
98 // If unmounting is not possible (eg. due to a pending operation), then
99 // <code>errorCallback</code> must be called.
100 [maxListeners
=1] static
void onUnmountRequested
(
102 ProviderSuccessCallback successCallback
,
103 ProviderErrorCallback errorCallback
);
105 // Raised when metadata of a file or a directory at <code>entryPath</code>
106 // is requested. The metadata should be returned with the <code>
107 // successCallback</code> call. In case of an error, <code>errorCallback
108 // </code> must be called.
109 [maxListeners
=1] static
void onGetMetadataRequested
(
112 MetadataCallback successCallback
,
113 ErrorCallback errorCallback
);