diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 22:21:59 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 22:21:59 +0000 |
commit | 11f515acdda3473200ff0cc4106a0020a7d4dc74 (patch) | |
tree | cdfd9713928d6f0fa73b5cd7bedbd965fc93e329 /ppapi/thunk | |
parent | f60d96e82acd547ac834b93cd68865b66ab5b4da (diff) | |
download | chromium_src-11f515acdda3473200ff0cc4106a0020a7d4dc74.zip chromium_src-11f515acdda3473200ff0cc4106a0020a7d4dc74.tar.gz chromium_src-11f515acdda3473200ff0cc4106a0020a7d4dc74.tar.bz2 |
New file chooser interface that uses the new PP_ArrayOutput feature. This also changes PP_ArrayOutput to be pass-by-value.
This keeps backwards compat for the old interface. It fixes some bugs in the callback system that I found when working on the patch and adds some new machinery for doing array output in the proxy. It also re-enables the file chooser feature which was recently broken.
BUG=118857
Review URL: https://chromiumcodereview.appspot.com/9728001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_dev.h | 2 | ||||
-rw-r--r-- | ppapi/thunk/ppb_file_chooser_api.h | 19 | ||||
-rw-r--r-- | ppapi/thunk/ppb_file_chooser_thunk.cc | 77 |
3 files changed, 80 insertions, 18 deletions
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index 72de91e..0296a2d 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -41,6 +41,8 @@ UNPROXIED_IFACE(PPB_DirectoryReader, PPB_DIRECTORYREADER_DEV_INTERFACE_0_5, UNPROXIED_IFACE(PPB_Find, PPB_FIND_DEV_INTERFACE_0_3, PPB_Find_Dev_0_3) PROXIED_IFACE(PPB_FileChooser, PPB_FILECHOOSER_DEV_INTERFACE_0_5, PPB_FileChooser_Dev_0_5) +PROXIED_IFACE(PPB_FileChooser, PPB_FILECHOOSER_DEV_INTERFACE_0_6, + PPB_FileChooser_Dev_0_6) PROXIED_IFACE(PPB_Instance, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev_0_4) PROXIED_IFACE(PPB_Instance, PPB_CONSOLE_DEV_INTERFACE_0_1, PPB_Console_Dev_0_1) PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_6, PPB_URLUtil_Dev_0_6) diff --git a/ppapi/thunk/ppb_file_chooser_api.h b/ppapi/thunk/ppb_file_chooser_api.h index 494f7bd..ed94782 100644 --- a/ppapi/thunk/ppb_file_chooser_api.h +++ b/ppapi/thunk/ppb_file_chooser_api.h @@ -14,13 +14,24 @@ class PPB_FileChooser_API { public: virtual ~PPB_FileChooser_API() {} - virtual int32_t Show(const PP_CompletionCallback& callback) = 0; - virtual PP_Resource GetNextChosenFile() = 0; + virtual int32_t Show(const PP_ArrayOutput& output, + const PP_CompletionCallback& callback) = 0; // Trusted API. virtual int32_t ShowWithoutUserGesture( - bool save_as, - const char* suggested_file_name, + PP_Bool save_as, + PP_Var suggested_file_name, + const PP_ArrayOutput& output, + const PP_CompletionCallback& callback) = 0; + + // Version 0.5 API. + virtual int32_t Show0_5(const PP_CompletionCallback& callback) = 0; + virtual PP_Resource GetNextChosenFile() = 0; + + // Trusted version 0.5 API. + virtual int32_t ShowWithoutUserGesture0_5( + PP_Bool save_as, + PP_Var suggested_file_name, const PP_CompletionCallback& callback) = 0; }; diff --git a/ppapi/thunk/ppb_file_chooser_thunk.cc b/ppapi/thunk/ppb_file_chooser_thunk.cc index b43b06a..4e590c7 100644 --- a/ppapi/thunk/ppb_file_chooser_thunk.cc +++ b/ppapi/thunk/ppb_file_chooser_thunk.cc @@ -34,53 +34,102 @@ PP_Bool IsFileChooser(PP_Resource resource) { return PP_FromBool(enter.succeeded()); } -int32_t Show(PP_Resource chooser, PP_CompletionCallback callback) { +int32_t Show0_5(PP_Resource chooser, PP_CompletionCallback callback) { EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); if (enter.failed()) return enter.retval(); - return enter.SetResult(enter.object()->Show(callback)); + return enter.SetResult(enter.object()->Show0_5(callback)); } -PP_Resource GetNextChosenFile(PP_Resource chooser) { +PP_Resource GetNextChosenFile0_5(PP_Resource chooser) { EnterResource<PPB_FileChooser_API> enter(chooser, true); if (enter.failed()) return 0; return enter.object()->GetNextChosenFile(); } +int32_t Show(PP_Resource chooser, + PP_ArrayOutput output, + PP_CompletionCallback callback) { + EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Show(output, callback)); +} + + int32_t ShowWithoutUserGesture(PP_Resource chooser, PP_Bool save_as, PP_Var suggested_file_name, + const PP_ArrayOutput* output, PP_CompletionCallback callback) { EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); if (enter.failed()) return enter.retval(); - scoped_refptr<StringVar> string_var = - StringVar::FromPPVar(suggested_file_name); - std::string str = string_var ? string_var->value() : std::string(); return enter.SetResult(enter.object()->ShowWithoutUserGesture( - save_as == PP_TRUE, str.c_str(), callback)); + save_as, suggested_file_name, *output, callback)); } -const PPB_FileChooser_Dev g_ppb_file_chooser_thunk = { +int32_t ShowWithoutUserGesture0_5(PP_Resource chooser, + PP_Bool save_as, + PP_Var suggested_file_name, + PP_CompletionCallback callback) { + EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->ShowWithoutUserGesture0_5( + save_as, suggested_file_name, callback)); +} + +int32_t ShowWithoutUserGesture0_6(PP_Resource chooser, + PP_Bool save_as, + PP_Var suggested_file_name, + PP_ArrayOutput output, + PP_CompletionCallback callback) { + EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->ShowWithoutUserGesture( + save_as, suggested_file_name, output, callback)); +} + +const PPB_FileChooser_Dev_0_5 g_ppb_file_chooser_0_5_thunk = { + &Create, + &IsFileChooser, + &Show0_5, + &GetNextChosenFile0_5 +}; + +const PPB_FileChooser_Dev_0_6 g_ppb_file_chooser_0_6_thunk = { &Create, &IsFileChooser, - &Show, - &GetNextChosenFile + &Show +}; + +const PPB_FileChooserTrusted_0_5 g_ppb_file_chooser_trusted_0_5_thunk = { + &ShowWithoutUserGesture0_5 }; -const PPB_FileChooserTrusted g_ppb_file_chooser_trusted_thunk = { - &ShowWithoutUserGesture +const PPB_FileChooserTrusted_0_6 g_ppb_file_chooser_trusted_0_6_thunk = { + &ShowWithoutUserGesture0_6 }; } // namespace const PPB_FileChooser_Dev_0_5* GetPPB_FileChooser_Dev_0_5_Thunk() { - return &g_ppb_file_chooser_thunk; + return &g_ppb_file_chooser_0_5_thunk; +} + +const PPB_FileChooser_Dev_0_6* GetPPB_FileChooser_Dev_0_6_Thunk() { + return &g_ppb_file_chooser_0_6_thunk; } const PPB_FileChooserTrusted_0_5* GetPPB_FileChooser_Trusted_0_5_Thunk() { - return &g_ppb_file_chooser_trusted_thunk; + return &g_ppb_file_chooser_trusted_0_5_thunk; +} + +const PPB_FileChooserTrusted_0_6* GetPPB_FileChooser_Trusted_0_6_Thunk() { + return &g_ppb_file_chooser_trusted_0_6_thunk; } } // namespace thunk |