OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ |
6 #define PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ |
7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" |
8 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
9 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
10 | 11 |
11 struct PP_CompletionCallback; | 12 struct PP_CompletionCallback; |
12 | 13 |
13 typedef enum { | 14 typedef enum { |
14 PP_FILECHOOSERMODE_OPEN, | 15 PP_FILECHOOSERMODE_OPEN, |
15 PP_FILECHOOSERMODE_OPENMULTIPLE | 16 PP_FILECHOOSERMODE_OPENMULTIPLE |
16 // TODO(darin): Should there be a way to choose a directory? | 17 // TODO(darin): Should there be a way to choose a directory? |
17 } PP_FileChooserMode_Dev; | 18 } PP_FileChooserMode_Dev; |
18 | 19 |
19 struct PP_FileChooserOptions_Dev { | 20 struct PP_FileChooserOptions_Dev { |
20 PP_FileChooserMode_Dev mode; | 21 PP_FileChooserMode_Dev mode; |
21 | 22 |
22 // A comma-separated list of MIME types such as audio/*,text/plain. The | 23 // A comma-separated list of MIME types such as audio/*,text/plain. The |
23 // dialog may restrict selectable files to the specified MIME types. | 24 // dialog may restrict selectable files to the specified MIME types. |
24 // TODO(darin): What if the mime type is unknown to the system? The plugin | 25 // TODO(darin): What if the mime type is unknown to the system? The plugin |
25 // may wish to describe the mime type and provide a matching file extension. | 26 // may wish to describe the mime type and provide a matching file extension. |
26 // It is more webby to use mime types here instead of file extensions. | 27 // It is more webby to use mime types here instead of file extensions. |
27 const char* accept_mime_types; | 28 const char* accept_mime_types; |
28 }; | 29 }; |
29 | 30 |
30 #define PPB_FILECHOOSER_DEV_INTERFACE "PPB_FileChooser(Dev);0.1" | 31 #define PPB_FILECHOOSER_DEV_INTERFACE "PPB_FileChooser(Dev);0.2" |
31 | 32 |
32 struct PPB_FileChooser_Dev { | 33 struct PPB_FileChooser_Dev { |
33 // Creates a file chooser dialog with the specified options. The chooser is | 34 // Creates a file chooser dialog with the specified options. The chooser is |
34 // associated with a particular instance, so that it may be positioned on the | 35 // associated with a particular instance, so that it may be positioned on the |
35 // screen relative to the tab containing the instance. Returns 0 if passed | 36 // screen relative to the tab containing the instance. Returns 0 if passed |
36 // an invalid instance. | 37 // an invalid instance. |
37 PP_Resource (*Create)(PP_Instance instance, | 38 PP_Resource (*Create)(PP_Instance instance, |
38 const struct PP_FileChooserOptions_Dev* options); | 39 const struct PP_FileChooserOptions_Dev* options); |
39 | 40 |
40 // Returns true if the given resource is a FileChooser. Returns false if the | 41 // Returns PP_TRUE if the given resource is a FileChooser. Returns PP_FALSE |
41 // resource is invalid or some type other than a FileChooser. | 42 // if the resource is invalid or some type other than a FileChooser. |
42 bool (*IsFileChooser)(PP_Resource resource); | 43 PP_Bool (*IsFileChooser)(PP_Resource resource); |
43 | 44 |
44 // Prompts the user to choose a file or files. | 45 // Prompts the user to choose a file or files. |
45 int32_t (*Show)(PP_Resource chooser, struct PP_CompletionCallback callback); | 46 int32_t (*Show)(PP_Resource chooser, struct PP_CompletionCallback callback); |
46 | 47 |
47 // After a successful call to Show, this method may be used to query the | 48 // After a successful call to Show, this method may be used to query the |
48 // chosen files. It should be called in a loop until it returns 0. | 49 // chosen files. It should be called in a loop until it returns 0. |
49 // Depending on the PP_ChooseFileMode requested when the FileChooser was | 50 // Depending on the PP_ChooseFileMode requested when the FileChooser was |
50 // created, the file refs will either be readable or writable. Their file | 51 // created, the file refs will either be readable or writable. Their file |
51 // system type will be PP_FileSystemType_External. If the user chose no | 52 // system type will be PP_FileSystemType_External. If the user chose no |
52 // files or cancelled the dialog, then this method will simply return 0 | 53 // files or cancelled the dialog, then this method will simply return 0 |
53 // the first time it is called. | 54 // the first time it is called. |
54 PP_Resource (*GetNextChosenFile)(PP_Resource chooser); | 55 PP_Resource (*GetNextChosenFile)(PP_Resource chooser); |
55 }; | 56 }; |
56 | 57 |
57 #endif // PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ | 58 #endif // PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ |
OLD | NEW |