Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: ppapi/proxy/ppb_instance_proxy.cc

Issue 10544085: Added PPB function to return default print settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/ppb_instance_proxy.cc
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index ac6fc8f1d82b9e3d91f5c5fc1d353288810683eb..8247cd5f2d825c7b508efd0559b1b997a3748e11 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -124,6 +124,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgLockMouse)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse,
OnHostMsgUnlockMouse)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBPrinting_GetDefaultPrintSettings,
+ OnHostMsgGetDefaultPrintSettings)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor,
OnHostMsgSetCursor)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType,
@@ -458,6 +460,22 @@ void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) {
API_ID_PPB_INSTANCE, instance));
}
+PP_Bool PPB_Instance_Proxy::GetDefaultPrintSettings(
+ PP_Instance instance,
+ PP_PrintSettings_Dev* print_settings) {
+ std::string settings_string;
+ bool result;
+ dispatcher()->Send(new PpapiMsg_PPBPrinting_GetDefaultPrintSettings(
+ API_ID_PPB_INSTANCE, instance, &settings_string, &result));
+
+ if (result && print_settings &&
yzshen1 2012/06/12 23:14:34 You could test print_settings at the top of the me
raymes 2012/06/13 18:23:47 Done.
+ settings_string.size() == sizeof(*print_settings)) {
+ memcpy(print_settings, &settings_string[0], sizeof(*print_settings));
yzshen1 2012/06/12 23:14:34 I don't think it is a good idea to pass a raw buff
raymes 2012/06/13 18:23:47 This is what was done in the existing code that tr
+ return PP_TRUE;
+ }
+ return PP_FALSE;
+}
+
void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance,
PP_TextInput_Type type) {
dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType(
@@ -650,6 +668,31 @@ void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) {
enter.functions()->UnlockMouse(instance);
}
+void PPB_Instance_Proxy::OnHostMsgGetDefaultPrintSettings(
+ PP_Instance instance,
+ std::string* settings_string,
+ bool* result) {
+ // TODO(raymes): This just returns some generic settings. Actually hook this
+ // up to the browser to return the real defaults.
+ PP_PrintSettings_Dev generic_print_settings = {
+ // |printable_area|: all of the sheet of paper.
+ { { 0, 0 }, { 612, 792 } },
+ // |content_area|: 0.5" margins all around.
+ { { 36, 36 }, { 540, 720 } },
+ // |paper_size|: 8.5" x 11" (US letter).
+ { 612, 792 },
+ 300, // |dpi|.
+ PP_PRINTORIENTATION_NORMAL, // |orientation|.
+ PP_PRINTSCALINGOPTION_NONE, // |print_scaling_option|.
+ PP_FALSE, // |grayscale|.
+ PP_PRINTOUTPUTFORMAT_PDF // |format|.
+ };
+ settings_string->resize(sizeof(generic_print_settings));
+ memcpy(&(*settings_string)[0], &generic_print_settings,
+ sizeof(generic_print_settings));
+ *result = true;
+}
+
#if !defined(OS_NACL)
void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument(
PP_Instance instance,

Powered by Google App Engine
This is Rietveld 408576698