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" |
11 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
12 | 12 |
13 namespace pp { | 13 namespace pp { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; | 17 static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; |
18 | 18 |
19 template <> const char* interface_name<PPB_Printing_Dev_0_7>() { | 19 template <> const char* interface_name<PPB_Printing_Dev_0_8>() { |
20 return PPB_PRINTING_DEV_INTERFACE_0_7; | 20 return PPB_PRINTING_DEV_INTERFACE_0_8; |
21 } | 21 } |
22 | 22 |
23 uint32_t QuerySupportedFormats(PP_Instance instance) { | 23 uint32_t QuerySupportedFormats(PP_Instance instance) { |
24 void* object = | 24 void* object = |
25 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); | 25 Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); |
26 if (!object) | 26 if (!object) |
27 return 0; | 27 return 0; |
28 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(); | 28 return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(); |
29 } | 29 } |
30 | 30 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 &IsScalingDisabled | 73 &IsScalingDisabled |
74 }; | 74 }; |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 Printing_Dev::Printing_Dev(Instance* instance) | 78 Printing_Dev::Printing_Dev(Instance* instance) |
79 : associated_instance_(instance) { | 79 : associated_instance_(instance) { |
80 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); | 80 Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing); |
81 instance->AddPerInstanceObject( | 81 instance->AddPerInstanceObject( |
82 kPPPPrintingInterface, this); | 82 kPPPPrintingInterface, this); |
83 if (has_interface<PPB_Printing_Dev_0_7>()) { | 83 if (has_interface<PPB_Printing_Dev_0_8>()) { |
84 PassRefFromConstructor(get_interface<PPB_Printing_Dev_0_7>()->Create( | 84 PassRefFromConstructor(get_interface<PPB_Printing_Dev_0_8>()->Create( |
85 associated_instance_.pp_instance())); | 85 associated_instance_.pp_instance())); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 Printing_Dev::~Printing_Dev() { | 89 Printing_Dev::~Printing_Dev() { |
90 Instance::RemovePerInstanceObject(associated_instance_, | 90 Instance::RemovePerInstanceObject(associated_instance_, |
91 kPPPPrintingInterface, this); | 91 kPPPPrintingInterface, this); |
92 } | 92 } |
93 | 93 |
94 // static | 94 // static |
95 bool Printing_Dev::IsAvailable() { | 95 bool Printing_Dev::IsAvailable() { |
96 return has_interface<PPB_Printing_Dev_0_7>(); | 96 return has_interface<PPB_Printing_Dev_0_8>(); |
97 } | 97 } |
98 | 98 |
99 int32_t Printing_Dev::GetDefaultPrintSettings( | 99 int32_t Printing_Dev::GetDefaultPrintSettings( |
100 const CompletionCallbackWithOutput<PP_PrintSettings_Dev>& callback) const { | 100 const CompletionCallbackWithOutput<PP_PrintSettings_Dev>& callback) const { |
101 if (has_interface<PPB_Printing_Dev_0_7>()) { | 101 if (has_interface<PPB_Printing_Dev_0_8>()) { |
102 return get_interface<PPB_Printing_Dev_0_7>()->GetDefaultPrintSettings( | 102 return get_interface<PPB_Printing_Dev_0_8>()->GetDefaultPrintSettings( |
103 pp_resource(), callback.output(), callback.pp_completion_callback()); | 103 pp_resource(), callback.output(), callback.pp_completion_callback()); |
104 } | 104 } |
105 return callback.MayForce(PP_ERROR_NOINTERFACE); | 105 return callback.MayForce(PP_ERROR_NOINTERFACE); |
106 } | 106 } |
107 | 107 |
| 108 void Printing_Dev::SetPrintPresetOptionsFromDocument( |
| 109 PP_PrintPresetOptions_Dev& print_options) { |
| 110 if (has_interface<PPB_Printing_Dev_0_8>()) { |
| 111 return get_interface<PPB_Printing_Dev_0_8>() |
| 112 ->SetPrintPresetOptionsFromDocument(pp_resource(), &print_options); |
| 113 } |
| 114 } |
| 115 |
108 } // namespace pp | 116 } // namespace pp |
OLD | NEW |