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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/completion_callback.h ('k') | ppapi/cpp/dev/file_chooser_dev.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/file_chooser_dev.h
diff --git a/ppapi/cpp/dev/file_chooser_dev.h b/ppapi/cpp/dev/file_chooser_dev.h
index c2abc703073e71da43b57e9ee424d4272f8a64c9..b588ac85a379ebff01d2109f764b50c6c3e64a5f 100644
--- a/ppapi/cpp/dev/file_chooser_dev.h
+++ b/ppapi/cpp/dev/file_chooser_dev.h
@@ -5,7 +5,11 @@
#ifndef PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_
#define PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_
+#include <vector>
+
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/file_ref.h"
#include "ppapi/cpp/resource.h"
namespace pp {
@@ -49,23 +53,47 @@ class FileChooser_Dev : public Resource {
FileChooser_Dev(const FileChooser_Dev& other);
/// This function displays a previously created file chooser resource as a
- /// dialog box, prompting the user to choose a file or files. The callback is
- /// called with PP_OK on successful completion with a file (or files) selected
- /// or PP_ERROR_USERCANCEL if the user selected no file.
+ /// 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.
+ ///
+ /// @param 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:
+ ///
+ /// @code
+ /// void OnFilesSelected(int32_t result,
+ /// const std::vector<pp::FileRef>& files) {
+ /// if (result == PP_OK)
+ /// // use files...
+ /// }
+ /// @endcode
///
/// @return PP_OK_COMPLETIONPENDING if request to show the dialog was
/// successful, another error code from pp_errors.h on failure.
- virtual int32_t Show(const CompletionCallback& cc);
+ virtual int32_t Show(
+ const CompletionCallbackWithOutput< std::vector<FileRef> >& callback);
+
+ protected:
+ // Heap-allocated data passed to the CallbackConverter for backwards compat.
+ struct ChooseCallbackData0_5 {
+ PP_Resource file_chooser;
+ PP_ArrayOutput output;
+ PP_CompletionCallback original_callback;
+ };
- /// After a successful completion callback call from Show, this method may be
- /// used to query the chosen files. It should be called in a loop until it
- /// returns an is_null() FileRef. Depending on the PP_ChooseFileMode
- /// requested when the FileChooser was created, the file refs will either
- /// be readable or writable. Their file system type will be
- /// PP_FileSystemType_External. If the user chose no files or cancelled the
- /// dialog, then this method will simply return an is_null() FileRef the
- /// first time it is called.
- virtual FileRef GetNextChosenFile() const;
+ // Provide backwards-compatability for older versions. Converts the old-style
+ // 0.5 "iterator" interface to the new-style 0.6 "array output" interface that
+ // the caller is expecting.
+ //
+ // This takes a heap-allocated ChooseCallbackData0_5 struct passed as the
+ // user data and deletes it when the call completes.
+ static void CallbackConverter(void* user_data, int32_t result);
};
} // namespace pp
« 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