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

Unified Diff: ppapi/proxy/ppb_instance_proxy.cc

Issue 10795051: Implement asynchronous interface/plumbing for GetDefaultPrintSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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 ea974ef29db254c7426ca35a6f99d264e49bf7f0..093f2c2a8b05bdd8edda5f930b56283e0667e792 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -124,8 +124,6 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgLockMouse)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse,
OnHostMsgUnlockMouse)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings,
- OnHostMsgGetDefaultPrintSettings)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor,
OnHostMsgSetCursor)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType,
@@ -152,6 +150,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
// Host -> Plugin messages.
IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete,
OnPluginMsgMouseLockComplete)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_GetDefaultPrintSettingsComplete,
+ OnPluginMsgGetDefaultPrintSettingsComplete)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -457,17 +457,28 @@ void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) {
API_ID_PPB_INSTANCE, instance));
}
-PP_Bool PPB_Instance_Proxy::GetDefaultPrintSettings(
+int32_t PPB_Instance_Proxy::GetDefaultPrintSettings(
PP_Instance instance,
- PP_PrintSettings_Dev* print_settings) {
+ PP_PrintSettings_Dev* print_settings,
+ scoped_refptr<TrackedCallback> callback) {
if (!print_settings)
- return PP_FALSE;
+ return PP_ERROR_BADARGUMENT;
+ PluginDispatcher* plugin_dispatcher =
+ static_cast<PluginDispatcher*>(dispatcher());
+ InstanceData* data = plugin_dispatcher->GetInstanceData(instance);
+ if (!data)
+ return PP_ERROR_BADARGUMENT;
+ if (TrackedCallback::IsPending(data->default_print_settings_callback))
+ return PP_ERROR_INPROGRESS; // Already have a pending callback.
+ data->default_print_settings_callback = callback;
+ data->default_print_settings = print_settings;
- bool result;
- dispatcher()->Send(new PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings(
- API_ID_PPB_INSTANCE, instance, print_settings, &result));
+ PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(
+ new PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings(
+ API_ID_PPB_INSTANCE, plugin_dispatcher->plugin_dispatcher_id(),
+ instance));
- return PP_FromBool(result);
+ return PP_OK_COMPLETIONPENDING;
}
void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance,
@@ -656,29 +667,6 @@ void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) {
enter.functions()->UnlockMouse(instance);
}
-void PPB_Instance_Proxy::OnHostMsgGetDefaultPrintSettings(
- PP_Instance instance,
- PP_PrintSettings_Dev* settings,
- 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 default_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 = default_settings;
- *result = true;
-}
-
#if !defined(OS_NACL)
void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument(
PP_Instance instance,
@@ -799,5 +787,24 @@ void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
API_ID_PPB_INSTANCE, instance, result));
}
+void PPB_Instance_Proxy::OnPluginMsgGetDefaultPrintSettingsComplete(
+ int32 routing_id,
+ PP_Instance instance,
+ const PP_PrintSettings_Dev& settings,
+ int32_t result) {
+ InstanceData* data =
+ static_cast<PluginDispatcher*>(dispatcher())->GetInstanceData(instance);
+ if (!data)
+ return; // Instance was probably deleted.
+ if (!TrackedCallback::IsPending(data->default_print_settings_callback) ||
+ !data->default_print_settings) {
+ NOTREACHED();
+ return;
+ }
+ *data->default_print_settings = settings;
+ TrackedCallback::ClearAndRun(
+ &(data->default_print_settings_callback), result);
+}
+
} // namespace proxy
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698