OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CPP_DEV_FILE_CHOOSER_DEV_H_ | 5 #ifndef PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_ |
6 #define PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_ | 6 #define PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_ |
7 | 7 |
8 #include "ppapi/c/dev/ppb_file_chooser_dev.h" | 8 #include "ppapi/c/dev/ppb_file_chooser_dev.h" |
9 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
10 | 10 |
11 namespace pp { | 11 namespace pp { |
12 | 12 |
13 class CompletionCallback; | 13 class CompletionCallback; |
14 class FileRef; | 14 class FileRef; |
15 class Instance; | 15 class InstanceHandle; |
16 class Var; | 16 class Var; |
17 | 17 |
18 class FileChooser_Dev : public Resource { | 18 class FileChooser_Dev : public Resource { |
19 public: | 19 public: |
20 /// Creates an is_null() FileChooser object. | 20 /// Creates an is_null() FileChooser object. |
21 FileChooser_Dev() {} | 21 FileChooser_Dev() {} |
22 | 22 |
23 /// This function creates a file chooser dialog resource. The chooser is | 23 /// This function creates a file chooser dialog resource. The chooser is |
24 /// associated with a particular instance, so that it may be positioned on the | 24 /// associated with a particular instance, so that it may be positioned on the |
25 /// screen relative to the tab containing the instance. Returns 0 if passed | 25 /// screen relative to the tab containing the instance. Returns 0 if passed |
26 /// an invalid instance. | 26 /// an invalid instance. |
27 /// | 27 /// |
28 /// @param mode A PPB_FileChooser_Dev instance can be used to select a single | 28 /// @param mode A PPB_FileChooser_Dev instance can be used to select a single |
29 /// file (PP_FILECHOOSERMODE_OPEN) or multiple files | 29 /// file (PP_FILECHOOSERMODE_OPEN) or multiple files |
30 /// (PP_FILECHOOSERMODE_OPENMULTIPLE). Unlike the HTML5 <input type="file"> | 30 /// (PP_FILECHOOSERMODE_OPENMULTIPLE). Unlike the HTML5 <input type="file"> |
31 /// tag, a PPB_FileChooser_Dev instance cannot be used to select a directory. | 31 /// tag, a PPB_FileChooser_Dev instance cannot be used to select a directory. |
32 /// In order to get the list of files in a directory, the | 32 /// In order to get the list of files in a directory, the |
33 /// PPB_DirectoryReader_Dev interface must be used. | 33 /// PPB_DirectoryReader_Dev interface must be used. |
34 /// | 34 /// |
35 /// @param accept_mime_types A comma-separated list of MIME types such as | 35 /// @param accept_mime_types A comma-separated list of MIME types such as |
36 /// "audio/ *,text/plain" (note there should be no space between the '/' and | 36 /// "audio/ *,text/plain" (note there should be no space between the '/' and |
37 /// the '*', but one is added to avoid confusing C++ comments). The dialog | 37 /// the '*', but one is added to avoid confusing C++ comments). The dialog |
38 /// may restrict selectable files to the specified MIME types. An empty string | 38 /// may restrict selectable files to the specified MIME types. An empty string |
39 /// or an undefined var may be given to indicate that all types should be | 39 /// or an undefined var may be given to indicate that all types should be |
40 /// accepted. | 40 /// accepted. |
41 /// | 41 /// |
42 /// TODO(darin): What if the mime type is unknown to the system? The plugin | 42 /// TODO(darin): What if the mime type is unknown to the system? The plugin |
43 /// may wish to describe the mime type and provide a matching file extension. | 43 /// may wish to describe the mime type and provide a matching file extension. |
44 /// It is more webby to use mime types here instead of file extensions. | 44 /// It is more webby to use mime types here instead of file extensions. |
45 FileChooser_Dev(const Instance* instance, | 45 FileChooser_Dev(const InstanceHandle& instance, |
46 PP_FileChooserMode_Dev mode, | 46 PP_FileChooserMode_Dev mode, |
47 const Var& accept_mime_types); | 47 const Var& accept_mime_types); |
48 | 48 |
49 FileChooser_Dev(const FileChooser_Dev& other); | 49 FileChooser_Dev(const FileChooser_Dev& other); |
50 | 50 |
51 /// This function displays a previously created file chooser resource as a | 51 /// This function displays a previously created file chooser resource as a |
52 /// dialog box, prompting the user to choose a file or files. The callback is | 52 /// dialog box, prompting the user to choose a file or files. The callback is |
53 /// called with PP_OK on successful completion with a file (or files) selected | 53 /// called with PP_OK on successful completion with a file (or files) selected |
54 /// or PP_ERROR_USERCANCEL if the user selected no file. | 54 /// or PP_ERROR_USERCANCEL if the user selected no file. |
55 /// | 55 /// |
56 /// @return PP_OK_COMPLETIONPENDING if request to show the dialog was | 56 /// @return PP_OK_COMPLETIONPENDING if request to show the dialog was |
57 /// successful, another error code from pp_errors.h on failure. | 57 /// successful, another error code from pp_errors.h on failure. |
58 virtual int32_t Show(const CompletionCallback& cc); | 58 virtual int32_t Show(const CompletionCallback& cc); |
59 | 59 |
60 /// After a successful completion callback call from Show, this method may be | 60 /// After a successful completion callback call from Show, this method may be |
61 /// used to query the chosen files. It should be called in a loop until it | 61 /// used to query the chosen files. It should be called in a loop until it |
62 /// returns an is_null() FileRef. Depending on the PP_ChooseFileMode | 62 /// returns an is_null() FileRef. Depending on the PP_ChooseFileMode |
63 /// requested when the FileChooser was created, the file refs will either | 63 /// requested when the FileChooser was created, the file refs will either |
64 /// be readable or writable. Their file system type will be | 64 /// be readable or writable. Their file system type will be |
65 /// PP_FileSystemType_External. If the user chose no files or cancelled the | 65 /// PP_FileSystemType_External. If the user chose no files or cancelled the |
66 /// dialog, then this method will simply return an is_null() FileRef the | 66 /// dialog, then this method will simply return an is_null() FileRef the |
67 /// first time it is called. | 67 /// first time it is called. |
68 virtual FileRef GetNextChosenFile() const; | 68 virtual FileRef GetNextChosenFile() const; |
69 }; | 69 }; |
70 | 70 |
71 } // namespace pp | 71 } // namespace pp |
72 | 72 |
73 #endif // PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_ | 73 #endif // PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_ |
OLD | NEW |