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 3 // found in the LICENSE file. 4 5 // From dev/ppb_file_chooser_dev.idl modified Tue Aug 20 08:13:36 2013. 6 7 #include "ppapi/c/dev/ppb_file_chooser_dev.h" 8 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/shared_impl/tracked_callback.h" 11 #include "ppapi/thunk/enter.h" 12 #include "ppapi/thunk/ppapi_thunk_export.h" 13 #include "ppapi/thunk/ppb_file_chooser_api.h" 14 15 namespace ppapi { 16 namespace thunk { 17 18 namespace { 19 20 PP_Resource Create(PP_Instance instance, 21 PP_FileChooserMode_Dev mode, 22 struct PP_Var accept_types) { 23 VLOG(4) << "PPB_FileChooser_Dev::Create()"; 24 EnterResourceCreation enter(instance); 25 if (enter.failed()) 26 return 0; 27 return enter.functions()->CreateFileChooser(instance, mode, accept_types); 28 } 29 30 PP_Bool IsFileChooser(PP_Resource resource) { 31 VLOG(4) << "PPB_FileChooser_Dev::IsFileChooser()"; 32 EnterResource<PPB_FileChooser_API> enter(resource, false); 33 return PP_FromBool(enter.succeeded()); 34 } 35 36 int32_t Show_0_5(PP_Resource chooser, struct PP_CompletionCallback callback) { 37 VLOG(4) << "PPB_FileChooser_Dev::Show()"; 38 EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); 39 if (enter.failed()) 40 return enter.retval(); 41 return enter.SetResult(enter.object()->Show0_5(enter.callback())); 42 } 43 44 PP_Resource GetNextChosenFile(PP_Resource chooser) { 45 VLOG(4) << "PPB_FileChooser_Dev::GetNextChosenFile()"; 46 EnterResource<PPB_FileChooser_API> enter(chooser, true); 47 if (enter.failed()) 48 return 0; 49 return enter.object()->GetNextChosenFile(); 50 } 51 52 int32_t Show(PP_Resource chooser, 53 struct PP_ArrayOutput output, 54 struct PP_CompletionCallback callback) { 55 VLOG(4) << "PPB_FileChooser_Dev::Show()"; 56 EnterResource<PPB_FileChooser_API> enter(chooser, callback, true); 57 if (enter.failed()) 58 return enter.retval(); 59 return enter.SetResult(enter.object()->Show(output, enter.callback())); 60 } 61 62 const PPB_FileChooser_Dev_0_5 g_ppb_filechooser_dev_thunk_0_5 = { 63 &Create, 64 &IsFileChooser, 65 &Show_0_5, 66 &GetNextChosenFile 67 }; 68 69 const PPB_FileChooser_Dev_0_6 g_ppb_filechooser_dev_thunk_0_6 = { 70 &Create, 71 &IsFileChooser, 72 &Show 73 }; 74 75 } // namespace 76 77 PPAPI_THUNK_EXPORT const PPB_FileChooser_Dev_0_5* 78 GetPPB_FileChooser_Dev_0_5_Thunk() { 79 return &g_ppb_filechooser_dev_thunk_0_5; 80 } 81 82 PPAPI_THUNK_EXPORT const PPB_FileChooser_Dev_0_6* 83 GetPPB_FileChooser_Dev_0_6_Thunk() { 84 return &g_ppb_filechooser_dev_thunk_0_6; 85 } 86 87 } // namespace thunk 88 } // namespace ppapi 89