| OLD | NEW |
| 1 // Copyright (c) 2011 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 "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h" | 5 #include "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h" |
| 6 | 6 |
| 7 #include "native_client/src/include/portability.h" | 7 #include "native_client/src/include/portability.h" |
| 8 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 8 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 9 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" | 9 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
| 10 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h" | 10 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h" |
| 11 #include "native_client/src/shared/ppapi_proxy/utility.h" | 11 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 12 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
| 13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
| 14 | 14 |
| 15 namespace ppapi_proxy { | 15 namespace ppapi_proxy { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const nacl_abi_size_t kPPPrintSettingsBytes = | 19 const nacl_abi_size_t kPPPrintSettingsBytes = |
| 20 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); | 20 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); |
| 21 const nacl_abi_size_t kPPPrintPageNumberRangeBytes = | 21 const nacl_abi_size_t kPPPrintPageNumberRangeBytes = |
| 22 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev)); | 22 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev)); |
| 23 | 23 |
| 24 uint32_t QuerySupportedFormats(PP_Instance instance) { | 24 uint32_t QuerySupportedFormats(PP_Instance instance) { |
| 25 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: " | 25 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: " |
| 26 "instance=%"NACL_PRIu32"\n", instance); | 26 "instance=%"NACL_PRId32"\n", instance); |
| 27 | 27 |
| 28 int32_t formats = 0; | 28 int32_t formats = 0; |
| 29 NaClSrpcError srpc_result = | 29 NaClSrpcError srpc_result = |
| 30 PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats( | 30 PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats( |
| 31 GetMainSrpcChannel(instance), | 31 GetMainSrpcChannel(instance), |
| 32 instance, | 32 instance, |
| 33 &formats); | 33 &formats); |
| 34 | 34 |
| 35 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n", | 35 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n", |
| 36 NaClSrpcErrorString(srpc_result)); | 36 NaClSrpcErrorString(srpc_result)); |
| 37 | 37 |
| 38 return static_cast<uint32_t>(formats); | 38 return static_cast<uint32_t>(formats); |
| 39 } | 39 } |
| 40 | 40 |
| 41 int32_t Begin(PP_Instance instance, | 41 int32_t Begin(PP_Instance instance, |
| 42 const struct PP_PrintSettings_Dev* print_settings) { | 42 const struct PP_PrintSettings_Dev* print_settings) { |
| 43 DebugPrintf("PPP_Printing_Dev::Begin: instance=%"NACL_PRIu32"\n", instance); | 43 DebugPrintf("PPP_Printing_Dev::Begin: instance=%"NACL_PRId32"\n", instance); |
| 44 | 44 |
| 45 int32_t pages_required = 0; | 45 int32_t pages_required = 0; |
| 46 NaClSrpcError srpc_result = | 46 NaClSrpcError srpc_result = |
| 47 PppPrintingRpcClient::PPP_Printing_Begin( | 47 PppPrintingRpcClient::PPP_Printing_Begin( |
| 48 GetMainSrpcChannel(instance), | 48 GetMainSrpcChannel(instance), |
| 49 instance, | 49 instance, |
| 50 kPPPrintSettingsBytes, | 50 kPPPrintSettingsBytes, |
| 51 reinterpret_cast<char*>( | 51 reinterpret_cast<char*>( |
| 52 const_cast<PP_PrintSettings_Dev*>(print_settings)), | 52 const_cast<PP_PrintSettings_Dev*>(print_settings)), |
| 53 &pages_required); | 53 &pages_required); |
| 54 | 54 |
| 55 DebugPrintf("PPP_Printing_Dev::Begin: %s\n", | 55 DebugPrintf("PPP_Printing_Dev::Begin: %s\n", |
| 56 NaClSrpcErrorString(srpc_result)); | 56 NaClSrpcErrorString(srpc_result)); |
| 57 return pages_required; | 57 return pages_required; |
| 58 } | 58 } |
| 59 | 59 |
| 60 PP_Resource PrintPages(PP_Instance instance, | 60 PP_Resource PrintPages(PP_Instance instance, |
| 61 const struct PP_PrintPageNumberRange_Dev* page_ranges, | 61 const struct PP_PrintPageNumberRange_Dev* page_ranges, |
| 62 uint32_t page_range_count) { | 62 uint32_t page_range_count) { |
| 63 DebugPrintf("PPP_Printing_Dev::PrintPages: " | 63 DebugPrintf("PPP_Printing_Dev::PrintPages: " |
| 64 "instance=%"NACL_PRIu32"\n", instance); | 64 "instance=%"NACL_PRId32"\n", instance); |
| 65 | 65 |
| 66 PP_Resource image_data = kInvalidResourceId; | 66 PP_Resource image_data = kInvalidResourceId; |
| 67 NaClSrpcError srpc_result = | 67 NaClSrpcError srpc_result = |
| 68 PppPrintingRpcClient::PPP_Printing_PrintPages( | 68 PppPrintingRpcClient::PPP_Printing_PrintPages( |
| 69 GetMainSrpcChannel(instance), | 69 GetMainSrpcChannel(instance), |
| 70 instance, | 70 instance, |
| 71 page_range_count * kPPPrintPageNumberRangeBytes, | 71 page_range_count * kPPPrintPageNumberRangeBytes, |
| 72 reinterpret_cast<char*>( | 72 reinterpret_cast<char*>( |
| 73 const_cast<PP_PrintPageNumberRange_Dev*>(page_ranges)), | 73 const_cast<PP_PrintPageNumberRange_Dev*>(page_ranges)), |
| 74 page_range_count, | 74 page_range_count, |
| 75 &image_data); | 75 &image_data); |
| 76 | 76 |
| 77 DebugPrintf("PPP_Printing_Dev::PrintPages: %s\n", | 77 DebugPrintf("PPP_Printing_Dev::PrintPages: %s\n", |
| 78 NaClSrpcErrorString(srpc_result)); | 78 NaClSrpcErrorString(srpc_result)); |
| 79 return image_data; | 79 return image_data; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void End(PP_Instance instance) { | 82 void End(PP_Instance instance) { |
| 83 DebugPrintf("PPP_Printing_Dev::End: instance=%"NACL_PRIu32"\n", instance); | 83 DebugPrintf("PPP_Printing_Dev::End: instance=%"NACL_PRId32"\n", instance); |
| 84 | 84 |
| 85 NaClSrpcError srpc_result = | 85 NaClSrpcError srpc_result = |
| 86 PppPrintingRpcClient::PPP_Printing_End(GetMainSrpcChannel(instance), | 86 PppPrintingRpcClient::PPP_Printing_End(GetMainSrpcChannel(instance), |
| 87 instance); | 87 instance); |
| 88 | 88 |
| 89 DebugPrintf("PPP_Printing_Dev::End: %s\n", NaClSrpcErrorString(srpc_result)); | 89 DebugPrintf("PPP_Printing_Dev::End: %s\n", NaClSrpcErrorString(srpc_result)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 PP_Bool IsScalingDisabled(PP_Instance instance) { | 92 PP_Bool IsScalingDisabled(PP_Instance instance) { |
| 93 DebugPrintf("PPP_Printing_Dev::IsScalingDisabled: " | 93 DebugPrintf("PPP_Printing_Dev::IsScalingDisabled: " |
| 94 "instance=%"NACL_PRIu32"\n", instance); | 94 "instance=%"NACL_PRId32"\n", instance); |
| 95 | 95 |
| 96 int32_t scaling_disabled = 0; | 96 int32_t scaling_disabled = 0; |
| 97 NaClSrpcError srpc_result = | 97 NaClSrpcError srpc_result = |
| 98 PppPrintingRpcClient::PPP_Printing_IsScalingDisabled( | 98 PppPrintingRpcClient::PPP_Printing_IsScalingDisabled( |
| 99 GetMainSrpcChannel(instance), | 99 GetMainSrpcChannel(instance), |
| 100 instance, | 100 instance, |
| 101 &scaling_disabled); | 101 &scaling_disabled); |
| 102 | 102 |
| 103 DebugPrintf("PPP_Printing_Dev::IsScalingDisabled: %s\n", | 103 DebugPrintf("PPP_Printing_Dev::IsScalingDisabled: %s\n", |
| 104 NaClSrpcErrorString(srpc_result)); | 104 NaClSrpcErrorString(srpc_result)); |
| 105 return scaling_disabled ? PP_TRUE : PP_FALSE; | 105 return PP_FromBool(scaling_disabled); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace | 108 } // namespace |
| 109 | 109 |
| 110 const PPP_Printing_Dev* BrowserPrinting::GetInterface() { | 110 const PPP_Printing_Dev* BrowserPrinting::GetInterface() { |
| 111 static const PPP_Printing_Dev printing_interface = { | 111 static const PPP_Printing_Dev printing_interface = { |
| 112 QuerySupportedFormats, | 112 QuerySupportedFormats, |
| 113 Begin, | 113 Begin, |
| 114 PrintPages, | 114 PrintPages, |
| 115 End, | 115 End, |
| 116 IsScalingDisabled | 116 IsScalingDisabled |
| 117 }; | 117 }; |
| 118 return &printing_interface; | 118 return &printing_interface; |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace ppapi_proxy | 121 } // namespace ppapi_proxy |
| 122 | |
| OLD | NEW |