OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/cpp/trusted/file_chooser_trusted.h" |
| 6 |
| 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/cpp/completion_callback.h" |
| 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/cpp/module_impl.h" |
| 11 #include "ppapi/cpp/var.h" |
| 12 #include "ppapi/c/trusted/ppb_file_chooser_trusted.h" |
| 13 |
| 14 namespace pp { |
| 15 |
| 16 namespace { |
| 17 |
| 18 template <> const char* interface_name<PPB_FileChooserTrusted>() { |
| 19 return PPB_FILECHOOSER_TRUSTED_INTERFACE; |
| 20 } |
| 21 |
| 22 } // namespace |
| 23 |
| 24 FileChooser_Trusted::FileChooser_Trusted() : save_as_(false) { |
| 25 } |
| 26 |
| 27 FileChooser_Trusted::FileChooser_Trusted(const Instance* instance, |
| 28 PP_FileChooserMode_Dev mode, |
| 29 const Var& accept_mime_types, |
| 30 bool save_as, |
| 31 const std::string& suggested_file_name) |
| 32 : FileChooser_Dev(instance, mode, accept_mime_types), |
| 33 save_as_(save_as), |
| 34 suggested_file_name_(suggested_file_name) { |
| 35 } |
| 36 |
| 37 FileChooser_Trusted::FileChooser_Trusted(const FileChooser_Trusted& other) |
| 38 : FileChooser_Dev(other), |
| 39 save_as_(other.save_as_), |
| 40 suggested_file_name_(other.suggested_file_name_) { |
| 41 } |
| 42 |
| 43 int32_t FileChooser_Trusted::Show(const CompletionCallback& cc) { |
| 44 if (!has_interface<PPB_FileChooserTrusted>()) |
| 45 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 46 return get_interface<PPB_FileChooserTrusted>()->ShowWithoutUserGesture( |
| 47 pp_resource(), |
| 48 PP_FromBool(save_as_), |
| 49 Var(suggested_file_name_).pp_var(), |
| 50 cc.pp_completion_callback()); |
| 51 } |
| 52 |
| 53 } // namespace pp |
OLD | NEW |