summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 20:58:01 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 20:58:01 +0000
commit8815b11a9262edd6a6d2c47504b043780d401a49 (patch)
treeaa76183d5bb7e928072268f94ea860b9990d29ea
parent085457cb23274fffc63f51882e6ada795ae70412 (diff)
downloadchromium_src-8815b11a9262edd6a6d2c47504b043780d401a49.zip
chromium_src-8815b11a9262edd6a6d2c47504b043780d401a49.tar.gz
chromium_src-8815b11a9262edd6a6d2c47504b043780d401a49.tar.bz2
Add IsScalingDisabled and PP_PRINTOUTPUTFORMAT_EMF to pepper printing interface.
IsScalingDisabled will let us handle PDFS that don't want to be scaled. PP_PRINTOUTPUTFORMAT_EMF is to simply the printing flow on Windows. BUG=67091, 92045, 91880, 92000, 92218, 95905 TEST=NONE Review URL: http://codereview.chromium.org/8041052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103177 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/c/dev/ppp_printing_dev.h13
-rw-r--r--ppapi/cpp/dev/printing_dev.cc13
-rw-r--r--ppapi/cpp/dev/printing_dev.h1
-rw-r--r--ppapi/example/example.cc16
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_printing.cc23
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc19
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppp_printing.srpc6
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc16
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc15
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h4
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h5
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc8
12 files changed, 122 insertions, 17 deletions
diff --git a/ppapi/c/dev/ppp_printing_dev.h b/ppapi/c/dev/ppp_printing_dev.h
index 336c588..cd83d45 100644
--- a/ppapi/c/dev/ppp_printing_dev.h
+++ b/ppapi/c/dev/ppp_printing_dev.h
@@ -23,7 +23,8 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOrientation_Dev, 4);
typedef enum {
PP_PRINTOUTPUTFORMAT_RASTER = 1u << 0,
PP_PRINTOUTPUTFORMAT_PDF = 1u << 1,
- PP_PRINTOUTPUTFORMAT_POSTSCRIPT = 1u << 2
+ PP_PRINTOUTPUTFORMAT_POSTSCRIPT = 1u << 2,
+ PP_PRINTOUTPUTFORMAT_EMF = 1u << 3
} PP_PrintOutputFormat_Dev;
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOutputFormat_Dev, 4);
@@ -48,8 +49,8 @@ struct PP_PrintPageNumberRange_Dev {
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PrintPageNumberRange_Dev, 8);
/* Interface for the plugin to implement printing. */
-#define PPP_PRINTING_DEV_INTERFACE_0_4 "PPP_Printing(Dev);0.4"
-#define PPP_PRINTING_DEV_INTERFACE PPP_PRINTING_DEV_INTERFACE_0_4
+#define PPP_PRINTING_DEV_INTERFACE_0_5 "PPP_Printing(Dev);0.5"
+#define PPP_PRINTING_DEV_INTERFACE PPP_PRINTING_DEV_INTERFACE_0_5
struct PPP_Printing_Dev {
/**
@@ -83,6 +84,12 @@ struct PPP_Printing_Dev {
/** Ends the print session. Further calls to PrintPage will fail. */
void (*End)(PP_Instance instance);
+
+ /**
+ * Returns true if the current content should be printed into the full page
+ * and not scaled down to fit within the printer's printable area.
+ */
+ PP_Bool (*IsScalingDisabled)(PP_Instance instance);
};
#endif /* PPAPI_C_DEV_PPP_PRINTING_DEV_H_ */
diff --git a/ppapi/cpp/dev/printing_dev.cc b/ppapi/cpp/dev/printing_dev.cc
index 93055e7..6c07be9 100644
--- a/ppapi/cpp/dev/printing_dev.cc
+++ b/ppapi/cpp/dev/printing_dev.cc
@@ -49,11 +49,22 @@ void End(PP_Instance instance) {
static_cast<Printing_Dev*>(object)->PrintEnd();
}
+PP_Bool IsScalingDisabled(PP_Instance instance) {
+ void* object =
+ pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
+ if (!object)
+ return PP_FALSE;
+ bool return_value =
+ static_cast<Printing_Dev*>(object)->IsPrintScalingDisabled();
+ return PP_FromBool(return_value);
+}
+
const PPP_Printing_Dev ppp_printing = {
&QuerySupportedFormats,
&Begin,
&PrintPages,
- &End
+ &End,
+ &IsScalingDisabled
};
} // namespace
diff --git a/ppapi/cpp/dev/printing_dev.h b/ppapi/cpp/dev/printing_dev.h
index 80d9fe4..6b8d7d0 100644
--- a/ppapi/cpp/dev/printing_dev.h
+++ b/ppapi/cpp/dev/printing_dev.h
@@ -27,6 +27,7 @@ class Printing_Dev {
virtual Resource PrintPages(const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count) = 0;
virtual void PrintEnd() = 0;
+ virtual bool IsPrintScalingDisabled() = 0;
private:
Instance* associated_instance_;
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index 1eec317..0caceff 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -328,16 +328,8 @@ int gettimeofday(struct timeval *tv, struct timezone*) {
}
// Print interfaces.
- // TODO(mball,dmichael) Replace this with the PPP_PRINTING_DEV_USE_0_4 version
- virtual PP_PrintOutputFormat_Dev* QuerySupportedPrintOutputFormats(
- uint32_t* format_count) {
- pp::Memory_Dev memory;
- PP_PrintOutputFormat_Dev* format =
- static_cast<PP_PrintOutputFormat_Dev*>(
- memory.MemAlloc(sizeof(PP_PrintOutputFormat_Dev)));
- *format = PP_PRINTOUTPUTFORMAT_RASTER;
- *format_count = 1;
- return format;
+ virtual uint32_t QuerySupportedPrintOutputFormats() {
+ return PP_PRINTOUTPUTFORMAT_RASTER;
}
virtual int32_t PrintBegin(const PP_PrintSettings_Dev& print_settings) {
@@ -378,6 +370,10 @@ int gettimeofday(struct timeval *tv, struct timezone*) {
print_settings_valid_ = false;
}
+ virtual bool IsScalingDisabled() {
+ return false;
+ }
+
void OnFlush() {
if (animation_counter_ % kStepsPerCircle == 0)
UpdateFps();
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_printing.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_printing.cc
index 075529a..e9bac01 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_printing.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_printing.cc
@@ -52,7 +52,7 @@ int32_t Begin(PP_Instance instance,
const_cast<PP_PrintSettings_Dev*>(print_settings)),
&pages_required);
- DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n",
+ DebugPrintf("PPP_Printing_Dev::Begin: %s\n",
NaClSrpcErrorString(srpc_result));
return pages_required;
}
@@ -74,7 +74,7 @@ PP_Resource PrintPages(PP_Instance instance,
page_range_count,
&image_data);
- DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n",
+ DebugPrintf("PPP_Printing_Dev::PrintPages: %s\n",
NaClSrpcErrorString(srpc_result));
return image_data;
}
@@ -89,6 +89,22 @@ void End(PP_Instance instance) {
DebugPrintf("PPP_Printing_Dev::End: %s\n", NaClSrpcErrorString(srpc_result));
}
+PP_Bool IsScalingDisabled(PP_Instance instance) {
+ DebugPrintf("PPP_Printing_Dev::IsScalingDisabled: "
+ "instance=%"NACL_PRIu32"\n", instance);
+
+ int32_t scaling_disabled = 0;
+ NaClSrpcError srpc_result =
+ PppPrintingRpcClient::PPP_Printing_IsScalingDisabled(
+ GetMainSrpcChannel(instance),
+ instance,
+ &scaling_disabled);
+
+ DebugPrintf("PPP_Printing_Dev::IsScalingDisabled: %s\n",
+ NaClSrpcErrorString(srpc_result));
+ return scaling_disabled ? PP_TRUE : PP_FALSE;
+}
+
} // namespace
const PPP_Printing_Dev* BrowserPrinting::GetInterface() {
@@ -96,7 +112,8 @@ const PPP_Printing_Dev* BrowserPrinting::GetInterface() {
QuerySupportedFormats,
Begin,
PrintPages,
- End
+ End,
+ IsScalingDisabled
};
return &printing_interface;
}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc
index ae6d95b..afd36ed 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc
@@ -106,3 +106,22 @@ void PppPrintingRpcServer::PPP_Printing_End(
DebugPrintf("PPP_Printing::End\n");
rpc->result = NACL_SRPC_RESULT_OK;
}
+
+void PppPrintingRpcServer::PPP_Printing_IsScalingDisabled(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ // inputs
+ PP_Instance instance,
+ // outputs
+ int32_t* /*PP_Bool*/ scaling_disabled) {
+ rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+ NaClSrpcClosureRunner runner(done);
+
+ PP_Bool pp_scaling_disabled =
+ PPPPrintingInterface()->IsScalingDisabled(instance);
+ *scaling_disabled = pp_scaling_disabled == PP_TRUE;
+
+ DebugPrintf("PPP_Printing::IsScalingDisabled: scaling_disabled=%d\n",
+ pp_scaling_disabled);
+ rpc->result = NACL_SRPC_RESULT_OK;
+}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppp_printing.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppp_printing.srpc
index c1301ef..608b933 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppp_printing.srpc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppp_printing.srpc
@@ -34,5 +34,11 @@
'outputs': [
]
},
+ {'name': 'PPP_Printing_IsScalingDisabled',
+ 'inputs': [['instance', 'PP_Instance'],
+ ],
+ 'outputs': [['result', 'int32_t'], # PP_Bool
+ ]
+ },
]
}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc
index 83a5940..65ecfcf 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_client.cc
@@ -362,6 +362,22 @@ NaClSrpcError PppPrintingRpcClient::PPP_Printing_End(
return retval;
}
+NaClSrpcError PppPrintingRpcClient::PPP_Printing_IsScalingDisabled(
+ NaClSrpcChannel* channel,
+ PP_Instance instance,
+ int32_t* result) {
+ NaClSrpcError retval;
+ retval = NaClSrpcInvokeBySignature(
+ channel,
+ "PPP_Printing_IsScalingDisabled:i:i",
+ instance,
+ result
+ );
+ if (retval == NACL_SRPC_RESULT_INTERNAL)
+ ppapi_proxy::CleanUpAfterDeadNexe(instance);
+ return retval;
+}
+
NaClSrpcError PppScrollbarRpcClient::PPP_Scrollbar_ValueChanged(
NaClSrpcChannel* channel,
PP_Instance instance,
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc
index 5275ffb..3254aa7 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppp_rpc_server.cc
@@ -329,6 +329,20 @@ static void PPP_Printing_EndDispatcher(
);
}
+static void PPP_Printing_IsScalingDisabledDispatcher(
+ NaClSrpcRpc* rpc,
+ NaClSrpcArg** inputs,
+ NaClSrpcArg** outputs,
+ NaClSrpcClosure* done
+) {
+ PppPrintingRpcServer::PPP_Printing_IsScalingDisabled(
+ rpc,
+ done,
+ inputs[0]->u.ival,
+ &(outputs[0]->u.ival)
+ );
+}
+
static void PPP_Scrollbar_ValueChangedDispatcher(
NaClSrpcRpc* rpc,
NaClSrpcArg** inputs,
@@ -431,6 +445,7 @@ NaClSrpcHandlerDesc PppRpcs::srpc_methods[] = {
{ "PPP_Printing_Begin:iC:i", PPP_Printing_BeginDispatcher },
{ "PPP_Printing_PrintPages:iCi:i", PPP_Printing_PrintPagesDispatcher },
{ "PPP_Printing_End:i:", PPP_Printing_EndDispatcher },
+ { "PPP_Printing_IsScalingDisabled:i:i", PPP_Printing_IsScalingDisabledDispatcher },
{ "PPP_Scrollbar_ValueChanged:iii:", PPP_Scrollbar_ValueChangedDispatcher },
{ "PPP_Scrollbar_OverlayChanged:iii:", PPP_Scrollbar_OverlayChangedDispatcher },
{ "PPP_Selection_GetSelectedText:ii:C", PPP_Selection_GetSelectedTextDispatcher },
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h
index 05ce4a2..c11c969 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h
@@ -187,6 +187,10 @@ class PppPrintingRpcClient {
static NaClSrpcError PPP_Printing_End(
NaClSrpcChannel* channel,
PP_Instance instance);
+ static NaClSrpcError PPP_Printing_IsScalingDisabled(
+ NaClSrpcChannel* channel,
+ PP_Instance instance,
+ int32_t* result);
private:
PppPrintingRpcClient();
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h
index 0d42db3..c6f6994 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h
@@ -207,6 +207,11 @@ class PppPrintingRpcServer {
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
PP_Instance instance);
+ static void PPP_Printing_IsScalingDisabled(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ PP_Instance instance,
+ int32_t* result);
private:
PppPrintingRpcServer();
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index 059ed49..8c4924b 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -366,6 +366,14 @@ class PrintingAdapter : public pp::Printing_Dev {
ppp_printing_->End(plugin_->pp_instance());
}
+ bool IsPrintScalingDisabled() {
+ if (ppp_printing_ != NULL) {
+ PP_Bool result = ppp_printing_->IsScalingDisabled(plugin_->pp_instance());
+ return result == PP_TRUE;
+ }
+ return false;
+ }
+
private:
Plugin* plugin_;
const PPP_Printing_Dev* ppp_printing_;