Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/cpp/trusted/file_chooser_trusted.h" | 5 #include "ppapi/cpp/trusted/file_chooser_trusted.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/cpp/completion_callback.h" | 8 #include "ppapi/cpp/completion_callback.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/cpp/module_impl.h" | 10 #include "ppapi/cpp/module_impl.h" |
| 11 #include "ppapi/cpp/var.h" | 11 #include "ppapi/cpp/var.h" |
| 12 #include "ppapi/c/trusted/ppb_file_chooser_trusted.h" | 12 #include "ppapi/c/trusted/ppb_file_chooser_trusted.h" |
| 13 | 13 |
| 14 namespace pp { | 14 namespace pp { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 template <> const char* interface_name<PPB_FileChooserTrusted>() { | 18 template <> const char* interface_name<PPB_FileChooserTrusted_0_5>() { |
| 19 return PPB_FILECHOOSER_TRUSTED_INTERFACE; | 19 return PPB_FILECHOOSER_TRUSTED_INTERFACE_0_5; |
| 20 } | |
| 21 | |
| 22 template <> const char* interface_name<PPB_FileChooserTrusted_0_6>() { | |
| 23 return PPB_FILECHOOSER_TRUSTED_INTERFACE_0_6; | |
| 20 } | 24 } |
| 21 | 25 |
| 22 } // namespace | 26 } // namespace |
| 23 | 27 |
| 24 FileChooser_Trusted::FileChooser_Trusted() : save_as_(false) { | 28 FileChooser_Trusted::FileChooser_Trusted() : save_as_(false) { |
| 25 } | 29 } |
| 26 | 30 |
| 27 FileChooser_Trusted::FileChooser_Trusted(const InstanceHandle& instance, | 31 FileChooser_Trusted::FileChooser_Trusted(const InstanceHandle& instance, |
| 28 PP_FileChooserMode_Dev mode, | 32 PP_FileChooserMode_Dev mode, |
| 29 const Var& accept_mime_types, | 33 const Var& accept_mime_types, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 41 } | 45 } |
| 42 | 46 |
| 43 FileChooser_Trusted& FileChooser_Trusted::operator=( | 47 FileChooser_Trusted& FileChooser_Trusted::operator=( |
| 44 const FileChooser_Trusted& other) { | 48 const FileChooser_Trusted& other) { |
| 45 FileChooser_Dev::operator=(other); | 49 FileChooser_Dev::operator=(other); |
| 46 save_as_ = other.save_as_; | 50 save_as_ = other.save_as_; |
| 47 suggested_file_name_ = other.suggested_file_name_; | 51 suggested_file_name_ = other.suggested_file_name_; |
| 48 return *this; | 52 return *this; |
| 49 } | 53 } |
| 50 | 54 |
| 51 int32_t FileChooser_Trusted::Show(const CompletionCallback& cc) { | 55 int32_t FileChooser_Trusted::Show( |
| 52 if (!has_interface<PPB_FileChooserTrusted>()) | 56 const CompletionCallbackWithOutput< std::vector<FileRef> >& callback) { |
| 53 return cc.MayForce(PP_ERROR_NOINTERFACE); | 57 if (has_interface<PPB_FileChooserTrusted_0_6>()) { |
| 54 return get_interface<PPB_FileChooserTrusted>()->ShowWithoutUserGesture( | 58 return get_interface<PPB_FileChooserTrusted_0_6>()->ShowWithoutUserGesture( |
| 55 pp_resource(), | 59 pp_resource(), |
| 56 PP_FromBool(save_as_), | 60 PP_FromBool(save_as_), |
| 57 Var(suggested_file_name_).pp_var(), | 61 Var(suggested_file_name_).pp_var(), |
| 58 cc.pp_completion_callback()); | 62 callback.output(), |
| 63 callback.pp_completion_callback()); | |
| 64 } else if (has_interface<PPB_FileChooserTrusted_0_5>()) { | |
|
viettrungluu
2012/03/26 16:55:19
No |else|, apparently.
| |
| 65 // Data for out callback. The callback handler will delete it. | |
|
viettrungluu
2012/03/26 16:55:19
"out"?
| |
| 66 ChooseCallbackData0_5* data = new ChooseCallbackData0_5; | |
| 67 data->file_chooser = pp_resource(); | |
| 68 data->output = callback.output(); | |
| 69 | |
| 70 return get_interface<PPB_FileChooserTrusted_0_5>()->ShowWithoutUserGesture( | |
| 71 pp_resource(), | |
| 72 PP_FromBool(save_as_), | |
| 73 Var(suggested_file_name_).pp_var(), | |
| 74 PP_MakeCompletionCallback(&CallbackConverter, data)); | |
| 75 } | |
| 76 return callback.MayForce(PP_ERROR_NOINTERFACE); | |
| 59 } | 77 } |
| 60 | 78 |
| 61 } // namespace pp | 79 } // namespace pp |
| OLD | NEW |