OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.fileSystemProvider</code> API to create file systems, | 5 // Use the <code>chrome.fileSystemProvider</code> API to create file systems, |
6 // that can be accessible from the file manager on Chrome OS. | 6 // that can be accessible from the file manager on Chrome OS. |
7 [platforms=("chromeos"), | 7 [platforms=("chromeos"), |
8 implemented_in="chrome/browser/chromeos/extensions/file_system_provider/file_sy
stem_provider_api.h"] | 8 implemented_in="chrome/browser/chromeos/extensions/file_system_provider/file_sy
stem_provider_api.h"] |
9 namespace fileSystemProvider { | 9 namespace fileSystemProvider { |
10 // Error codes used by providing extensions in response to requests. For | 10 // Error codes used by providing extensions in response to requests. For |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DOMString name; | 44 DOMString name; |
45 | 45 |
46 // File size in bytes. | 46 // File size in bytes. |
47 double size; | 47 double size; |
48 | 48 |
49 // The last modified time of this entry. | 49 // The last modified time of this entry. |
50 [instanceOf=Date] object modificationTime; | 50 [instanceOf=Date] object modificationTime; |
51 }; | 51 }; |
52 | 52 |
53 // Callback to receive the result of mount() function. | 53 // Callback to receive the result of mount() function. |
54 // <code>fileSystemID</code> will be a unique ID for the file system just | 54 callback MountCallback = void([nodoc, instanceOf=DOMError] object error); |
55 // mounted. The ID is used to distinguish multiple file systems mounted | |
56 // from a single File System Provider. | |
57 callback MountCallback = void(long fileSystemId, | |
58 [nodoc, instanceOf=DOMError] object error); | |
59 | 55 |
60 | 56 |
61 // Callback to receive the result of unmount() function with the <code> | 57 // Callback to receive the result of unmount() function. |
62 // fileSystemId</code> identifier. | 58 callback UnmountCallback = void([nodoc, instanceOf=DOMError] object error); |
63 callback UnmountCallback = void(long fileSystemId, | |
64 [nodoc, instanceOf=DOMError] object error); | |
65 | 59 |
66 // Callback to be called by the providing extension in case of a success. | 60 // Callback to be called by the providing extension in case of a success. |
67 callback ProviderSuccessCallback = void(); | 61 callback ProviderSuccessCallback = void(); |
68 | 62 |
69 // Callback to be called by the providing extension in case of an error. | 63 // Callback to be called by the providing extension in case of an error. |
70 callback ProviderErrorCallback = void(ProviderError error); | 64 callback ProviderErrorCallback = void(ProviderError error); |
71 | 65 |
72 // Callback to handle an error raised from the browser. | 66 // Callback to handle an error raised from the browser. |
73 [nocompile] callback ErrorCallback = void([instanceOf=DOMError] object error); | 67 [nocompile] callback ErrorCallback = void([instanceOf=DOMError] object error); |
74 | 68 |
75 // Success callback for the <code>onGetMetadataRequested</code> event. | 69 // Success callback for the <code>onGetMetadataRequested</code> event. |
76 callback MetadataCallback = void(EntryMetadata metadata); | 70 callback MetadataCallback = void(EntryMetadata metadata); |
77 | 71 |
78 // Success callback for the <code>onReadDirectoryRequested</code> event. If | 72 // Success callback for the <code>onReadDirectoryRequested</code> event. If |
79 // more entries will be returned, then <code>hasNext</code> must be true, and | 73 // more entries will be returned, then <code>hasNext</code> must be true, and |
80 // it has to be called again with additional entries. If no more entries are | 74 // it has to be called again with additional entries. If no more entries are |
81 // available, then <code>hasNext</code> must be set to false. | 75 // available, then <code>hasNext</code> must be set to false. |
82 callback EntriesCallback = void(ResourceEntry[] entries, bool hasNext); | 76 callback EntriesCallback = void(ResourceEntry[] entries, bool hasNext); |
83 | 77 |
84 // Success callback for the <code>onReadFileRequested</code> event. If more | 78 // Success callback for the <code>onReadFileRequested</code> event. If more |
85 // data will be returned, then <code>hasNext</code> must be true, and it | 79 // data will be returned, then <code>hasNext</code> must be true, and it |
86 // has to be called again with additional entries. If no more data is | 80 // has to be called again with additional entries. If no more data is |
87 // available, then <code>hasNext</code> must be set to false. | 81 // available, then <code>hasNext</code> must be set to false. |
88 callback FileDataCallback = void(ArrayBuffer data, bool hasNext); | 82 callback FileDataCallback = void(ArrayBuffer data, bool hasNext); |
89 | 83 |
90 interface Functions { | 84 interface Functions { |
91 // Mounts a file system with the given <code>displayName</code>. | 85 // Mounts a file system with the given <code>fileSystemId</code> and <code> |
92 // <code>displayName</code> will be shown in the left panel of | 86 // displayName</code>. <code>displayName</code> will be shown in the left |
93 // Files.app. <code>displayName</code> can contain any characters | 87 // panel of Files.app. <code>displayName</code> can contain any characters |
94 // including '/', but cannot be an empty string. <code>displayName</code> | 88 // including '/', but cannot be an empty string. <code>displayName</code> |
95 // should be descriptive but doesn't have to be unique. Duplicate display | 89 // should be descriptive but doesn't have to be unique. Duplicate display |
96 // names are uniquified by adding suffix like "(1)" in the Files.app UI. | 90 // names are uniquified by adding suffix like "(1)" in the Files app UI. |
97 static void mount(DOMString displayName, | 91 // |
| 92 // If a file system with the passed <code>fileSystemId</code> is already |
| 93 // mounted by this extension, then <code>errorCallback</code> will be called |
| 94 // with <code>ProviderError.EXISTS</code> value. The <code>fileSystemId |
| 95 // </code> must not be an empty string. |
| 96 static void mount(DOMString fileSystemId, |
| 97 DOMString displayName, |
98 MountCallback successCallback, | 98 MountCallback successCallback, |
99 [nocompile] ErrorCallback errorCallback); | 99 [nocompile] ErrorCallback errorCallback); |
100 | 100 |
101 // Unmounts a file system with the given <code>fileSystemId</code>. It | 101 // Unmounts a file system with the given <code>fileSystemId</code>. It |
102 // should be called after <code>onUnmountRequested</code> is invoked. Also, | 102 // should be called after <code>onUnmountRequested</code> is invoked. Also, |
103 // the providing extension can decide to perform unmounting if not requested | 103 // the providing extension can decide to perform unmounting if not requested |
104 // (eg. in case of lost connection, or a file error). If there is no file | 104 // (eg. in case of lost connection, or a file error). If there is no file |
105 // system with the requested id, or unmounting fails, then the | 105 // system with the requested id, or unmounting fails, then the |
106 // <code>errorCallback</code> must be called. | 106 // <code>errorCallback</code> will be called. |
107 static void unmount(long fileSystemId, | 107 static void unmount(DOMString fileSystemId, |
108 UnmountCallback successCallback, | 108 UnmountCallback successCallback, |
109 [nocompile] ErrorCallback errorCallback); | 109 [nocompile] ErrorCallback errorCallback); |
110 }; | 110 }; |
111 | 111 |
112 interface Events { | 112 interface Events { |
113 // Raised when unmounting for the file system with the <code>fileSystemId | 113 // Raised when unmounting for the file system with the <code>fileSystemId |
114 // </code> identifier is requested. In the response, the <code>unmount | 114 // </code> identifier is requested. In the response, the <code>unmount |
115 // </code> API method should be called together with <code>successCallback | 115 // </code> API method should be called together with <code>successCallback |
116 // </code>. If unmounting is not possible (eg. due to a pending operation), | 116 // </code>. If unmounting is not possible (eg. due to a pending operation), |
117 // then <code>errorCallback</code> must be called. | 117 // then <code>errorCallback</code> must be called. |
118 [maxListeners=1] static void onUnmountRequested( | 118 [maxListeners=1] static void onUnmountRequested( |
119 long fileSystemId, | 119 DOMString fileSystemId, |
120 ProviderSuccessCallback successCallback, | 120 ProviderSuccessCallback successCallback, |
121 ProviderErrorCallback errorCallback); | 121 ProviderErrorCallback errorCallback); |
122 | 122 |
123 // Raised when metadata of a file or a directory at <code>entryPath</code> | 123 // Raised when metadata of a file or a directory at <code>entryPath</code> |
124 // is requested. The metadata should be returned with the <code> | 124 // is requested. The metadata should be returned with the <code> |
125 // successCallback</code> call. In case of an error, <code>errorCallback | 125 // successCallback</code> call. In case of an error, <code>errorCallback |
126 // </code> must be called. | 126 // </code> must be called. |
127 [maxListeners=1] static void onGetMetadataRequested( | 127 [maxListeners=1] static void onGetMetadataRequested( |
128 long fileSystemId, | 128 DOMString fileSystemId, |
129 DOMString entryPath, | 129 DOMString entryPath, |
130 MetadataCallback successCallback, | 130 MetadataCallback successCallback, |
131 ProviderErrorCallback errorCallback); | 131 ProviderErrorCallback errorCallback); |
132 | 132 |
133 // Raised when contents of a directory at <code>directoryPath</code> are | 133 // Raised when contents of a directory at <code>directoryPath</code> are |
134 // requested. The results should be returned in chunks by calling the <code> | 134 // requested. The results should be returned in chunks by calling the <code> |
135 // successCallback</code> several times. In case of an error, <code> | 135 // successCallback</code> several times. In case of an error, <code> |
136 // errorCallback</code> must be called. | 136 // errorCallback</code> must be called. |
137 [maxListeners=1] static void onReadDirectoryRequested( | 137 [maxListeners=1] static void onReadDirectoryRequested( |
138 long fileSystemId, | 138 DOMString fileSystemId, |
139 DOMString directoryPath, | 139 DOMString directoryPath, |
140 EntriesCallback successCallback, | 140 EntriesCallback successCallback, |
141 ProviderErrorCallback errorCallback); | 141 ProviderErrorCallback errorCallback); |
142 | 142 |
143 // Raised when opening a file at <code>filePath</code> is requested. | 143 // Raised when opening a file at <code>filePath</code> is requested. |
144 // If <code>create</code> is set to <code>true</code> and the file does not | 144 // If <code>create</code> is set to <code>true</code> and the file does not |
145 // exist, then it should be created. | 145 // exist, then it should be created. |
146 [maxListeners=1] static void onOpenFileRequested( | 146 [maxListeners=1] static void onOpenFileRequested( |
147 long fileSystemId, | 147 DOMString fileSystemId, |
148 long requestId, | 148 long requestId, |
149 DOMString filePath, | 149 DOMString filePath, |
150 OpenFileMode mode, | 150 OpenFileMode mode, |
151 boolean create, | 151 boolean create, |
152 ProviderSuccessCallback successCallback, | 152 ProviderSuccessCallback successCallback, |
153 ProviderErrorCallback errorCallback); | 153 ProviderErrorCallback errorCallback); |
154 | 154 |
155 // Raised when opening a file previously opened with <code>openRequestId | 155 // Raised when opening a file previously opened with <code>openRequestId |
156 // </code> is requested to be closed. | 156 // </code> is requested to be closed. |
157 [maxListeners=1] static void onCloseFileRequested( | 157 [maxListeners=1] static void onCloseFileRequested( |
158 long fileSystemId, | 158 DOMString fileSystemId, |
159 long openRequestId, | 159 long openRequestId, |
160 ProviderSuccessCallback successCallback, | 160 ProviderSuccessCallback successCallback, |
161 ProviderErrorCallback errorCallback); | 161 ProviderErrorCallback errorCallback); |
162 | 162 |
163 // Raised when contents of a file opened previously with <code>openRequestId | 163 // Raised when contents of a file opened previously with <code>openRequestId |
164 // </code>. The results should be returned in chunks by calling <code> | 164 // </code>. The results should be returned in chunks by calling <code> |
165 // successCallback</code> several times. In case of an error, <code> | 165 // successCallback</code> several times. In case of an error, <code> |
166 // errorCallback</code> must be called. | 166 // errorCallback</code> must be called. |
167 [maxListeners=1] static void onReadFileRequested( | 167 [maxListeners=1] static void onReadFileRequested( |
168 long fileSystemId, | 168 DOMString fileSystemId, |
169 long openRequestId, | 169 long openRequestId, |
170 double offset, | 170 double offset, |
171 double length, | 171 double length, |
172 FileDataCallback successCallback, | 172 FileDataCallback successCallback, |
173 ProviderErrorCallback errorCallback); | 173 ProviderErrorCallback errorCallback); |
174 }; | 174 }; |
175 }; | 175 }; |
176 | 176 |
OLD | NEW |