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 #include "ppapi/proxy/file_chooser_resource.h" | 5 #include "ppapi/proxy/file_chooser_resource.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
11 #include "ppapi/proxy/dispatch_reply_message.h" | 11 #include "ppapi/proxy/dispatch_reply_message.h" |
| 12 #include "ppapi/proxy/file_ref_resource.h" |
12 #include "ppapi/proxy/ppapi_messages.h" | 13 #include "ppapi/proxy/ppapi_messages.h" |
13 #include "ppapi/proxy/ppb_file_ref_proxy.h" | |
14 #include "ppapi/shared_impl/var.h" | 14 #include "ppapi/shared_impl/var.h" |
15 | 15 |
16 namespace ppapi { | 16 namespace ppapi { |
17 namespace proxy { | 17 namespace proxy { |
18 | 18 |
19 FileChooserResource::FileChooserResource(Connection connection, | 19 FileChooserResource::FileChooserResource(Connection connection, |
20 PP_Instance instance, | 20 PP_Instance instance, |
21 PP_FileChooserMode_Dev mode, | 21 PP_FileChooserMode_Dev mode, |
22 const std::string& accept_types) | 22 const std::string& accept_types) |
23 : PluginResource(connection, instance), | 23 : PluginResource(connection, instance), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 continue; | 93 continue; |
94 if (type.find_first_of('/') == std::string::npos && type[0] != '.') | 94 if (type.find_first_of('/') == std::string::npos && type[0] != '.') |
95 continue; | 95 continue; |
96 StringToLowerASCII(&type); | 96 StringToLowerASCII(&type); |
97 output->push_back(type); | 97 output->push_back(type); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 void FileChooserResource::OnPluginMsgShowReply( | 101 void FileChooserResource::OnPluginMsgShowReply( |
102 const ResourceMessageReplyParams& params, | 102 const ResourceMessageReplyParams& params, |
103 const std::vector<PPB_FileRef_CreateInfo>& chosen_files) { | 103 const std::vector<FileRefCreateInfo>& chosen_files) { |
104 if (output_.is_valid()) { | 104 if (output_.is_valid()) { |
105 // Using v0.6 of the API with the output array. | 105 // Using v0.6 of the API with the output array. |
106 std::vector<PP_Resource> files; | 106 std::vector<PP_Resource> files; |
107 for (size_t i = 0; i < chosen_files.size(); i++) | 107 for (size_t i = 0; i < chosen_files.size(); i++) { |
108 files.push_back(PPB_FileRef_Proxy::DeserializeFileRef(chosen_files[i])); | 108 files.push_back(FileRefResource::CreateFileRef( |
| 109 connection(), |
| 110 pp_instance(), |
| 111 chosen_files[i])); |
| 112 } |
109 output_.StoreResourceVector(files); | 113 output_.StoreResourceVector(files); |
110 } else { | 114 } else { |
111 // Convert each of the passed in file infos to resources. These will be | 115 // Convert each of the passed in file infos to resources. These will be |
112 // owned by the FileChooser object until they're passed to the plugin. | 116 // owned by the FileChooser object until they're passed to the plugin. |
113 DCHECK(file_queue_.empty()); | 117 DCHECK(file_queue_.empty()); |
114 for (size_t i = 0; i < chosen_files.size(); i++) { | 118 for (size_t i = 0; i < chosen_files.size(); i++) { |
115 file_queue_.push(PPB_FileRef_Proxy::DeserializeFileRef( | 119 file_queue_.push(FileRefResource::CreateFileRef( |
| 120 connection(), |
| 121 pp_instance(), |
116 chosen_files[i])); | 122 chosen_files[i])); |
117 } | 123 } |
118 } | 124 } |
119 | 125 |
120 // Notify the plugin of the new data. | 126 // Notify the plugin of the new data. |
121 callback_->Run(params.result()); | 127 callback_->Run(params.result()); |
122 // DANGER: May delete |this|! | 128 // DANGER: May delete |this|! |
123 } | 129 } |
124 | 130 |
125 int32_t FileChooserResource::ShowInternal( | 131 int32_t FileChooserResource::ShowInternal( |
(...skipping 14 matching lines...) Expand all Loading... |
140 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE, | 146 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE, |
141 sugg_str ? sugg_str->value() : std::string(), | 147 sugg_str ? sugg_str->value() : std::string(), |
142 accept_types_); | 148 accept_types_); |
143 Call<PpapiPluginMsg_FileChooser_ShowReply>(RENDERER, msg, | 149 Call<PpapiPluginMsg_FileChooser_ShowReply>(RENDERER, msg, |
144 base::Bind(&FileChooserResource::OnPluginMsgShowReply, this)); | 150 base::Bind(&FileChooserResource::OnPluginMsgShowReply, this)); |
145 return PP_OK_COMPLETIONPENDING; | 151 return PP_OK_COMPLETIONPENDING; |
146 } | 152 } |
147 | 153 |
148 } // namespace proxy | 154 } // namespace proxy |
149 } // namespace ppapi | 155 } // namespace ppapi |
OLD | NEW |