| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/c/dev/ppb_file_chooser_dev.h" | 9 #include "ppapi/c/dev/ppb_file_chooser_dev.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 const std::string& accept_mime_types, | 187 const std::string& accept_mime_types, |
| 188 HostResource* result) { | 188 HostResource* result) { |
| 189 PP_FileChooserOptions_Dev options; | 189 PP_FileChooserOptions_Dev options; |
| 190 options.mode = static_cast<PP_FileChooserMode_Dev>(mode); | 190 options.mode = static_cast<PP_FileChooserMode_Dev>(mode); |
| 191 options.accept_mime_types = accept_mime_types.c_str(); | 191 options.accept_mime_types = accept_mime_types.c_str(); |
| 192 result->SetHostResource( | 192 result->SetHostResource( |
| 193 instance, ppb_file_chooser_target()->Create(instance, &options)); | 193 instance, ppb_file_chooser_target()->Create(instance, &options)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void PPB_FileChooser_Proxy::OnMsgShow(const HostResource& chooser) { | 196 void PPB_FileChooser_Proxy::OnMsgShow(const HostResource& chooser) { |
| 197 CompletionCallback callback = callback_factory_.NewOptionalCallback( | 197 EnterHostFromHostResourceForceCallback<PPB_FileChooser_API> enter( |
| 198 &PPB_FileChooser_Proxy::OnShowCallback, chooser); | 198 chooser, callback_factory_, &PPB_FileChooser_Proxy::OnShowCallback, |
| 199 | 199 chooser); |
| 200 int32_t result = ppb_file_chooser_target()->Show( | 200 if (enter.succeeded()) |
| 201 chooser.host_resource(), callback.pp_completion_callback()); | 201 enter.SetResult(enter.object()->Show(enter.callback())); |
| 202 if (result != PP_OK_COMPLETIONPENDING) | |
| 203 callback.Run(result); | |
| 204 } | 202 } |
| 205 | 203 |
| 206 void PPB_FileChooser_Proxy::OnMsgChooseComplete( | 204 void PPB_FileChooser_Proxy::OnMsgChooseComplete( |
| 207 const HostResource& chooser, | 205 const HostResource& chooser, |
| 208 int32_t result_code, | 206 int32_t result_code, |
| 209 const std::vector<PPBFileRef_CreateInfo>& chosen_files) { | 207 const std::vector<PPBFileRef_CreateInfo>& chosen_files) { |
| 210 EnterPluginFromHostResource<PPB_FileChooser_API> enter(chooser); | 208 EnterPluginFromHostResource<PPB_FileChooser_API> enter(chooser); |
| 211 if (enter.succeeded()) { | 209 if (enter.succeeded()) { |
| 212 static_cast<FileChooser*>(enter.object())->ChooseComplete( | 210 static_cast<FileChooser*>(enter.object())->ChooseComplete( |
| 213 result_code, chosen_files); | 211 result_code, chosen_files); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 234 files.push_back(cur_create_info); | 232 files.push_back(cur_create_info); |
| 235 } | 233 } |
| 236 } | 234 } |
| 237 | 235 |
| 238 dispatcher()->Send(new PpapiMsg_PPBFileChooser_ChooseComplete( | 236 dispatcher()->Send(new PpapiMsg_PPBFileChooser_ChooseComplete( |
| 239 INTERFACE_ID_PPB_FILE_CHOOSER, chooser, result, files)); | 237 INTERFACE_ID_PPB_FILE_CHOOSER, chooser, result, files)); |
| 240 } | 238 } |
| 241 | 239 |
| 242 } // namespace proxy | 240 } // namespace proxy |
| 243 } // namespace pp | 241 } // namespace pp |
| OLD | NEW |