Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / ppapi / thunk / ppb_file_chooser_dev_thunk.cc
blobfe1aa0dbf77e6b583fc4503e8b0709076d15300d
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 Apr 1 08:24:03 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/ppb_file_chooser_api.h"
13 #include "ppapi/thunk/ppb_instance_api.h"
14 #include "ppapi/thunk/resource_creation_api.h"
15 #include "ppapi/thunk/thunk.h"
17 namespace ppapi {
18 namespace thunk {
20 namespace {
22 PP_Resource Create(PP_Instance instance,
23 PP_FileChooserMode_Dev mode,
24 struct PP_Var accept_types) {
25 VLOG(4) << "PPB_FileChooser_Dev::Create()";
26 EnterResourceCreation enter(instance);
27 if (enter.failed())
28 return 0;
29 return enter.functions()->CreateFileChooser(instance, mode, accept_types);
32 PP_Bool IsFileChooser(PP_Resource resource) {
33 VLOG(4) << "PPB_FileChooser_Dev::IsFileChooser()";
34 EnterResource<PPB_FileChooser_API> enter(resource, false);
35 return PP_FromBool(enter.succeeded());
38 int32_t Show_0_5(PP_Resource chooser, struct PP_CompletionCallback callback) {
39 VLOG(4) << "PPB_FileChooser_Dev::Show()";
40 EnterResource<PPB_FileChooser_API> enter(chooser, callback, true);
41 if (enter.failed())
42 return enter.retval();
43 return enter.SetResult(enter.object()->Show0_5(enter.callback()));
46 PP_Resource GetNextChosenFile(PP_Resource chooser) {
47 VLOG(4) << "PPB_FileChooser_Dev::GetNextChosenFile()";
48 EnterResource<PPB_FileChooser_API> enter(chooser, true);
49 if (enter.failed())
50 return 0;
51 return enter.object()->GetNextChosenFile();
54 int32_t Show(PP_Resource chooser,
55 struct PP_ArrayOutput output,
56 struct PP_CompletionCallback callback) {
57 VLOG(4) << "PPB_FileChooser_Dev::Show()";
58 EnterResource<PPB_FileChooser_API> enter(chooser, callback, true);
59 if (enter.failed())
60 return enter.retval();
61 return enter.SetResult(enter.object()->Show(output, enter.callback()));
64 const PPB_FileChooser_Dev_0_5 g_ppb_filechooser_dev_thunk_0_5 = {
65 &Create,
66 &IsFileChooser,
67 &Show_0_5,
68 &GetNextChosenFile
71 const PPB_FileChooser_Dev_0_6 g_ppb_filechooser_dev_thunk_0_6 = {
72 &Create,
73 &IsFileChooser,
74 &Show
77 } // namespace
79 const PPB_FileChooser_Dev_0_5* GetPPB_FileChooser_Dev_0_5_Thunk() {
80 return &g_ppb_filechooser_dev_thunk_0_5;
83 const PPB_FileChooser_Dev_0_6* GetPPB_FileChooser_Dev_0_6_Thunk() {
84 return &g_ppb_filechooser_dev_thunk_0_6;
87 } // namespace thunk
88 } // namespace ppapi