summaryrefslogtreecommitdiffstats
path: root/third_party/npapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 19:52:47 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 19:52:47 +0000
commitcdaf8d04617e815d8e8fb0fe1c707a23cc583904 (patch)
treeb323d372b6e01fe6d13e37b8a50016386bd6142e /third_party/npapi
parent39c4e1a8b2343b3883a098a8e0d21fb8bd3204cf (diff)
downloadchromium_src-cdaf8d04617e815d8e8fb0fe1c707a23cc583904.zip
chromium_src-cdaf8d04617e815d8e8fb0fe1c707a23cc583904.tar.gz
chromium_src-cdaf8d04617e815d8e8fb0fe1c707a23cc583904.tar.bz2
Extend the file browser/chooser to support more modes of operation, and plumb
it through to the pepper API. This pepper API just supports adding the filename to the "upload files" whitelist and returning it to the plugin, but it does not actually give any ability for a sandboxed plugin to read the file (this will come in a separate changelist). TEST=none BUG=none Review URL: http://codereview.chromium.org/1094004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/npapi')
-rw-r--r--third_party/npapi/bindings/npapi_extensions.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/third_party/npapi/bindings/npapi_extensions.h b/third_party/npapi/bindings/npapi_extensions.h
index f7ac489..f8c05f4 100644
--- a/third_party/npapi/bindings/npapi_extensions.h
+++ b/third_party/npapi/bindings/npapi_extensions.h
@@ -197,6 +197,63 @@ typedef void (*NPSelectedFindResultChangedPtr)(
NPP instance,
int index);
+/* Supports opening files anywhere on the system after prompting the user to
+ * pick one.
+ *
+ * This API is asynchronous. It will return immediately and the user will be
+ * prompted in parallel to pick a file. The plugin may continue to receive
+ * events while the open file dialog is up, and may continue to paint. Plugins
+ * may want to ignore input events between the call and the callback to avoid
+ * reentrant behavior. If the return value is not NPERR_NO_ERROR, the callback
+ * will NOT be executed.
+ *
+ * It is an error to call BrowseForFile before a previous call has executed
+ * the callback.
+ *
+ * Setting the flags to "Open" requires that the file exist to allow picking.
+ * Setting the flags to "Save" allows selecting nonexistant files (which will
+ * then be created), and will prompt the user if they want to overwrite an
+ * existing file if it exists.
+ *
+ * The plugin may specify a comma-separated list of possible mime types in
+ * the "extensions" parameter. If no extensions are specified, the dialog box
+ * will default to allowing all extensions. The first extension in the list
+ * will be the default.
+ *
+ * TODO(brettw) On Windows the extensions traditionally include a text
+ * description with the extension in the popup, do we want to allow this?
+ * We should probably also allow the ability to put "All files" in the
+ * list on Windows.
+ *
+ * Once the user has picked a file or has canceled the dialog box, the given
+ * callback will be called with the results of the operation and the passed in
+ * "user data" pointer. If the user successfully picked a file, the filename
+ * will be non-NULL and will contain a pointer to an array of strings, one for
+ * each file picked (the first file will be file_paths[0]). This buffer will
+ * become invalid as soon as the call completes, so it is the plugin's
+ * responsibility to copy the filename(sp if it needs future access to them.
+ * A NULL file_paths in the callback means the user canceled the dialog box.
+ *
+ * The filename will be in UTF-8. It may not actually correspond to the actual
+ * file on disk on a Linux system, because we'll do our best to convert it from
+ * the filesystem's locale to UTF-8. Instead, the string will be appropriate for
+ * displaying to the user which file they picked.
+ * */
+typedef enum {
+ NPChooseFile_Open = 1,
+ NPChooseFile_OpenMultiple = 2,
+ NPChooseFile_Save = 3,
+} NPChooseFileMode;
+typedef void (*NPChooseFileCallback)(const char** filePaths,
+ uint32 pathCount,
+ void* userData);
+typedef NPError (*NPChooseFilePtr)(
+ NPP instance,
+ const char* mimeTypes,
+ NPChooseFileMode mode,
+ NPChooseFileCallback callback,
+ void* userData);
+
/* Pepper extensions */
struct NPNExtensions {
/* Device interface acquisition */
@@ -206,6 +263,8 @@ struct NPNExtensions {
/* Find */
NPNumberOfFindResultsChangedPtr numberOfFindResultsChanged;
NPSelectedFindResultChangedPtr selectedFindResultChanged;
+ /* File I/O extensions */
+ NPChooseFilePtr chooseFile;
};
/* Events -------------------------------------------------------------------*/