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..d3c6e7ebec445ebd26f870adca449b27cfb93260 100644 |
| --- a/ppapi/cpp/dev/printing_dev.cc |
| +++ b/ppapi/cpp/dev/printing_dev.cc |
| @@ -16,6 +16,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; |
| } |
| @@ -76,9 +80,14 @@ const PPP_Printing_Dev ppp_printing = { |
| } // namespace |
| Printing_Dev::Printing_Dev(Instance* instance) |
| - : associated_instance_(instance) { |
| + : associated_instance_(instance) { |
| Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); |
| - instance->AddPerInstanceObject(kPPPPrintingInterface, this); |
| + instance->AddPerInstanceObject( |
| + kPPPPrintingInterface, this); |
| + if (has_interface<PPB_Printing_Dev_0_7>()) { |
| + PassRefFromConstructor(get_interface<PPB_Printing_Dev_0_7>()->Create( |
| + associated_instance_.pp_instance())); |
| + } |
| } |
| Printing_Dev::~Printing_Dev() { |
| @@ -88,16 +97,28 @@ 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( |
| - PP_PrintSettings_Dev* print_settings) const { |
| - if (!has_interface<PPB_Printing_Dev_0_6>()) |
| - return false; |
| - return PP_ToBool( |
| - get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings( |
| - associated_instance_.pp_instance(), print_settings)); |
| +void Printing_Dev::GetDefaultPrintSettings( |
| + const CompletionCallbackWithOutput<PP_PrintSettings_Dev>& callback) const { |
| + if (has_interface<PPB_Printing_Dev_0_7>()) { |
| + int32_t result = |
| + get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings( |
| + pp_resource(), callback.output(), |
| + callback.pp_completion_callback()); |
| + if (result != PP_OK_COMPLETIONPENDING) |
|
brettw
2012/09/18 21:41:38
You shouldn't need to do this check in the C++ wra
raymes
2012/09/18 23:43:57
Done.
|
| + Module::Get()->core()->CallOnMainThread(0, callback, result); |
| + } |
| + else if (has_interface<PPB_Printing_Dev_0_6>()) { |
|
brettw
2012/09/18 21:41:38
Goes on previous line.
raymes
2012/09/18 23:43:57
Done.
|
| + bool success = PP_ToBool(get_interface<PPB_Printing_Dev_0_6>()-> |
| + GetDefaultPrintSettings(associated_instance_.pp_instance(), |
| + callback.output())); |
| + Module::Get()->core()->CallOnMainThread(0, callback, |
| + success ? PP_OK : PP_ERROR_FAILED); |
| + } |
| } |
| } // namespace pp |