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