| 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_bool.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_macros.h" | 10 #include "ppapi/c/pp_macros.h" |
| 11 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
| 12 | 12 |
| 13 struct PP_CompletionCallback; | 13 struct PP_CompletionCallback; |
| 14 | 14 |
| 15 typedef enum { | 15 typedef enum { |
| 16 PP_FILECHOOSERMODE_OPEN, | 16 PP_FILECHOOSERMODE_OPEN, |
| 17 PP_FILECHOOSERMODE_OPENMULTIPLE | 17 PP_FILECHOOSERMODE_OPENMULTIPLE |
| 18 // TODO(darin): Should there be a way to choose a directory? | 18 // TODO(darin): Should there be a way to choose a directory? |
| 19 } PP_FileChooserMode_Dev; | 19 } PP_FileChooserMode_Dev; |
| 20 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileChooserMode_Dev, 4); | 20 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileChooserMode_Dev, 4); |
| 21 | 21 |
| 22 struct PP_FileChooserOptions_Dev { | 22 struct PP_FileChooserOptions_Dev { |
| 23 PP_FileChooserMode_Dev mode; | 23 PP_FileChooserMode_Dev mode; |
| 24 | 24 |
| 25 // A comma-separated list of MIME types such as audio/*,text/plain. The | 25 // A comma-separated list of MIME types such as audio/*,text/plain. The |
| 26 // dialog may restrict selectable files to the specified MIME types. | 26 // dialog may restrict selectable files to the specified MIME types. Null may |
| 27 // be given to indicate that all types should be accepted. |
| 27 // TODO(darin): What if the mime type is unknown to the system? The plugin | 28 // TODO(darin): What if the mime type is unknown to the system? The plugin |
| 28 // may wish to describe the mime type and provide a matching file extension. | 29 // may wish to describe the mime type and provide a matching file extension. |
| 29 // It is more webby to use mime types here instead of file extensions. | 30 // It is more webby to use mime types here instead of file extensions. |
| 30 const char* accept_mime_types; | 31 const char* accept_mime_types; |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 #define PPB_FILECHOOSER_DEV_INTERFACE "PPB_FileChooser(Dev);0.3" | 34 #define PPB_FILECHOOSER_DEV_INTERFACE "PPB_FileChooser(Dev);0.3" |
| 34 | 35 |
| 35 struct PPB_FileChooser_Dev { | 36 struct PPB_FileChooser_Dev { |
| 36 // Creates a file chooser dialog with the specified options. The chooser is | 37 // Creates a file chooser dialog with the specified options. The chooser is |
| 37 // associated with a particular instance, so that it may be positioned on the | 38 // associated with a particular instance, so that it may be positioned on the |
| 38 // screen relative to the tab containing the instance. Returns 0 if passed | 39 // screen relative to the tab containing the instance. Returns 0 if passed |
| 39 // an invalid instance. | 40 // an invalid instance. |
| 40 // | 41 // |
| 41 // A PPB_FileChooser_Dev instance can be used to select a single file | 42 // A PPB_FileChooser_Dev instance can be used to select a single file |
| 42 // (PP_FILECHOOSERMODE_OPEN) or multiple files | 43 // (PP_FILECHOOSERMODE_OPEN) or multiple files |
| 43 // (PP_FILECHOOSERMODE_OPENMULTIPLE). Unlike the HTML5 <input type="file"> | 44 // (PP_FILECHOOSERMODE_OPENMULTIPLE). Unlike the HTML5 <input type="file"> |
| 44 // tag, a PPB_FileChooser_Dev instance cannot be used to select a directory. | 45 // tag, a PPB_FileChooser_Dev instance cannot be used to select a directory. |
| 45 // In order to get the list of files in a directory, the | 46 // In order to get the list of files in a directory, the |
| 46 // PPB_DirectoryReader_Dev interface must be used. | 47 // PPB_DirectoryReader_Dev interface must be used. |
| 47 PP_Resource (*Create)(PP_Instance instance, | 48 PP_Resource (*Create)(PP_Instance instance, |
| 48 const struct PP_FileChooserOptions_Dev* options); | 49 const struct PP_FileChooserOptions_Dev* options); |
| 49 | 50 |
| 50 // Returns PP_TRUE if the given resource is a FileChooser. Returns PP_FALSE | 51 // Returns PP_TRUE if the given resource is a FileChooser. Returns PP_FALSE |
| 51 // if the resource is invalid or some type other than a FileChooser. | 52 // if the resource is invalid or some type other than a FileChooser. |
| 52 PP_Bool (*IsFileChooser)(PP_Resource resource); | 53 PP_Bool (*IsFileChooser)(PP_Resource resource); |
| 53 | 54 |
| 54 // Prompts the user to choose a file or files. | 55 // Prompts the user to choose a file or files. The callback is called with |
| 56 // PP_OK on successful completion with a file (or files) selected or |
| 57 // PP_ERROR_USERCANCEL if the user selected no file. |
| 55 int32_t (*Show)(PP_Resource chooser, struct PP_CompletionCallback callback); | 58 int32_t (*Show)(PP_Resource chooser, struct PP_CompletionCallback callback); |
| 56 | 59 |
| 57 // After a successful call to Show, this method may be used to query the | 60 // After a successful call to Show, this method may be used to query the |
| 58 // chosen files. It should be called in a loop until it returns 0. | 61 // chosen files. It should be called in a loop until it returns 0. |
| 59 // Depending on the PP_ChooseFileMode requested when the FileChooser was | 62 // Depending on the PP_ChooseFileMode requested when the FileChooser was |
| 60 // created, the file refs will either be readable or writable. Their file | 63 // created, the file refs will either be readable or writable. Their file |
| 61 // system type will be PP_FileSystemType_External. If the user chose no | 64 // system type will be PP_FileSystemType_External. If the user chose no |
| 62 // files or cancelled the dialog, then this method will simply return 0 | 65 // files or cancelled the dialog, then this method will simply return 0 |
| 63 // the first time it is called. | 66 // the first time it is called. |
| 64 PP_Resource (*GetNextChosenFile)(PP_Resource chooser); | 67 PP_Resource (*GetNextChosenFile)(PP_Resource chooser); |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 #endif /* PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ */ | 70 #endif /* PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ */ |
| 68 | |
| OLD | NEW |