Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: ppapi/cpp/dev/file_chooser_dev.h

Issue 9728001: Make the file chooser use PP_ArrayOutput (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/completion_callback.h ('k') | ppapi/cpp/dev/file_chooser_dev.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector>
9
8 #include "ppapi/c/dev/ppb_file_chooser_dev.h" 10 #include "ppapi/c/dev/ppb_file_chooser_dev.h"
11 #include "ppapi/cpp/completion_callback.h"
12 #include "ppapi/cpp/file_ref.h"
9 #include "ppapi/cpp/resource.h" 13 #include "ppapi/cpp/resource.h"
10 14
11 namespace pp { 15 namespace pp {
12 16
13 class CompletionCallback; 17 class CompletionCallback;
14 class FileRef; 18 class FileRef;
15 class InstanceHandle; 19 class InstanceHandle;
16 class Var; 20 class Var;
17 21
18 class FileChooser_Dev : public Resource { 22 class FileChooser_Dev : public Resource {
(...skipping 23 matching lines...) Expand all
42 /// TODO(darin): What if the mime type is unknown to the system? The plugin 46 /// 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. 47 /// 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. 48 /// It is more webby to use mime types here instead of file extensions.
45 FileChooser_Dev(const InstanceHandle& instance, 49 FileChooser_Dev(const InstanceHandle& instance,
46 PP_FileChooserMode_Dev mode, 50 PP_FileChooserMode_Dev mode,
47 const Var& accept_mime_types); 51 const Var& accept_mime_types);
48 52
49 FileChooser_Dev(const FileChooser_Dev& other); 53 FileChooser_Dev(const FileChooser_Dev& other);
50 54
51 /// This function displays a previously created file chooser resource as a 55 /// 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 56 /// dialog box, prompting the user to choose a file or files. This function
53 /// called with PP_OK on successful completion with a file (or files) selected 57 /// must be called in response to a user gesture, such as a mouse click or
54 /// or PP_ERROR_USERCANCEL if the user selected no file. 58 /// touch event. The callback is called with PP_OK on successful completion
59 /// with a file (or files) selected, PP_ERROR_USERCANCEL if the user selected
60 /// no file, or another error code from pp_errors.h on failure.
61 ///
62 /// @param callback The completion callback that will be executed. On success,
63 /// the selected files will be passed to the given function.
64 ///
65 /// Normally you would use a CompletionCallbackFactory to allow callbacks to
66 /// be bound to your class. See completion_callback_factory.h for more
67 /// discussion on how to use this. Your callback will generally look like:
68 ///
69 /// @code
70 /// void OnFilesSelected(int32_t result,
71 /// const std::vector<pp::FileRef>& files) {
72 /// if (result == PP_OK)
73 /// // use files...
74 /// }
75 /// @endcode
55 /// 76 ///
56 /// @return PP_OK_COMPLETIONPENDING if request to show the dialog was 77 /// @return PP_OK_COMPLETIONPENDING if request to show the dialog was
57 /// successful, another error code from pp_errors.h on failure. 78 /// successful, another error code from pp_errors.h on failure.
58 virtual int32_t Show(const CompletionCallback& cc); 79 virtual int32_t Show(
80 const CompletionCallbackWithOutput< std::vector<FileRef> >& callback);
59 81
60 /// After a successful completion callback call from Show, this method may be 82 protected:
61 /// used to query the chosen files. It should be called in a loop until it 83 // Heap-allocated data passed to the CallbackConverter for backwards compat.
62 /// returns an is_null() FileRef. Depending on the PP_ChooseFileMode 84 struct ChooseCallbackData0_5 {
63 /// requested when the FileChooser was created, the file refs will either 85 PP_Resource file_chooser;
64 /// be readable or writable. Their file system type will be 86 PP_ArrayOutput output;
65 /// PP_FileSystemType_External. If the user chose no files or cancelled the 87 PP_CompletionCallback original_callback;
66 /// dialog, then this method will simply return an is_null() FileRef the 88 };
67 /// first time it is called. 89
68 virtual FileRef GetNextChosenFile() const; 90 // Provide backwards-compatability for older versions. Converts the old-style
91 // 0.5 "iterator" interface to the new-style 0.6 "array output" interface that
92 // the caller is expecting.
93 //
94 // This takes a heap-allocated ChooseCallbackData0_5 struct passed as the
95 // user data and deletes it when the call completes.
96 static void CallbackConverter(void* user_data, int32_t result);
69 }; 97 };
70 98
71 } // namespace pp 99 } // namespace pp
72 100
73 #endif // PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_ 101 #endif // PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/completion_callback.h ('k') | ppapi/cpp/dev/file_chooser_dev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698