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/ppb_file_chooser_proxy.h" | 5 #include "ppapi/proxy/ppb_file_chooser_proxy.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "ppapi/c/dev/ppb_file_chooser_dev.h" | 10 #include "ppapi/c/dev/ppb_file_chooser_dev.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 197 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
198 } | 198 } |
199 | 199 |
200 PPB_FileChooser_Proxy::~PPB_FileChooser_Proxy() { | 200 PPB_FileChooser_Proxy::~PPB_FileChooser_Proxy() { |
201 } | 201 } |
202 | 202 |
203 // static | 203 // static |
204 PP_Resource PPB_FileChooser_Proxy::CreateProxyResource( | 204 PP_Resource PPB_FileChooser_Proxy::CreateProxyResource( |
205 PP_Instance instance, | 205 PP_Instance instance, |
206 PP_FileChooserMode_Dev mode, | 206 PP_FileChooserMode_Dev mode, |
207 const char* accept_mime_types) { | 207 const char* accept_types) { |
208 Dispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 208 Dispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
209 if (!dispatcher) | 209 if (!dispatcher) |
210 return 0; | 210 return 0; |
211 | 211 |
212 HostResource result; | 212 HostResource result; |
213 dispatcher->Send(new PpapiHostMsg_PPBFileChooser_Create( | 213 dispatcher->Send(new PpapiHostMsg_PPBFileChooser_Create( |
214 API_ID_PPB_FILE_CHOOSER, instance, | 214 API_ID_PPB_FILE_CHOOSER, instance, |
215 mode, | 215 mode, |
216 accept_mime_types ? accept_mime_types : "", | 216 accept_types ? accept_types : "", |
217 &result)); | 217 &result)); |
218 | 218 |
219 if (result.is_null()) | 219 if (result.is_null()) |
220 return 0; | 220 return 0; |
221 return (new FileChooser(result))->GetReference(); | 221 return (new FileChooser(result))->GetReference(); |
222 } | 222 } |
223 | 223 |
224 bool PPB_FileChooser_Proxy::OnMessageReceived(const IPC::Message& msg) { | 224 bool PPB_FileChooser_Proxy::OnMessageReceived(const IPC::Message& msg) { |
225 bool handled = true; | 225 bool handled = true; |
226 IPC_BEGIN_MESSAGE_MAP(PPB_FileChooser_Proxy, msg) | 226 IPC_BEGIN_MESSAGE_MAP(PPB_FileChooser_Proxy, msg) |
227 // Plugin -> host messages. | 227 // Plugin -> host messages. |
228 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileChooser_Create, OnMsgCreate) | 228 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileChooser_Create, OnMsgCreate) |
229 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileChooser_Show, OnMsgShow) | 229 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileChooser_Show, OnMsgShow) |
230 | 230 |
231 // Host -> plugin messages. | 231 // Host -> plugin messages. |
232 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileChooser_ChooseComplete, | 232 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileChooser_ChooseComplete, |
233 OnMsgChooseComplete) | 233 OnMsgChooseComplete) |
234 IPC_MESSAGE_UNHANDLED(handled = false) | 234 IPC_MESSAGE_UNHANDLED(handled = false) |
235 IPC_END_MESSAGE_MAP() | 235 IPC_END_MESSAGE_MAP() |
236 return handled; | 236 return handled; |
237 } | 237 } |
238 | 238 |
239 void PPB_FileChooser_Proxy::OnMsgCreate( | 239 void PPB_FileChooser_Proxy::OnMsgCreate( |
240 PP_Instance instance, | 240 PP_Instance instance, |
241 int mode, | 241 int mode, |
242 std::string accept_mime_types, | 242 std::string accept_types, |
243 HostResource* result) { | 243 HostResource* result) { |
244 thunk::EnterResourceCreation enter(instance); | 244 thunk::EnterResourceCreation enter(instance); |
245 if (enter.succeeded()) { | 245 if (enter.succeeded()) { |
246 result->SetHostResource(instance, enter.functions()->CreateFileChooser( | 246 result->SetHostResource(instance, enter.functions()->CreateFileChooser( |
247 instance, | 247 instance, |
248 static_cast<PP_FileChooserMode_Dev>(mode), | 248 static_cast<PP_FileChooserMode_Dev>(mode), |
249 accept_mime_types.c_str())); | 249 accept_types.c_str())); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 void PPB_FileChooser_Proxy::OnMsgShow( | 253 void PPB_FileChooser_Proxy::OnMsgShow( |
254 const HostResource& chooser, | 254 const HostResource& chooser, |
255 PP_Bool save_as, | 255 PP_Bool save_as, |
256 SerializedVarReceiveInput suggested_file_name, | 256 SerializedVarReceiveInput suggested_file_name, |
257 bool require_user_gesture) { | 257 bool require_user_gesture) { |
258 scoped_refptr<RefCountedArrayOutputAdapter<PP_Resource> > output( | 258 scoped_refptr<RefCountedArrayOutputAdapter<PP_Resource> > output( |
259 new RefCountedArrayOutputAdapter<PP_Resource>); | 259 new RefCountedArrayOutputAdapter<PP_Resource>); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 files.push_back(cur_create_info); | 305 files.push_back(cur_create_info); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 dispatcher()->Send(new PpapiMsg_PPBFileChooser_ChooseComplete( | 309 dispatcher()->Send(new PpapiMsg_PPBFileChooser_ChooseComplete( |
310 API_ID_PPB_FILE_CHOOSER, chooser, result, files)); | 310 API_ID_PPB_FILE_CHOOSER, chooser, result, files)); |
311 } | 311 } |
312 | 312 |
313 } // namespace proxy | 313 } // namespace proxy |
314 } // namespace ppapi | 314 } // namespace ppapi |
OLD | NEW |