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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 const PPP_Printing_Dev ppp_printing = { | 68 const PPP_Printing_Dev ppp_printing = { |
| 64 &QuerySupportedFormats, | 69 &QuerySupportedFormats, |
| 65 &Begin, | 70 &Begin, |
| 66 &PrintPages, | 71 &PrintPages, |
| 67 &End, | 72 &End, |
| 68 &IsScalingDisabled | 73 &IsScalingDisabled |
| 69 }; | 74 }; |
| 70 | 75 |
| 71 } // namespace | 76 } // namespace |
| 72 | 77 |
| 78 // static | |
| 79 bool Printing_Dev::GetDefaultPrintSettings( | |
|
yzshen1
2012/06/12 23:14:34
Please keep method definitions in the same order a
raymes
2012/06/13 18:23:46
Done.
| |
| 80 const InstanceHandle& instance_handle, | |
| 81 PP_PrintSettings_Dev* print_settings) { | |
| 82 if (!has_interface<PPB_Printing_Dev_0_6>()) | |
| 83 return PP_FALSE; | |
| 84 return PP_ToBool( | |
| 85 get_interface<PPB_Printing_Dev_0_6>()->GetDefaultPrintSettings( | |
| 86 instance_handle.pp_instance(), print_settings)); | |
| 87 } | |
| 88 | |
| 73 Printing_Dev::Printing_Dev(Instance* instance) | 89 Printing_Dev::Printing_Dev(Instance* instance) |
| 74 : associated_instance_(instance) { | 90 : associated_instance_(instance) { |
| 75 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); | 91 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); |
| 76 instance->AddPerInstanceObject(kPPPPrintingInterface, this); | 92 instance->AddPerInstanceObject(kPPPPrintingInterface, this); |
| 77 } | 93 } |
| 78 | 94 |
| 79 Printing_Dev::~Printing_Dev() { | 95 Printing_Dev::~Printing_Dev() { |
| 80 Instance::RemovePerInstanceObject(associated_instance_, | 96 Instance::RemovePerInstanceObject(associated_instance_, |
| 81 kPPPPrintingInterface, this); | 97 kPPPPrintingInterface, this); |
| 82 } | 98 } |
| 83 | 99 |
| 84 } // namespace pp | 100 } // namespace pp |
| OLD | NEW |