#include <file_chooser_dev.h>
Definition at line 22 of file file_chooser_dev.h.
pp::FileChooser_Dev::FileChooser_Dev |
( |
| ) |
|
|
inline |
pp::FileChooser_Dev::FileChooser_Dev |
( |
const InstanceHandle & |
instance, |
|
|
PP_FileChooserMode_Dev |
mode, |
|
|
const Var & |
accept_types |
|
) |
| |
This function creates a file chooser dialog resource. The chooser is associated with a particular instance, so that it may be positioned on the screen relative to the tab containing the instance. Returns 0 if passed an invalid instance.
- Parameters
-
mode | A PPB_FileChooser_Dev instance can be used to select a single file (PP_FILECHOOSERMODE_OPEN) or multiple files (PP_FILECHOOSERMODE_OPENMULTIPLE). Unlike the HTML5 <input type="file"> tag, a PPB_FileChooser_Dev instance cannot be used to select a directory. In order to get the list of files in a directory, the PPB_FileRef::ReadDirectoryEntries interface must be used. |
accept_types | A comma-separated list of MIME types and file extensions such as "audio/ *,text/plain,.html" (note there should be no space between the '/' and the '*', but one is added to avoid confusing C++ comments). The dialog may restrict selectable files to the specified MIME types and file extensions. If a string in the comma-separated list begins with a period (.) then the string is interpreted as a file extension, otherwise it is interpreted as a MIME-type. An empty string or an undefined var may be given to indicate that all types should be accepted. |
static void pp::FileChooser_Dev::CallbackConverter |
( |
void * |
user_data, |
|
|
int32_t |
result |
|
) |
| |
|
staticprotected |
This function displays a previously created file chooser resource as a dialog box, prompting the user to choose a file or files. This function must be called in response to a user gesture, such as a mouse click or touch event. The callback is called with PP_OK on successful completion with a file (or files) selected, PP_ERROR_USERCANCEL if the user selected no file, or another error code from pp_errors.h on failure.
- Parameters
-
callback | The completion callback that will be executed. On success, the selected files will be passed to the given function. |
Normally you would use a CompletionCallbackFactory to allow callbacks to be bound to your class. See completion_callback_factory.h for more discussion on how to use this. Your callback will generally look like:
void OnFilesSelected(
int32_t result,
const std::vector<pp::FileRef>& files) {
if (result == PP_OK)
}
- Returns
- PP_OK_COMPLETIONPENDING if request to show the dialog was successful, another error code from pp_errors.h on failure.
The documentation for this class was generated from the following file: