summaryrefslogtreecommitdiffstats
path: root/ppapi/thunk
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-13 02:48:50 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-13 02:48:50 +0000
commit459fba846839922dc77873aa3181a2684cd03e0c (patch)
treed48784892c57993f21e92b6fdebf99836845d5e7 /ppapi/thunk
parent721c0ceae9fef3230bd36b0d1b742f231f37ad19 (diff)
downloadchromium_src-459fba846839922dc77873aa3181a2684cd03e0c.zip
chromium_src-459fba846839922dc77873aa3181a2684cd03e0c.tar.gz
chromium_src-459fba846839922dc77873aa3181a2684cd03e0c.tar.bz2
Implement 'SAVEAS' mode for PPB_FileChooser_Impl. Also, fix the Save File dialog when thesuggested file name is a root directory, such as "C:\".
BUG=73070 TEST=manual Review URL: http://codereview.chromium.org/8142018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r--ppapi/thunk/ppb_file_chooser_api.h6
-rw-r--r--ppapi/thunk/ppb_file_chooser_thunk.cc31
-rw-r--r--ppapi/thunk/resource_creation_api.h2
-rw-r--r--ppapi/thunk/thunk.h3
4 files changed, 39 insertions, 3 deletions
diff --git a/ppapi/thunk/ppb_file_chooser_api.h b/ppapi/thunk/ppb_file_chooser_api.h
index fba94c7..494f7bd 100644
--- a/ppapi/thunk/ppb_file_chooser_api.h
+++ b/ppapi/thunk/ppb_file_chooser_api.h
@@ -16,6 +16,12 @@ class PPB_FileChooser_API {
virtual int32_t Show(const PP_CompletionCallback& callback) = 0;
virtual PP_Resource GetNextChosenFile() = 0;
+
+ // Trusted API.
+ virtual int32_t ShowWithoutUserGesture(
+ bool save_as,
+ const char* suggested_file_name,
+ const PP_CompletionCallback& callback) = 0;
};
} // namespace thunk
diff --git a/ppapi/thunk/ppb_file_chooser_thunk.cc b/ppapi/thunk/ppb_file_chooser_thunk.cc
index 774ef03..e5cbc5d 100644
--- a/ppapi/thunk/ppb_file_chooser_thunk.cc
+++ b/ppapi/thunk/ppb_file_chooser_thunk.cc
@@ -5,6 +5,8 @@
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/trusted/ppb_file_chooser_trusted.h"
+#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/thunk.h"
@@ -22,8 +24,10 @@ PP_Resource Create(PP_Instance instance,
EnterFunction<ResourceCreationAPI> enter(instance, true);
if (enter.failed())
return 0;
- return enter.functions()->CreateFileChooser(instance, mode,
- accept_mime_types);
+ scoped_refptr<StringVar> string_var =
+ StringVar::FromPPVar(accept_mime_types);
+ std::string str = string_var ? string_var->value() : std::string();
+ return enter.functions()->CreateFileChooser(instance, mode, str.c_str());
}
PP_Bool IsFileChooser(PP_Resource resource) {
@@ -46,6 +50,21 @@ PP_Resource GetNextChosenFile(PP_Resource chooser) {
return enter.object()->GetNextChosenFile();
}
+int32_t ShowWithoutUserGesture(PP_Resource chooser,
+ PP_Bool save_as,
+ PP_Var suggested_file_name,
+ PP_CompletionCallback callback) {
+ EnterResource<PPB_FileChooser_API> enter(chooser, true);
+ if (enter.failed())
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ scoped_refptr<StringVar> string_var =
+ StringVar::FromPPVar(suggested_file_name);
+ std::string str = string_var ? string_var->value() : std::string();
+ int32_t result = enter.object()->ShowWithoutUserGesture(
+ save_as == PP_TRUE, str.c_str(), callback);
+ return MayForceCallback(callback, result);
+}
+
const PPB_FileChooser_Dev g_ppb_file_chooser_thunk = {
&Create,
&IsFileChooser,
@@ -53,11 +72,19 @@ const PPB_FileChooser_Dev g_ppb_file_chooser_thunk = {
&GetNextChosenFile
};
+const PPB_FileChooserTrusted g_ppb_file_chooser_trusted_thunk = {
+ &ShowWithoutUserGesture
+};
+
} // namespace
const PPB_FileChooser_Dev* GetPPB_FileChooser_Dev_Thunk() {
return &g_ppb_file_chooser_thunk;
}
+const PPB_FileChooserTrusted* GetPPB_FileChooser_Trusted_Thunk() {
+ return &g_ppb_file_chooser_trusted_thunk;
+}
+
} // namespace thunk
} // namespace ppapi
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index 256c9e8..59cc1c2 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -62,7 +62,7 @@ class ResourceCreationAPI {
virtual PP_Resource CreateFileChooser(
PP_Instance instance,
PP_FileChooserMode_Dev mode,
- const PP_Var& accept_mime_types) = 0;
+ const char* accept_mime_types) = 0;
virtual PP_Resource CreateFileIO(PP_Instance instance) = 0;
virtual PP_Resource CreateFileRef(PP_Resource file_system,
const char* path) = 0;
diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h
index fe90eff..bac3a63 100644
--- a/ppapi/thunk/thunk.h
+++ b/ppapi/thunk/thunk.h
@@ -31,6 +31,7 @@ struct PPB_AudioTrusted;
struct PPB_BrokerTrusted;
struct PPB_BufferTrusted;
struct PPB_Context3DTrusted_Dev;
+struct PPB_FileChooserTrusted;
struct PPB_FileIOTrusted;
struct PPB_Flash_Menu;
struct PPB_Flash_NetConnector;
@@ -56,6 +57,8 @@ PPAPI_THUNK_EXPORT const PPB_BrokerTrusted* GetPPB_Broker_Thunk();
PPAPI_THUNK_EXPORT const PPB_BufferTrusted* GetPPB_BufferTrusted_Thunk();
PPAPI_THUNK_EXPORT const PPB_Context3DTrusted_Dev*
GetPPB_Context3DTrusted_Thunk();
+PPAPI_THUNK_EXPORT const PPB_FileChooserTrusted*
+ GetPPB_FileChooser_Trusted_Thunk();
PPAPI_THUNK_EXPORT const PPB_FileIOTrusted* GetPPB_FileIOTrusted_Thunk();
PPAPI_THUNK_EXPORT const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk();
PPAPI_THUNK_EXPORT const PPB_Flash_NetConnector*