| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PROXY_FILE_CHOOSER_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_ | 6 #define PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ppapi/proxy/plugin_resource.h" | 12 #include "ppapi/proxy/plugin_resource.h" |
| 13 #include "ppapi/proxy/ppapi_proxy_export.h" | 13 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 14 #include "ppapi/shared_impl/array_writer.h" | 14 #include "ppapi/shared_impl/array_writer.h" |
| 15 #include "ppapi/shared_impl/tracked_callback.h" | 15 #include "ppapi/shared_impl/tracked_callback.h" |
| 16 #include "ppapi/thunk/ppb_file_chooser_api.h" | 16 #include "ppapi/thunk/ppb_file_chooser_api.h" |
| 17 | 17 |
| 18 namespace ppapi { | 18 namespace ppapi { |
| 19 | 19 |
| 20 struct PPB_FileRef_CreateInfo; | 20 struct PPB_FileRef_CreateInfo; |
| 21 | 21 |
| 22 namespace proxy { | 22 namespace proxy { |
| 23 | 23 |
| 24 class PPAPI_PROXY_EXPORT FileChooserResource | 24 class PPAPI_PROXY_EXPORT FileChooserResource |
| 25 : public PluginResource, | 25 : public PluginResource, |
| 26 public NON_EXPORTED_BASE(thunk::PPB_FileChooser_API) { | 26 public NON_EXPORTED_BASE(thunk::PPB_FileChooser_API) { |
| 27 public: | 27 public: |
| 28 FileChooserResource(IPC::Sender* sender, | 28 FileChooserResource(Connection connection, |
| 29 PP_Instance instance, | 29 PP_Instance instance, |
| 30 PP_FileChooserMode_Dev mode, | 30 PP_FileChooserMode_Dev mode, |
| 31 const std::string& accept_types); | 31 const std::string& accept_types); |
| 32 virtual ~FileChooserResource(); | 32 virtual ~FileChooserResource(); |
| 33 | 33 |
| 34 // Resource overrides. | 34 // Resource overrides. |
| 35 virtual thunk::PPB_FileChooser_API* AsPPB_FileChooser_API() OVERRIDE; | 35 virtual thunk::PPB_FileChooser_API* AsPPB_FileChooser_API() OVERRIDE; |
| 36 | 36 |
| 37 // PPB_FileChooser_API. | 37 // PPB_FileChooser_API. |
| 38 virtual int32_t Show(const PP_ArrayOutput& output, | 38 virtual int32_t Show(const PP_ArrayOutput& output, |
| 39 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 39 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 40 virtual int32_t ShowWithoutUserGesture( | 40 virtual int32_t ShowWithoutUserGesture( |
| 41 PP_Bool save_as, | 41 PP_Bool save_as, |
| 42 PP_Var suggested_file_name, | 42 PP_Var suggested_file_name, |
| 43 const PP_ArrayOutput& output, | 43 const PP_ArrayOutput& output, |
| 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 45 virtual int32_t Show0_5(scoped_refptr<TrackedCallback> callback) OVERRIDE; | 45 virtual int32_t Show0_5(scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 46 virtual PP_Resource GetNextChosenFile() OVERRIDE; | 46 virtual PP_Resource GetNextChosenFile() OVERRIDE; |
| 47 virtual int32_t ShowWithoutUserGesture0_5( | 47 virtual int32_t ShowWithoutUserGesture0_5( |
| 48 PP_Bool save_as, | 48 PP_Bool save_as, |
| 49 PP_Var suggested_file_name, | 49 PP_Var suggested_file_name, |
| 50 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 50 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 51 | 51 |
| 52 // Parses the accept string into the given vector. | 52 // Parses the accept string into the given vector. |
| 53 static void PopulateAcceptTypes(const std::string& input, | 53 static void PopulateAcceptTypes(const std::string& input, |
| 54 std::vector<std::string>* output); | 54 std::vector<std::string>* output); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // PluginResource override. | 57 // PluginResource override. |
| 58 virtual void OnReplyReceived(int sequence, | 58 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
| 59 int32_t result, | |
| 60 const IPC::Message& msg) OVERRIDE; | 59 const IPC::Message& msg) OVERRIDE; |
| 61 | 60 |
| 62 void OnPluginMsgShowReply( | 61 void OnPluginMsgShowReply( |
| 63 const std::vector<ppapi::PPB_FileRef_CreateInfo>& chosen_files); | 62 const ResourceMessageReplyParams& params, |
| 63 const std::vector<PPB_FileRef_CreateInfo>& chosen_files); |
| 64 | 64 |
| 65 int32_t ShowInternal(PP_Bool save_as, | 65 int32_t ShowInternal(PP_Bool save_as, |
| 66 const PP_Var& suggested_file_name, | 66 const PP_Var& suggested_file_name, |
| 67 scoped_refptr<TrackedCallback> callback); | 67 scoped_refptr<TrackedCallback> callback); |
| 68 | 68 |
| 69 PP_FileChooserMode_Dev mode_; | 69 PP_FileChooserMode_Dev mode_; |
| 70 std::vector<std::string> accept_types_; | 70 std::vector<std::string> accept_types_; |
| 71 | 71 |
| 72 // When using v0.6 of the API, contains the array output info. | 72 // When using v0.6 of the API, contains the array output info. |
| 73 ArrayWriter output_; | 73 ArrayWriter output_; |
| 74 | 74 |
| 75 // When using v0.5 of the API, contains all files returned by the current | 75 // When using v0.5 of the API, contains all files returned by the current |
| 76 // show callback that haven't yet been given to the plugin. The plugin will | 76 // show callback that haven't yet been given to the plugin. The plugin will |
| 77 // repeatedly call us to get the next file, and we'll vend those out of this | 77 // repeatedly call us to get the next file, and we'll vend those out of this |
| 78 // queue, removing them when ownership has transferred to the plugin. | 78 // queue, removing them when ownership has transferred to the plugin. |
| 79 std::queue<PP_Resource> file_queue_; | 79 std::queue<PP_Resource> file_queue_; |
| 80 | 80 |
| 81 scoped_refptr<TrackedCallback> callback_; | 81 scoped_refptr<TrackedCallback> callback_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(FileChooserResource); | 83 DISALLOW_COPY_AND_ASSIGN(FileChooserResource); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } // namespace proxy | 86 } // namespace proxy |
| 87 } // namespace ppapi | 87 } // namespace ppapi |
| 88 | 88 |
| 89 #endif // PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_ | 89 #endif // PPAPI_PROXY_FILE_CHOOSER_RESOURCE_H_ |
| OLD | NEW |