Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/dev/printing_dev.h" | 5 #include "ppapi/cpp/dev/printing_dev.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_printing_dev.h" | |
| 7 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
| 8 #include "ppapi/cpp/instance_handle.h" | 9 #include "ppapi/cpp/instance_handle.h" |
| 9 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| 10 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
| 11 | 12 |
| 12 namespace pp { | 13 namespace pp { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; | 17 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; |
| 17 | 18 |
| 19 template <> const char* interface_name<PPB_Printing_Dev_0_6>() { | |
| 20 return PPB_PRINTING_DEV_INTERFACE_0_6; | |
| 21 } | |
| 22 | |
| 18 uint32_t QuerySupportedFormats(PP_Instance instance) { | 23 uint32_t QuerySupportedFormats(PP_Instance instance) { |
| 19 void* object = | 24 void* object = |
| 20 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); | 25 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); |
| 21 if (!object) | 26 if (!object) |
| 22 return 0; | 27 return 0; |
| 23 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(); | 28 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(); |
| 24 } | 29 } |
| 25 | 30 |
| 26 int32_t Begin(PP_Instance instance, | 31 int32_t Begin(PP_Instance instance, |
| 27 const struct PP_PrintSettings_Dev* print_settings) { | 32 const struct PP_PrintSettings_Dev* print_settings) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 : associated_instance_(instance) { | 79 : associated_instance_(instance) { |
| 75 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); | 80 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); |
| 76 instance->AddPerInstanceObject(kPPPPrintingInterface, this); | 81 instance->AddPerInstanceObject(kPPPPrintingInterface, this); |
| 77 } | 82 } |
| 78 | 83 |
| 79 Printing_Dev::~Printing_Dev() { | 84 Printing_Dev::~Printing_Dev() { |
| 80 Instance::RemovePerInstanceObject(associated_instance_, | 85 Instance::RemovePerInstanceObject(associated_instance_, |
| 81 kPPPPrintingInterface, this); | 86 kPPPPrintingInterface, this); |
| 82 } | 87 } |
| 83 | 88 |
| 89 bool Printing_Dev::GetDefaultPrintSettings( | |
| 90 const InstanceHandle& instance_handle, | |
|
yzshen1
2012/06/14 05:01:38
Can we use associated_instance_?
raymes
2012/06/14 17:30:49
Done.
| |
| 91 PP_PrintSettings_Dev* print_settings) { | |
| 92 if (!has_interface<PPB_Printing_Dev_0_6>()) | |
| 93 return PP_FALSE; | |
| 94 return PP_ToBool( | |
| 95 get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings( | |
| 96 instance_handle.pp_instance(), print_settings)); | |
| 97 } | |
| 98 | |
| 84 } // namespace pp | 99 } // namespace pp |
| OLD | NEW |