Pepper_31_C++_interfaces
Classes | Public Member Functions | Static Protected Member Functions | List of all members
pp::FileChooser_Dev Class Reference

#include <file_chooser_dev.h>

Inheritance diagram for pp::FileChooser_Dev:
Inheritance graph
Collaboration diagram for pp::FileChooser_Dev:
Collaboration graph

Classes

struct  ChooseCallbackData0_5
 

Public Member Functions

 FileChooser_Dev ()
 Creates an is_null() FileChooser object. More...
 
 FileChooser_Dev (const InstanceHandle &instance, PP_FileChooserMode_Dev mode, const Var &accept_types)
 
 FileChooser_Dev (const FileChooser_Dev &other)
 
virtual int32_t Show (const CompletionCallbackWithOutput< std::vector< FileRef > > &callback)
 
- Public Member Functions inherited from pp::Resource
 Resource ()
 The default constructor. More...
 
 Resource (const Resource &other)
 
virtual ~Resource ()
 Destructor. More...
 
Resourceoperator= (const Resource &other)
 
bool is_null () const
 
PP_Resource pp_resource () const
 
PP_Resource detach ()
 

Static Protected Member Functions

static void CallbackConverter (void *user_data, int32_t result)
 

Additional Inherited Members

- Protected Member Functions inherited from pp::Resource
 Resource (PP_Resource resource)
 
 Resource (PassRef, PP_Resource resource)
 
void PassRefFromConstructor (PP_Resource resource)
 

Detailed Description

Definition at line 22 of file file_chooser_dev.h.

Constructor & Destructor Documentation

pp::FileChooser_Dev::FileChooser_Dev ( )
inline

Creates an is_null() FileChooser object.

Definition at line 25 of file file_chooser_dev.h.

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
modeA 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_typesA 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.
pp::FileChooser_Dev::FileChooser_Dev ( const FileChooser_Dev other)

Member Function Documentation

static void pp::FileChooser_Dev::CallbackConverter ( void *  user_data,
int32_t  result 
)
staticprotected
virtual int32_t pp::FileChooser_Dev::Show ( const CompletionCallbackWithOutput< std::vector< FileRef > > &  callback)
virtual

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
callbackThe 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)
// use files...
}
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: