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 |
| 11 // success, <code>OK</code> should be used. |
| 12 enum ProviderError { |
| 13 OK, |
| 14 FAILED, |
| 15 IN_USE, |
| 16 EXISTS, |
| 17 NOT_FOUND, |
| 18 ACCESS_DENIED, |
| 19 TOO_MANY_OPENED, |
| 20 NO_MEMORY, |
| 21 NO_SPACE, |
| 22 NOT_A_DIRECTORY, |
| 23 INVALID_OPERATION, |
| 24 SECURITY, |
| 25 ABORT, |
| 26 NOT_A_FILE, |
| 27 NOT_EMPTY, |
| 28 INVALID_URL, |
| 29 IO |
| 30 }; |
| 31 |
10 // Callback to receive the result of mount() function. | 32 // Callback to receive the result of mount() function. |
11 // <code>fileSystemID</code> will be a unique ID for the file system just | 33 // <code>fileSystemID</code> will be a unique ID for the file system just |
12 // mounted. The ID is used to distinguish multiple file systems mounted | 34 // mounted. The ID is used to distinguish multiple file systems mounted |
13 // from a single File System Provider. | 35 // from a single File System Provider. |
14 callback MountCallback = void(long fileSystemId, | 36 callback MountCallback = void(long fileSystemId, |
15 [nodoc, instanceOf=DOMError] object error); | 37 [nodoc, instanceOf=DOMError] object error); |
16 | 38 |
| 39 |
| 40 // Callback to receive the result of unmount() function with the <code> |
| 41 // fileSystemId</code> identifier. |
| 42 callback UnmountCallback = void(long fileSystemId, |
| 43 [nodoc, instanceOf=DOMError] object error); |
| 44 |
| 45 // Callback to be called by the providing extension in case of a success. |
| 46 callback ProviderSuccessCallback = void(); |
| 47 |
| 48 // Callback to be called by the providing extension in case of an error. |
| 49 callback ProviderErrorCallback = void(ProviderError error); |
| 50 |
17 // Callback to handle an error raised from the browser. | 51 // Callback to handle an error raised from the browser. |
18 [nocompile] callback ErrorCallback = void([instanceOf=DOMError] object error); | 52 [nocompile] callback ErrorCallback = void([instanceOf=DOMError] object error); |
19 | 53 |
20 interface Functions { | 54 interface Functions { |
21 // Mounts a file system with the given <code>displayName</code>. | 55 // Mounts a file system with the given <code>displayName</code>. |
22 // <code>displayName</code> will be shown in the left panel of | 56 // <code>displayName</code> will be shown in the left panel of |
23 // Files.app. <code>displayName</code> can contain any characters | 57 // Files.app. <code>displayName</code> can contain any characters |
24 // including '/', but cannot be an empty string. <code>displayName</code> | 58 // including '/', but cannot be an empty string. <code>displayName</code> |
25 // should be descritive but doesn't have to be unique. Duplicate display | 59 // should be descriptive but doesn't have to be unique. Duplicate display |
26 // names are uniquified by adding suffix like "(1)" in the Files.app UI. | 60 // names are uniquified by adding suffix like "(1)" in the Files.app UI. |
27 static void mount(DOMString displayName, | 61 static void mount(DOMString displayName, |
28 MountCallback successCallback, | 62 MountCallback successCallback, |
29 [nocompile] ErrorCallback errorCallback); | 63 [nocompile] ErrorCallback errorCallback); |
| 64 |
| 65 // Unmounts a file system with the given <code>fileSystemId</code>. It |
| 66 // should be called after <code>onUnmountRequested</code> is invoked. Also, |
| 67 // the providing extension can decide to perform unmounting if not requested |
| 68 // (eg. in case of lost connection, or a file error). If there is no file |
| 69 // system with the requested id, or unmounting fails, then the |
| 70 // <code>errorCallback</code> will be called. |
| 71 static void unmount(long fileSystemId, |
| 72 UnmountCallback successCallback, |
| 73 [nocompile] ErrorCallback errorCallback); |
| 74 }; |
| 75 |
| 76 interface Events { |
| 77 // Raised, when the user requests unmounting of the file system with the |
| 78 // <code>fileSystemId</code> identifier in the Files.app UI. In response, |
| 79 // the <code>unmount</code> API method should be called. If unmounting is |
| 80 // not possible (eg. due to pending operation), then <code>errorCallback |
| 81 // </code> should be called, and <code>unmount</code> should not be called. |
| 82 [maxListeners=1] static void onUnmountRequested( |
| 83 long fileSystemId, |
| 84 ProviderSuccessCallback successCallback, |
| 85 ProviderErrorCallback errorCallback); |
30 }; | 86 }; |
31 }; | 87 }; |
| 88 |
OLD | NEW |