Chromium Code Reviews| Index: ppapi/cpp/dev/printing_dev.cc |
| diff --git a/ppapi/cpp/dev/printing_dev.cc b/ppapi/cpp/dev/printing_dev.cc |
| index 8c307251fbac70261bd2fa8089976449852f8966..05477e83fa85490ee24c9df1108235dc69fa0059 100644 |
| --- a/ppapi/cpp/dev/printing_dev.cc |
| +++ b/ppapi/cpp/dev/printing_dev.cc |
| @@ -5,6 +5,7 @@ |
| #include "ppapi/cpp/dev/printing_dev.h" |
| #include "ppapi/c/dev/ppb_printing_dev.h" |
| +#include "ppapi/cpp/completion_callback.h" |
| #include "ppapi/cpp/instance.h" |
| #include "ppapi/cpp/instance_handle.h" |
| #include "ppapi/cpp/module.h" |
| @@ -16,6 +17,10 @@ namespace { |
| static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; |
| +template <> const char* interface_name<PPB_Printing_Dev_0_7>() { |
| + return PPB_PRINTING_DEV_INTERFACE_0_7; |
| +} |
| + |
| template <> const char* interface_name<PPB_Printing_Dev_0_6>() { |
| return PPB_PRINTING_DEV_INTERFACE_0_6; |
| } |
| @@ -88,7 +93,8 @@ Printing_Dev::~Printing_Dev() { |
| // static |
| bool Printing_Dev::IsAvailable() { |
| - return has_interface<PPB_Printing_Dev_0_6>(); |
| + return has_interface<PPB_Printing_Dev_0_7>() || |
| + has_interface<PPB_Printing_Dev_0_6>(); |
| } |
| bool Printing_Dev::GetDefaultPrintSettings( |
| @@ -100,4 +106,23 @@ bool Printing_Dev::GetDefaultPrintSettings( |
| associated_instance_.pp_instance(), print_settings)); |
| } |
| +int32_t Printing_Dev::GetDefaultPrintSettings( |
|
viettrungluu
2012/07/24 00:44:35
This isn't a very good design, since Printing_Dev
viettrungluu
2012/07/24 01:08:37
(Probably using the callback-with-output solves th
|
| + PP_PrintSettings_Dev* print_settings, |
| + const CompletionCallback& callback) const { |
| + if (has_interface<PPB_Printing_Dev_0_6>()) { |
|
viettrungluu
2012/07/24 00:44:35
These interface checks are in the wrong order.
|
| + bool success = |
| + get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings( |
|
viettrungluu
2012/07/24 00:44:35
You should convert from a PP_Bool to a bool proper
|
| + associated_instance_.pp_instance(), print_settings); |
| + Module::Get()->core()->CallOnMainThread(0, callback, |
| + success ? PP_OK : PP_ERROR); |
|
viettrungluu
2012/07/24 00:44:35
PP_ERROR_FAILED
|
| + return PP_OK_COMPLETIONPENDING; |
| + } |
| + if (has_interface<PPB_Printing_Dev_0_7>()) { |
| + return get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings( |
| + associated_instance_.pp_instance(), print_settings, |
| + callback.pp_completion_callback()); |
| + } |
| + return PP_ERROR_FAILED; |
| +} |
| + |
| } // namespace pp |