OLD | NEW |
1 <h2 id="manifest">Manifest</h2> | 1 <h2 id="manifest">Manifest</h2> |
2 <p>You must declare the "fileSystemProvider" permission | 2 <p>You must declare the "fileSystemProvider" permission and section |
3 in the <a href="manifest">extension manifest</a> | 3 in the <a href="manifest">extension manifest</a> |
4 to use the File System Provider API. | 4 to use the File System Provider API. |
5 For example:</p> | 5 For example:</p> |
6 <pre data-filename="manifest.json"> | 6 <pre data-filename="manifest.json"> |
7 { | 7 { |
8 "name": "My extension", | 8 "name": "My {{platform}}", |
9 ... | 9 ... |
10 <b>"permissions": [ | 10 "permissions": [ |
11 "fileSystemProvider" | 11 "fileSystemProvider" |
12 ]</b>, | 12 ], |
| 13 ... |
| 14 "file_system_provider_capabilities": [ |
| 15 "configurable": true, |
| 16 "multiple_mounts": true, |
| 17 <span id="manifest-source">"source": "network"</span> |
| 18 ], |
13 ... | 19 ... |
14 } | 20 } |
15 </pre> | 21 </pre> |
16 | 22 |
| 23 <p class="api_reference"> |
| 24 The <code>file_system_provider</code> section must be declared as follows: |
| 25 {{+partials.manifest_type |
| 26 type:apis.extensions.manifestTypes.byName.FileSystemProviderCapabilities /}} |
| 27 </p> |
| 28 <p> |
| 29 Files app uses above information in order to render related UI elements |
| 30 approprietly. For example, if <code>configurable</code> is set to |
| 31 </code>true</code>, then a menu item for configuring volumes will be rendered. |
| 32 Similarly, if <code>multiple_mounts</code> is set to <code>true</code>, then |
| 33 Files app will allow to add more than one mount points from the UI. |
| 34 </p> |
| 35 |
17 <h2 id="overview">Overview</h2> | 36 <h2 id="overview">Overview</h2> |
18 <p> | 37 <p> |
19 File System Provider API allows extensions to support virtual file systems, | 38 File System Provider API allows extensions to support virtual file systems, |
20 which are available in the file manager on Chrome OS. | 39 which are available in the file manager on Chrome OS. |
21 Use cases include decompressing archives and accessing files in a cloud | 40 Use cases include decompressing archives and accessing files in a cloud |
22 service other than Drive. | 41 service other than Drive. |
23 </p> | 42 </p> |
24 | 43 |
25 <h2 id="archives">File handlers</h2> | 44 <h2 id="archives">Mounting file systems</h2> |
26 <p> | 45 <p> |
27 Provided file systems can either provide file system contents from an external | 46 Providing extensions can either provide file system contents from an external |
28 source (such as a remote server), or using a local file (such as an archive) as | 47 source (such as a remote server or a USB device), or using a local file (such as |
29 its input. | 48 an archive) as its input. |
30 </p> | 49 </p> |
31 <p> | 50 <p> |
32 In the second case, the providing extension should have a | 51 {{?is_apps}} |
| 52 For file handlers, the providing extension should have a |
33 <a href="manifest/file_handlers">file_handlers</a> manifest entry in order | 53 <a href="manifest/file_handlers">file_handlers</a> manifest entry in order |
34 to be launched when the file is selected in the file manager. | 54 to be launched when the file is selected in the file manager. |
35 When the extension is executed with a file to be handled, it has to mount a | 55 When the extension is executed with a file to be handled, it has to mount a |
36 file system and start serving contents from the provided file. | 56 file system and start serving contents from the provided file. |
| 57 {{:is_apps}} |
| 58 In order to write file systems which are file handlers (source is |
| 59 <code>"file"</code>) the provider must be a packaged app, as the |
| 60 <code>onLaunched</code>event is not available to extensions. |
| 61 {{/is_apps}} |
| 62 </p> |
| 63 <p> |
| 64 If the source is network or a device, then the file system should be mounted |
| 65 when $(ref:onMountRequested) event is called. |
| 66 </p> |
| 67 <p> |
| 68 <table id="source-table"> |
| 69 <tr> |
| 70 <th> |
| 71 <a href="#manifest-source">Source</a> of the file system data |
| 72 </th> |
| 73 <th>Entry point</th> |
| 74 </tr> |
| 75 <tr> |
| 76 <td> |
| 77 <code>"file"</code> |
| 78 </td> |
| 79 <td> |
| 80 {{?is_apps}} |
| 81 $(ref:app.runtime.onLaunched) |
| 82 {{:is_apps}} |
| 83 Available to <a href="/apps/fileSystemProvider#source-table">packaged |
| 84 apps</a> only. |
| 85 {{/is_apps}} |
| 86 </td> |
| 87 </tr> |
| 88 <tr> |
| 89 <td> |
| 90 <code>"device"</code> or <code>"network"</code> |
| 91 </td> |
| 92 <td> |
| 93 $(ref:onMountRequested) |
| 94 </td> |
| 95 </tr> |
| 96 </table> |
| 97 </p> |
| 98 |
| 99 <h2 id="archives">Configuring file systems</h2> |
| 100 <p> |
| 101 Provided file systems once mounted can be configured via the |
| 102 $(ref:onConfigureRequested) event. It's especially useful for file systems which |
| 103 provide contents via network in order to set proper credentials. Handling this |
| 104 event is optional. |
37 </p> | 105 </p> |
38 | 106 |
39 <h2 id="archives">Life cycle</h2> | 107 <h2 id="archives">Life cycle</h2> |
40 <p> | 108 <p> |
41 Provided file systems once mounted are remembered by Chrome and remounted | 109 Provided file systems once mounted are remembered by Chrome and remounted |
42 automatically after reboot or restart. Hence, once a file system is | 110 automatically after reboot or restart. Hence, once a file system is |
43 <a href="method-mount">mounted</a> by a providing extension, it will stay until | 111 $(ref:mount mounted) by a providing extension, it will stay until either the |
44 either the extension is unloaded, or the extension calls the | 112 extension is unloaded, or the extension calls the $(ref:unmount) method. |
45 <a href="#method-unmount"> unmount</a> method. | |
46 </p> | 113 </p> |
| 114 {{?is_apps}} |
47 <p> | 115 <p> |
48 In case of acting as a file handler, the handled file may need to be stored | 116 In case of acting as a file handler, the handled file may need to be stored |
49 to access it after either a reboot, or suspending and resuming an event page | 117 to access it after either a reboot, or suspending and resuming an event page |
50 of the providing extension. In such case | 118 of the providing extension. In such case $(ref:fileSystem.retainEntry) and |
51 <a href="fileSystem#method-retainEntry">chrome.fileSystem.retainEntry</a> and | 119 $(ref:fileSystem.restoreEntry) should be used. |
52 <a href="fileSystem#method-restoreEntry">chrome.fileSystem.restoreEntry</a> | |
53 should be used. | |
54 </p> | 120 </p> |
| 121 {{/is_apps}} |
OLD | NEW |