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/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/c/dev/ppb_printing_dev.h" |
8 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
9 #include "ppapi/cpp/instance_handle.h" | 9 #include "ppapi/cpp/instance_handle.h" |
10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 PP_Bool IsScalingDisabled(PP_Instance instance) { | 58 PP_Bool IsScalingDisabled(PP_Instance instance) { |
59 void* object = | 59 void* object = |
60 pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); | 60 pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); |
61 if (!object) | 61 if (!object) |
62 return PP_FALSE; | 62 return PP_FALSE; |
63 bool return_value = | 63 bool return_value = |
64 static_cast<Printing_Dev*>(object)->IsPrintScalingDisabled(); | 64 static_cast<Printing_Dev*>(object)->IsPrintScalingDisabled(); |
65 return PP_FromBool(return_value); | 65 return PP_FromBool(return_value); |
66 } | 66 } |
67 | 67 |
| 68 int32_t GetCopiesToPrint(PP_Instance instance) { |
| 69 void* object = |
| 70 pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); |
| 71 if (!object) |
| 72 return 1; |
| 73 return static_cast<Printing_Dev*>(object)->GetCopiesToPrint(); |
| 74 } |
| 75 |
68 const PPP_Printing_Dev ppp_printing = { | 76 const PPP_Printing_Dev ppp_printing = { |
69 &QuerySupportedFormats, | 77 &QuerySupportedFormats, &Begin, &PrintPages, |
70 &Begin, | 78 &End, &IsScalingDisabled, &GetCopiesToPrint}; |
71 &PrintPages, | |
72 &End, | |
73 &IsScalingDisabled | |
74 }; | |
75 | 79 |
76 } // namespace | 80 } // namespace |
77 | 81 |
78 Printing_Dev::Printing_Dev(Instance* instance) | 82 Printing_Dev::Printing_Dev(Instance* instance) |
79 : associated_instance_(instance) { | 83 : associated_instance_(instance) { |
80 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); | 84 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); |
81 instance->AddPerInstanceObject( | 85 instance->AddPerInstanceObject( |
82 kPPPPrintingInterface, this); | 86 kPPPPrintingInterface, this); |
83 if (has_interface<PPB_Printing_Dev_0_7>()) { | 87 if (has_interface<PPB_Printing_Dev_0_7>()) { |
84 PassRefFromConstructor(get_interface<PPB_Printing_Dev_0_7>()->Create( | 88 PassRefFromConstructor(get_interface<PPB_Printing_Dev_0_7>()->Create( |
(...skipping 14 matching lines...) Expand all Loading... |
99 int32_t Printing_Dev::GetDefaultPrintSettings( | 103 int32_t Printing_Dev::GetDefaultPrintSettings( |
100 const CompletionCallbackWithOutput<PP_PrintSettings_Dev>& callback) const { | 104 const CompletionCallbackWithOutput<PP_PrintSettings_Dev>& callback) const { |
101 if (has_interface<PPB_Printing_Dev_0_7>()) { | 105 if (has_interface<PPB_Printing_Dev_0_7>()) { |
102 return get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings( | 106 return get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings( |
103 pp_resource(), callback.output(), callback.pp_completion_callback()); | 107 pp_resource(), callback.output(), callback.pp_completion_callback()); |
104 } | 108 } |
105 return callback.MayForce(PP_ERROR_NOINTERFACE); | 109 return callback.MayForce(PP_ERROR_NOINTERFACE); |
106 } | 110 } |
107 | 111 |
108 } // namespace pp | 112 } // namespace pp |
OLD | NEW |