Update user pod message to use Smart Lock.
[chromium-blink-merge.git] / ppapi / thunk / ppb_file_chooser_dev_thunk.cc
blobe0d824b7709df8bdb815a3a561bab1fc0b1c2761
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.
5 // From dev/ppb_file_chooser_dev.idl modified Mon May 6 10:11:29 2013.
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"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
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);
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());
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()));
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();
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()));
62 const PPB_FileChooser_Dev_0_5 g_ppb_filechooser_dev_thunk_0_5 =
63 {&Create, &IsFileChooser, &Show_0_5, &GetNextChosenFile};
65 const PPB_FileChooser_Dev_0_6 g_ppb_filechooser_dev_thunk_0_6 = {&Create,
66 &IsFileChooser,
67 &Show};
69 } // namespace
71 PPAPI_THUNK_EXPORT const PPB_FileChooser_Dev_0_5*
72 GetPPB_FileChooser_Dev_0_5_Thunk() {
73 return &g_ppb_filechooser_dev_thunk_0_5;
76 PPAPI_THUNK_EXPORT const PPB_FileChooser_Dev_0_6*
77 GetPPB_FileChooser_Dev_0_6_Thunk() {
78 return &g_ppb_filechooser_dev_thunk_0_6;
81 } // namespace thunk
82 } // namespace ppapi